Do you use comments not exclusion files when you ignore a Code Analysis rule?

Updated by Brady Stroud [SSW] 1 year ago. See history

123
<introEmbed body={<> 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. </>} />
Image

❌ Figure: Bad example -

Image

✅ Figure: Good example - The Solution and Projects are named consistently

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: Figure: Good example - The Solution and Projects are named consistently

Acknowledgements

Eric Phan
Related rules

Need help?

SSW Consulting has over 30 years of experience developing awesome software solutions.

We open source.Loving SSW Rules? Star us on GitHub. Star