Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2005/2008: How can you share/force all developers to use the same formatting rules?

I would like to have all developers on my team to use the same rules for formatting several types of code (ASPX, CSS, JavaScript, C#). Can I have visual studio look to a common place for these rules?

I would like to not rely on export/import settings as that brings many settings along. I (for example) don't care what font colors the developer uses when typing, I just want similar formatting. Can you import a subset of settings?

like image 752
Mike Schall Avatar asked Sep 02 '08 14:09

Mike Schall


People also ask

How do I change the code format in Visual Studio?

To access this options page, choose Tools > Options from the menu bar. In the Options dialog box, choose Text Editor > C# > Code Style > Formatting.

How do I change preferences in Visual Studio?

Code style preferences can be set for all of your C# and Visual Basic projects by opening the Options dialog box from the Tools menu. In the Options dialog box, select Text Editor > [C# or Basic] > Code Style > General.

How do I use EditorConfig in Visual Studio?

Add an EditorConfig file to a projectOpen a project or solution in Visual Studio. Select either the project or solution node, depending on whether your . editorconfig settings should apply to all projects in the solution or just one. You can also select a folder in your project or solution to add the .

What do the colors in Visual Studio mean?

Here's your quick reference to the colors and icons in the editor window's right-hand margin: Yellow: The line has been changed but not yet saved. Green: The line has been changed and saved. Orange: The line has been changed, saved, and the change undone. Little square dots in the middle of the margin: Break points.


2 Answers

StyleCop, originally called "Source Analysis" is the best choice for C#. The first version was rather inflexible, but after recognizing the value that it provides for the community, Microsoft has opened it up to extensions and customizations. It's a solid tool.

For Visual Studio settings, it's trivial to export a sub-set of your settings into a .settings file and require that other team members import and use these settings.

Like any standards, the tools are only as good as the team members, so it probably goes without saying that you will need team buy-in regardless of what tool you use for enforcement.

like image 192
Brad Tutterow Avatar answered Oct 26 '22 02:10

Brad Tutterow


If you're using C#, take a look at StyleCop.

like image 27
Luke Girvin Avatar answered Oct 26 '22 02:10

Luke Girvin