Support Suppress using attributes on member and namespace levels

Currenly two options are offered in Visual Studio: using #pragma on the line level, or using Attributes on the assembly level.

I actually prefer a third option: using the Attribute, but on the member level, so the method, class or namespace the issue resides in.

  • Often a suppression is repeated in the same class, for instance because the class is used hevaliy in the UI and therefore ConfigurAwait(false) is not applicable. In this way multiple violations can be fixed at once
  • Code is more readable, but still also it is clear that a supression is taking place because it is located in the same file.

I now do this bij choosing the option to supress in a separate file, then copy-paste the attribute code and change it. It would be very helpful if Sonarlint just natively would support this as a third option.

Apologies for the delay in replying, and thanks for the suggestion.

I agree that this would be useful, and in the past I’ve manually copied attributes around in a similar fashion.

The menu items/suppression/pragma/attribute behaviour for C# and VB.NET is completely handled by VS - currently SonarLint doesn’t play any part in it. We could add it as a feature to SLVS, but it feels more like a feature that should be supported natively by Visual Studio.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.