We’re considering making two changes to the way the formatting engine works, based on feedback we’ve received from Beta 1. I’d like to post them here, and see what you all think of them, to make sure we’re making the right decision.
Change 1: Comments that start at column 1.
In Beta 1, if you have a comment that starts at column 1 (the very left edge of the screen), we won’t change it’s indentation. The main reason for this behaviour is that if you select a block of text and use Edit->Advanced->Comment selection, we place all the ‘//’ that we generate at the left edge, and we wouldn’t want a subsequent formatting to push them way in.
We’re finding that this behaviour has bad effects in two main ways.
- It’s confusing. It’s not really clear why we change the indentation of some comments, but not others.
- It has a negative effect on generated code. Often it’s nice to be able to generate some code with comments in it(say with a snippet). But it looks kind of ugly if either all you’re comments end up at the left margin, or you need to add spaces to the snippet file.
Our proposed solution to this is to make the formatting engine always indent comments, and fix our “Comment Selection” behaviour to generate comments at the indent of the line with the least indentation in a block. For example comment selection would now generate something like this:
Change 2: Anonymous methods default to having the open brace on the same line.
This change is mainly for readability. Basically we want to change the default value of “Tools->Options->Text Editor->C#->Formatting->New Lines->New line options for braces->Place open brace on new line for anonymous methods” from true to false. The reason for this is that we think that if you have code like this:
It’s easier to tell that it’s part of an anonymous method than:
All of which look sort of like you just have a random block.
So what do you think? Are we on the right track, or is there a better way to solve these problems?