From 025016b36123d0833ee78e620a8a8f316eda0ec8 Mon Sep 17 00:00:00 2001 From: Radek Zikmund Date: Wed, 12 Jun 2024 18:17:02 +0200 Subject: [PATCH 01/12] Support overriding MsQuic.dll in the application directory on Windows. --- .../System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs b/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs index 0358742914485d..0eb3d50e332327 100644 --- a/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs +++ b/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net.Sockets; +using System.IO; using System.Runtime.InteropServices; using Microsoft.Quic; using static Microsoft.Quic.MsQuic; From 7eebfcb50f4560ffd4ba1e23051df755cc154e43 Mon Sep 17 00:00:00 2001 From: Radek Zikmund Date: Fri, 14 Jun 2024 10:44:07 +0200 Subject: [PATCH 02/12] Hide functionality behind appctx switch --- .../src/System/AppContextSwitchHelper.cs | 30 +++++++++++++++++++ .../src/System.Net.Quic.csproj | 1 + .../src/System/Net/Quic/Internal/MsQuicApi.cs | 6 ++-- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 src/libraries/Common/src/System/AppContextSwitchHelper.cs diff --git a/src/libraries/Common/src/System/AppContextSwitchHelper.cs b/src/libraries/Common/src/System/AppContextSwitchHelper.cs new file mode 100644 index 00000000000000..32d8d9b4445056 --- /dev/null +++ b/src/libraries/Common/src/System/AppContextSwitchHelper.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Globalization; + +namespace System +{ + internal static class AppContextSwitchHelper + { + internal static bool GetBooleanConfig(string switchName, bool defaultValue) => + AppContext.TryGetSwitch(switchName, out bool value) ? value : defaultValue; + + internal static bool GetBooleanConfig(string switchName, string envVariable, bool defaultValue = false) + { + if (Environment.GetEnvironmentVariable(envVariable) is string str) + { + if (str == "1" || string.Equals(str, bool.TrueString, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + if (str == "1" || string.Equals(str, bool.FalseString, StringComparison.OrdinalIgnoreCase)) + { + return false; + } + } + + return GetBooleanConfig(switchName, defaultValue); + } + } +} diff --git a/src/libraries/System.Net.Quic/src/System.Net.Quic.csproj b/src/libraries/System.Net.Quic/src/System.Net.Quic.csproj index f09a5d14dd08b0..546996f4b97c33 100644 --- a/src/libraries/System.Net.Quic/src/System.Net.Quic.csproj +++ b/src/libraries/System.Net.Quic/src/System.Net.Quic.csproj @@ -25,6 +25,7 @@ + diff --git a/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs b/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs index 0eb3d50e332327..6b0663654c52a2 100644 --- a/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs +++ b/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs @@ -76,7 +76,7 @@ private MsQuicApi(QUIC_API_TABLE* apiTable) static MsQuicApi() { bool loaded = false; - IntPtr msQuicHandle; + IntPtr msQuicHandle = IntPtr.Zero; Version = default; // MsQuic is using DualMode sockets and that will fail even for IPv4 if AF_INET6 is not available. @@ -95,7 +95,7 @@ static MsQuicApi() // Windows ships msquic in the assembly directory next to System.Net.Quic, so load that. // For single-file deployments, the assembly location is an empty string so we fall back // to AppContext.BaseDirectory which is the directory containing the single-file executable. - string path = typeof(MsQuicApi).Assembly.Location is string assemblyLocation && !string.IsNullOrEmpty(assemblyLocation) + string path = typeof(MsQuicApi).Assembly.Location is string assemblyLocation && !string.IsNullOrEmpty(assemblyLocation) && !AllowAppLocalMsQuic() ? System.IO.Path.GetDirectoryName(assemblyLocation)! : AppContext.BaseDirectory; @@ -279,4 +279,6 @@ private static bool IsTls13Disabled(bool isServer) #endif return false; } + + private static bool AllowAppLocalMsQuic() => AppContextSwitchHelper.GetBooleanConfig("System.Net.Quic.AppLocalMsQuic", "DOTNET_SYSTEM_NET_QUIC_APPLOCALMSQUIC"); } From 7be20fdc093a43c22a72447e1f7a913a260f4c70 Mon Sep 17 00:00:00 2001 From: Radek Zikmund Date: Fri, 14 Jun 2024 10:59:02 +0200 Subject: [PATCH 03/12] Prioritize appctx switch, deduplicate usage --- .../src/System/AppContextSwitchHelper.cs | 7 +++++- .../Internal/MsQuicConfiguration.Cache.cs | 24 +++---------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/libraries/Common/src/System/AppContextSwitchHelper.cs b/src/libraries/Common/src/System/AppContextSwitchHelper.cs index 32d8d9b4445056..2706769f3a725e 100644 --- a/src/libraries/Common/src/System/AppContextSwitchHelper.cs +++ b/src/libraries/Common/src/System/AppContextSwitchHelper.cs @@ -12,6 +12,11 @@ internal static bool GetBooleanConfig(string switchName, bool defaultValue) => internal static bool GetBooleanConfig(string switchName, string envVariable, bool defaultValue = false) { + if (AppContext.TryGetSwitch(switchName, out bool value)) + { + return value; + } + if (Environment.GetEnvironmentVariable(envVariable) is string str) { if (str == "1" || string.Equals(str, bool.TrueString, StringComparison.OrdinalIgnoreCase)) @@ -24,7 +29,7 @@ internal static bool GetBooleanConfig(string switchName, string envVariable, boo } } - return GetBooleanConfig(switchName, defaultValue); + return defaultValue; } } } diff --git a/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicConfiguration.Cache.cs b/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicConfiguration.Cache.cs index 6beddff6638336..4e06f6c6b0bd1e 100644 --- a/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicConfiguration.Cache.cs +++ b/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicConfiguration.Cache.cs @@ -16,27 +16,9 @@ namespace System.Net.Quic; internal static partial class MsQuicConfiguration { - private const string DisableCacheEnvironmentVariable = "DOTNET_SYSTEM_NET_QUIC_DISABLE_CONFIGURATION_CACHE"; - private const string DisableCacheCtxSwitch = "System.Net.Quic.DisableConfigurationCache"; - - internal static bool ConfigurationCacheEnabled { get; } = GetConfigurationCacheEnabled(); - - private static bool GetConfigurationCacheEnabled() - { - // AppContext switch takes precedence - if (AppContext.TryGetSwitch(DisableCacheCtxSwitch, out bool value)) - { - return !value; - } - // check environment variable second - else if (Environment.GetEnvironmentVariable(DisableCacheEnvironmentVariable) is string envVar) - { - return !(envVar == "1" || envVar.Equals("true", StringComparison.OrdinalIgnoreCase)); - } - - // enabled by default - return true; - } + internal static bool ConfigurationCacheEnabled { get; } = !AppContextSwitchHelper.GetBooleanConfig( + "System.Net.Quic.DisableConfigurationCache", + "DOTNET_SYSTEM_NET_QUIC_DISABLE_CONFIGURATION_CACHE"); private static readonly MsQuicConfigurationCache s_configurationCache = new MsQuicConfigurationCache(); From fbfb883605f1ca6b51941f93bee10ea2eb30b579 Mon Sep 17 00:00:00 2001 From: Radek Zikmund Date: Fri, 14 Jun 2024 11:00:53 +0200 Subject: [PATCH 04/12] Change method name --- .../System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs b/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs index 6b0663654c52a2..ccd96a9887f075 100644 --- a/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs +++ b/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs @@ -280,5 +280,7 @@ private static bool IsTls13Disabled(bool isServer) return false; } - private static bool AllowAppLocalMsQuic() => AppContextSwitchHelper.GetBooleanConfig("System.Net.Quic.AppLocalMsQuic", "DOTNET_SYSTEM_NET_QUIC_APPLOCALMSQUIC"); + private static bool IsAppLocalMsQuicAllowed() => AppContextSwitchHelper.GetBooleanConfig( + "System.Net.Quic.AppLocalMsQuic", + "DOTNET_SYSTEM_NET_QUIC_APPLOCALMSQUIC"); } From 055b76d6205ffc5590506c7a46c74dc7647f242d Mon Sep 17 00:00:00 2001 From: Radek Zikmund Date: Mon, 17 Jun 2024 10:21:28 +0200 Subject: [PATCH 05/12] No envvar, no fallback --- src/libraries/Common/src/System/AppContextSwitchHelper.cs | 2 +- .../src/System/Net/Quic/Internal/MsQuicApi.cs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libraries/Common/src/System/AppContextSwitchHelper.cs b/src/libraries/Common/src/System/AppContextSwitchHelper.cs index 2706769f3a725e..5d6f5f2b7c4054 100644 --- a/src/libraries/Common/src/System/AppContextSwitchHelper.cs +++ b/src/libraries/Common/src/System/AppContextSwitchHelper.cs @@ -7,7 +7,7 @@ namespace System { internal static class AppContextSwitchHelper { - internal static bool GetBooleanConfig(string switchName, bool defaultValue) => + internal static bool GetBooleanConfig(string switchName, bool defaultValue = false) => AppContext.TryGetSwitch(switchName, out bool value) ? value : defaultValue; internal static bool GetBooleanConfig(string switchName, string envVariable, bool defaultValue = false) diff --git a/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs b/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs index ccd96a9887f075..e609a69f20f582 100644 --- a/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs +++ b/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicApi.cs @@ -95,7 +95,7 @@ static MsQuicApi() // Windows ships msquic in the assembly directory next to System.Net.Quic, so load that. // For single-file deployments, the assembly location is an empty string so we fall back // to AppContext.BaseDirectory which is the directory containing the single-file executable. - string path = typeof(MsQuicApi).Assembly.Location is string assemblyLocation && !string.IsNullOrEmpty(assemblyLocation) && !AllowAppLocalMsQuic() + string path = !ShouldUseAppLocalMsQuic() && typeof(MsQuicApi).Assembly.Location is string assemblyLocation && !string.IsNullOrEmpty(assemblyLocation) ? System.IO.Path.GetDirectoryName(assemblyLocation)! : AppContext.BaseDirectory; @@ -280,7 +280,6 @@ private static bool IsTls13Disabled(bool isServer) return false; } - private static bool IsAppLocalMsQuicAllowed() => AppContextSwitchHelper.GetBooleanConfig( - "System.Net.Quic.AppLocalMsQuic", - "DOTNET_SYSTEM_NET_QUIC_APPLOCALMSQUIC"); + private static bool ShouldUseAppLocalMsQuic() => AppContextSwitchHelper.GetBooleanConfig( + "System.Net.Quic.AppLocalMsQuic"); } From cc53b9bf25a9211af68d52baf842fd78b168e610 Mon Sep 17 00:00:00 2001 From: Radek Zikmund Date: Mon, 17 Jun 2024 11:07:15 +0200 Subject: [PATCH 06/12] Run tests on older windows. --- .../tests/FunctionalTests/MsQuicTests.cs | 4 ++-- .../tests/FunctionalTests/QuicTestBase.cs | 12 ++++++++++++ .../FunctionalTests/QuicTestCollection.cs | 17 ++++++++++++++++- .../System.Net.Quic.Functional.Tests.csproj | 18 ++++++++++++++++++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs b/src/libraries/System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs index 5e3b440377814a..7f9af662755d60 100644 --- a/src/libraries/System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs +++ b/src/libraries/System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs @@ -720,7 +720,7 @@ public async Task ConnectWithClientCertificate(bool sendCertificate, ClientCertS await serverConnection.DisposeAsync(); } - [Fact] + [ConditionalFact(typeof(QuicTestCollection), nameof(QuicTestCollection.IsUsingSchannelBackend))] [PlatformSpecific(TestPlatforms.Windows)] public async Task Server_CertificateWithEphemeralKey_Throws() { @@ -764,7 +764,7 @@ public async Task Server_CertificateWithEphemeralKey_Throws() } } - [Fact] + [ConditionalFact(typeof(QuicTestCollection), nameof(QuicTestCollection.IsUsingSchannelBackend))] [PlatformSpecific(TestPlatforms.Windows)] public async Task Client_CertificateWithEphemeralKey_Throws() { diff --git a/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs b/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs index 0cc5c418719b61..f7d2c68fbf18cd 100644 --- a/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs +++ b/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs @@ -44,6 +44,18 @@ public abstract class QuicTestBase : IDisposable public const int PassingTestTimeoutMilliseconds = 4 * 60 * 1000; public static TimeSpan PassingTestTimeout => TimeSpan.FromMilliseconds(PassingTestTimeoutMilliseconds); + static QuicTestBase() + { + // Opt in to run with OpenSSL version on MsQuic on older windows where Schannel + // version is not supported. + // + // This has to happen here in order to be called before QuicTestBase.IsSupported + if (PlatformDetection.IsWindows && !QuicTestCollection.IsWindowsVersionWithSchannelSupport()) + { + AppContext.SetSwitch("System.Net.Quic.AppLocalMsQuic", true); + } + } + public QuicTestBase(ITestOutputHelper output) { _output = output; diff --git a/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs b/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs index 699a41fcd1042b..ff60bb2dc3d4f9 100644 --- a/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs +++ b/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs @@ -26,8 +26,9 @@ public unsafe class QuicTestCollection : ICollectionFixture, public QuicTestCollection() { string msQuicLibraryVersion = GetMsQuicLibraryVersion(); + string tlsBackend = IsUsingSchannelBackend() ? "Schannel" : "OpenSSL"; // If any of the reflection bellow breaks due to changes in "System.Net.Quic.MsQuicApi", also check and fix HttpStress project as it uses the same hack. - Console.WriteLine($"MsQuic {(IsSupported ? "supported" : "not supported")} and using '{msQuicLibraryVersion}'."); + Console.WriteLine($"MsQuic {(IsSupported ? "supported" : "not supported")} and using '{msQuicLibraryVersion}' ({tlsBackend})."); if (IsSupported) { @@ -111,6 +112,20 @@ private static Version GetMsQuicVersion() return (string)msQuicApiType.GetProperty("MsQuicLibraryVersion", BindingFlags.NonPublic | BindingFlags.Static).GetGetMethod(true).Invoke(null, Array.Empty()); } + internal static bool IsWindowsVersionWithSchannelSupport() + { + Type msQuicApiType = Type.GetType("System.Net.Quic.MsQuicApi, System.Net.Quic"); + + return (bool)msQuicApiType.GetMethod("IsWindowsVersionSupported", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, Array.Empty()); + } + + internal static bool IsUsingSchannelBackend() + { + Type msQuicApiType = Type.GetType("System.Net.Quic.MsQuicApi, System.Net.Quic"); + + return (bool)msQuicApiType.GetProperty("UsesSChannelBackend", BindingFlags.NonPublic | BindingFlags.Static).GetGetMethod(true).Invoke(null, Array.Empty()); + } + private static QUIC_API_TABLE* GetApiTable() { Type msQuicApiType = Type.GetType("System.Net.Quic.MsQuicApi, System.Net.Quic"); diff --git a/src/libraries/System.Net.Quic/tests/FunctionalTests/System.Net.Quic.Functional.Tests.csproj b/src/libraries/System.Net.Quic/tests/FunctionalTests/System.Net.Quic.Functional.Tests.csproj index 3ac6d417fa09d5..4454d0b299984f 100644 --- a/src/libraries/System.Net.Quic/tests/FunctionalTests/System.Net.Quic.Functional.Tests.csproj +++ b/src/libraries/System.Net.Quic/tests/FunctionalTests/System.Net.Quic.Functional.Tests.csproj @@ -42,4 +42,22 @@ + + + + + + + + + + + + + From 6c933629ca00e3ecdab7cdd2a3cd9ff1e5262ff9 Mon Sep 17 00:00:00 2001 From: Radek Zikmund Date: Tue, 18 Jun 2024 17:15:22 +0200 Subject: [PATCH 07/12] Fix tests, log msquic load path --- .../tests/FunctionalTests/QuicTestCollection.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs b/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs index ff60bb2dc3d4f9..74d2812a5e5874 100644 --- a/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs +++ b/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs @@ -98,6 +98,14 @@ void DumpCounter(QUIC_PERFORMANCE_COUNTERS counter) Console.WriteLine($"Unobserved exceptions of {s_unobservedExceptions.Count} different types: {Environment.NewLine}{string.Join(Environment.NewLine + new string('=', 120) + Environment.NewLine, s_unobservedExceptions.Select(pair => $"Count {pair.Value}: {pair.Key}"))}"); } + internal static bool IsWindowsVersionWithSchannelSupport() + { + // copied from MsQuicApi implementation to avoid triggering the static constructor + Version minWindowsVersion = new Version(10, 0, 20145, 1000); + return OperatingSystem.IsWindowsVersionAtLeast(minWindowsVersion.Major, + minWindowsVersion.Minor, minWindowsVersion.Build, minWindowsVersion.Revision); + } + private static Version GetMsQuicVersion() { Type msQuicApiType = Type.GetType("System.Net.Quic.MsQuicApi, System.Net.Quic"); @@ -112,13 +120,6 @@ private static Version GetMsQuicVersion() return (string)msQuicApiType.GetProperty("MsQuicLibraryVersion", BindingFlags.NonPublic | BindingFlags.Static).GetGetMethod(true).Invoke(null, Array.Empty()); } - internal static bool IsWindowsVersionWithSchannelSupport() - { - Type msQuicApiType = Type.GetType("System.Net.Quic.MsQuicApi, System.Net.Quic"); - - return (bool)msQuicApiType.GetMethod("IsWindowsVersionSupported", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, Array.Empty()); - } - internal static bool IsUsingSchannelBackend() { Type msQuicApiType = Type.GetType("System.Net.Quic.MsQuicApi, System.Net.Quic"); From 3c182c646ccbaef7a90e064672b4a154892dbe74 Mon Sep 17 00:00:00 2001 From: Radek Zikmund Date: Wed, 19 Jun 2024 14:33:27 +0200 Subject: [PATCH 08/12] Make sure the msquic.dll is included in the helix package --- .../FunctionalTests/System.Net.Quic.Functional.Tests.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Net.Quic/tests/FunctionalTests/System.Net.Quic.Functional.Tests.csproj b/src/libraries/System.Net.Quic/tests/FunctionalTests/System.Net.Quic.Functional.Tests.csproj index 4454d0b299984f..73b57fb5cda38a 100644 --- a/src/libraries/System.Net.Quic/tests/FunctionalTests/System.Net.Quic.Functional.Tests.csproj +++ b/src/libraries/System.Net.Quic/tests/FunctionalTests/System.Net.Quic.Functional.Tests.csproj @@ -53,10 +53,10 @@ GeneratePathProperty="true" /> - + - + From e14cbf0918d4e2178ef99e9571d296b959e5ffff Mon Sep 17 00:00:00 2001 From: Radek Zikmund Date: Wed, 19 Jun 2024 19:32:42 +0200 Subject: [PATCH 09/12] Don't run on Win 8 --- .../System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs b/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs index f7d2c68fbf18cd..b8453c973747cb 100644 --- a/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs +++ b/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs @@ -50,7 +50,7 @@ static QuicTestBase() // version is not supported. // // This has to happen here in order to be called before QuicTestBase.IsSupported - if (PlatformDetection.IsWindows && !QuicTestCollection.IsWindowsVersionWithSchannelSupport()) + if (PlatformDetection.IsWindows && !QuicTestCollection.IsWindowsVersionWithSchannelSupport() && PlatformDetection.IsWindows10OrLater) { AppContext.SetSwitch("System.Net.Quic.AppLocalMsQuic", true); } From cf751af0bc0ca058173b6db6f7d856871956ccd1 Mon Sep 17 00:00:00 2001 From: Radek Zikmund Date: Fri, 21 Jun 2024 15:02:42 +0200 Subject: [PATCH 10/12] Simplify support condition --- .../System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs | 2 +- .../System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs b/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs index b8453c973747cb..2a4eb4db68a80f 100644 --- a/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs +++ b/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs @@ -50,7 +50,7 @@ static QuicTestBase() // version is not supported. // // This has to happen here in order to be called before QuicTestBase.IsSupported - if (PlatformDetection.IsWindows && !QuicTestCollection.IsWindowsVersionWithSchannelSupport() && PlatformDetection.IsWindows10OrLater) + if (PlatformDetection.IsWindows10OrLater && !QuicTestCollection.IsWindowsVersionWithSchannelSupport()) { AppContext.SetSwitch("System.Net.Quic.AppLocalMsQuic", true); } diff --git a/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs b/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs index 74d2812a5e5874..8a9c090acd1e46 100644 --- a/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs +++ b/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs @@ -28,7 +28,7 @@ public QuicTestCollection() string msQuicLibraryVersion = GetMsQuicLibraryVersion(); string tlsBackend = IsUsingSchannelBackend() ? "Schannel" : "OpenSSL"; // If any of the reflection bellow breaks due to changes in "System.Net.Quic.MsQuicApi", also check and fix HttpStress project as it uses the same hack. - Console.WriteLine($"MsQuic {(IsSupported ? "supported" : "not supported")} and using '{msQuicLibraryVersion}' ({tlsBackend})."); + Console.WriteLine($"MsQuic {(IsSupported ? "supported" : "not supported")} and using '{msQuicLibraryVersion}' {(IsSupported ? "({tlsBackend})" : "")}."); if (IsSupported) { From 81131992ac10464b2e59dee09676b1b699e76efb Mon Sep 17 00:00:00 2001 From: Radek Zikmund Date: Mon, 31 Mar 2025 11:15:56 +0200 Subject: [PATCH 11/12] Fix log --- .../System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs b/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs index 8a9c090acd1e46..c77e5f5aca9a4d 100644 --- a/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs +++ b/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs @@ -28,7 +28,7 @@ public QuicTestCollection() string msQuicLibraryVersion = GetMsQuicLibraryVersion(); string tlsBackend = IsUsingSchannelBackend() ? "Schannel" : "OpenSSL"; // If any of the reflection bellow breaks due to changes in "System.Net.Quic.MsQuicApi", also check and fix HttpStress project as it uses the same hack. - Console.WriteLine($"MsQuic {(IsSupported ? "supported" : "not supported")} and using '{msQuicLibraryVersion}' {(IsSupported ? "({tlsBackend})" : "")}."); + Console.WriteLine($"MsQuic {(IsSupported ? "supported" : "not supported")} and using '{msQuicLibraryVersion}' {(IsSupported ? $"({tlsBackend})" : "")}."); if (IsSupported) { From dd1ed54fa6ca00756d03f4c892095c13c3426cc8 Mon Sep 17 00:00:00 2001 From: Radek Zikmund Date: Tue, 1 Apr 2025 10:21:36 +0200 Subject: [PATCH 12/12] Code review feedback --- src/libraries/Common/src/System/AppContextSwitchHelper.cs | 2 +- .../tests/FunctionalTests/QuicTestCollection.cs | 3 +-- .../FunctionalTests/System.Net.Quic.Functional.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libraries/Common/src/System/AppContextSwitchHelper.cs b/src/libraries/Common/src/System/AppContextSwitchHelper.cs index 5d6f5f2b7c4054..e2607ca66eb3e8 100644 --- a/src/libraries/Common/src/System/AppContextSwitchHelper.cs +++ b/src/libraries/Common/src/System/AppContextSwitchHelper.cs @@ -23,7 +23,7 @@ internal static bool GetBooleanConfig(string switchName, string envVariable, boo { return true; } - if (str == "1" || string.Equals(str, bool.FalseString, StringComparison.OrdinalIgnoreCase)) + if (str == "0" || string.Equals(str, bool.FalseString, StringComparison.OrdinalIgnoreCase)) { return false; } diff --git a/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs b/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs index c77e5f5aca9a4d..1ca9a9e9dd7e5a 100644 --- a/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs +++ b/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs @@ -102,8 +102,7 @@ internal static bool IsWindowsVersionWithSchannelSupport() { // copied from MsQuicApi implementation to avoid triggering the static constructor Version minWindowsVersion = new Version(10, 0, 20145, 1000); - return OperatingSystem.IsWindowsVersionAtLeast(minWindowsVersion.Major, - minWindowsVersion.Minor, minWindowsVersion.Build, minWindowsVersion.Revision); + return OperatingSystem.IsWindowsVersionAtLeast(minWindowsVersion.Major, minWindowsVersion.Minor, minWindowsVersion.Build, minWindowsVersion.Revision); } private static Version GetMsQuicVersion() diff --git a/src/libraries/System.Net.Quic/tests/FunctionalTests/System.Net.Quic.Functional.Tests.csproj b/src/libraries/System.Net.Quic/tests/FunctionalTests/System.Net.Quic.Functional.Tests.csproj index 73b57fb5cda38a..29cacbc56ddffe 100644 --- a/src/libraries/System.Net.Quic/tests/FunctionalTests/System.Net.Quic.Functional.Tests.csproj +++ b/src/libraries/System.Net.Quic/tests/FunctionalTests/System.Net.Quic.Functional.Tests.csproj @@ -54,7 +54,7 @@ - +