What is C# 6.0 #pragma disable warnings feature?

The list of C# 6.0 final features contains a feature called #pragma listed as "Added" and the example is to disable warnings. However this feature did exist in C# before 6.0. What exactly was added in 6.0?

Jon Skeet
people
quotationmark

Previously, you had to specify the warning number. So to disable CS0501, you'd use

#pragma warning disable 0501

Now, you can use

#pragma warning disable CS0501

... which is incredibly important when you've got Roslyn Code Analyzers raising warnings with different identifiers. It's basically changed the namespace of warnings from "digits" to "alphanumeric strings".

I don't know the details of the new grammar - I haven't seen a C# 6 spec yet - but the old grammar was:

warning-list:
  decimal-digits
 warning-list whitespaceopt , whitespaceopt decimal-digits

people

See more on this question at Stackoverflow