Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Obsolete causes error? [duplicate]

I use:

[Obsolete("Use AnotherMethod() insted.", false)]

2nd parameter is false but Visual Studio shows Warning as Error for every obsolete method call preventing project from compilation. How to make VS mark these calls as Warning not Error?

like image 790
Sergey Metlov Avatar asked Apr 30 '12 08:04

Sergey Metlov


People also ask

What does obsolete attribute mean?

Obsolete attributes are used to display an error or warning during compilation with an optional message to alert the developer that the given type or its member should not be used in the code as it is going to be replaced.

What does obsolete mean in C#?

In programming the term 'OBSOLETE' means that the assembly/resource/function/type its deprecated or old, translated it means that the compiler notices you that there is a better or newer way to do it.


1 Answers

On the obsolete method define:

#pragma warning disable 0618
        [Obsolete("test",false)]
        private void myMethod()

then go to project properties, under build, in suppress warning type type 0618, Now it will ignore that particular method and project will compile

like image 83
Habib Avatar answered Oct 13 '22 09:10

Habib