Skip to content

Commit 5c23fb4

Browse files
authored
Merge pull request #1304 from shimat/net5detection
Fix IsDotNetCore
2 parents 262dd42 + 5e60027 commit 5c23fb4

File tree

7 files changed

+26
-3
lines changed

7 files changed

+26
-3
lines changed

src/OpenCvSharp/Internal/PInvoke/WindowsLibraryLoader.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public bool IsLibraryLoaded(string dllName)
8484
}
8585

8686
/// <summary>
87-
///
87+
/// Determine if the OS is Windows
8888
/// </summary>
8989
/// <returns></returns>
9090
public static bool IsCurrentPlatformSupported()
@@ -98,7 +98,7 @@ public static bool IsCurrentPlatformSupported()
9898
}
9999

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

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#nullable enable
2+
3+
using OpenCvSharp.Internal;
4+
using Xunit;
5+
6+
namespace OpenCvSharp.Tests
7+
{
8+
public class WindowsLibraryLoaderTest
9+
{
10+
[Fact]
11+
public void IsDotNetCore()
12+
{
13+
#if NET48
14+
Assert.False(WindowsLibraryLoader.IsDotNetCore());
15+
#elif NETCOREAPP3_1_OR_GREATER
16+
Assert.True(WindowsLibraryLoader.IsDotNetCore());
17+
#else
18+
throw new OpenCvSharpException("Unexpected environment.");
19+
#endif
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)