Current filter:
                                You should refresh the page.
                                  • Hi .. I'm struggling to find which combination of formatting options I need to combine in order to get the desired output. Ive played around with spacing, braces, and newlines, and it gets close - but when nested lambdas come into play everything gets a bit hairy. The default VS indentation in this case is preferable.

                                    A picture speaks a thousand words so let s just look and see... Ive set the text to smaller than I generally have it to see more and get a better feel for the output.

                                    Also, you should allow ctrl+v pasting image data directly to this form :p . The amount of idents seems to be related, but only to delcaration or statement - there doesnt seem to be a scope of ("The start of the line that called the method where this inline lambda or block is an argument") ...  which sounds wordy, but its the default for vs, after a format document / Ctrl K, Ctrl D.

                                    Ahh and i only seem to be able ot add 1 image so i guess i will respond to myself with a comment.

                                Show all comments
                                • JoeB 03.22.2019

                                  here the undesired excessive unindenting ( but only in this nested case )

                                • Alex Eg (DevExpress) 03.22.2019

                                  Formatting results can vary because of the source code and settings. To help us better understand the situation, send us your settings (CodeRush\Support\Settings Folder...) along with the source document (the compilable state is not necessary) you want to format?

                                • JoeB 03.22.2019

                                  ok, for the time being i have just disabled the section that was getting confused : c# > Formatting > Braces > Lambda Expression \ Anon Method

                                  Attached my settings

                                • JoeB 03.22.2019

                                  Repro file attached

                                • JoeB 03.22.2019

                                  And from the screenshot there is one section which uses a local function ( ) which doesn't seem to fall into the same category, but is affected by the same undesirable excessive unindenting.

                                • Alex Eg (DevExpress) 03.22.2019

                                  I've created a separate ticket on your behalf (Formatting - Local function with the lambda expression is formatted incorrectly). It has been placed in our processing queue and will be answered shortly.

                                1 Solution

                                Creation Date Importance Sort by

                                Thank you for the provided information. I can reproduce the described behavior. We have researched the situation with the lambda formatting in your sample. It seems that we can't find any other way to keep code formatted as you need without disabling the 'C#->Formatting->Braces\Lambda Expression and Anonymous methods' option because your code construction looks too complex and is initially formatted in a custom manner - our formatting engine can't currently handle such constructions. We will keep your case as a potential source of information for possible future formatting improvements. It's unlikely that we will make any corrections or improvements in this direction soon - there is a strong possibility that such changes can break existing behavior in many other cases.

                                • JoeB 03.22.2019

                                  Ok, disappointing but I guess it is what it is. The code *is* somewhat complex, but all the DI examples and net core code use similar format ( with the exception of egyptian brackets, which is my preference.) Visual studio by default handles this correctly, so perhaps digging into how the lexer and roslyn syntaxtrees look like might help to gain some context.

                                  Regardless, despite the unsatisfactory outcome, I appreciate you looking at it as quickly as you have.

                                • JoeB 03.22.2019

                                  just an example from the official docs where you will see similiar "complexity":

                                  public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .ConfigureAppConfiguration((hostingContext, config) => { HostingEnvironment = hostingContext.HostingEnvironment; Configuration = config.Build(); }) .ConfigureServices(services => { ... }) .Configure(app => { var loggerFactory = app.ApplicationServices .GetRequiredService<ILoggerFactory>(); var logger = loggerFactory.CreateLogger<Program>(); logger.LogInformation("Logged in Configure"); if (HostingEnvironment.IsDevelopment()) { ... } else { ... } var configValue = Configuration["subsection:suboption1"]; ... }); }
                                • JoeB 03.22.2019

                                  attached the default vs options which will give the desired effect ( eqyptian style braces on same line as statement )

                                • Alex Eg (DevExpress) 03.22.2019

                                  Thank you for the sample from the MS documentation. We have checked our formatting on this sample and found that it works as you requested:
                                  Then we have compared it with your original code and found that there is a minor difference in a code structure (the level of chained method calls) and now it seems that we can the add an extra setting for the 'Chained method call' options and formatting will work in your code as requested. I added this task in our formatting improvement backlog, however I cannot give you an estimation on it's implementation. Thank you for pointing our attention to this situation and providing the additional information!