roslyn: Format document should not add braces by default
Formatting a document by default now has started adding braces around single line blocks:
using System;
namespace ConsoleApp75
{
class Program
{
static void Main(string[] args)
{
if (args.Length == 0)
throw new Exception();
}
}
}
To:
using System;
namespace ConsoleApp75
{
internal class Program
{
private static void Main(string[] args)
{
if (args.Length == 0)
{
throw new Exception();
}
}
}
}
However there is no way to enforce whether or not braces are optional for single line statements in editorconfig. This is going to lead to unneeded changes to my tree without a way to enforce it. This option should be turned off by default unless there is a way to enforce it.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 43 (40 by maintainers)
I agree with @Neme12 . I think it’s totally fine to tie these two things together. However, i also think it would make sense to have a dedicated keystroke for this purpose that someone could use instead.
So, the changes i would have would be:
This seems to address nearly all the use cases i can consider. People who want to keep the commands separate can do so. People who want a single command can have it (albeit opt-in). People can control what runs when the command executes. And it’s easy to discover the commands through the gold-bar and the edit menu.
This feels wrong to me. There is not explicit consent being given when the user just navigates somewhere, then hits ‘ok’ to close a page. What would probably make sense would be to change this list:
Into something more like:
This “perform additional cleanup during formatting” would be unchecked by default. It would only be checked if the user explicitly clicked it, or if they accepted through the gold-bar.
Thoughts @kuhlenh @sharwell @jinujoseph @JieCarolHu ?