0

I was wondering if it were at all possible to change the warning level for invoking obsolete method/class in c# just like the way we can do it in c++. For example,

#pragma warning(2,some_warning)

can change some_warning's level to level 2 from whatever the warning level it by default has. It is at all possible to do stuff like that in c#?

Note: I have already considered the option of suppressing the warning using #pragma warning disable and restoring it after the api call. But my ask is, Is there a way to change the default warning level thrown by for example, ObsoleteAttribute?

1 Answers1

0

You can use

#pragma warning disable 612

to disable the warning for accessing items decorated with the ObsoleteAttribute and

#pragma warning restore 612

to restore the warning.

Owain Williams
  • 2,387
  • 17
  • 22