How to suppress SYSLIB0051 in a globl suppressions file

98 Views Asked by At

In some generated code, which I cannot change and for which I cannot modify the generator, after updating to .NET 8, I get a number of SYSLIB0051 warnings. I thought it should be straightforward to suppress them using a global suppressions file.

However, I cannot find the correct Category (maybe "Compiler"?), CheckId, and maybe MessageId and Scope that the SuppressMessageAttribute requires.

How can I suppress this message in a global suppressions file and/or where can I find the necessary information?

1

There are 1 best solutions below

2
Martin Costello On

One approach is to use #pragma directives around the code causing the issues if you want to target specific areas of concern.

For example in your case, wrap the line(s) with:

#pragma warning disable SYSLIB0051
// "bad" code here
#pragma warning restore SYSLIB0051