<MicrosoftCodeAnalysisVersion>3.8.0</MicrosoftCodeAnalysisVersion>
</PropertyGroup>
<PropertyGroup>
- <MicrosoftCodeAnalysisNetAnalyzersVersion>6.0.0-preview5.21219.2</MicrosoftCodeAnalysisNetAnalyzersVersion>
+ <MicrosoftCodeAnalysisNetAnalyzersVersion>6.0.0-preview5.21262.4</MicrosoftCodeAnalysisNetAnalyzersVersion>
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>3.10.0-2.final</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
<MicrosoftCodeAnalysisCSharpVersion>3.10.0-2.final</MicrosoftCodeAnalysisCSharpVersion>
<!-- Arcade dependencies -->
_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);
}
}
- 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))
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 { } }
[UnsupportedOSPlatform("browser")]
public sealed class SocketsHttpHandler : HttpMessageHandler
{
+ [UnsupportedOSPlatformGuard("browser")]
public static bool IsSupported => false;
public bool UseCookies
private byte[]? _http2AltSvcOriginUri;
internal readonly byte[]? _http2EncodedAuthorityHostHeader;
+ [SupportedOSPlatformGuard("linux")]
+ [SupportedOSPlatformGuard("macOS")]
+ [SupportedOSPlatformGuard("Windows")]
private readonly bool _http3Enabled;
private Http3Connection? _http3Connection;
private SemaphoreSlim? _http3ConnectionCreateLock;
}
_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;
}
_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)
{
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<SslApplicationProtocol> s_http3ApplicationProtocols = CreateHttp3ApplicationProtocols();
private static readonly List<SslApplicationProtocol> s_http2ApplicationProtocols = new List<SslApplicationProtocol>() { SslApplicationProtocol.Http2, SslApplicationProtocol.Http11 };
private static readonly List<SslApplicationProtocol> s_http2OnlyApplicationProtocols = new List<SslApplicationProtocol>() { SslApplicationProtocol.Http2 };
private static List<SslApplicationProtocol> 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<SslApplicationProtocol>() { Http3Connection.Http3ApplicationProtocol31, Http3Connection.Http3ApplicationProtocol30, Http3Connection.Http3ApplicationProtocol29 };
{
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)
_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;
}
/// <summary>
/// Gets a value that indicates whether the handler is supported on the current platform.
/// </summary>
+ [UnsupportedOSPlatformGuard("browser")]
public static bool IsSupported => true;
public bool UseCookies
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<int> Main(string[] args)
{
using var client = new HttpClient();
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;
return quicDllExists ? -1 : 100;
}
}
-}
\ No newline at end of file
+}
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
{
}
#if !TARGET_BROWSER
- internal const bool IsThreadStartSupported = true;
+ [UnsupportedOSPlatformGuard("browser")]
+ internal static bool IsThreadStartSupported => true;
/// <summary>Causes the operating system to change the state of the current instance to <see cref="ThreadState.Running"/>, and optionally supplies an object containing data to be used by the method the thread executes.</summary>
/// <param name="parameter">An object that contains data to be used by the method the thread executes.</param>
{
public partial class Thread
{
- internal const bool IsThreadStartSupported = false;
+ [UnsupportedOSPlatformGuard("browser")]
+ internal static bool IsThreadStartSupported => false;
[UnsupportedOSPlatform("browser")]
public void Start() => throw new PlatformNotSupportedException();