Question

My group has a source analysis tool that enforces certain styles that we have to comply with. I can't change it, and some of the rules are just a pain. One example is that all properties have to come before methods, and all constructors must come before properties. It seems silly to me that I have to take time to do something to the program when to the compiler it is the same. I would like some thing that is a plugin to VS that will let me do things like this automatically. Also, it would be nice to have it automatically put using's inside the namespace block.

Was it helpful?

Solution

You have different possibilities, depending on what exactly you want to do:

Resharper: There is a auto-format function which formats the source code of a single file or all files in the project / solution depending on your selected rules. So you set the settings for braces, naming, whitespaces, operators, lamdas, ... For more information see here. Resharper also supports settings a source- code file for all solutions or a shared settings file which is the same for all persons in the team.

FxCop: I havn't ever used this at work, but it's also a great tool an you can also select the rules which you want to enforce.

OTHER TIPS

Unless they bake it into VS2010, Resharper has the auto formatting capabilities you're probably looking for. CodeSmith probably has it too, I just haven't used it...

There are some formatting options built into VS. Goto Tools-->Options-->Text Editor-->C#-->Formatting.

They don't include every scenario, but might get you close.

Resharper - what a fantastic tool. I don't think I could manage without it. It must be the ultimate productivity tool for Visual Studio. Re-factoring, code analysis, code formatting, code completion - it has the lot.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top