Just a quick post to put this out there. Chances are you already know of this, but I can imagine far from everybody does.
When building a project or solution, Visual Studio will report on what’s happening in the Output window. (By the way, you can control the verbosity of said window in the Tools – Options… – Projects and Solutions – Build and Run screen. And the first thing I do on a new system configuration, is enable the ‘Show Output window when build starts’ option in the screen before that.) It will print informational lines of text, but also, and more importantly, warnings and errors while compiling.
Obviously, your attention should be focused on the errors, as they will likely prevent you from running your application. Call it neurotical behaviour, but I always aim to have an as clear Output window as I can, so the warnings receive equal attention from me (although not as diligently of course).
But sometimes warnings will keep being generated by Visual Studio, even though you intentionally wrote the code the way you did. An example can be fields that are declared and assigned, but only used in a
statement, like a bunch of license key registrations meant for production.
To keep the warnings from always popping up in the Output window when building, use the #pragma preprocessor directive.
#pragma warning disable 414, 3021
You can get the warning numbers by building your code. If you can’t or won’t, you can also wrap the code in question in a
#pragma warning disable
#pragma warning restore
‘block’. This will disable all warnings in between, so use with caution !
PS: VSCommands by Squared Infinity is a great extension for VS that will color-code the lines in the output window to increase readability. You can even define your own custom formatting.