.net.net-standardsharp-snmp

Definition of Conditional NET452 in sharpsnmplib?


I'm confused about the meaning/use of the NET452 conditional symbol in sharpsnmplib. One example is this property in SnmpMessageExtension:

    public static bool IsRunningOnWindows
    {
        get
        {
#if NET452
            return !IsRunningOnMono;
#elif NETSTANDARD1_3
            return RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
#else
            return false;
#endif
        }

Doesn't this mean that if I change the target framework to - say - .NET Version 4.6.1, then this property will always return false, though I'm still running on Windows?

Thanks


Solution

  • That conditional define only has the scope of its own project (a .NET Standard class library that targets net452 and others).

    Thus, when your project consumes the library via NuGet or project reference, the net effect is just like ".NET Framework 4.5.2 and above". You can easily test that out by making a few experiments.

    All the technical details are handled by .NET Core tooling automatically, and not mine.