SubMain - CodeIt.Right The First Time!

/Community

Support Community for SubMain Products
 Home Products Services Download Purchase Support
in Search
 
Home Forums Blogs Tutorials/CIR Tutorials/GD Downloads
Welcome to SubMain Community Sign in | Join | Help

Tutorials

CodeIt.Right SuppressMessage Attribute Primer

While CodeIt.Right comes with a great number of ways to ignore (exclude) violation, rule, file, project, etc, it also supports the SuppressMessage route. In this post you will find sample syntax for SuppressMessage attribute. You will find that CodeIt.Right supports all of the FxCop SuppressMessage variations and slightly enhances the attribute syntax.

// excludes all violations of the Design category
[SuppressMessage("SubMain.CodeItRight.Rules.Design", "")]

// excludes violation by rule ID
[SuppressMessage("SubMain.CodeItRight.Rules.Design", "DE00010")]

// excludes violation by rule name
[SuppressMessage("SubMain.CodeItRight.Rules.Design", "TypesContainStaticMembersShouldBeSealed")]

// excludes violation by rule ID and rule name
[SuppressMessage("SubMain.CodeItRight.Rules.Design", "DE00010:TypesContainStaticMembersShouldBeSealed")]

// excludes TypesAndMembersShouldHaveXmlComments rule for the class and all its members 
[SuppressMessage("SubMain.CodeItRight.Rules.General", "GE00005:TypesAndMembersShouldHaveXmlComments")]
public class MyUndocumentedClass
{
    public void MyUndocumentedMethod1{}
    public void MyUndocumentedMethod2{}
}

CodeIt.Right also supports the following syntax:

[SuppressMessage("SubMain.CodeItRight.Rules.Naming", "IdentifiersShouldBeCasedCorrectly", Scope = "method")]

Acceptable values for Scope include:

  • member
  • resource
  • module
  • type
  • method
  • namespace
  • method
  • member
  • parameter
  • type
  • namespace
  • module
  • statement
  • expression

Using Target parameter:

[SuppressMessage("SubMain.CodeItRight.Rules.Naming", "IdentifiersShouldBeCasedCorrectly",
Scope = "method", Target = "Class1.Main(System.String[]):System.Void")] class Class1 { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) { string fileIdentifier = name; string fileName = name; string version = String.Empty } }

If you are using the Enterprise Edition of CodeIt.Right, you can also use GlobalSuppression.cs or GlobalSuppression.vb file:

using System.Diagnostics.CodeAnalysis;

[assembly:SuppressMessage("SubMain.CodeItRight.Rules.Naming", "IdentifiersShouldBeCasedCorrectly", 
			Scope="method", Target="Class1.Main(System.String[]):System.Void")];
Published Thursday, May 24, 2012 6:13 AM by Serge B. (SubMain)

Comments

No Comments
Anonymous comments are disabled
    
 
     
 
Home |  Products |  Services |  Download |  Purchase |  Support |  Community |  About Us |