Dave New
Dave New

Reputation: 40002

Restrict Code Analysis suppression?

We have recently implemented the use of Code Analysis.

Is it possible to restrict users from suppressing Code Analysis results to In Source?

I only want suppressions to be stored in the suppression file (GlobalSuppressions.cs).

enter image description here

Our projects are hosted on TFS (on Visual Studio Online).

Upvotes: 2

Views: 172

Answers (3)

KMoraz
KMoraz

Reputation: 14164

It's possible using a custom check-on policy. See how to create and implement it.

Upvotes: 2

Nicole Calinoiu
Nicole Calinoiu

Reputation: 20982

You could create a custom code analysis rule to detect any SuppressMessageAttribute instances applied against anything other than the module or assembly.

Upvotes: 1

Crono
Crono

Reputation: 10478

No it's not possible. If a team member can edit the file then he's free to add any code he likes, including the SuppressMessageAttribute.

Upvotes: 1

Related Questions