Improving Code Quality - Warnings as Errors

This will save you from ignoring those issues that eventually cause a snowball of Technical Debt. This is of course only a practical option on greenfield applications or existing applications with few errors.

To turn this on – for each project in turn, right click on the project and choose Properties. In the properties window, choose “Build” from the left hand tabs. Ensure that Configuration is set to “All Configurations” (we don’t want a release build to succeed where a debug build fails), then further down the page find the “Treat warnings as errors”. Select the “All” radio button and save. Repeat this for each project in your solution.


Now build your projects. Any warnings you had previously will now be treated as errors. For example, I had an unused exception variable:



This may seem like it will be awkward but if you are serious about improving your code quality, this will help get you into good habits.


Next: Improving Code Quality - Code Metrics

Tagged: Code Quality, Visual Studio, .Net,
Categorised: Application Lifecycle Management,