How to ignore compiler warning when using Obsolete attribute on a class used with a KnownType attribute

Use this to disable the corresponding warnings just before the offending line:

#pragma warning disable 612, 618

And reenable the warnings after it:

#pragma warning restore 612, 618

Curiously enough, there’re 2 warnings related to this: CS0612 and CS0618 – one is for [Obsolete] and the other for [Obsolete("Message")]. Go figure…

Leave a Comment