diff --git a/eng/versioning.targets b/eng/versioning.targets
index 3177b48b0ba6d..98fd08c850104 100644
--- a/eng/versioning.targets
+++ b/eng/versioning.targets
@@ -29,6 +29,15 @@
+
+ true
+
+
+
+
+
+
+
<_unsupportedOSPlatforms Include="$(UnsupportedOSPlatforms)" />
diff --git a/src/libraries/Common/src/System/Net/WebSockets/ManagedWebSocket.cs b/src/libraries/Common/src/System/Net/WebSockets/ManagedWebSocket.cs
index 7ed7a15994062..cffafdd0c41aa 100644
--- a/src/libraries/Common/src/System/Net/WebSockets/ManagedWebSocket.cs
+++ b/src/libraries/Common/src/System/Net/WebSockets/ManagedWebSocket.cs
@@ -7,6 +7,7 @@
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
@@ -23,6 +24,7 @@ namespace System.Net.WebSockets
/// a send operation while another is in progress or a receive operation while another is in progress will
/// result in an exception.
///
+ [UnsupportedOSPlatform("browser")]
internal sealed partial class ManagedWebSocket : WebSocket
{
/// Creates a from a connected to a websocket endpoint.
diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.cs b/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.cs
index 80e365a657530..4cca93a0012af 100644
--- a/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.cs
+++ b/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.cs
@@ -6,6 +6,7 @@
namespace Microsoft.Extensions.Logging
{
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static partial class ConsoleLoggerExtensions
{
public static Microsoft.Extensions.Logging.ILoggingBuilder AddConsole(this Microsoft.Extensions.Logging.ILoggingBuilder builder) { throw null; }
@@ -63,6 +64,7 @@ public ConsoleLoggerOptions() { }
[System.ObsoleteAttribute("ConsoleLoggerOptions.UseUtcTimestamp has been deprecated. Please use ConsoleFormatterOptions.UseUtcTimestamp instead.", false)]
public bool UseUtcTimestamp { get { throw null; } set { } }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[Microsoft.Extensions.Logging.ProviderAliasAttribute("Console")]
public partial class ConsoleLoggerProvider : Microsoft.Extensions.Logging.ILoggerProvider, Microsoft.Extensions.Logging.ISupportExternalScope, System.IDisposable
{
diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.csproj b/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.csproj
index 048eb0459608a..41c181ec7a7d0 100644
--- a/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.csproj
+++ b/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.csproj
@@ -1,6 +1,7 @@
netstandard2.0;net461
+ true
diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/AnsiParsingLogConsole.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/AnsiParsingLogConsole.cs
index 9f42ec6302932..6a4473289b287 100644
--- a/src/libraries/Microsoft.Extensions.Logging.Console/src/AnsiParsingLogConsole.cs
+++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/AnsiParsingLogConsole.cs
@@ -3,9 +3,11 @@
using System;
using System.IO;
+using System.Runtime.Versioning;
namespace Microsoft.Extensions.Logging.Console
{
+ [UnsupportedOSPlatform("browser")]
internal class AnsiParsingLogConsole : IConsole
{
private readonly TextWriter _textWriter;
diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLogger.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLogger.cs
index 1d544f3228109..daa903da318b0 100644
--- a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLogger.cs
+++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLogger.cs
@@ -3,10 +3,12 @@
using System;
using System.IO;
+using System.Runtime.Versioning;
using Microsoft.Extensions.Logging.Abstractions;
namespace Microsoft.Extensions.Logging.Console
{
+ [UnsupportedOSPlatform("browser")]
internal class ConsoleLogger : ILogger
{
private readonly string _name;
diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerExtensions.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerExtensions.cs
index 8cd8a594e359b..9d12ac5e111f4 100644
--- a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerExtensions.cs
+++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerExtensions.cs
@@ -3,6 +3,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
+using System.Runtime.Versioning;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
@@ -12,6 +13,7 @@
namespace Microsoft.Extensions.Logging
{
+ [UnsupportedOSPlatform("browser")]
public static class ConsoleLoggerExtensions
{
///
@@ -154,6 +156,7 @@ private static ILoggingBuilder AddFormatterWithName(this ILoggingBuilder builder
}
}
+ [UnsupportedOSPlatform("browser")]
internal class ConsoleLoggerFormatterConfigureOptions : ConfigureFromConfigurationOptions
where TOptions : ConsoleFormatterOptions
where TFormatter : ConsoleFormatter
@@ -164,6 +167,7 @@ public ConsoleLoggerFormatterConfigureOptions(ILoggerProviderConfiguration : ConfigurationChangeTokenSource
where TOptions : ConsoleFormatterOptions
where TFormatter : ConsoleFormatter
diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProcessor.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProcessor.cs
index 83a49c20d4c89..c79ccac72f9fd 100644
--- a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProcessor.cs
+++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProcessor.cs
@@ -3,10 +3,12 @@
using System;
using System.Collections.Concurrent;
+using System.Runtime.Versioning;
using System.Threading;
namespace Microsoft.Extensions.Logging.Console
{
+ [UnsupportedOSPlatform("browser")]
internal class ConsoleLoggerProcessor : IDisposable
{
private const int _maxQueuedMessages = 1024;
diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProvider.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProvider.cs
index d5a22520a1e29..859a206a78931 100644
--- a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProvider.cs
+++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProvider.cs
@@ -6,6 +6,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
using Microsoft.Extensions.Options;
namespace Microsoft.Extensions.Logging.Console
@@ -13,6 +14,7 @@ namespace Microsoft.Extensions.Logging.Console
///
/// A provider of instances.
///
+ [UnsupportedOSPlatform("browser")]
[ProviderAlias("Console")]
public class ConsoleLoggerProvider : ILoggerProvider, ISupportExternalScope
{
diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/Microsoft.Extensions.Logging.Console.csproj b/src/libraries/Microsoft.Extensions.Logging.Console/src/Microsoft.Extensions.Logging.Console.csproj
index 1e8e0f43fa4b7..ef573cddb9a39 100644
--- a/src/libraries/Microsoft.Extensions.Logging.Console/src/Microsoft.Extensions.Logging.Console.csproj
+++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/Microsoft.Extensions.Logging.Console.csproj
@@ -1,4 +1,4 @@
-
+
$(NetCoreAppCurrent);netcoreapp3.0;netstandard2.0;net461
@@ -8,6 +8,7 @@
$(DefineConstants);NO_SUPPRESS_GC_TRANSITION
false
+ true
diff --git a/src/libraries/System.Collections.Concurrent/ref/System.Collections.Concurrent.cs b/src/libraries/System.Collections.Concurrent/ref/System.Collections.Concurrent.cs
index c1a477bb048de..a7955b0912052 100644
--- a/src/libraries/System.Collections.Concurrent/ref/System.Collections.Concurrent.cs
+++ b/src/libraries/System.Collections.Concurrent/ref/System.Collections.Concurrent.cs
@@ -6,6 +6,7 @@
namespace System.Collections.Concurrent
{
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public partial class BlockingCollection : System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.ICollection, System.Collections.IEnumerable, System.IDisposable
{
public BlockingCollection() { }
diff --git a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs
index 40dc97191207e..3640d0d4e829b 100644
--- a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs
+++ b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs
@@ -15,6 +15,7 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
+using System.Runtime.Versioning;
using System.Threading;
namespace System.Collections.Concurrent
@@ -38,6 +39,7 @@ namespace System.Collections.Concurrent
/// away as an .
///
/// Specifies the type of elements in the collection.
+ [UnsupportedOSPlatform("browser")]
[DebuggerTypeProxy(typeof(BlockingCollectionDebugView<>))]
[DebuggerDisplay("Count = {Count}, Type = {_collection}")]
public class BlockingCollection : IEnumerable, ICollection, IDisposable, IReadOnlyCollection
@@ -1801,6 +1803,7 @@ public BlockingCollectionDebugView(BlockingCollection collection)
}
/// Returns a snapshot of the underlying collection's elements.
+ [UnsupportedOSPlatform("browser")]
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public T[] Items
{
diff --git a/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs
index af7ab07bb2441..d646fcd66ecbd 100644
--- a/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs
+++ b/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs
@@ -1309,7 +1309,6 @@ public abstract partial class TypeDescriptionProvider
{
protected TypeDescriptionProvider() { }
protected TypeDescriptionProvider(System.ComponentModel.TypeDescriptionProvider parent) { }
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public virtual object CreateInstance(System.IServiceProvider provider, System.Type objectType, System.Type[] argTypes, object[] args) { throw null; }
public virtual System.Collections.IDictionary GetCache(object instance) { throw null; }
public virtual System.ComponentModel.ICustomTypeDescriptor GetExtendedTypeDescriptor(object instance) { throw null; }
@@ -1352,7 +1351,6 @@ public static void CreateAssociation(object primary, object secondary) { }
public static System.ComponentModel.Design.IDesigner CreateDesigner(System.ComponentModel.IComponent component, System.Type designerBaseType) { throw null; }
public static System.ComponentModel.EventDescriptor CreateEvent(System.Type componentType, System.ComponentModel.EventDescriptor oldEventDescriptor, params System.Attribute[] attributes) { throw null; }
public static System.ComponentModel.EventDescriptor CreateEvent(System.Type componentType, string name, System.Type type, params System.Attribute[] attributes) { throw null; }
- [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public static object CreateInstance(System.IServiceProvider provider, System.Type objectType, System.Type[] argTypes, object[] args) { throw null; }
public static System.ComponentModel.PropertyDescriptor CreateProperty(System.Type componentType, System.ComponentModel.PropertyDescriptor oldPropertyDescriptor, params System.Attribute[] attributes) { throw null; }
public static System.ComponentModel.PropertyDescriptor CreateProperty(System.Type componentType, string name, System.Type type, params System.Attribute[] attributes) { throw null; }
diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptionProvider.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptionProvider.cs
index 565bc42e68f0a..28b7a3aa94d2e 100644
--- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptionProvider.cs
+++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptionProvider.cs
@@ -50,7 +50,6 @@ protected TypeDescriptionProvider(TypeDescriptionProvider parent)
/// parent provider was passed. If a parent provider was passed, this
/// method will invoke the parent provider's CreateInstance method.
///
- [UnsupportedOSPlatform("browser")]
public virtual object CreateInstance(IServiceProvider provider, Type objectType, Type[] argTypes, object[] args)
{
if (_parent != null)
diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs
index a542eb25d86ac..0dc2b3297adab 100644
--- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs
+++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs
@@ -429,7 +429,6 @@ public static EventDescriptor CreateEvent(Type componentType, EventDescriptor ol
/// a TypeDescriptionProvider object that is associated with the given
/// data type. If it finds one, it will delegate the call to that object.
///
- [UnsupportedOSPlatform("browser")]
public static object CreateInstance(IServiceProvider provider, Type objectType, Type[] argTypes, object[] args)
{
if (objectType == null)
diff --git a/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs b/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs
index bf97f5fe8418c..798968dfce17a 100644
--- a/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs
+++ b/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs
@@ -258,14 +258,14 @@ private void WriteEndHeader()
string? processName = s_processName;
if (processName is null)
{
- try
+ if (OperatingSystem.IsBrowser()) // Process isn't supported on Browser
{
- using Process process = Process.GetCurrentProcess();
- s_processName = processName = process.ProcessName;
+ s_processName = processName = string.Empty;
}
- catch (PlatformNotSupportedException) // Process isn't supported on Browser
+ else
{
- s_processName = processName = string.Empty;
+ using Process process = Process.GetCurrentProcess();
+ s_processName = processName = process.ProcessName;
}
}
diff --git a/src/libraries/System.Diagnostics.Tracing/ref/System.Diagnostics.Tracing.Counters.cs b/src/libraries/System.Diagnostics.Tracing/ref/System.Diagnostics.Tracing.Counters.cs
index 2e1cce9f780a4..56c748f026e3e 100644
--- a/src/libraries/System.Diagnostics.Tracing/ref/System.Diagnostics.Tracing.Counters.cs
+++ b/src/libraries/System.Diagnostics.Tracing/ref/System.Diagnostics.Tracing.Counters.cs
@@ -3,6 +3,7 @@
namespace System.Diagnostics.Tracing
{
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract partial class DiagnosticCounter : System.IDisposable
{
internal DiagnosticCounter() { }
@@ -13,11 +14,13 @@ internal DiagnosticCounter() { }
public void AddMetadata(string key, string? value) { }
public void Dispose() { }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public partial class PollingCounter : System.Diagnostics.Tracing.DiagnosticCounter
{
public PollingCounter(string name, System.Diagnostics.Tracing.EventSource eventSource, System.Func metricProvider) { }
public override string ToString() { throw null; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public partial class IncrementingEventCounter : System.Diagnostics.Tracing.DiagnosticCounter
{
public IncrementingEventCounter(string name, System.Diagnostics.Tracing.EventSource eventSource) { }
@@ -25,12 +28,14 @@ public IncrementingEventCounter(string name, System.Diagnostics.Tracing.EventSou
public void Increment(double increment = 1) { }
public override string ToString() { throw null; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public partial class IncrementingPollingCounter : System.Diagnostics.Tracing.DiagnosticCounter
{
public IncrementingPollingCounter(string name, System.Diagnostics.Tracing.EventSource eventSource, System.Func totalValueProvider) { }
public System.TimeSpan DisplayRateTimeScale { get { throw null; } set { } }
public override string ToString() { throw null; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public partial class EventCounter : System.Diagnostics.Tracing.DiagnosticCounter
{
public EventCounter(string name, System.Diagnostics.Tracing.EventSource eventSource) { }
diff --git a/src/libraries/System.Linq.Parallel/Directory.Build.props b/src/libraries/System.Linq.Parallel/Directory.Build.props
index e8d65546d0c80..7c0e0c24870de 100644
--- a/src/libraries/System.Linq.Parallel/Directory.Build.props
+++ b/src/libraries/System.Linq.Parallel/Directory.Build.props
@@ -2,5 +2,6 @@
Microsoft
+ browser
diff --git a/src/libraries/System.Net.Connections/Directory.Build.props b/src/libraries/System.Net.Connections/Directory.Build.props
index 63f02a0f817ef..0a5c8467bb6a9 100644
--- a/src/libraries/System.Net.Connections/Directory.Build.props
+++ b/src/libraries/System.Net.Connections/Directory.Build.props
@@ -2,5 +2,6 @@
Microsoft
+ browser
\ No newline at end of file
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 957f8f05e36c9..444c8692560c5 100644
--- a/src/libraries/System.Net.Http/ref/System.Net.Http.cs
+++ b/src/libraries/System.Net.Http/ref/System.Net.Http.cs
@@ -118,6 +118,7 @@ public HttpClientHandler() { }
public System.Net.CookieContainer CookieContainer { get { throw null; } set { } }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public System.Net.ICredentials? Credentials { get { throw null; } set { } }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public static System.Func DangerousAcceptAnyServerCertificateValidator { get { throw null; } }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public System.Net.ICredentials? DefaultProxyCredentials { get { throw null; } set { } }
diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj
index febae717a7fe9..98bae845888d7 100644
--- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj
+++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj
@@ -1,4 +1,4 @@
-
+
win
true
@@ -106,8 +106,6 @@
-
+
+
+
diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/HttpTelemetry.Browser.cs b/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/HttpTelemetry.Browser.cs
new file mode 100644
index 0000000000000..406afd10a87a0
--- /dev/null
+++ b/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/HttpTelemetry.Browser.cs
@@ -0,0 +1,22 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Diagnostics.Tracing;
+
+namespace System.Net.Http
+{
+ internal sealed partial class HttpTelemetry
+ {
+ public void Http11RequestLeftQueue(double timeOnQueueMilliseconds)
+ {
+ }
+
+ public void Http20RequestLeftQueue(double timeOnQueueMilliseconds)
+ {
+ }
+
+ protected override void OnEventCommand(EventCommandEventArgs command)
+ {
+ }
+ }
+}
diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpClient.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpClient.cs
index 0a9aa07790909..f741e9f618879 100644
--- a/src/libraries/System.Net.Http/src/System/Net/Http/HttpClient.cs
+++ b/src/libraries/System.Net.Http/src/System/Net/Http/HttpClient.cs
@@ -511,7 +511,9 @@ private async ValueTask SendAsyncCore(
// Wait for the send request to complete, getting back the response.
response = async ?
await base.SendAsync(request, cts.Token).ConfigureAwait(false) :
+#pragma warning disable CA1416 // Validate platform compatibility, not supported on browser, safe to suppress
base.Send(request, cts.Token);
+#pragma warning restore CA1416
ThrowForNullResponse(response);
// Buffer the response content if we've been asked to.
diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs
index 81de5ba140afe..2e3289643cfbe 100644
--- a/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs
+++ b/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs
@@ -306,6 +306,7 @@ protected internal override Task SendAsync(HttpRequestMessa
// lazy-load the validator func so it can be trimmed by the ILLinker if it isn't used.
private static Func? s_dangerousAcceptAnyServerCertificateValidator;
+ [UnsupportedOSPlatform("browser")]
public static Func DangerousAcceptAnyServerCertificateValidator =>
Volatile.Read(ref s_dangerousAcceptAnyServerCertificateValidator) ??
Interlocked.CompareExchange(ref s_dangerousAcceptAnyServerCertificateValidator, delegate { return true; }, null) ??
diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpTelemetry.AnyOS.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpTelemetry.AnyOS.cs
new file mode 100644
index 0000000000000..0a7e908bf0c31
--- /dev/null
+++ b/src/libraries/System.Net.Http/src/System/Net/Http/HttpTelemetry.AnyOS.cs
@@ -0,0 +1,104 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Diagnostics;
+using System.Diagnostics.Tracing;
+using System.Threading;
+
+namespace System.Net.Http
+{
+ internal sealed partial class HttpTelemetry
+ {
+ private IncrementingPollingCounter? _startedRequestsPerSecondCounter;
+ private IncrementingPollingCounter? _failedRequestsPerSecondCounter;
+ private PollingCounter? _startedRequestsCounter;
+ private PollingCounter? _currentRequestsCounter;
+ private PollingCounter? _failedRequestsCounter;
+ private PollingCounter? _totalHttp11ConnectionsCounter;
+ private PollingCounter? _totalHttp20ConnectionsCounter;
+ private EventCounter? _http11RequestsQueueDurationCounter;
+ private EventCounter? _http20RequestsQueueDurationCounter;
+
+ [NonEvent]
+ public void Http11RequestLeftQueue(double timeOnQueueMilliseconds)
+ {
+ _http11RequestsQueueDurationCounter!.WriteMetric(timeOnQueueMilliseconds);
+ RequestLeftQueue(timeOnQueueMilliseconds, versionMajor: 1, versionMinor: 1);
+ }
+
+ [NonEvent]
+ public void Http20RequestLeftQueue(double timeOnQueueMilliseconds)
+ {
+ _http20RequestsQueueDurationCounter!.WriteMetric(timeOnQueueMilliseconds);
+ RequestLeftQueue(timeOnQueueMilliseconds, versionMajor: 2, versionMinor: 0);
+ }
+
+ protected override void OnEventCommand(EventCommandEventArgs command)
+ {
+ if (command.Command == EventCommand.Enable)
+ {
+ // This is the convention for initializing counters in the RuntimeEventSource (lazily on the first enable command).
+ // They aren't disabled afterwards...
+
+ // The cumulative number of HTTP requests started since the process started.
+ _startedRequestsCounter ??= new PollingCounter("requests-started", this, () => Interlocked.Read(ref _startedRequests))
+ {
+ DisplayName = "Requests Started",
+ };
+
+ // The number of HTTP requests started per second since the process started.
+ _startedRequestsPerSecondCounter ??= new IncrementingPollingCounter("requests-started-rate", this, () => Interlocked.Read(ref _startedRequests))
+ {
+ DisplayName = "Requests Started Rate",
+ DisplayRateTimeScale = TimeSpan.FromSeconds(1)
+ };
+
+ // The cumulative number of HTTP requests failed since the process started.
+ // Failed means that an exception occurred during the handler's Send(Async) call as a result of a connection related error, timeout, or explicitly cancelled.
+ // In case of using HttpClient's SendAsync(and friends) with buffering, this includes exceptions that occured while buffering the response content
+ // In case of using HttpClient's helper methods (GetString/ByteArray/Stream), this includes responses with non-success status codes
+ _failedRequestsCounter ??= new PollingCounter("requests-failed", this, () => Interlocked.Read(ref _failedRequests))
+ {
+ DisplayName = "Requests Failed"
+ };
+
+ // The number of HTTP requests failed per second since the process started.
+ _failedRequestsPerSecondCounter ??= new IncrementingPollingCounter("requests-failed-rate", this, () => Interlocked.Read(ref _failedRequests))
+ {
+ DisplayName = "Requests Failed Rate",
+ DisplayRateTimeScale = TimeSpan.FromSeconds(1)
+ };
+
+ // The current number of active HTTP requests that have started but not yet completed or failed.
+ // Use (-_stoppedRequests + _startedRequests) to avoid returning a negative value if _stoppedRequests is
+ // incremented after reading _startedRequests due to race conditions with completing the HTTP request.
+ _currentRequestsCounter ??= new PollingCounter("current-requests", this, () => -Interlocked.Read(ref _stoppedRequests) + Interlocked.Read(ref _startedRequests))
+ {
+ DisplayName = "Current Requests"
+ };
+
+ _totalHttp11ConnectionsCounter ??= new PollingCounter("http11-connections-current-total", this, () => Interlocked.Read(ref _openedHttp11Connections))
+ {
+ DisplayName = "Current Http 1.1 Connections"
+ };
+
+ _totalHttp20ConnectionsCounter ??= new PollingCounter("http20-connections-current-total", this, () => Interlocked.Read(ref _openedHttp20Connections))
+ {
+ DisplayName = "Current Http 2.0 Connections"
+ };
+
+ _http11RequestsQueueDurationCounter ??= new EventCounter("http11-requests-queue-duration", this)
+ {
+ DisplayName = "HTTP 1.1 Requests Queue Duration",
+ DisplayUnits = "ms"
+ };
+
+ _http20RequestsQueueDurationCounter ??= new EventCounter("http20-requests-queue-duration", this)
+ {
+ DisplayName = "HTTP 2.0 Requests Queue Duration",
+ DisplayUnits = "ms"
+ };
+ }
+ }
+ }
+}
diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpTelemetry.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpTelemetry.cs
index 5879581504f45..385d959770732 100644
--- a/src/libraries/System.Net.Http/src/System/Net/Http/HttpTelemetry.cs
+++ b/src/libraries/System.Net.Http/src/System/Net/Http/HttpTelemetry.cs
@@ -8,20 +8,10 @@
namespace System.Net.Http
{
[EventSource(Name = "System.Net.Http")]
- internal sealed class HttpTelemetry : EventSource
+ internal sealed partial class HttpTelemetry : EventSource
{
public static readonly HttpTelemetry Log = new HttpTelemetry();
- private IncrementingPollingCounter? _startedRequestsPerSecondCounter;
- private IncrementingPollingCounter? _failedRequestsPerSecondCounter;
- private PollingCounter? _startedRequestsCounter;
- private PollingCounter? _currentRequestsCounter;
- private PollingCounter? _failedRequestsCounter;
- private PollingCounter? _totalHttp11ConnectionsCounter;
- private PollingCounter? _totalHttp20ConnectionsCounter;
- private EventCounter? _http11RequestsQueueDurationCounter;
- private EventCounter? _http20RequestsQueueDurationCounter;
-
private long _startedRequests;
private long _stoppedRequests;
private long _failedRequests;
@@ -168,88 +158,6 @@ public void Http20ConnectionClosed()
ConnectionClosed(versionMajor: 2, versionMinor: 0);
}
- [NonEvent]
- public void Http11RequestLeftQueue(double timeOnQueueMilliseconds)
- {
- _http11RequestsQueueDurationCounter!.WriteMetric(timeOnQueueMilliseconds);
- RequestLeftQueue(timeOnQueueMilliseconds, versionMajor: 1, versionMinor: 1);
- }
-
- [NonEvent]
- public void Http20RequestLeftQueue(double timeOnQueueMilliseconds)
- {
- _http20RequestsQueueDurationCounter!.WriteMetric(timeOnQueueMilliseconds);
- RequestLeftQueue(timeOnQueueMilliseconds, versionMajor: 2, versionMinor: 0);
- }
-
- protected override void OnEventCommand(EventCommandEventArgs command)
- {
- if (command.Command == EventCommand.Enable)
- {
- // This is the convention for initializing counters in the RuntimeEventSource (lazily on the first enable command).
- // They aren't disabled afterwards...
-
- // The cumulative number of HTTP requests started since the process started.
- _startedRequestsCounter ??= new PollingCounter("requests-started", this, () => Interlocked.Read(ref _startedRequests))
- {
- DisplayName = "Requests Started",
- };
-
- // The number of HTTP requests started per second since the process started.
- _startedRequestsPerSecondCounter ??= new IncrementingPollingCounter("requests-started-rate", this, () => Interlocked.Read(ref _startedRequests))
- {
- DisplayName = "Requests Started Rate",
- DisplayRateTimeScale = TimeSpan.FromSeconds(1)
- };
-
- // The cumulative number of HTTP requests failed since the process started.
- // Failed means that an exception occurred during the handler's Send(Async) call as a result of a connection related error, timeout, or explicitly cancelled.
- // In case of using HttpClient's SendAsync(and friends) with buffering, this includes exceptions that occured while buffering the response content
- // In case of using HttpClient's helper methods (GetString/ByteArray/Stream), this includes responses with non-success status codes
- _failedRequestsCounter ??= new PollingCounter("requests-failed", this, () => Interlocked.Read(ref _failedRequests))
- {
- DisplayName = "Requests Failed"
- };
-
- // The number of HTTP requests failed per second since the process started.
- _failedRequestsPerSecondCounter ??= new IncrementingPollingCounter("requests-failed-rate", this, () => Interlocked.Read(ref _failedRequests))
- {
- DisplayName = "Requests Failed Rate",
- DisplayRateTimeScale = TimeSpan.FromSeconds(1)
- };
-
- // The current number of active HTTP requests that have started but not yet completed or failed.
- // Use (-_stoppedRequests + _startedRequests) to avoid returning a negative value if _stoppedRequests is
- // incremented after reading _startedRequests due to race conditions with completing the HTTP request.
- _currentRequestsCounter ??= new PollingCounter("current-requests", this, () => -Interlocked.Read(ref _stoppedRequests) + Interlocked.Read(ref _startedRequests))
- {
- DisplayName = "Current Requests"
- };
-
- _totalHttp11ConnectionsCounter ??= new PollingCounter("http11-connections-current-total", this, () => Interlocked.Read(ref _openedHttp11Connections))
- {
- DisplayName = "Current Http 1.1 Connections"
- };
-
- _totalHttp20ConnectionsCounter ??= new PollingCounter("http20-connections-current-total", this, () => Interlocked.Read(ref _openedHttp20Connections))
- {
- DisplayName = "Current Http 2.0 Connections"
- };
-
- _http11RequestsQueueDurationCounter ??= new EventCounter("http11-requests-queue-duration", this)
- {
- DisplayName = "HTTP 1.1 Requests Queue Duration",
- DisplayUnits = "ms"
- };
-
- _http20RequestsQueueDurationCounter ??= new EventCounter("http20-requests-queue-duration", this)
- {
- DisplayName = "HTTP 2.0 Requests Queue Duration",
- DisplayUnits = "ms"
- };
- }
- }
-
[NonEvent]
private unsafe void WriteEvent(int eventId, string? arg1, string? arg2, int arg3, string? arg4, byte arg5, byte arg6, HttpVersionPolicy arg7)
{
diff --git a/src/libraries/System.Net.ServicePoint/ref/System.Net.ServicePoint.cs b/src/libraries/System.Net.ServicePoint/ref/System.Net.ServicePoint.cs
index d7adfc5a1484e..f26d234238f72 100644
--- a/src/libraries/System.Net.ServicePoint/ref/System.Net.ServicePoint.cs
+++ b/src/libraries/System.Net.ServicePoint/ref/System.Net.ServicePoint.cs
@@ -48,6 +48,7 @@ internal ServicePointManager() { }
public static int DefaultConnectionLimit { get { throw null; } set { } }
public static int DnsRefreshTimeout { get { throw null; } set { } }
public static bool EnableDnsRoundRobin { get { throw null; } set { } }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static System.Net.Security.EncryptionPolicy EncryptionPolicy { get { throw null; } }
public static bool Expect100Continue { get { throw null; } set { } }
public static int MaxServicePointIdleTime { get { throw null; } set { } }
diff --git a/src/libraries/System.Net.ServicePoint/src/System/Net/ServicePointManager.cs b/src/libraries/System.Net.ServicePoint/src/System/Net/ServicePointManager.cs
index 267610d2d675f..eb278644472e5 100644
--- a/src/libraries/System.Net.ServicePoint/src/System/Net/ServicePointManager.cs
+++ b/src/libraries/System.Net.ServicePoint/src/System/Net/ServicePointManager.cs
@@ -4,6 +4,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Net.Security;
+using System.Runtime.Versioning;
using System.Threading;
namespace System.Net
@@ -102,6 +103,7 @@ public static int DnsRefreshTimeout
public static bool CheckCertificateRevocationList { get; set; }
+ [UnsupportedOSPlatform("browser")]
public static EncryptionPolicy EncryptionPolicy { get; } = EncryptionPolicy.RequireEncryption;
[Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
diff --git a/src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.cs b/src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.cs
index b853be87dadef..a5db1a07205d8 100644
--- a/src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.cs
+++ b/src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.cs
@@ -6,6 +6,7 @@
using System.Globalization;
using System.Net.NetworkInformation;
using System.Runtime.Serialization;
+using System.Runtime.Versioning;
using System.Text.RegularExpressions;
namespace System.Net
@@ -160,6 +161,7 @@ private bool IsLocal(Uri host)
string hostString = host.Host;
+#pragma warning disable CA1416 // Validate platform compatibility, issue: https://github.com/dotnet/runtime/issues/43751
if (IPAddress.TryParse(hostString, out IPAddress? hostAddress))
{
return IPAddress.IsLoopback(hostAddress) || IsAddressLocal(hostAddress);
@@ -174,11 +176,13 @@ private bool IsLocal(Uri host)
// If it matches the primary domain, it's local. (Whether or not the hostname matches.)
string local = "." + IPGlobalProperties.GetIPGlobalProperties().DomainName;
+#pragma warning restore CA1416 // Validate platform compatibility
return
local.Length == (hostString.Length - dot) &&
string.Compare(local, 0, hostString, dot, local.Length, StringComparison.OrdinalIgnoreCase) == 0;
}
+ [UnsupportedOSPlatform("browser")]
private static bool IsAddressLocal(IPAddress ipAddress)
{
// Perf note: The .NET Framework caches this and then uses network change notifications to track
diff --git a/src/libraries/System.Net.WebSockets.WebSocketProtocol/Directory.Build.props b/src/libraries/System.Net.WebSockets.WebSocketProtocol/Directory.Build.props
index bdcfca3b543cb..1db5968484c1e 100644
--- a/src/libraries/System.Net.WebSockets.WebSocketProtocol/Directory.Build.props
+++ b/src/libraries/System.Net.WebSockets.WebSocketProtocol/Directory.Build.props
@@ -2,5 +2,6 @@
Open
+ true
\ No newline at end of file
diff --git a/src/libraries/System.Net.WebSockets.WebSocketProtocol/ref/System.Net.WebSockets.WebSocketProtocol.cs b/src/libraries/System.Net.WebSockets.WebSocketProtocol/ref/System.Net.WebSockets.WebSocketProtocol.cs
index 7b6113f06d6a5..295705fdf90ac 100644
--- a/src/libraries/System.Net.WebSockets.WebSocketProtocol/ref/System.Net.WebSockets.WebSocketProtocol.cs
+++ b/src/libraries/System.Net.WebSockets.WebSocketProtocol/ref/System.Net.WebSockets.WebSocketProtocol.cs
@@ -6,6 +6,7 @@
namespace System.Net.WebSockets
{
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static partial class WebSocketProtocol
{
public static System.Net.WebSockets.WebSocket CreateFromStream(System.IO.Stream stream, bool isServer, string? subProtocol, System.TimeSpan keepAliveInterval) { throw null; }
diff --git a/src/libraries/System.Net.WebSockets.WebSocketProtocol/src/System/Net/WebSockets/WebSocketProtocol.cs b/src/libraries/System.Net.WebSockets.WebSocketProtocol/src/System/Net/WebSockets/WebSocketProtocol.cs
index 49e3196964bd7..1178e70d760c1 100644
--- a/src/libraries/System.Net.WebSockets.WebSocketProtocol/src/System/Net/WebSockets/WebSocketProtocol.cs
+++ b/src/libraries/System.Net.WebSockets.WebSocketProtocol/src/System/Net/WebSockets/WebSocketProtocol.cs
@@ -2,10 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.IO;
+using System.Runtime.Versioning;
using System.Threading;
namespace System.Net.WebSockets
{
+ [UnsupportedOSPlatform("browser")]
public static class WebSocketProtocol
{
public static WebSocket CreateFromStream(
diff --git a/src/libraries/System.Net.WebSockets/ref/System.Net.WebSockets.cs b/src/libraries/System.Net.WebSockets/ref/System.Net.WebSockets.cs
index e4ff945bb5b64..ca1e25ea21289 100644
--- a/src/libraries/System.Net.WebSockets/ref/System.Net.WebSockets.cs
+++ b/src/libraries/System.Net.WebSockets/ref/System.Net.WebSockets.cs
@@ -26,8 +26,10 @@ protected WebSocket() { }
public abstract System.Threading.Tasks.Task CloseAsync(System.Net.WebSockets.WebSocketCloseStatus closeStatus, string? statusDescription, System.Threading.CancellationToken cancellationToken);
public abstract System.Threading.Tasks.Task CloseOutputAsync(System.Net.WebSockets.WebSocketCloseStatus closeStatus, string? statusDescription, System.Threading.CancellationToken cancellationToken);
public static System.ArraySegment CreateClientBuffer(int receiveBufferSize, int sendBufferSize) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static System.Net.WebSockets.WebSocket CreateClientWebSocket(System.IO.Stream innerStream, string? subProtocol, int receiveBufferSize, int sendBufferSize, System.TimeSpan keepAliveInterval, bool useZeroMaskingKey, System.ArraySegment internalBuffer) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static System.Net.WebSockets.WebSocket CreateFromStream(System.IO.Stream stream, bool isServer, string? subProtocol, System.TimeSpan keepAliveInterval) { throw null; }
public static System.ArraySegment CreateServerBuffer(int receiveBufferSize) { throw null; }
public abstract void Dispose();
diff --git a/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocket.cs b/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocket.cs
index 3bd6835a16f1d..14732fb6b77ca 100644
--- a/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocket.cs
+++ b/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocket.cs
@@ -5,6 +5,7 @@
using System.ComponentModel;
using System.IO;
using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
@@ -133,6 +134,7 @@ public static ArraySegment CreateServerBuffer(int receiveBufferSize)
/// The agreed upon sub-protocol that was used when creating the connection.
/// The keep-alive interval to use, or to disable keep-alives.
/// The created .
+ [UnsupportedOSPlatform("browser")]
public static WebSocket CreateFromStream(Stream stream, bool isServer, string? subProtocol, TimeSpan keepAliveInterval)
{
if (stream == null)
@@ -172,6 +174,7 @@ public static void RegisterPrefixes()
throw new PlatformNotSupportedException();
}
+ [UnsupportedOSPlatform("browser")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static WebSocket CreateClientWebSocket(Stream innerStream,
string? subProtocol, int receiveBufferSize, int sendBufferSize,
diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterGroup.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterGroup.cs
index effc21fd61ad5..e6ce6fda4a38a 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterGroup.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterGroup.cs
@@ -6,6 +6,7 @@
using System.Diagnostics;
#endif
using System.Collections.Generic;
+using System.Runtime.Versioning;
using System.Threading;
#if ES_BUILD_STANDALONE
@@ -14,6 +15,7 @@ namespace Microsoft.Diagnostics.Tracing
namespace System.Diagnostics.Tracing
#endif
{
+ [UnsupportedOSPlatform("browser")]
internal class CounterGroup
{
private readonly EventSource _eventSource;
diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/DiagnosticCounter.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/DiagnosticCounter.cs
index c2c7e20b347f4..16724c371c49f 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/DiagnosticCounter.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/DiagnosticCounter.cs
@@ -6,6 +6,7 @@
using System.Diagnostics;
#endif
using System.Collections.Generic;
+using System.Runtime.Versioning;
using System.Text;
using System.Threading;
@@ -19,6 +20,7 @@ namespace System.Diagnostics.Tracing
/// DiagnosticCounter is an abstract class that serves as the parent class for various Counter* classes,
/// namely EventCounter, PollingCounter, IncrementingEventCounter, and IncrementingPollingCounter.
///
+ [UnsupportedOSPlatform("browser")]
public abstract class DiagnosticCounter : IDisposable
{
///
diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventCounter.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventCounter.cs
index 9d14c881e183b..2f4489afc9e6c 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventCounter.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventCounter.cs
@@ -6,6 +6,7 @@
using System.Diagnostics;
#endif
using System.Diagnostics.CodeAnalysis;
+using System.Runtime.Versioning;
using System.Threading;
#if ES_BUILD_STANDALONE
@@ -23,6 +24,7 @@ namespace System.Diagnostics.Tracing
/// See https://github.com/dotnet/runtime/blob/master/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestEventCounter.cs
/// which shows tests, which are also useful in seeing actual use.
///
+ [UnsupportedOSPlatform("browser")]
public partial class EventCounter : DiagnosticCounter
{
///
diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingEventCounter.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingEventCounter.cs
index 8d3d378956107..4b4d08ec738bf 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingEventCounter.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingEventCounter.cs
@@ -9,6 +9,8 @@
#if ES_BUILD_STANDALONE
namespace Microsoft.Diagnostics.Tracing
#else
+using System.Runtime.Versioning;
+
namespace System.Diagnostics.Tracing
#endif
{
@@ -18,6 +20,9 @@ namespace System.Diagnostics.Tracing
/// It does not calculate statistics like mean, standard deviation, etc. because it only accumulates
/// the counter value.
///
+#if NETCOREAPP
+ [UnsupportedOSPlatform("browser")]
+#endif
public partial class IncrementingEventCounter : DiagnosticCounter
{
///
diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingPollingCounter.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingPollingCounter.cs
index 3854d1c93cce6..d18e5ad6f93c3 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingPollingCounter.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingPollingCounter.cs
@@ -8,6 +8,8 @@
#if ES_BUILD_STANDALONE
namespace Microsoft.Diagnostics.Tracing
#else
+using System.Runtime.Versioning;
+
namespace System.Diagnostics.Tracing
#endif
{
@@ -19,6 +21,9 @@ namespace System.Diagnostics.Tracing
/// Unlike IncrementingEventCounter, this takes in a polling callback that it can call to update
/// its own metric periodically.
///
+#if NETCOREAPP
+ [UnsupportedOSPlatform("browser")]
+#endif
public partial class IncrementingPollingCounter : DiagnosticCounter
{
///
diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/PollingCounter.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/PollingCounter.cs
index 12f0349067f0a..d2b88669b21ac 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/PollingCounter.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/PollingCounter.cs
@@ -8,6 +8,8 @@
#if ES_BUILD_STANDALONE
namespace Microsoft.Diagnostics.Tracing
#else
+using System.Runtime.Versioning;
+
namespace System.Diagnostics.Tracing
#endif
{
@@ -17,6 +19,9 @@ namespace System.Diagnostics.Tracing
/// function to collect metrics on its own rather than the user having to call WriteMetric()
/// every time.
///
+#if NETCOREAPP
+ [UnsupportedOSPlatform("browser")]
+#endif
public partial class PollingCounter : DiagnosticCounter
{
///
diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.Unix.cs
index a411b09746be2..d5fc11b588c0b 100644
--- a/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.Unix.cs
@@ -4,6 +4,7 @@
using Microsoft.Win32.SafeHandles;
using System.Diagnostics;
using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
@@ -333,7 +334,9 @@ private void FlushOSBuffer()
private void FlushWriteBufferForWriteByte()
{
+#pragma warning disable CA1416 // Validate platform compatibility, issue: https://github.com/dotnet/runtime/issues/44542
_asyncState?.Wait();
+#pragma warning restore CA1416
try { FlushWriteBuffer(); }
finally { _asyncState?.Release(); }
}
@@ -583,7 +586,9 @@ private unsafe int ReadNative(Span buffer)
/// Reads from the file handle into the buffer, overwriting anything in it.
private int FillReadBufferForReadByte()
{
+#pragma warning disable CA1416 // Validate platform compatibility, issue: https://github.com/dotnet/runtime/issues/44542
_asyncState?.Wait();
+#pragma warning restore CA1416
try { return ReadNative(_buffer); }
finally { _asyncState?.Release(); }
}
diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Stream.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Stream.cs
index a34ec709b6dac..6729439695e38 100644
--- a/src/libraries/System.Private.CoreLib/src/System/IO/Stream.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/IO/Stream.cs
@@ -212,7 +212,9 @@ internal IAsyncResult BeginReadInternal(
}
else
{
+#pragma warning disable CA1416 // Validate platform compatibility, issue: https://github.com/dotnet/runtime/issues/44543
semaphore.Wait();
+#pragma warning restore CA1416
}
// Create the task to asynchronously do a Read. This task serves both
@@ -367,7 +369,9 @@ internal IAsyncResult BeginWriteInternal(
}
else
{
+#pragma warning disable CA1416 // Validate platform compatibility, issue: https://github.com/dotnet/runtime/issues/44543
semaphore.Wait(); // synchronously wait here
+#pragma warning restore CA1416
}
// Create the task to asynchronously do a Write. This task serves both
diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs
index 9af60a64ff757..4f88b6670e270 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
+using System.Runtime.Versioning;
namespace System.Threading
{
@@ -357,6 +358,7 @@ public void Reset()
/// The caller of this method blocks indefinitely until the current instance is set. The caller will
/// return immediately if the event is currently in a set state.
///
+ [UnsupportedOSPlatform("browser")]
public void Wait()
{
Wait(Timeout.Infinite, CancellationToken.None);
@@ -377,6 +379,7 @@ public void Wait()
/// The caller of this method blocks indefinitely until the current instance is set. The caller will
/// return immediately if the event is currently in a set state.
///
+ [UnsupportedOSPlatform("browser")]
public void Wait(CancellationToken cancellationToken)
{
Wait(Timeout.Infinite, cancellationToken);
@@ -397,6 +400,7 @@ public void Wait(CancellationToken cancellationToken)
///
/// The maximum number of waiters has been exceeded.
///
+ [UnsupportedOSPlatform("browser")]
public bool Wait(TimeSpan timeout)
{
long totalMilliseconds = (long)timeout.TotalMilliseconds;
@@ -428,6 +432,7 @@ public bool Wait(TimeSpan timeout)
///
/// The maximum number of waiters has been exceeded.
///
+ [UnsupportedOSPlatform("browser")]
public bool Wait(TimeSpan timeout, CancellationToken cancellationToken)
{
long totalMilliseconds = (long)timeout.TotalMilliseconds;
@@ -452,6 +457,7 @@ public bool Wait(TimeSpan timeout, CancellationToken cancellationToken)
///
/// The maximum number of waiters has been exceeded.
///
+ [UnsupportedOSPlatform("browser")]
public bool Wait(int millisecondsTimeout)
{
return Wait(millisecondsTimeout, CancellationToken.None);
@@ -475,6 +481,7 @@ public bool Wait(int millisecondsTimeout)
///
/// was canceled.
+ [UnsupportedOSPlatform("browser")]
public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken)
{
ThrowIfDisposed();
diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs
index 4e9438112fba6..dd573007ce215 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs
@@ -3,6 +3,7 @@
using System.Diagnostics;
using System.Runtime.CompilerServices;
+using System.Runtime.Versioning;
using System.Threading.Tasks;
namespace System.Threading
@@ -172,6 +173,7 @@ public SemaphoreSlim(int initialCount, int maxCount)
///
/// The current instance has already been
/// disposed.
+ [UnsupportedOSPlatform("browser")]
public void Wait()
{
// Call wait with infinite timeout
@@ -188,6 +190,7 @@ public void Wait()
/// canceled.
/// The current instance has already been
/// disposed.
+ [UnsupportedOSPlatform("browser")]
public void Wait(CancellationToken cancellationToken)
{
// Call wait with infinite timeout
@@ -206,6 +209,7 @@ public void Wait(CancellationToken cancellationToken)
/// is a negative
/// number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater
/// than .
+ [UnsupportedOSPlatform("browser")]
public bool Wait(TimeSpan timeout)
{
// Validate the timeout
@@ -236,6 +240,7 @@ public bool Wait(TimeSpan timeout)
/// number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater
/// than .
/// was canceled.
+ [UnsupportedOSPlatform("browser")]
public bool Wait(TimeSpan timeout, CancellationToken cancellationToken)
{
// Validate the timeout
@@ -260,6 +265,7 @@ public bool Wait(TimeSpan timeout, CancellationToken cancellationToken)
/// otherwise, false.
/// is a
/// negative number other than -1, which represents an infinite time-out.
+ [UnsupportedOSPlatform("browser")]
public bool Wait(int millisecondsTimeout)
{
return Wait(millisecondsTimeout, CancellationToken.None);
@@ -277,6 +283,7 @@ public bool Wait(int millisecondsTimeout)
/// is a negative number other than -1,
/// which represents an infinite time-out.
/// was canceled.
+ [UnsupportedOSPlatform("browser")]
public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken)
{
CheckDispose();
@@ -432,6 +439,7 @@ public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken)
/// The start ticks to calculate the elapsed time
/// The CancellationToken to observe.
/// true if the monitor received a signal, false if the timeout expired
+ [UnsupportedOSPlatform("browser")]
private bool WaitUntilCountOrTimeout(int millisecondsTimeout, uint startTime, CancellationToken cancellationToken)
{
int remainingWaitMilliseconds = Timeout.Infinite;
diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs
index b2ca3898176ce..0e9090a0c62fa 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs
@@ -677,6 +677,7 @@ internal static Task FromAsyncImpl(
}
else
{
+#pragma warning disable CA1416 // Validate platform compatibility, issue: https://github.com/dotnet/runtime/issues/44544
ThreadPool.RegisterWaitForSingleObject(
asyncResult.AsyncWaitHandle,
delegate
@@ -687,6 +688,7 @@ internal static Task FromAsyncImpl(
null,
Timeout.Infinite,
true);
+#pragma warning restore CA1416
}
return promise;
diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs
index 27a785f7e658e..2d2cb0b3b69ed 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs
@@ -15,6 +15,7 @@
using System.Diagnostics.Tracing;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
+using System.Runtime.Versioning;
using Internal.Runtime.CompilerServices;
namespace System.Threading.Tasks
@@ -2845,6 +2846,7 @@ private bool SpinThenBlockingWait(int millisecondsTimeout, CancellationToken can
try
{
AddCompletionAction(mres, addBeforeOthers: true);
+#pragma warning disable CA1416 // Validate platform compatibility, issue: https://github.com/dotnet/runtime/issues/44622
if (infiniteWait)
{
returnValue = mres.Wait(Timeout.Infinite, cancellationToken);
@@ -2857,6 +2859,7 @@ private bool SpinThenBlockingWait(int millisecondsTimeout, CancellationToken can
returnValue = mres.Wait((int)(millisecondsTimeout - elapsedTimeTicks), cancellationToken);
}
}
+#pragma warning restore CA1416
}
finally
{
@@ -4438,6 +4441,7 @@ internal void RemoveContinuation(object continuationObject) // could be TaskCont
/// At least one of the instances was canceled -or- an exception was thrown during
/// the execution of at least one of the instances.
///
+ [UnsupportedOSPlatform("browser")]
[MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger
public static void WaitAll(params Task[] tasks)
{
@@ -4480,6 +4484,7 @@ public static void WaitAll(params Task[] tasks)
/// infinite time-out -or- timeout is greater than
/// .
///
+ [UnsupportedOSPlatform("browser")]
[MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger
public static bool WaitAll(Task[] tasks, TimeSpan timeout)
{
@@ -4518,6 +4523,7 @@ public static bool WaitAll(Task[] tasks, TimeSpan timeout)
/// is a negative number other than -1, which represents an
/// infinite time-out.
///
+ [UnsupportedOSPlatform("browser")]
[MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger
public static bool WaitAll(Task[] tasks, int millisecondsTimeout)
{
@@ -4546,6 +4552,7 @@ public static bool WaitAll(Task[] tasks, int millisecondsTimeout)
///
/// The was canceled.
///
+ [UnsupportedOSPlatform("browser")]
[MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger
public static void WaitAll(Task[] tasks, CancellationToken cancellationToken)
{
@@ -4586,12 +4593,14 @@ public static void WaitAll(Task[] tasks, CancellationToken cancellationToken)
///
/// The was canceled.
///
+ [UnsupportedOSPlatform("browser")]
[MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger
public static bool WaitAll(Task[] tasks, int millisecondsTimeout, CancellationToken cancellationToken) =>
WaitAllCore(tasks, millisecondsTimeout, cancellationToken);
// Separated out to allow it to be optimized (caller is marked NoOptimization for VS parallel debugger
// to be able to see the method on the stack and inspect arguments).
+ [UnsupportedOSPlatform("browser")]
private static bool WaitAllCore(Task[] tasks, int millisecondsTimeout, CancellationToken cancellationToken)
{
if (tasks == null)
@@ -4730,6 +4739,7 @@ private static void AddToList(T item, ref List? list, int initSize)
/// The timeout.
/// The cancellation token.
/// true if all of the tasks completed; otherwise, false.
+ [UnsupportedOSPlatform("browser")]
private static bool WaitAllBlockingCore(List tasks, int millisecondsTimeout, CancellationToken cancellationToken)
{
Debug.Assert(tasks != null, "Expected a non-null list of tasks");
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 d6b85c5035711..dbe39bf4e71fb 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
@@ -47,7 +47,9 @@ protected internal override void QueueTask(Task task)
// Run LongRunning tasks on their own dedicated thread.
Thread thread = new Thread(s_longRunningThreadWork);
thread.IsBackground = true; // Keep this thread from blocking process shutdown
+#if !TARGET_BROWSER
thread.Start(task);
+#endif
}
else
{
diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XmlDownloadManagerAsync.cs b/src/libraries/System.Private.Xml/src/System/Xml/XmlDownloadManagerAsync.cs
index 87b3da75f3b59..35886f6aad519 100644
--- a/src/libraries/System.Private.Xml/src/System/Xml/XmlDownloadManagerAsync.cs
+++ b/src/libraries/System.Private.Xml/src/System/Xml/XmlDownloadManagerAsync.cs
@@ -29,6 +29,7 @@ private async Task GetNonFileStreamAsync(Uri uri, ICredentials? credenti
var handler = new HttpClientHandler();
using (var client = new HttpClient(handler))
{
+#pragma warning disable CA1416 // Validate platform compatibility, 'credentials' and 'proxy' will not be set for browser, so safe to suppress
if (credentials != null)
{
handler.Credentials = credentials;
@@ -37,6 +38,7 @@ private async Task GetNonFileStreamAsync(Uri uri, ICredentials? credenti
{
handler.Proxy = proxy;
}
+#pragma warning restore CA1416
using (Stream respStream = await client.GetStreamAsync(uri).ConfigureAwait(false))
{
diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XmlUrlResolver.cs b/src/libraries/System.Private.Xml/src/System/Xml/XmlUrlResolver.cs
index 641e5842c58f2..3f39f1ab09d57 100644
--- a/src/libraries/System.Private.Xml/src/System/Xml/XmlUrlResolver.cs
+++ b/src/libraries/System.Private.Xml/src/System/Xml/XmlUrlResolver.cs
@@ -22,11 +22,13 @@ public partial class XmlUrlResolver : XmlResolver
public XmlUrlResolver() { }
+ [UnsupportedOSPlatform("browser")]
public override ICredentials? Credentials
{
set { _credentials = value; }
}
+ [UnsupportedOSPlatform("browser")]
public IWebProxy? Proxy
{
set { _proxy = value; }
diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs
index c954f9be6226d..a867a67d10d29 100644
--- a/src/libraries/System.Runtime/ref/System.Runtime.cs
+++ b/src/libraries/System.Runtime/ref/System.Runtime.cs
@@ -11075,10 +11075,15 @@ public void Wait() { }
public bool Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; }
public void Wait(System.Threading.CancellationToken cancellationToken) { }
public bool Wait(System.TimeSpan timeout) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static void WaitAll(params System.Threading.Tasks.Task[] tasks) { }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static bool WaitAll(System.Threading.Tasks.Task[] tasks, int millisecondsTimeout) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static bool WaitAll(System.Threading.Tasks.Task[] tasks, int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static void WaitAll(System.Threading.Tasks.Task[] tasks, System.Threading.CancellationToken cancellationToken) { }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static bool WaitAll(System.Threading.Tasks.Task[] tasks, System.TimeSpan timeout) { throw null; }
public static int WaitAny(params System.Threading.Tasks.Task[] tasks) { throw null; }
public static int WaitAny(System.Threading.Tasks.Task[] tasks, int millisecondsTimeout) { throw null; }
diff --git a/src/libraries/System.Security.Permissions/Directory.Build.props b/src/libraries/System.Security.Permissions/Directory.Build.props
index bdcfca3b543cb..1db5968484c1e 100644
--- a/src/libraries/System.Security.Permissions/Directory.Build.props
+++ b/src/libraries/System.Security.Permissions/Directory.Build.props
@@ -2,5 +2,6 @@
Open
+ true
\ No newline at end of file
diff --git a/src/libraries/System.Security.Permissions/ref/System.Security.Permissions.netcoreapp.cs b/src/libraries/System.Security.Permissions/ref/System.Security.Permissions.netcoreapp.cs
index 6de1351b17e50..4ed1e3eea90ef 100644
--- a/src/libraries/System.Security.Permissions/ref/System.Security.Permissions.netcoreapp.cs
+++ b/src/libraries/System.Security.Permissions/ref/System.Security.Permissions.netcoreapp.cs
@@ -14,6 +14,7 @@ public sealed partial class XamlLoadPermission : System.Security.CodeAccessPermi
public XamlLoadPermission(System.Collections.Generic.IEnumerable allowedAccess) { }
public XamlLoadPermission(System.Security.Permissions.PermissionState state) { }
public XamlLoadPermission(System.Xaml.Permissions.XamlAccessLevel allowedAccess) { }
+ [System.Runtime.Versioning.SupportedOSPlatform("windows")]
public System.Collections.Generic.IList AllowedAccess { get { throw null; } }
public override System.Security.IPermission Copy() { throw null; }
public override bool Equals(object obj) { throw null; }
diff --git a/src/libraries/System.Security.Permissions/src/System/Xaml/Permissions/XamlLoadPermission.cs b/src/libraries/System.Security.Permissions/src/System/Xaml/Permissions/XamlLoadPermission.cs
index 12e7abe0a0f25..cc98e5d7774fa 100644
--- a/src/libraries/System.Security.Permissions/src/System/Xaml/Permissions/XamlLoadPermission.cs
+++ b/src/libraries/System.Security.Permissions/src/System/Xaml/Permissions/XamlLoadPermission.cs
@@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
@@ -21,6 +22,7 @@ public XamlLoadPermission(IEnumerable allowedAccess) { }
public override bool Equals(object obj) { return ReferenceEquals(this, obj); }
[ComVisible(false)]
public override int GetHashCode() { return base.GetHashCode(); }
+ [SupportedOSPlatform("windows")]
public IList AllowedAccess { get; private set; } = new ReadOnlyCollection(Array.Empty());
public override IPermission Copy() { return new XamlLoadPermission(PermissionState.Unrestricted); }
public override void FromXml(SecurityElement elem) { }
diff --git a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.cs b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.cs
index 21cee18d3763d..09f40edb97d98 100644
--- a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.cs
+++ b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.cs
@@ -346,7 +346,9 @@ public static void Invoke(ParallelOptions parallelOptions, params Action[] actio
// threw an exception. We let such exceptions go completely unhandled.
try
{
+#pragma warning disable CA1416 // Validate platform compatibility, issue: https://github.com/dotnet/runtime/issues/44605
Task.WaitAll(tasks);
+#pragma warning restore CA1416
}
catch (AggregateException aggExp)
{
diff --git a/src/libraries/System.Threading/ref/System.Threading.cs b/src/libraries/System.Threading/ref/System.Threading.cs
index b60d6d0aac95b..f25070b0279e9 100644
--- a/src/libraries/System.Threading/ref/System.Threading.cs
+++ b/src/libraries/System.Threading/ref/System.Threading.cs
@@ -57,17 +57,25 @@ public Barrier(int participantCount, System.Action? po
public long CurrentPhaseNumber { get { throw null; } }
public int ParticipantCount { get { throw null; } }
public int ParticipantsRemaining { get { throw null; } }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public long AddParticipant() { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public long AddParticipants(int participantCount) { throw null; }
public void Dispose() { }
protected virtual void Dispose(bool disposing) { }
public void RemoveParticipant() { }
public void RemoveParticipants(int participantCount) { }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public void SignalAndWait() { }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public bool SignalAndWait(int millisecondsTimeout) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public bool SignalAndWait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public void SignalAndWait(System.Threading.CancellationToken cancellationToken) { }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public bool SignalAndWait(System.TimeSpan timeout) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public bool SignalAndWait(System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken) { throw null; }
}
public partial class BarrierPostPhaseException : System.Exception
@@ -96,11 +104,17 @@ public void Reset(int count) { }
public bool Signal(int signalCount) { throw null; }
public bool TryAddCount() { throw null; }
public bool TryAddCount(int signalCount) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public void Wait() { }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public bool Wait(int millisecondsTimeout) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public bool Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public void Wait(System.Threading.CancellationToken cancellationToken) { }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public bool Wait(System.TimeSpan timeout) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public bool Wait(System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken) { throw null; }
}
public enum EventResetMode
@@ -258,11 +272,17 @@ public void Dispose() { }
protected virtual void Dispose(bool disposing) { }
public void Reset() { }
public void Set() { }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public void Wait() { }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public bool Wait(int millisecondsTimeout) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public bool Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public void Wait(System.Threading.CancellationToken cancellationToken) { }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public bool Wait(System.TimeSpan timeout) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public bool Wait(System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken) { throw null; }
}
public static partial class Monitor
@@ -307,7 +327,9 @@ public ReaderWriterLock() { }
public bool IsReaderLockHeld { get { throw null; } }
public bool IsWriterLockHeld { get { throw null; } }
public int WriterSeqNum { get { throw null; } }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public void AcquireReaderLock(int millisecondsTimeout) { }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public void AcquireReaderLock(System.TimeSpan timeout) { }
public void AcquireWriterLock(int millisecondsTimeout) { }
public void AcquireWriterLock(System.TimeSpan timeout) { }
@@ -316,8 +338,11 @@ public void DowngradeFromWriterLock(ref System.Threading.LockCookie lockCookie)
public System.Threading.LockCookie ReleaseLock() { throw null; }
public void ReleaseReaderLock() { }
public void ReleaseWriterLock() { }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public void RestoreLock(ref System.Threading.LockCookie lockCookie) { }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public System.Threading.LockCookie UpgradeToWriterLock(int millisecondsTimeout) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public System.Threading.LockCookie UpgradeToWriterLock(System.TimeSpan timeout) { throw null; }
}
public partial class ReaderWriterLockSlim : System.IDisposable
@@ -378,11 +403,17 @@ public void Dispose() { }
protected virtual void Dispose(bool disposing) { }
public int Release() { throw null; }
public int Release(int releaseCount) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public void Wait() { }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public bool Wait(int millisecondsTimeout) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public bool Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public void Wait(System.Threading.CancellationToken cancellationToken) { }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public bool Wait(System.TimeSpan timeout) { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public bool Wait(System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken) { throw null; }
public System.Threading.Tasks.Task WaitAsync() { throw null; }
public System.Threading.Tasks.Task WaitAsync(int millisecondsTimeout) { throw null; }
diff --git a/src/libraries/System.Threading/src/System/Threading/Barrier.cs b/src/libraries/System.Threading/src/System/Threading/Barrier.cs
index 12024d6cb4a07..3f5b1e993a540 100644
--- a/src/libraries/System.Threading/src/System/Threading/Barrier.cs
+++ b/src/libraries/System.Threading/src/System/Threading/Barrier.cs
@@ -12,6 +12,7 @@
using System.Diagnostics;
using System.Runtime.Serialization;
+using System.Runtime.Versioning;
using System.Security;
namespace System.Threading
@@ -283,6 +284,7 @@ private bool SetCurrentTotal(int currentTotal, int current, int total, bool sens
///
/// The current instance has already been
/// disposed.
+ [UnsupportedOSPlatform("browser")]
public long AddParticipant()
{
try
@@ -311,6 +313,7 @@ public long AddParticipant()
///
/// The current instance has already been
/// disposed.
+ [UnsupportedOSPlatform("browser")]
public long AddParticipants(int participantCount)
{
// check dispose
@@ -483,6 +486,7 @@ public void RemoveParticipants(int participantCount)
///
/// The current instance has already been
/// disposed.
+ [UnsupportedOSPlatform("browser")]
public void SignalAndWait()
{
SignalAndWait(CancellationToken.None);
@@ -503,6 +507,7 @@ public void SignalAndWait()
/// canceled.
/// The current instance has already been
/// disposed.
+ [UnsupportedOSPlatform("browser")]
public void SignalAndWait(CancellationToken cancellationToken)
{
#if DEBUG
@@ -532,6 +537,7 @@ public void SignalAndWait(CancellationToken cancellationToken)
///
/// The current instance has already been
/// disposed.
+ [UnsupportedOSPlatform("browser")]
public bool SignalAndWait(TimeSpan timeout)
{
return SignalAndWait(timeout, CancellationToken.None);
@@ -559,6 +565,7 @@ public bool SignalAndWait(TimeSpan timeout)
/// canceled.
/// The current instance has already been
/// disposed.
+ [UnsupportedOSPlatform("browser")]
public bool SignalAndWait(TimeSpan timeout, CancellationToken cancellationToken)
{
long totalMilliseconds = (long)timeout.TotalMilliseconds;
@@ -586,6 +593,7 @@ public bool SignalAndWait(TimeSpan timeout, CancellationToken cancellationToken)
///
/// The current instance has already been
/// disposed.
+ [UnsupportedOSPlatform("browser")]
public bool SignalAndWait(int millisecondsTimeout)
{
return SignalAndWait(millisecondsTimeout, CancellationToken.None);
@@ -612,6 +620,7 @@ public bool SignalAndWait(int millisecondsTimeout)
/// canceled.
/// The current instance has already been
/// disposed.
+ [UnsupportedOSPlatform("browser")]
public bool SignalAndWait(int millisecondsTimeout, CancellationToken cancellationToken)
{
ThrowIfDisposed();
@@ -855,6 +864,7 @@ private void WaitCurrentPhase(ManualResetEventSlim currentPhaseEvent, long obser
/// cancellation token passed to SignalAndWait
/// The current phase number for this thread
/// True if the event is set or the phase number changed, false if the timeout expired
+ [UnsupportedOSPlatform("browser")]
private bool DiscontinuousWait(ManualResetEventSlim currentPhaseEvent, int totalTimeout, CancellationToken token, long observedPhase)
{
int maxWait = 100; // 100 ms
diff --git a/src/libraries/System.Threading/src/System/Threading/CountdownEvent.cs b/src/libraries/System.Threading/src/System/Threading/CountdownEvent.cs
index 7ef433c8c4094..dc3ad707338a3 100644
--- a/src/libraries/System.Threading/src/System/Threading/CountdownEvent.cs
+++ b/src/libraries/System.Threading/src/System/Threading/CountdownEvent.cs
@@ -8,6 +8,7 @@
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
using System.Diagnostics;
+using System.Runtime.Versioning;
namespace System.Threading
{
@@ -414,6 +415,7 @@ public void Reset(int count)
///
/// The current instance has already been
/// disposed.
+ [UnsupportedOSPlatform("browser")]
public void Wait()
{
Wait(Timeout.Infinite, CancellationToken.None);
@@ -437,6 +439,7 @@ public void Wait()
/// canceled.
/// The current instance has already been
/// disposed.
+ [UnsupportedOSPlatform("browser")]
public void Wait(CancellationToken cancellationToken)
{
Wait(Timeout.Infinite, cancellationToken);
@@ -456,6 +459,7 @@ public void Wait(CancellationToken cancellationToken)
/// than .
/// The current instance has already been
/// disposed.
+ [UnsupportedOSPlatform("browser")]
public bool Wait(TimeSpan timeout)
{
long totalMilliseconds = (long)timeout.TotalMilliseconds;
@@ -486,6 +490,7 @@ public bool Wait(TimeSpan timeout)
/// disposed.
/// has
/// been canceled.
+ [UnsupportedOSPlatform("browser")]
public bool Wait(TimeSpan timeout, CancellationToken cancellationToken)
{
long totalMilliseconds = (long)timeout.TotalMilliseconds;
@@ -509,6 +514,7 @@ public bool Wait(TimeSpan timeout, CancellationToken cancellationToken)
/// negative number other than -1, which represents an infinite time-out.
/// The current instance has already been
/// disposed.
+ [UnsupportedOSPlatform("browser")]
public bool Wait(int millisecondsTimeout)
{
return Wait(millisecondsTimeout, CancellationToken.None);
@@ -531,6 +537,7 @@ public bool Wait(int millisecondsTimeout)
/// disposed.
/// has
/// been canceled.
+ [UnsupportedOSPlatform("browser")]
public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken)
{
if (millisecondsTimeout < -1)
diff --git a/src/libraries/System.Threading/src/System/Threading/ReaderWriterLock.cs b/src/libraries/System.Threading/src/System/Threading/ReaderWriterLock.cs
index 90a8e5140efca..1d49a2cfae236 100644
--- a/src/libraries/System.Threading/src/System/Threading/ReaderWriterLock.cs
+++ b/src/libraries/System.Threading/src/System/Threading/ReaderWriterLock.cs
@@ -4,6 +4,7 @@
using System.Diagnostics;
using System.Runtime.ConstrainedExecution;
using System.Runtime.Serialization;
+using System.Runtime.Versioning;
namespace System.Threading
{
@@ -73,6 +74,7 @@ public bool AnyWritersSince(int seqNum)
return (uint)_writerSeqNum > (uint)seqNum;
}
+ [UnsupportedOSPlatform("browser")]
public void AcquireReaderLock(int millisecondsTimeout)
{
if (millisecondsTimeout < -1)
@@ -275,6 +277,7 @@ public void AcquireReaderLock(int millisecondsTimeout)
++threadLocalLockEntry._readerLevel;
}
+ [UnsupportedOSPlatform("browser")]
public void AcquireReaderLock(TimeSpan timeout) => AcquireReaderLock(ToTimeoutMilliseconds(timeout));
public void AcquireWriterLock(int millisecondsTimeout)
@@ -665,6 +668,7 @@ public void ReleaseWriterLock()
}
}
+ [UnsupportedOSPlatform("browser")]
public LockCookie UpgradeToWriterLock(int millisecondsTimeout)
{
if (millisecondsTimeout < -1)
@@ -744,6 +748,7 @@ public LockCookie UpgradeToWriterLock(int millisecondsTimeout)
}
}
+ [UnsupportedOSPlatform("browser")]
public LockCookie UpgradeToWriterLock(TimeSpan timeout) => UpgradeToWriterLock(ToTimeoutMilliseconds(timeout));
public void DowngradeFromWriterLock(ref LockCookie lockCookie)
@@ -911,6 +916,7 @@ public LockCookie ReleaseLock()
return lockCookie;
}
+ [UnsupportedOSPlatform("browser")]
public void RestoreLock(ref LockCookie lockCookie)
{
// Validate cookie
@@ -976,6 +982,7 @@ public void RestoreLock(ref LockCookie lockCookie)
///
/// Helper function that restores the lock to the original state indicated by parameters
///
+ [UnsupportedOSPlatform("browser")]
private void RecoverLock(ref LockCookie lockCookie, LockCookieFlags flags)
{
// Contrary to the legacy code, this method does not use a finite timeout for recovering the previous lock state, as
diff --git a/src/libraries/System.Transactions.Local/ref/System.Transactions.Local.cs b/src/libraries/System.Transactions.Local/ref/System.Transactions.Local.cs
index d6c0a609c4c51..9520218380b23 100644
--- a/src/libraries/System.Transactions.Local/ref/System.Transactions.Local.cs
+++ b/src/libraries/System.Transactions.Local/ref/System.Transactions.Local.cs
@@ -6,6 +6,7 @@
namespace System.Transactions
{
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public sealed partial class CommittableTransaction : System.Transactions.Transaction, System.IAsyncResult
{
public CommittableTransaction() { }
@@ -218,6 +219,7 @@ protected TransactionPromotionException(System.Runtime.Serialization.Serializati
public TransactionPromotionException(string? message) { }
public TransactionPromotionException(string? message, System.Exception? innerException) { }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public sealed partial class TransactionScope : System.IDisposable
{
public TransactionScope() { }
diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/CommittableTransaction.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/CommittableTransaction.cs
index 1388352093c41..e387159e95073 100644
--- a/src/libraries/System.Transactions.Local/src/System/Transactions/CommittableTransaction.cs
+++ b/src/libraries/System.Transactions.Local/src/System/Transactions/CommittableTransaction.cs
@@ -2,10 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
+using System.Runtime.Versioning;
using System.Threading;
namespace System.Transactions
{
+ [UnsupportedOSPlatform("browser")]
public sealed class CommittableTransaction : Transaction, IAsyncResult
{
// Create a transaction with defaults
diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/Transaction.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/Transaction.cs
index 2cc0efd7af7c2..3851ed0c53ccc 100644
--- a/src/libraries/System.Transactions.Local/src/System/Transactions/Transaction.cs
+++ b/src/libraries/System.Transactions.Local/src/System/Transactions/Transaction.cs
@@ -70,7 +70,9 @@ internal static EnterpriseServicesInteropOption InteropMode(TransactionScope? cu
{
if (currentScope != null)
{
+#pragma warning disable CA1416 // Validate platform compatibility, the property is not platform-specific, safe to suppress
return currentScope.InteropMode;
+#pragma warning restore CA1416
}
return EnterpriseServicesInteropOption.None;
@@ -161,7 +163,9 @@ public static Transaction? Current
if (currentScope != null)
{
+#pragma warning disable CA1416 // Validate platform compatibility, the property is not platform-specific, safe to suppress
if (currentScope.ScopeComplete)
+#pragma warning restore CA1416
{
throw new InvalidOperationException(SR.TransactionScopeComplete);
}
diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionScope.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionScope.cs
index 3a991ca09b4f4..a022034d2dd72 100644
--- a/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionScope.cs
+++ b/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionScope.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
+using System.Runtime.Versioning;
using System.Threading;
namespace System.Transactions
@@ -32,6 +33,7 @@ public enum EnterpriseServicesInteropOption
Full = 2
}
+ [UnsupportedOSPlatform("browser")]
public sealed class TransactionScope : IDisposable
{
public TransactionScope() : this(TransactionScopeOption.Required)
diff --git a/src/libraries/System.Xml.ReaderWriter/ref/System.Xml.ReaderWriter.cs b/src/libraries/System.Xml.ReaderWriter/ref/System.Xml.ReaderWriter.cs
index ef1f8e22a2f42..ddbf60bfb624b 100644
--- a/src/libraries/System.Xml.ReaderWriter/ref/System.Xml.ReaderWriter.cs
+++ b/src/libraries/System.Xml.ReaderWriter/ref/System.Xml.ReaderWriter.cs
@@ -1138,7 +1138,9 @@ public partial class XmlUrlResolver : System.Xml.XmlResolver
{
public XmlUrlResolver() { }
public System.Net.Cache.RequestCachePolicy CachePolicy { set { } }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public override System.Net.ICredentials? Credentials { set { } }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public System.Net.IWebProxy? Proxy { set { } }
public override object? GetEntity(System.Uri absoluteUri, string? role, System.Type? ofObjectToReturn) { throw null; }
public override System.Threading.Tasks.Task