From ae983443e6fee16d0f7aa6f52b84333cbfef5782 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Fri, 11 Aug 2023 09:01:33 +0800 Subject: [PATCH] Fix tests --- src/Grpc.Net.Client/Internal/NtDll.cs | 2 +- src/Grpc.Net.Client/Internal/OperatingSystem.cs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Grpc.Net.Client/Internal/NtDll.cs b/src/Grpc.Net.Client/Internal/NtDll.cs index 12c224f8f..0061decbe 100644 --- a/src/Grpc.Net.Client/Internal/NtDll.cs +++ b/src/Grpc.Net.Client/Internal/NtDll.cs @@ -16,7 +16,7 @@ #endregion -#if NET462_OR_GREATER +#if !NET5_0_OR_GREATER using System.Runtime.InteropServices; diff --git a/src/Grpc.Net.Client/Internal/OperatingSystem.cs b/src/Grpc.Net.Client/Internal/OperatingSystem.cs index 3cdbffcf6..4d2e45c73 100644 --- a/src/Grpc.Net.Client/Internal/OperatingSystem.cs +++ b/src/Grpc.Net.Client/Internal/OperatingSystem.cs @@ -39,14 +39,16 @@ internal sealed class OperatingSystem : IOperatingSystem private OperatingSystem() { - IsBrowser = RuntimeInformation.IsOSPlatform(OSPlatform.Create("browser")); #if NET5_0_OR_GREATER IsAndroid = System.OperatingSystem.IsAndroid(); + IsWindows = System.OperatingSystem.IsWindows(); + IsBrowser = System.OperatingSystem.IsBrowser(); + OSVersion = Environment.OSVersion.Version; #else IsAndroid = false; -#endif IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); -#if NET462_OR_GREATER + IsBrowser = RuntimeInformation.IsOSPlatform(OSPlatform.Create("browser")); + // Older versions of .NET report an OSVersion.Version based on Windows compatibility settings. // For example, if an app running on Windows 11 is configured to be "compatible" with Windows 10 // then the version returned is always Windows 10. @@ -54,8 +56,6 @@ private OperatingSystem() // Get correct Windows version directly from Windows by calling RtlGetVersion. // https://www.pinvoke.net/default.aspx/ntdll/RtlGetVersion.html OSVersion = IsWindows ? NtDll.DetectWindowsVersion() : Environment.OSVersion.Version; -#else - OSVersion = Environment.OSVersion.Version; #endif } }