Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly tell macOS from UNIX starting from .NET Core #217

Merged
merged 1 commit into from
Nov 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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