I have a project for which I want to use the terrific Code Analysis
features of the Visual Studio 2005 Team Edition for Software Developers.
I have everything working just fine except for one thing: I have a
few files in this project that are poorly designed and implemented, so
they generate too many warnings to address at this time. I need to set
up the code analysis so that it does not generate any messages for the
code in a select set of C# files.
For example, in my C# library project of 20 files, there are two that
generate 100 warnings that I am unable to address at this time. I would
like to know the most straightforward way to suppress all messages
related to any code in those two files. Is there a way to use the
SuppressMessage attribute to suppress all code analysis messages for a
- file
- class
- method
By using the IDE to suppress messages I have a GlobalSuppression.cs that
has the following two statements (among others)
[assembly:
System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1014:MarkAssembliesWithClsCompliant")]
[assembly:
System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization",
"CA1305:SpecifyIFormatProvider", Scope = "member", Target =
"LoadFromFiles.ConvertTime..ctor(System.String)", MessageId =
"System.Convert.ToInt32(System.String)")]
But I would like to have something like
SuppressMessage( "Microsoft.Design", "*", Scope="type",
Target="MyPoorlyDesignedClass" )
where the checkId argument is a wildcard so that all design messages for
the target class are suppressed.
If this is not possible with the VS 2005 Code Analysis feature, is it
possible with the standalone FxCop?
Thanks,
Phil
WenYuan Wang [MSFT] - 17 Aug 2007 08:49 GMT
Hello Phil
Thanks for your great suggestion. I will submit this suggestion to our
product team. VS IDE maybe could provide this feature in future.
However, in current version of VS (VS 2005), I'm sorry to say this is not
possible for us to suppress message for a whole class.
But, it's possible in FxCop. In FxCop world, each class will be presented
with a checkbox. We could uncheck the checkbox. This means, FxCop will not
analysis this class.
Hope this helps. Please let me know if you have any more concern. It's my
pleasure to assist you.
Have a great day.
Best regards,
Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
WenYuan Wang [MSFT] - 20 Aug 2007 14:51 GMT
Hello Phil,
This is Wen Yuan again. I haven't heard from you a couple of days.
Have you checked with FxCop so far? Is this what you need?
http://www.gotdotnet.com/Team/FxCop/
[FxCop Team Page]
If you have any more concern on this issue, please feel free to let me
know. We are glad to assist you.
Have a geat day.
Best regards,
Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.