Public musings, often on software development RSS 2.0
# Wednesday, November 16, 2005

So one of the new features I've found with Static Code Analysis in Visual Studio 2005 is that it allows you to suppress messages.  As I blogged earlier, the typical behavior is for the tool to add a line to your source file to suppress a warning that you find to be unnecessary.  So I was playing with the Namespace related rules which allow you to try and keep variables named appropriately and it flagged the namespace name I used.  I have an acronym as my Namespace and that meant it’s all capitals which of course the rule didn’t like.  So I decided to ignore the warning, only this time since the warning occurs across several files instead of adding a line to each file which referenced the namespace the Static Analysis tool created a new source file called GlobalSuppressions.cs and added the suppression line to that file.  Here are the contents of this new source file in my project:

[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1705:LongAcronymsShouldBePascalCased", Scope = "namespace", Target = "IKRulz")]

 

As you can see the only thing in the file is the declaration to create an exception for that rule, but in theory I could add other rules to this file if I found the same message in several locations in my code allowing me to limit the number of times I needed to exclude a particular message.  Of course I could also just avoid running certain rules, but that’s a different discussion.

Wednesday, November 16, 2005 9:34:24 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
.NET | Team System | Technology
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Bill Sheldon
Sign In
All Content © 2012, Bill Sheldon