Skip to content

Commit

Permalink
Properly tell macOS from UNIX starting from .NET Core
Browse files Browse the repository at this point in the history
  • Loading branch information
KaKusaOAO committed Nov 10, 2022
1 parent 235f6e6 commit c58baa4
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions DiscordRPC/Registry/UriScheme.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
using DiscordRPC.Logging;
#if NETSTANDARD1_1_OR_GREATER
#define USE_RUNTIME_INFO
#endif

using DiscordRPC.Logging;
using System;
using System.Diagnostics;
#if USE_RUNTIME_INFO
using System.Runtime.InteropServices;
#endif

namespace DiscordRPC.Registry
{
Expand Down Expand Up @@ -53,14 +60,28 @@ public bool RegisterUriScheme()
break;

case PlatformID.Unix:
_logger.Trace("Creating Unix Scheme Creator");
creator = new UnixUriSchemeCreator(_logger);
#if USE_RUNTIME_INFO
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
_logger.Trace("Creating MacOSX Scheme Creator");
creator = new MacUriSchemeCreator(_logger);
}
else
{
#endif
_logger.Trace("Creating Unix Scheme Creator");
creator = new UnixUriSchemeCreator(_logger);
#if USE_RUNTIME_INFO
}
#endif
break;

#if !USE_RUNTIME_INFO
case PlatformID.MacOSX:
_logger.Trace("Creating MacOSX Scheme Creator");
creator = new MacUriSchemeCreator(_logger);
break;
#endif

default:
_logger.Error("Unkown Platform: {0}", Environment.OSVersion.Platform);
Expand Down

0 comments on commit c58baa4

Please sign in to comment.