Modified C# directive parser to allow #pragma warning disable/restore to take...
Modified C# directive parser to allow #pragma warning disable/restore to take string IDs in addition to integers in order to generalize to user-generated diagnostics. Compiler-generated diagnostics all have integer error codes in addition to a string ID, but user-generated diagnostics are only identified by a string ID. This change also affects the language grammar, effectively changing the grammar of "warning-list" in section 2.5.8.1 of the C# spec from: warning-list: decimal-digits warning-list whitespaceopt , whitespaceopt decimal-digits to: warning-id: decimal-digits string-literal warning-list: warning-id warning-list whitespaceopt , whitespaceopt warning-id As implemented, the compiler will accept the following: #pragma warning disable ?CS0168? #pragma warning disable ?CS0168?, ?CS0219? #pragma warning disable ?CS0168?, 219 // , ... etc. And warn about the following: #pragma warning disable ?CS168? // warning CS1691: 'CS168' is not a valid warning number #pragma warning disable 1 // warning CS1691: ?1? is not a valid warning number (current behavior) Only strings that match 'CS[0-9]*' are assumed to be compiler diagnostic IDs, so the compiler will not warn about something like: #pragma warning disable "CS1MyWarning" // This could be a user diagnostic ID (changeset 1209083)
Showing
想要评论请 注册 或 登录