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

Fix IsDotNetCore #1304

Merged
merged 1 commit into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions src/OpenCvSharp/Internal/PInvoke/WindowsLibraryLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public bool IsLibraryLoaded(string dllName)
}

/// <summary>
///
/// Determine if the OS is Windows
/// </summary>
/// <returns></returns>
public static bool IsCurrentPlatformSupported()
Expand All @@ -98,7 +98,7 @@ public static bool IsCurrentPlatformSupported()
}

/// <summary>
///
/// Determine if the runtime is .NET Core
/// </summary>
/// <returns></returns>
public static bool IsDotNetCore()
Expand All @@ -107,7 +107,8 @@ public static bool IsDotNetCore()
return false;
#else
// https://github.com/dotnet/corefx/blob/v2.1-preview1/src/CoreFx.Private.TestUtilities/src/System/PlatformDetection.cs
return RuntimeInformation.FrameworkDescription.StartsWith(".NET Core", StringComparison.Ordinal);
return Environment.Version.Major >= 5 ||
RuntimeInformation.FrameworkDescription.StartsWith(".NET Core", StringComparison.OrdinalIgnoreCase);
#endif
}

Expand Down
22 changes: 22 additions & 0 deletions test/OpenCvSharp.Tests/system/WindowsLibraryLoaderTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#nullable enable

using OpenCvSharp.Internal;
using Xunit;

namespace OpenCvSharp.Tests
{
public class WindowsLibraryLoaderTest
{
[Fact]
public void IsDotNetCore()
{
#if NET48
Assert.False(WindowsLibraryLoader.IsDotNetCore());
#elif NETCOREAPP3_1_OR_GREATER
Assert.True(WindowsLibraryLoader.IsDotNetCore());
#else
throw new OpenCvSharpException("Unexpected environment.");
#endif
}
}
}