Formatting LINQ

2 posts, 0 answers
  1. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 15 Apr 2011 Link to this post

    I have found myself writing code like this a lot lately...
    foldersToBeUpdated.Where(f=>blah).Select.(f=> MoreBlah).ToList().Foreach(f=> {
    f.Something = somethingelse;
    f.foo = bar;
         });

    Sometimes the statements can go on a bit. So, to make it a bit more readable, I've been doing this...
    foldersToBeUpdated
        .Where(f=>blah)
        .Select.(f=> MoreBlah)
        .ToList()
        .Foreach(f=>{
                    f.Something = somethingelse;
                    f.foo = bar;
                });
     (Format painter is messing with the spacing inside the {} brackets).

    However, JC, when asked to format the code turns it in to this ...
    foldersToBeUpdated
    .Where(f=>blah)
    .Select.(f=> MoreBlah)
    .ToList()
    .Foreach(f=>
             {
         f.Something = somethingelse;
         f.foo = bar;
       });

    I would have thought that the 2nd and subsequent lines of the LINQ statement should have been indented below the first.

    Hardly the end of the world, I know, but...

    -- 
    Stuart


  2. Blagoev
    Admin
    Blagoev avatar
    49 posts

    Posted 26 Apr 2011 Link to this post

    Hello Stuart Hemming,
    We are planning on improving the formatter for the next release this problem is high on our list. Hopefully it will be included in our future internal builds

    Best wishes,
    Blagoev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
Back to Top