I want to hide some member vars in my C# class.
I can do this via the DebuggerBrowsable attribute:
using System.Diagnostics;
[DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
int myvar;
However, I only want this attribute to be applied for Release builds - I want to hide the var from my assembly's Release-build consumers but I want the var visible in Debug builds for inspection during dev, etc.
I could, but would prefer not to, wrap each attribute in an #if block:
#if !DEBUG
[DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
#endif
That would do the trick, but creates some pretty messy-looking code.
If I were in C++/CLI - and had macros - I could do this:
#ifdef _DEBUG
#define HIDDEN_MEMBER
#else
#define HIDDEN_MEMBER [System::Diagnostics::DebuggerBrowsableAttribute(System::Diagnostics::DebuggerBrowsableState::Never)]
#endif
and then
HIDDEN_MEMBER
int myvar;
But no macros in C# :(
Any bright ideas as to how to achieve the macro-like syntax in C#?