I am using Visual Studio 2008. In my editor whenever I write an automatic property it's "get" and "set" wraps to a single line whenever I wrote "set" and put semicolon(;). like this:
public string MyProperty
{
get; set;
}
I want it to be formatted like this
public string MyProperty
{
get;
set;
}
Currently I am manually formatting it to this after writing it. How can I set it as a default format?
Options > Text Editor > C# > Formatting > Wrapping > Leave block on single line is already unchecked for me.
I unchecked all three option available in Options > Text Editor > C# > Formatting > General, but it doesn't work. Anything else?
If you put it all on one line, the default formatting options will leave it alone:
public string MyProperty { get; set; }
This is controlled by:
Options > Text Editor > C# > Formatting > Wrapping > Leave block on single line
If you really want to format it your way, you could disable:
Options > Text Editor > C# > Formatting > General > Automatically format completed block on }
But you'd probably want to disable Automatically format on paste too.
If you're using ReSharper, Code Editing -> C# -> Formatting Style -> Line Breaks and Wrapping has an option "Place abstract/auto property/indexer/event on single line" that controls the behavior you describe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With