C# - Selectively suppress custom Obsolete warnings

后端 未结 4 1739
小鲜肉
小鲜肉 2020-11-28 05:04

I\'m using the Obsolete attribute (as just suggested by fellow programmers) to show a warning if a certain method is used.

Is there a way to suppress the

4条回答
  •  长情又很酷
    2020-11-28 05:11

    The intent is to disable the warning for obsolete usage, regardless of whether the construct is marked with [Obsolete] or [Obsolete("Message")]. So use both CS0612 and CS0618:

    #pragma warning disable 612, 618 
    
    ...
    
    #pragma warning restore 612, 618 
    

提交回复
热议问题