Wanted to see if anyone has any ideas. At work we have started developing some coding standards, so all of our code will look somewhat similar(braces, variable naming). One thing we cannot agree on is the location of braces...some of us like them on the same line, some on the next. And both sides of this are unwilling to compromise. I was wondering if there's anyway upon opening a solution I could run my settings file against it(so all braces are on the same line)...but then when i finish up a project I could run a different settings file(so all braces are on the next line) to match our standards. Or Vise Versa for a different developer...


Re: Visual C# IDE Formatting an Entire Solution off of a vs.settings file


You are under the false assumption that the settings file controls how things are displayed and this is not really correct. The settings file contains some rules for controlling formatting of code when it is entered. Once it is entered the settings file won't impact it any more. Thus if you originally saved a file with braces on the same line as an if-statement then irrelevant of the settings file it'll appear that way when opened again. You can toggle settings files all you want and it won't change. However if you were to later make a change to the if-statement then the settings file may impact the new layout of the code.

The only real solution that I see is to write a macro or add-in that reformats the file when loading and saving based upon the user's settings. There are also third-party components available that already do some of this. Coding standards enforcement tools exist for VS so you might want to check them out.

My personal opinion though is that coding standards are great (I have a 100 page one myself) but coding style should not be standardized. The goal of good coding standards should be to help create usable, reliable, secure, robust and maintainable code. Standards should be interested in the how and why more than the layout of code. I've seen companies standardize on 70 column lines of code with no C-style commenting allowed. How does that help anyone develop code I've seen too many companies try to standardize on coding style. In the end you gain nothing except lost productivity as developers try to re-learn the coding style of the company. Does it honestly matter whether a curly brace is on the same line or a separate line Does this somehow impact the usability, reliability or maintainability of the code If a developer can't figure out a piece of code because the curly brace isn't on the appropriate line then isn't this a sign of a bigger why aren't there any comments There are very few areas where coding style should, IMHO, be included in a coding standard. Some exceptions would be a corporate copyright header, mandatory commenting format for members and code changes and naming conventions for public members. These particular exceptions impact legal, maintainable and usable aspects of the code. There are probably a few others as well. Ultimately every developer will have their own coding style and each will feverishly defend their position. If I have a dev who can't read another dev's code because of style (or even mimic it when maintaining someone else's code - a requirement) then I think there is a problem.

Michael Taylor - 2/15/07

Re: Visual C# IDE Formatting an Entire Solution off of a vs.settings file

Mark Benningfield

Hello All.


No, you don't understand. Managers must manage. And, you know, we are writing managed code, so the coding must be managed. For that, you must have a manager. And if the manager is not managing, then he or she is not managing well. So, well-managed means much-managed. That way, when they manage to manage the train right off the tracks, the result is a well-managed train wreck. When the wheels came off, they came off according to the managed standard.

Re: Visual C# IDE Formatting an Entire Solution off of a vs.settings file


Clever. I liked it. But if the manager manages everything should it not have been in the managed project plan that the train would derail Therefore shouldn't the manager have managed to create a disaster recovery plan :} I pity you. .NET developers are in high demand...

Michael Taylor - 2/16/07