.NET Open Source Projects and Coding Guidelines

In my projects, we use a lot of open source libraries like Ninject, xUnit, Machine.Specifications, FluentAssertions, StyleCop, Moq, statLight, AgUnit and of course the project I lead myself: bbv.Common.

These projects are really cool. But sometimes of course, we need something that they do not (yet) provide. Like adding Machine.Specification support in FluentAssertions or a faster runner for xUnit unit tests under silverlight with AgUnit and statLight.

Therfore, we download the source code and try to contribute the features we need. And we try to follow the coding style of the existing code so that the project owners are willing to merge our changes into their code base. But this is almost impossible!

Almost every project uses different coding guidelines – if any. Some of them have written down their coding guidelines in their project wiki, some of them did not even do that. How should I be able to write code that matches the existing style? I cannot keep over 5 different coding styles in my head! Do the authors believe that I have time to contribute a new feature and to spend a lot of energy checking my changes against their coding guidelines manually? That’s really wasting time.

There is however a very simple solution to this problem. No it’s not about one single coding style that is better than all others and everyone should follow this one style. It’s about checking coding guidelines with a tool – automatically.

Therefore, if I had one wish free (regarding software 😉 ), it’d would be that all open source projects use a tool like for example StyleCop (in .NET) to check their coding guidelines automatically. I even don’t care what the rules look like exactly (e.g. { on the same line or on a new line). But I care that a tool can say me in real-time, whether I follow the style guidelines or not. Everything else is just a waste of time.

StyleCop is open source itself. If you don’t like the rules as they are out-of-the-box, create your own. Together with Resharper it provides real-time style checking in Visual Studio, just like spell checking in Word.

About the author

Urs Enzler

2 comments

By Urs Enzler

Recent Posts