Preprocessor directives in Razor
I am writing my first Razor page today, and can’t figure out how to enter #if debug … #else … #endif How can I do that in Razor? 10 Answers 10
I am writing my first Razor page today, and can’t figure out how to enter #if debug … #else … #endif How can I do that in Razor? 10 Answers 10
I am making an app that processes sensitive credit card data. If my code is running in debug mode I want to log this data to the console and make some file dumps. However on the final appstore version (ie when it is running in release mode) it is essential all of this is disabled … Read more
Which is better to use, and why, on a large project: #if DEBUG public void SetPrivateValue(int value) { … } #endif or [System.Diagnostics.Conditional(“DEBUG”)] public void SetPrivateValue(int value) { … } 8 s 8 It really depends on what you’re going for: #if DEBUG: The code in here won’t even reach the IL on release. [Conditional(“DEBUG”)]: … Read more
In C/C++/Objective C you can define a macro using compiler preprocessors. Moreover, you can include/exclude some parts of code using compiler preprocessors. #ifdef DEBUG // Debug-only code #endif Is there a similar solution in Swift? 18 s 18 Yes you can do it. In Swift you can still use the “#if/#else/#endif” preprocessor macros (although more … Read more