Recently, I used. NET Compact framwork 3.5 (C #) as a Windows Mobile (6.5) project.CodeThe quality requirements are strict. I thought there was no major problem in the code. I did not expect to use fxcop for an analysis and I had reported more than 400 improvement suggestions.
Fxcop was used for the first time. In fact, visual studio.net 2008 has integrated the code analysis function. Right-click the project and choose Properties> codeanlysis. For details, see.
After "Enable code analysis on build" is selected, compileProgramThe code will be checked automatically at the same time. For non-compliant code, it will be reported in the form of warning. Of course, the proposed specifications may not always be observed in the actual project, after review, we can right-click and select "suppressmessage" to make it no longer displayed.
The same is true for fxcop. After we mark the relevant suppressmessageattribute in the code that violates the rules, fxcop will no longer report this conflict. For example:
[System. Diagnostics. codeanalysis. suppressmessage ("Microsoft. Design", "ca1004: genericmethodsshouldprovidetypeparameter")]
Public static t createform <t> (bool showaftercreated) where T: baseform, new ()
{
Return createform <t> (showaftercreated, true );
}
However, to make the above tag take effect, you must define "in" Conditional compilation symbols "on the build tab of the Project property.Code_analysis",
Suppressmessage can also be defined in assemblyinfo. CS, for example:
// Below attribute is to suppress fxcop warning "ca2232: Microsoft. Usage: Add stathreadattrito to assembly"
// As device app does not support sta thread.
[Assembly: system. Diagnostics. codeanalysis. suppressmessage ("Microsoft. Usage", "ca2232: markwindowsformsentrypointswithstathread")]
If you want to suppressmessage at the project level, you can write it in "globalsuppressions. cs.
Reference: http://blogs.msdn.com/fxcop/archive/2006/03/23/faq-why-does-fxcop-ignore-my-in-code-suppressmessageattribute-suppressions-david-kean.aspx