diff --git a/eng/Versions.props b/eng/Versions.props
index ae34e9f29851a2..2b9e23ccb0ca6f 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -47,7 +47,7 @@
3.8.0
- 6.0.0-preview5.21219.2
+ 6.0.0-preview5.21262.4
3.10.0-2.final
3.10.0-2.final
diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProvider.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProvider.cs
index a7ac0f7f86d877..9f4c45a6f95890 100644
--- a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProvider.cs
+++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProvider.cs
@@ -47,8 +47,8 @@ public ConsoleLoggerProvider(IOptionsMonitor options, IEnu
_optionsReloadToken = _options.OnChange(ReloadLoggerOptions);
_messageQueue = new ConsoleLoggerProcessor();
- // TODO update when https://github.com/dotnet/runtime/issues/44922 implemented
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || DoesWindowsConsoleSupportAnsi())
+
+ if (DoesConsoleSupportAnsi())
{
_messageQueue.Console = new AnsiLogConsole();
_messageQueue.ErrorConsole = new AnsiLogConsole(stdErr: true);
@@ -60,8 +60,14 @@ public ConsoleLoggerProvider(IOptionsMonitor options, IEnu
}
}
- private static bool DoesWindowsConsoleSupportAnsi()
+ [UnsupportedOSPlatformGuard("windows")]
+ private static bool DoesConsoleSupportAnsi()
{
+ if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ {
+ return true;
+ }
+
// for Windows, check the console mode
var stdOutHandle = Interop.Kernel32.GetStdHandle(Interop.Kernel32.STD_OUTPUT_HANDLE);
if (!Interop.Kernel32.GetConsoleMode(stdOutHandle, out int consoleMode))
diff --git a/src/libraries/System.Net.Http/ref/System.Net.Http.cs b/src/libraries/System.Net.Http/ref/System.Net.Http.cs
index c05f0e0e9aead8..9fa9bdc34287ed 100644
--- a/src/libraries/System.Net.Http/ref/System.Net.Http.cs
+++ b/src/libraries/System.Net.Http/ref/System.Net.Http.cs
@@ -352,6 +352,7 @@ protected override void SerializeToStream(System.IO.Stream stream, System.Net.Tr
public sealed partial class SocketsHttpHandler : System.Net.Http.HttpMessageHandler
{
public SocketsHttpHandler() { }
+ [System.Runtime.Versioning.UnsupportedOSPlatformGuardAttribute("browser")]
public static bool IsSupported { get { throw null; } }
public bool AllowAutoRedirect { get { throw null; } set { } }
public System.Net.DecompressionMethods AutomaticDecompression { get { throw null; } set { } }
diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs
index 0fb0ca57b099a3..f85f0a3521e822 100644
--- a/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs
+++ b/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs
@@ -16,6 +16,7 @@ namespace System.Net.Http
[UnsupportedOSPlatform("browser")]
public sealed class SocketsHttpHandler : HttpMessageHandler
{
+ [UnsupportedOSPlatformGuard("browser")]
public static bool IsSupported => false;
public bool UseCookies
diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs
index 16272cbaa43361..1a3b68c55c7116 100644
--- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs
+++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs
@@ -76,6 +76,9 @@ internal sealed class HttpConnectionPool : IDisposable
private byte[]? _http2AltSvcOriginUri;
internal readonly byte[]? _http2EncodedAuthorityHostHeader;
+ [SupportedOSPlatformGuard("linux")]
+ [SupportedOSPlatformGuard("macOS")]
+ [SupportedOSPlatformGuard("Windows")]
private readonly bool _http3Enabled;
private Http3Connection? _http3Connection;
private SemaphoreSlim? _http3ConnectionCreateLock;
@@ -122,8 +125,8 @@ public HttpConnectionPool(HttpConnectionPoolManager poolManager, HttpConnectionK
}
_http2Enabled = _poolManager.Settings._maxHttpVersion >= HttpVersion.Version20;
- // TODO: Replace with Platform-Guard Assertion Annotations once https://github.com/dotnet/runtime/issues/44922 is finished
- if ((OperatingSystem.IsLinux() && !OperatingSystem.IsAndroid()) || OperatingSystem.IsWindows() || OperatingSystem.IsMacOS())
+
+ if (IsHttp3Supported())
{
_http3Enabled = _poolManager.Settings._maxHttpVersion >= HttpVersion.Version30 && (_poolManager.Settings._quicImplementationProvider ?? QuicImplementationProviders.Default).IsSupported;
}
@@ -261,8 +264,7 @@ public HttpConnectionPool(HttpConnectionPoolManager poolManager, HttpConnectionK
_http3EncodedAuthorityHostHeader = QPackEncoder.EncodeLiteralHeaderFieldWithStaticNameReferenceToArray(H3StaticTable.Authority, hostHeader);
}
- // TODO: Replace with Platform-Guard Assertion Annotations once https://github.com/dotnet/runtime/issues/44922 is finished
- if ((OperatingSystem.IsLinux() && !OperatingSystem.IsAndroid()) || OperatingSystem.IsWindows() || OperatingSystem.IsMacOS())
+ if (IsHttp3Supported())
{
if (_http3Enabled)
{
@@ -281,14 +283,17 @@ public HttpConnectionPool(HttpConnectionPoolManager poolManager, HttpConnectionK
if (NetEventSource.Log.IsEnabled()) Trace($"{this}");
}
+ [SupportedOSPlatformGuard("linux")]
+ [SupportedOSPlatformGuard("macOS")]
+ [SupportedOSPlatformGuard("Windows")]
+ internal static bool IsHttp3Supported() => (OperatingSystem.IsLinux() && !OperatingSystem.IsAndroid()) || OperatingSystem.IsWindows() || OperatingSystem.IsMacOS();
private static readonly List s_http3ApplicationProtocols = CreateHttp3ApplicationProtocols();
private static readonly List s_http2ApplicationProtocols = new List() { SslApplicationProtocol.Http2, SslApplicationProtocol.Http11 };
private static readonly List s_http2OnlyApplicationProtocols = new List() { SslApplicationProtocol.Http2 };
private static List CreateHttp3ApplicationProtocols()
{
- // TODO: Replace with Platform-Guard Assertion Annotations once https://github.com/dotnet/runtime/issues/44922 is finished
- if ((OperatingSystem.IsLinux() && !OperatingSystem.IsAndroid()) || OperatingSystem.IsWindows() || OperatingSystem.IsMacOS())
+ if (IsHttp3Supported())
{
// TODO: Once the HTTP/3 versions are part of SslApplicationProtocol, see https://github.com/dotnet/runtime/issues/1293, move this back to field initialization.
return new List() { Http3Connection.Http3ApplicationProtocol31, Http3Connection.Http3ApplicationProtocol30, Http3Connection.Http3ApplicationProtocol29 };
@@ -866,8 +871,7 @@ private async ValueTask DetermineVersionAndSendAsync(HttpRe
{
HttpResponseMessage? response;
- // TODO: Replace with Platform-Guard Assertion Annotations once https://github.com/dotnet/runtime/issues/44922 is finished
- if ((OperatingSystem.IsLinux() && !OperatingSystem.IsAndroid()) || OperatingSystem.IsWindows() || OperatingSystem.IsMacOS())
+ if (IsHttp3Supported())
{
response = await TrySendUsingHttp3Async(request, async, doRequestAuth, cancellationToken).ConfigureAwait(false);
if (response is not null)
diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionSettings.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionSettings.cs
index cf81a5d5a2929a..1ccbc3d8673d1d 100644
--- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionSettings.cs
+++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionSettings.cs
@@ -122,9 +122,8 @@ public HttpConnectionSettings CloneAndNormalize()
_plaintextStreamFilter = _plaintextStreamFilter
};
- // TODO: Replace with Platform-Guard Assertion Annotations once https://github.com/dotnet/runtime/issues/44922 is finished
// TODO: Remove if/when QuicImplementationProvider is removed from System.Net.Quic.
- if ((OperatingSystem.IsLinux() && !OperatingSystem.IsAndroid()) || OperatingSystem.IsWindows() || OperatingSystem.IsMacOS())
+ if (HttpConnectionPool.IsHttp3Supported())
{
settings._quicImplementationProvider = _quicImplementationProvider;
}
diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs
index 8e0b508e6a4858..31a9e6ac2cc1e0 100644
--- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs
+++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs
@@ -42,6 +42,7 @@ private void CheckDisposedOrStarted()
///
/// Gets a value that indicates whether the handler is supported on the current platform.
///
+ [UnsupportedOSPlatformGuard("browser")]
public static bool IsSupported => true;
public bool UseCookies
diff --git a/src/libraries/System.Net.Http/tests/TrimmingTests/HttpClientTest.cs b/src/libraries/System.Net.Http/tests/TrimmingTests/HttpClientTest.cs
index c05cac77920e66..7ded3b5b65be8e 100644
--- a/src/libraries/System.Net.Http/tests/TrimmingTests/HttpClientTest.cs
+++ b/src/libraries/System.Net.Http/tests/TrimmingTests/HttpClientTest.cs
@@ -4,10 +4,16 @@
using System;
using System.IO;
using System.Net.Http;
+using System.Runtime.Versioning;
using System.Threading.Tasks;
class Program
{
+ [SupportedOSPlatformGuard("linux")]
+ [SupportedOSPlatformGuard("macOS")]
+ [SupportedOSPlatformGuard("Windows")]
+ private static bool IsHttp3Supported => (OperatingSystem.IsLinux() && !OperatingSystem.IsAndroid()) || OperatingSystem.IsWindows() || OperatingSystem.IsMacOS();
+
static async Task Main(string[] args)
{
using var client = new HttpClient();
@@ -18,8 +24,7 @@ static async Task Main(string[] args)
const string quicDll = "System.Net.Quic.dll";
var quicDllExists = File.Exists(Path.Combine(AppContext.BaseDirectory, quicDll));
- // TODO: Replace with Platform-Guard Assertion Annotations once https://github.com/dotnet/runtime/issues/44922 is finished
- if ((OperatingSystem.IsLinux() && !OperatingSystem.IsAndroid()) || OperatingSystem.IsWindows() || OperatingSystem.IsMacOS())
+ if (IsHttp3Supported)
{
Console.WriteLine($"Expected {quicDll} is {(quicDllExists ? "present - OK" : "missing - BAD")}.");
return quicDllExists ? 100 : -1;
@@ -30,4 +35,4 @@ static async Task Main(string[] args)
return quicDllExists ? -1 : 100;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ThreadPoolTaskScheduler.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ThreadPoolTaskScheduler.cs
index 692e39bb6b015d..e1469c5cc8b80b 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ThreadPoolTaskScheduler.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ThreadPoolTaskScheduler.cs
@@ -45,13 +45,11 @@ protected internal override void QueueTask(Task task)
if (Thread.IsThreadStartSupported && (options & TaskCreationOptions.LongRunning) != 0)
{
// Run LongRunning tasks on their own dedicated thread.
-#pragma warning disable CA1416 // TODO: https://github.com/dotnet/runtime/issues/44922
new Thread(s_longRunningThreadWork)
{
IsBackground = true,
Name = ".NET Long Running Task"
}.UnsafeStart(task);
-#pragma warning restore CA1416
}
else
{
diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs
index aa6e8c6f8d582a..d6b20c461a5ce4 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs
@@ -164,7 +164,8 @@ public Thread(ParameterizedThreadStart start, int maxStackSize)
}
#if !TARGET_BROWSER
- internal const bool IsThreadStartSupported = true;
+ [UnsupportedOSPlatformGuard("browser")]
+ internal static bool IsThreadStartSupported => true;
/// Causes the operating system to change the state of the current instance to , and optionally supplies an object containing data to be used by the method the thread executes.
/// An object that contains data to be used by the method the thread executes.
diff --git a/src/mono/System.Private.CoreLib/src/System/Threading/Thread.Browser.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Threading/Thread.Browser.Mono.cs
index a456c5d8207ada..435a155c4ed164 100644
--- a/src/mono/System.Private.CoreLib/src/System/Threading/Thread.Browser.Mono.cs
+++ b/src/mono/System.Private.CoreLib/src/System/Threading/Thread.Browser.Mono.cs
@@ -7,7 +7,8 @@ namespace System.Threading
{
public partial class Thread
{
- internal const bool IsThreadStartSupported = false;
+ [UnsupportedOSPlatformGuard("browser")]
+ internal static bool IsThreadStartSupported => false;
[UnsupportedOSPlatform("browser")]
public void Start() => throw new PlatformNotSupportedException();