Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2017 Encapsulate Field - how to get the old format back?

So let's say I want to encapsulate the field with the good ol' Edit->Refactor->Encapsulate field, since it saves quite a bit of time:

private GameSettings gameSettings;

In Visual Studio 2015, I would get:

public GameSettings GameSettings
   {
      get
      {
         return gameSettings;
      }
      set
      {
         gameSettings = value;
      }
}

But with Visual Studio 2017 I get:

internal GameSettings GameSettings { get => gameSettings; set => gameSettings = value; }

Is there any way I can make it generate the old style? It looks wrong to have half the properties in one style and half in another...

like image 372
Oana Avatar asked Jun 15 '17 11:06

Oana


1 Answers

I know this thread is old, but the answer can help anyone else...

You can go to Options > Text Editor > C# > Code Style > General and change "Use expression body for accessors" to "Never". So you'll get the old style.

like image 70
thiago-rcarvalho Avatar answered Sep 21 '22 20:09

thiago-rcarvalho