internal static bool IsQuicSupported { get; }
internal static string MsQuicLibraryVersion { get; } = "unknown";
+ internal static string? NotSupportedReason { get; }
internal static bool UsesSChannelBackend { get; }
bool loaded = false;
IntPtr msQuicHandle;
-
// MsQuic is using DualMode sockets and that will fail even for IPv4 if AF_INET6 is not available.
if (!Socket.OSSupportsIPv6)
{
- NetEventSource.Info(null, "OS does not support dual mode sockets");
+ NotSupportedReason = "OS does not support dual mode sockets.";
+ if (NetEventSource.Log.IsEnabled())
+ {
+ NetEventSource.Info(null, NotSupportedReason);
+ }
return;
}
if (!loaded)
{
// MsQuic library not loaded
+ NotSupportedReason = $"Unable to load MsQuic library version '{s_minMsQuicVersion.Major}'.";
if (NetEventSource.Log.IsEnabled())
{
- NetEventSource.Info(null, $"Unable to load MsQuic library version '{s_minMsQuicVersion.Major}'.");
+ NetEventSource.Info(null, NotSupportedReason);
}
return;
}
MsQuicOpenVersion = (delegate* unmanaged[Cdecl]<uint, QUIC_API_TABLE**, int>)NativeLibrary.GetExport(msQuicHandle, nameof(MsQuicOpenVersion));
MsQuicClose = (delegate* unmanaged[Cdecl]<QUIC_API_TABLE*, void>)NativeLibrary.GetExport(msQuicHandle, nameof(MsQuicClose));
- if (!TryOpenMsQuic(out QUIC_API_TABLE* apiTable, out _))
+ if (!TryOpenMsQuic(out QUIC_API_TABLE* apiTable, out int openStatus))
{
// Too low version of the library (likely pre-2.0)
+ NotSupportedReason = $"MsQuicOpenVersion for version {s_minMsQuicVersion.Major} returned {openStatus} status code.";
+ if (NetEventSource.Log.IsEnabled())
+ {
+ NetEventSource.Info(null, NotSupportedReason);
+ }
return;
}
if (version < s_minMsQuicVersion)
{
+ NotSupportedReason = $"Incompatible MsQuic library version '{version}', expecting higher than '{s_minMsQuicVersion}'.";
if (NetEventSource.Log.IsEnabled())
{
- NetEventSource.Info(null, $"Incompatible MsQuic library version '{version}', expecting higher than '{s_minMsQuicVersion}'.");
+ NetEventSource.Info(null, NotSupportedReason);
}
return;
}
// Implies windows platform, check TLS1.3 availability
if (!IsWindowsVersionSupported())
{
+ NotSupportedReason = $"Current Windows version ({Environment.OSVersion}) is not supported by QUIC. Minimal supported version is {s_minWindowsVersion}.";
if (NetEventSource.Log.IsEnabled())
{
- NetEventSource.Info(null, $"Current Windows version ({Environment.OSVersion}) is not supported by QUIC. Minimal supported version is {s_minWindowsVersion}");
+ NetEventSource.Info(null, NotSupportedReason);
}
return;
}
openStatus = MsQuicOpenVersion((uint)s_minMsQuicVersion.Major, &table);
if (StatusFailed(openStatus))
{
- if (NetEventSource.Log.IsEnabled())
- {
- NetEventSource.Info(null, $"MsQuicOpenVersion for version {s_minMsQuicVersion.Major} returned {openStatus} status code.");
- }
-
apiTable = null;
return false;
}
public static bool IsQuicUnsupported => !IsSupported;
[ConditionalFact(nameof(IsQuicUnsupported))]
- public void UnsupportedPlatforms_ThrowsPlatformNotSupportedException()
+ public async Task UnsupportedPlatforms_ThrowsPlatformNotSupportedException()
{
- Assert.ThrowsAsync<PlatformNotSupportedException>(async () => await CreateQuicListener());
- Assert.ThrowsAsync<PlatformNotSupportedException>(async () => await CreateQuicConnection(new IPEndPoint(IPAddress.Loopback, 0)));
+ PlatformNotSupportedException listenerEx = await Assert.ThrowsAsync<PlatformNotSupportedException>(async () => await CreateQuicListener());
+ PlatformNotSupportedException connectionEx = await Assert.ThrowsAsync<PlatformNotSupportedException>(async () => await CreateQuicConnection(new IPEndPoint(IPAddress.Loopback, 0)));
+ Assert.Equal(listenerEx.Message, connectionEx.Message);
+ _output.WriteLine(listenerEx.Message);
}
[ActiveIssue("https://github.com/dotnet/runtime/issues/73290", typeof(PlatformDetection), nameof(PlatformDetection.IsSingleFile))]