Why can't I insert nested Visual Studio 2010 C # Express code correctly?

Consider this code ...

Create(x,y,z,
null, null, null,
new Class1[     ] {
    new Class1(a,b,c),
    new Class1(a,b,c)
},
new Class2[] {
    new Class2(d,e,f    )
},
true);

      

Notice the lack of spaces after the commas of the parameters and the extra spacing in the definition of Class1 and the call to class 2.

If I format my document - Ctrl + E, D or Ctrl + K, D - the code is formatted for that ...

Create(x, y, z,
null, null, null,
new Class1[] {
    new Class1(a,b,c),
    new Class1(a,b,c)
},
new Class2[] {
    new Class2(d,e,f    )
},
true);

      

Note that the parameter commas in the outer code have been correctly formatted with spaces (as per my preference), and the extra spaces have been removed from the definition of the Class1 array (again, my settings). However, the comma parameters in the inner code were NOT properly formatted and the extra spacing remains in the call to Class2.

There is absolutely nothing wrong with the code - it compiles and runs without errors.

This happens every time I make nested, complex calls using curly braces. I suppose I could make my code longer and more complex by breaking it all into parts and using temporary variables, but that seems like overkill.

Why is Visual Studio 2010 C # Express unable to format such nested code correctly? Has anyone else experienced this? If necessary, I can specify my formatting settings. Thank you in advance!:)

+3


source to share


1 answer


@tvwxyz: I could reproduce this issue with Ctrl + K, D.

But, interestingly, if I enable "Automatically format completed block", it works fine (assumed as expected) when I close this function.



Tools -> Options -> Text Editor-> C # -> Formatting -> General -> Automatically Format Completed Block}

+1


source







All Articles