Refactor...">

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

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

private GameSettings gameSettings; 

In Visual Studio 2015, I 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 a way to get it to generate an old style? It seems like half of the properties have one style and half in another ...

+5
source share
2 answers

I know this thread is outdated, but the answer might help someone else ...

You can go to Options> Text Editor> C #> Code Style> General and Use Expression Body For Accessories in Never. So you get the old style.

+1
source

Try using fragments:

 "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC#\Snippets\1033\Refactoring\EncapsulateField.snippet" 
0
source

Source: https://habr.com/ru/post/1268868/


All Articles