Methods and properties with an attribute do not raise issues.
ORIGINAL: SuppressMessage with nonexistent category and check ID still suppresses issues.
Define the following method and make sure S2325: Methods and properties that don't access instance data should be static is enabled:
private int Get()
{
return 42;
}
Note S2325 is reported. Now add the following suppression attribute:
[System.Diagnostics.CodeAnalysis.SuppressMessage("Foo", "Bar", Justification = "baz")]
private int Get()
{
return 42;
}
EDIT: Any attribute breaks the rule.
The issue should remain, since the proper category (pitfall?) and check ID (S2325) weren't supplied.
The issue is suppressed.
Use #pragma warning disable / #pragma warning restore
6.2.0.2536Thanks for your feedback! I was able to reproduce the problem, the fix will be included in the next version of SonarC#.
We decided to allow raising issues only if there is a SuppressMessage attribute. If other attributes are present we will not raise in order to reduce the false positives when using attribute-based functionality such as serialization, WCF, etc...