__MonoCS__ does not work in mono 5.0. How to determine platform at compile time?

Viewed 457

This code is broken after upgrading to mono 5.0:

#if __MonoCS__ //Linux...
        var mode = LZ4StreamMode.Compress;
#else //Windows...
        var mode = System.IO.Compression.CompressionMode.Compress;
#endif

What constant can I use as a replacement ?

1 Answers

this is noted in the release notes for mono 5.0 as well as the reasoning:

Note: mcs defined the MonoCS symbol and some users incorrectly used it to conditionally compile code specific to Mono. This is considered bad practice and won’t work anymore now that csc is the default compiler. You can detect whether you’re running on Mono at runtime instead.

Related