I am trying to disable the code analysis rule for the whole class, but NOT for the whole project, just one class. In the example below, the assembly generates warning CA1822 because it considers the unit test methods to be static.
The fix is ββto add the following attribute to each unit test method: [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
However, this is cumbersome and will interfere with a class with many unit tests.
I tried:
- Moving an attribute to a class
- Wrap all methods in
#pragma warning disable CA1822
#pragma warning restore CA1822
None of these two approaches worked.
public class TestClass { public TestClass() {
Using VS2015 Update 2, .net 4.61 and new code analyzers.
SFun28
source share