Home
Do you use comments not exclusion files when you ignore a Code Analysis rule?
  v2.0 Posted at 13/06/2012 1:07 AM by Tiago Araujo
When running code analysis you may need to ignore some rules that aren't relevant to your application. Visual Studio has a handy way of doing thing.
code-analysis-bad-example Figure: Good Example - The Solution and Projects are named consistently code-analysis-good-example
public partial class Account
    {
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification="Gold Plating")]
        public Account()
        {
            this.Centres = new HashSet();
            this.AccountUsers = new HashSet();
            this.Campaigns = new HashSet();
Figure: Good Example - The Solution and Projects are named consistently

Related rules

    Do you feel this rule needs an update?

    If you want to be notified when this rule is updated, please enter your email address:

    Comments: