Set suppress warnings for website

点点圈 提交于 2019-12-22 06:32:20

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/7067939/set-suppress-warnings-for-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!