Disable a compiler warning which is not in the rule set

My C# application uses the Code Analysis rule set Microsoft Managed Recommended Rules. I'm using some obsolete classes so I get the warning CS0618. (I cannot replace the obsolete classes because it's defined in a 3rd party API, so I have to use it)

I wanted to disable this warning by editing the default rule set and saving it under a new name, but the CS0618 rule is not part of this rule set.

So I have two questions:

  • Why does the compiler check against CS0618 although it's not part of the selected rule set?
  • How can I disable the warning per project/per solution and not in each single place?

For those who are curious why I cannot simply fix the compiler warning: see Refactoring XmlSchemaCollection, XmlValidatingReader and ValidationType.XDR to get rid of compiler warning

Jon Skeet
people
quotationmark

CS0168 isn't part of Code Analysis - it's a simple C# compiler warning. That's got nothing to do with any later code analysis.

To disable it in project properties, go into the project properties, the Build tab, Errors and Warnings section, Suppress Warnings, and specify 0168 (not CS0168).

people

See more on this question at Stackoverflow