Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Did C# formatting change in Visual Studio 2015? And how can I change it back?

In past versions of Visual Studio, I could create a single-line autoproperty in C# like this:

public int Whatever { get; set; } 

If I hit Control-K, Control-D to format, the property would stay that way.

But in Visual Studio 2015 RC, when I type the property, it wraps, and even if I unwrap it, formatting wraps it again:

public int Whatever { get; set; } 

I've noticed it with constructors as well. In the past, an empty constructor (e.g. that just called a base class constructor) could look like this:

public Whatever(int stuff)     : base(stuff) { } 

Now Visual Studio 2015 insists on doing this:

public Whatever(int stuff)     : base(stuff) { } 

Have others noticed this? Is this a change made in Visual Studio 2015? If so, is there a way I can change it back? I looked through the C# formatting section of Tools > Options, but couldn't find any new setting that might affect this.

(It's not impossible that one of my add-ins is causing it, but I didn't find any obvious culprits.)

(Why even care? Because when I use the Collapse to Definitions outlining command, single-line properties and constructors stay as they are, whereas wrapped ones collapse. If they're collapsed, I can't tell at a glance that they're empty; I have to toggle them to uncollapsed just to see that nothing's there.)

like image 994
Ryan Lundy Avatar asked May 29 '15 03:05

Ryan Lundy


People also ask

Why did C become popular?

The C programming language is so popular because it is known as the mother of all programming languages. This language is widely flexible to use memory management. C is the best option for system level programming language.

When was C made?

In 1978, Brian Kernighan and Dennis Ritchie published the first edition of The C Programming Language.

Where did C came from?

The Beginning The C programming language came out of Bell Labs in the early 1970s. According to the Bell Labs paper The Development of the C Language by Dennis Ritchie, “The C programming language was devised in the early 1970s as a system implementation language for the nascent Unix operating system.

Is Pascal better than C?

The Pascal method is arguably faster, because no interpretation takes place, but the C method is highly extensible.


1 Answers

Go to Tools > Options > Text editor > C# > Formatting > Wrapping

Check "Leave block on single line" and "Leave statements and member declarations on the same line"

enter image description here

like image 75
Oddmar Dam Avatar answered Sep 28 '22 11:09

Oddmar Dam