I'm having trouble the same instance of a C# class being used in multiple places. I'd like to be able to tell at a glance in the debugger which instance is which, so I've added a field called DebugUID
like so:
public readonly string DebugUID = Guid.NewGuid().ToString();
and I've also added the attribute [DebuggerDisplay("DebugUID= {DebugUID}")]
to the class.
I'd like the compiler to ignore the DebugUID field in release mode. If it were a method, I'd add [Conditional("Debug")]
before it, but it won't let me do that for fields. How do make a field be debug-only in C#?