Standardize code formatting Visual Studio

Asked

Viewed 185 times

1

I have an automatically generated code as shown below:

inserir a descrição da imagem aqui

I wanted to format automatically so that it was in format:

public int Id {get; set;}

Note: This code was automatically generated by Visual Studio modeling project - Class diagram inserir a descrição da imagem aqui

1 answer

1


Go to: Tools -> Options -> Text Editor -> C# -> Formatting -> Wrapping -> (bookmark):

  • Leave block on single line
  • Leave Statements and Member declaration on the same line

Visual Studio Configuration

This works under normal conditions.

  • Was already with this setting @bigown did not work. Investigating I realized that the template used to generate the code comes from the file ClassTemplate.t4 in the briefcase ...\IDE\EXTENSIONS\MICROSOFT\ARCHITECTURE TOOLS\EXTENSIBILITY\Templates\Text I will try to learn how to modify to suit the desired.

  • Does your VS is not bugle?

  • Maybe, I’ll check these Templates which are used to generate these automatic codes. I also have Resharper and Productivity Power Tools I don’t know if there might be a conflict/bug.

  • I have the impression that the Resharper 'took the reins' of VS. When I select the code and use the option Format Selection of Resharper the code is standardized as I want. Anyway I will Templates so that the code is generated as I want.

  • @rubStackOverflow this is important, other tools prevent normal VS operation, although there are settings to let you do this. Anyway, Resharper lets you set that up, too. Perhaps the problem cannot be reproduced, at least not in the form presented in the question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.