You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Suggest generic link to show how to suppress compiler warnings #33722
The article briefly discusses the CS0184 warning. An improvement would be to add a generic link (to a separate page) at the bottom for how the warning can be disabled. This would probably need to be generic across all (level 1?) compiler warnings so you don't have to update hundreds of individual help pages.
Code snippet to generate the warning in a C# file, along with the #pragma to (temporarily) disable the warning.
#pragma warning disable CS0184
// Or "#pragma warning disable CS0184, CS0219" to disable multiple warnings
// Following would have generated the warning "The given expression is never of the provided ('int') type"
byte myByte = 5;
if (myByte is int)
DoSomethingElse();
else
DoSomething();
#pragma warning restore CS0184
// Or "#pragma warning restore CS0184, CS0219" to restore multiple warnings
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
ID: 8d019b89-8a06-a863-01d6-9530cf0799d3
Version Independent ID: 1df16f14-1a7d-1aec-1798-2c4d5f6a2704
Activity
BillWagner commentedon Jan 26, 2023
That's an excellent idea @abdekker
I'll keep this open, and continue to apply it across the docs for compiler warnings and errors.
Thanks!
Add warning suppression and remediation guidance for CS0184 (Fixes do…