I cannot figure out how to get rid of errors that basically should not be halting my compile in Visual Studio 2010 and should not be show stoppers, or at least I will fix them later, but I don't want the compile to just error and halt on these kinds of problems.
For example, I'm getting the following error:
Error 1 Warning as Error: XML comment on 'ScrewTurn.Wiki.SearchEngine.Relevance.Finalize(float)' has a paramref tag for 'IsFinalized', but there is no parameter by that name C:\www\Wiki\Screwturn3_0_2_509\SearchEngine\Relevance.cs 60 70 SearchEngine
for this code:
/// <summary> /// Normalizes the relevance after finalization. /// </summary> /// <param name="factor">The normalization factor.</param> /// <exception cref="InvalidOperationException">If <paramref name="IsFinalized"/> is <c>false</c> (<see cref="M:Finalize"/> was not called).</exception> public void NormalizeAfterFinalization(float factor) { if (factor < 0) throw new ArgumentOutOfRangeException("factor", "Factor must be greater than or equal to zero"); if (!isFinalized) throw new InvalidOperationException("Normalization can be performed only after finalization"); value = value * factor; }
I looked in menu Tools -> Options, and I don't see where I can tweak the compiler and tell it not to worry about comment or XHTML based errors.
You can make all warnings being treated as such using -Wno-error. You can make specific warnings being treated as such by using -Wno-error=<warning name> where <warning name> is the name of the warning you don't want treated as an error. If you want to entirely disable all warnings, use -w (not recommended).
Yes, even once in a while you will encounter the occasional warning you'd be better off leaving as a warning or even disabling completely. Those should be the exception to the rule, though. Here's some practical advise: at the start of a new project, start treating all warnings as errors, by default.
To turn off the warning for a specific line of code, use the warning pragma, #pragma warning(suppress : 4996) .
To disable a set of warnings for a given piece of code, you have to start with a “push” pre-processor instruction, then with a disabling instruction for each of the warning you want to suppress, and finish with a “pop” pre-processor instruction.
Each project in Visual Studio has a "treat warnings as errors" option. Go through each of your projects and change that setting:
The location of this switch varies, depending on the type of project (class library vs. web application, for example).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With