C
C#2y ago
mogaeon

❔ Suppressing CS0162 for a specific constant

I got a constant that wraps the type of compilation the application is (Debug, Testing, Release). The value is defined using #if DEBUG. The main reason being to not actually compile the code that isnt fully developed yet and just keep everything a little bit smaller in size. Is there any way to suppress the resulting CS0162 (Unreachable code) somehow, since the SuppressWarning-Attribute does not support Compilerwarnings?
3 Replies
333fred
333fred2y ago
#pragma warning disable The ide will offer to do this for you Though I'm not really sure what in your description would trigger unreachable code
ero
ero2y ago
Probably something like
#if DEBUG
return 123;
#endif

return 42;
#if DEBUG
return 123;
#endif

return 42;
Instead of #else
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server