C# Conditional equivalent of !DEBUG -


this question has answer here:

what c# system.diagnostics.conditional equivalent of #if (!debug)?

i want encrypt section of app.config file of console application if has not been compiled in debug mode. achieved so:

public static void main(string[] args) {     #if (!debug)     configencryption.encryptappsettings();     #endif     //... } 

but somehow, prefer decorating encrypt method conditional attribute:

[conditional("!debug")] internal static void encryptappsettings() {     //... } 

however makes compiler sad: the argument 'system.diagnostics.conditionalattribute' attribute must valid identifier...

what correct syntax negating conditional argument?

edit: @gusdor, used (i preferred keep program.cs file free of if/else debug logic):

#if !debug #define encrypt_config #endif  [conditional("encrypt_config")] internal static void encryptappsettings() {     //... } 

using attribute bit of hack can done.

#if debug //you have nothing here c# requires #else #define not_debug //define symbol specifying non debug environment #endif  [conditional("not_debug")] internal static void encryptappsettings() {     //... } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -