4

My problem is following: I have huge C# project with 1591 disabled globally in the .csproj file.

<NoWarn>$(NoWarn);1591</NoWarn>

However, I need to enable this warning in some files (some things MUST have xml comments).

I tried with #pragma warning restore 1591 at the top of the C# file, but it does not work. The warning is ignored.

Can I disable some C# compiler warning globally and enable it per file?

I don't want to enable this warning per entire project (6908 warnings).

Adam Sitnik
  • 1,256
  • 11
  • 15
  • Looks like this is related: https://stackoverflow.com/questions/11444631/how-to-disable-a-particular-compiler-warning-for-a-particular-file?rq=1 This link asks a question that is the inverse of yours. – C.J. May 30 '18 at 22:10
  • 1
    Hi @CJohnson you are right, however, it does not work in my case (enabling rules globally and disabling per file is possible, the opposite seems to be not) – Adam Sitnik May 31 '18 at 12:45
  • You can enable and disable warnings with C++, but not c#. I have never seen that with C# before. – C.J. May 31 '18 at 14:24

0 Answers0