I was surprised to learn that System.Diagnostics.Trace is not included in the Portable Class Library profiles. System.Diagnostics.Debug is available though.
I'm porting a library to a PCL and have typically used Trace statements to provide additional troubleshooting to consumers. For performance reasons, I want the assembly optimized so I only ship Release versions of the assembly in my NuGet package.
My understanding is that the methods for System.Diagnostics.Debug are conditionally compiled and therefore only useful when the assembly includes the DEBUG directive.
If I change my code to use System.Diagnostics.Debug and then compile in Release the approach is useless -- is there an alternative to System.Diagnostics.Trace in PCL or do I have to include the DEBUG directive in my Release build? Or is there another approach I should be considering?
You can specify conditional compilation directives in an individual C# file. So you can create your own wrapper around Debug.Trace, and define the DEBUG directive just for that code file, which will let you call Debug.Trace from a release DLL.