Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Enterprise Tools / August 2007

Tip: Looking for answers? Try searching our database.

How to use SuppressMessage for a whole block

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pwm - 16 Aug 2007 19:02 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.