5

I am working with a project from another developer that has hundreds of obsolete method warnings. In the compiled dlls, I set suppress warnings 618 (the full warning number is CS0618).

Is there a way to set the same setting on a web site?

The problem is that there are so many obsolete warnings that I can't find any of the important ones.

yakatz
  • 2,142
  • 1
  • 18
  • 47

1 Answers1

8

I believe you need to specify this in the web.config. See also: Compiler Element and Web Project Settings

  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp"
        extension=".cs"
        type="Microsoft.CSharp.CSharpCodeProvider, System, 
          Version=2.0.3600.0, Culture=neutral, 
          PublicKeyToken=b77a5c561934e089" 
        compilerOptions="/nowarn:618"/>
    </compilers>
  </system.codedom>

An alternative would be to add #pragma statements around each of the offending methods, but if there are hundreds, the blanket suppression would probably be quicker.

#pragma warning disable 612, 618
[Obsolete("Use something else instead")]
#pragma warning restore 612, 618
Community
  • 1
  • 1
David Ruttka
  • 14,269
  • 2
  • 44
  • 39
  • You are absolutely correct that adding `#pragma` around each statement is not an option. I used the web.config option and I went from 311 warnings to 2 (which are easy enough to fix.) – yakatz Aug 15 '11 at 18:11
  • If I have a .net 4.6.2 project and my Microsoft.CSharp reference is for .net 4.0, is it better that I specify its Version instead of the 2.0.3600.0 you have here? – JohnZaj Apr 14 '17 at 03:13