From 8f7b5af4b301603af5cf1f8dda78abf8ea8736ac Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Fri, 21 Aug 2020 09:20:40 -0400 Subject: [PATCH 01/11] [wasm] Mark System.ComponentModel APIs as unsupported on Browser (#41094) * [wasm] System.ComponentModel enable platform attributes * [wasm] Mark ExtendedProtectionPolicyTypeConverter.ConvertTo as unsupported * [wasm] Mark System.ComponentModel.TypeDescriptor.CreateInstance as unsupported * [wasm] Mark System.ComponentModel.TypeDescriptionProvider.CreateInstance as unsupported * [wasm] Mark System.ComponentModel.LicenseManager.CreateWithContext as unsupported * [wasm] Mark System.ComponentModel.MaskedTextProvider.Clone as unsupported Co-authored-by: Mitchell Hwang --- .../Directory.Build.props | 1 + .../ref/System.ComponentModel.TypeConverter.cs | 6 ++++++ .../src/System/ComponentModel/LicenseManager.cs | 3 +++ .../src/System/ComponentModel/MaskedTextProvider.cs | 2 ++ .../src/System/ComponentModel/TypeDescriptionProvider.cs | 2 ++ .../src/System/ComponentModel/TypeDescriptor.cs | 2 ++ .../ExtendedProtectionPolicyTypeConverter.cs | 2 ++ 7 files changed, 18 insertions(+) diff --git a/src/libraries/System.ComponentModel.TypeConverter/Directory.Build.props b/src/libraries/System.ComponentModel.TypeConverter/Directory.Build.props index 63f02a0f817ef..d68d22c1b917f 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/Directory.Build.props +++ b/src/libraries/System.ComponentModel.TypeConverter/Directory.Build.props @@ -2,5 +2,6 @@ Microsoft + true \ No newline at end of file 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 0c4990e50491e..ab3fa3e9fbe2c 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs @@ -687,7 +687,9 @@ public sealed partial class LicenseManager internal LicenseManager() { } public static System.ComponentModel.LicenseContext CurrentContext { get { throw null; } set { } } public static System.ComponentModel.LicenseUsageMode UsageMode { get { throw null; } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static object CreateWithContext(System.Type type, System.ComponentModel.LicenseContext creationContext) { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static object CreateWithContext(System.Type type, System.ComponentModel.LicenseContext creationContext, object[] args) { throw null; } public static bool IsLicensed(System.Type type) { throw null; } public static bool IsValid(System.Type type) { throw null; } @@ -868,6 +870,7 @@ public MaskedTextProvider(string mask, System.Globalization.CultureInfo culture, public bool Add(string input, out int testPosition, out System.ComponentModel.MaskedTextResultHint resultHint) { throw null; } public void Clear() { } public void Clear(out System.ComponentModel.MaskedTextResultHint resultHint) { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public object Clone() { throw null; } public int FindAssignedEditPositionFrom(int position, bool direction) { throw null; } public int FindAssignedEditPositionInRange(int startPosition, int endPosition, bool direction) { throw null; } @@ -1305,6 +1308,7 @@ 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; } @@ -1347,6 +1351,7 @@ 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; } @@ -2217,6 +2222,7 @@ public partial class ExtendedProtectionPolicyTypeConverter : System.ComponentMod { public ExtendedProtectionPolicyTypeConverter() { } public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { throw null; } } } diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseManager.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseManager.cs index 8208d3c54d096..c340d12247eee 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseManager.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseManager.cs @@ -5,6 +5,7 @@ using System.ComponentModel.Design; using System.Diagnostics; using System.Reflection; +using System.Runtime.Versioning; using System.Threading; namespace System.ComponentModel @@ -116,6 +117,7 @@ private static void CacheProvider(Type type, LicenseProvider provider) /// creationContext /// as the context in which the licensed instance can be used. /// + [UnsupportedOSPlatform("browser")] public static object CreateWithContext(Type type, LicenseContext creationContext) { return CreateWithContext(type, creationContext, Array.Empty()); @@ -126,6 +128,7 @@ public static object CreateWithContext(Type type, LicenseContext creationContext /// specified arguments, using creationContext as the context in which the licensed /// instance can be used. /// + [UnsupportedOSPlatform("browser")] public static object CreateWithContext(Type type, LicenseContext creationContext, object[] args) { object created = null; diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MaskedTextProvider.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MaskedTextProvider.cs index 4a3b6ccc2f77f..46e996946fbab 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MaskedTextProvider.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MaskedTextProvider.cs @@ -6,6 +6,7 @@ using System.Collections.Specialized; using System.Diagnostics; using System.Globalization; +using System.Runtime.Versioning; using System.Text; namespace System.ComponentModel @@ -467,6 +468,7 @@ private void Initialize() /// Derived classes can override this method and call base.Clone to get proper cloning semantics but must /// implement the full-parameter constructor (passing parameters to the base constructor as well). /// + [UnsupportedOSPlatform("browser")] public object Clone() { MaskedTextProvider clonedProvider; 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 c85f2e6391521..565bc42e68f0a 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptionProvider.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptionProvider.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections; +using System.Runtime.Versioning; namespace System.ComponentModel { @@ -49,6 +50,7 @@ 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 8c3139a48e084..a542eb25d86ac 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs @@ -8,6 +8,7 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Reflection; +using System.Runtime.Versioning; using System.Threading; namespace System.ComponentModel @@ -428,6 +429,7 @@ 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.ComponentModel.TypeConverter/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicyTypeConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicyTypeConverter.cs index 7b6bcc6cab34d..522a5b984ce0a 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicyTypeConverter.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicyTypeConverter.cs @@ -6,6 +6,7 @@ using System.ComponentModel.Design.Serialization; using System.Globalization; using System.Reflection; +using System.Runtime.Versioning; namespace System.Security.Authentication.ExtendedProtection { @@ -16,6 +17,7 @@ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinati return destinationType == typeof(InstanceDescriptor) || base.CanConvertTo(context, destinationType); } + [UnsupportedOSPlatform("browser")] public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) From 9468e388461cd72ea7299d2f94a426c2155017bf Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Fri, 4 Sep 2020 17:31:48 -0400 Subject: [PATCH 02/11] [wasm] Mark System.Console APIs as unsupported on Browser (#41184) * [wasm] Mark System.Console APIs as unsupported on Browser * System.Console remove unsupported attribute from Console.Clear() * System.Console mark SetIn as unsupported on Browser * System.Console move UnsupportedOSPlatform attributes down to the accessor Co-authored-by: Mitchell Hwang --- .../System.Console/ref/System.Console.cs | 35 +++++++++++++++---- .../System.Console/src/System/Console.cs | 28 +++++++++++++++ 2 files changed, 56 insertions(+), 7 deletions(-) diff --git a/src/libraries/System.Console/ref/System.Console.cs b/src/libraries/System.Console/ref/System.Console.cs index b3faa64611241..7a342d5268563 100644 --- a/src/libraries/System.Console/ref/System.Console.cs +++ b/src/libraries/System.Console/ref/System.Console.cs @@ -8,40 +8,52 @@ namespace System { public static partial class Console { + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static System.ConsoleColor BackgroundColor { get { throw null; } set { } } - public static int BufferHeight { get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } - public static int BufferWidth { get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } + public static int BufferHeight { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } + public static int BufferWidth { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static bool CapsLock { get { throw null; } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static int CursorLeft { get { throw null; } set { } } - public static int CursorSize { get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } + public static int CursorSize { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static int CursorTop { get { throw null; } set { } } - public static bool CursorVisible { [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] get { throw null; } set { } } + public static bool CursorVisible { [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] get { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] set { } } public static System.IO.TextWriter Error { get { throw null; } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static System.ConsoleColor ForegroundColor { get { throw null; } set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static System.IO.TextReader In { get { throw null; } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static System.Text.Encoding InputEncoding { get { throw null; } set { } } public static bool IsErrorRedirected { get { throw null; } } public static bool IsInputRedirected { get { throw null; } } public static bool IsOutputRedirected { get { throw null; } } public static bool KeyAvailable { get { throw null; } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static int LargestWindowHeight { get { throw null; } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static int LargestWindowWidth { get { throw null; } } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static bool NumberLock { get { throw null; } } public static System.IO.TextWriter Out { get { throw null; } } public static System.Text.Encoding OutputEncoding { get { throw null; } set { } } - public static string Title { [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] get { throw null; } set { } } + public static string Title { [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] get { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static bool TreatControlCAsInput { get { throw null; } set { } } - public static int WindowHeight { get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } + public static int WindowHeight { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } public static int WindowLeft { get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } public static int WindowTop { get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } - public static int WindowWidth { get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } + public static int WindowWidth { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static event System.ConsoleCancelEventHandler? CancelKeyPress { add { } remove { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static void Beep() { } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static void Beep(int frequency, int duration) { } public static void Clear() { } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static (int Left, int Top) GetCursorPosition() { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static void MoveBufferArea(int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight, int targetLeft, int targetTop) { } @@ -49,19 +61,28 @@ public static void MoveBufferArea(int sourceLeft, int sourceTop, int sourceWidth public static void MoveBufferArea(int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight, int targetLeft, int targetTop, char sourceChar, System.ConsoleColor sourceForeColor, System.ConsoleColor sourceBackColor) { } public static System.IO.Stream OpenStandardError() { throw null; } public static System.IO.Stream OpenStandardError(int bufferSize) { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static System.IO.Stream OpenStandardInput() { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static System.IO.Stream OpenStandardInput(int bufferSize) { throw null; } public static System.IO.Stream OpenStandardOutput() { throw null; } public static System.IO.Stream OpenStandardOutput(int bufferSize) { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static int Read() { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static System.ConsoleKeyInfo ReadKey() { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static System.ConsoleKeyInfo ReadKey(bool intercept) { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static string? ReadLine() { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static void ResetColor() { } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static void SetBufferSize(int width, int height) { } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static void SetCursorPosition(int left, int top) { } public static void SetError(System.IO.TextWriter newError) { } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static void SetIn(System.IO.TextReader newIn) { } public static void SetOut(System.IO.TextWriter newOut) { } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] diff --git a/src/libraries/System.Console/src/System/Console.cs b/src/libraries/System.Console/src/System/Console.cs index ec589857c1613..b4f2270afb861 100644 --- a/src/libraries/System.Console/src/System/Console.cs +++ b/src/libraries/System.Console/src/System/Console.cs @@ -33,6 +33,7 @@ public static class Console private static ConsoleCancelEventHandler? s_cancelCallbacks; private static ConsolePal.ControlCHandlerRegistrar? s_registrar; + [UnsupportedOSPlatform("browser")] public static TextReader In { get @@ -56,6 +57,7 @@ static TextReader EnsureInitialized() } } + [UnsupportedOSPlatform("browser")] public static Encoding InputEncoding { get @@ -152,11 +154,13 @@ public static bool KeyAvailable } } + [UnsupportedOSPlatform("browser")] public static ConsoleKeyInfo ReadKey() { return ConsolePal.ReadKey(false); } + [UnsupportedOSPlatform("browser")] public static ConsoleKeyInfo ReadKey(bool intercept) { return ConsolePal.ReadKey(intercept); @@ -276,6 +280,7 @@ static StrongBox EnsureInitialized() public static int CursorSize { + [UnsupportedOSPlatform("browser")] get { return ConsolePal.CursorSize; } [SupportedOSPlatform("windows")] set { ConsolePal.CursorSize = value; } @@ -295,18 +300,21 @@ public static bool CapsLock internal const ConsoleColor UnknownColor = (ConsoleColor)(-1); + [UnsupportedOSPlatform("browser")] public static ConsoleColor BackgroundColor { get { return ConsolePal.BackgroundColor; } set { ConsolePal.BackgroundColor = value; } } + [UnsupportedOSPlatform("browser")] public static ConsoleColor ForegroundColor { get { return ConsolePal.ForegroundColor; } set { ConsolePal.ForegroundColor = value; } } + [UnsupportedOSPlatform("browser")] public static void ResetColor() { ConsolePal.ResetColor(); @@ -314,6 +322,7 @@ public static void ResetColor() public static int BufferWidth { + [UnsupportedOSPlatform("browser")] get { return ConsolePal.BufferWidth; } [SupportedOSPlatform("windows")] set { ConsolePal.BufferWidth = value; } @@ -321,6 +330,7 @@ public static int BufferWidth public static int BufferHeight { + [UnsupportedOSPlatform("browser")] get { return ConsolePal.BufferHeight; } [SupportedOSPlatform("windows")] set { ConsolePal.BufferHeight = value; } @@ -348,6 +358,7 @@ public static int WindowTop public static int WindowWidth { + [UnsupportedOSPlatform("browser")] get { return ConsolePal.WindowWidth; } [SupportedOSPlatform("windows")] set { ConsolePal.WindowWidth = value; } @@ -355,6 +366,7 @@ public static int WindowWidth public static int WindowHeight { + [UnsupportedOSPlatform("browser")] get { return ConsolePal.WindowHeight; } [SupportedOSPlatform("windows")] set { ConsolePal.WindowHeight = value; } @@ -372,11 +384,13 @@ public static void SetWindowSize(int width, int height) ConsolePal.SetWindowSize(width, height); } + [UnsupportedOSPlatform("browser")] public static int LargestWindowWidth { get { return ConsolePal.LargestWindowWidth; } } + [UnsupportedOSPlatform("browser")] public static int LargestWindowHeight { get { return ConsolePal.LargestWindowHeight; } @@ -386,15 +400,18 @@ public static bool CursorVisible { [SupportedOSPlatform("windows")] get { return ConsolePal.CursorVisible; } + [UnsupportedOSPlatform("browser")] set { ConsolePal.CursorVisible = value; } } + [UnsupportedOSPlatform("browser")] public static int CursorLeft { get { return ConsolePal.GetCursorPosition().Left; } set { SetCursorPosition(value, CursorTop); } } + [UnsupportedOSPlatform("browser")] public static int CursorTop { get { return ConsolePal.GetCursorPosition().Top; } @@ -406,6 +423,7 @@ public static int CursorTop /// /// Columns are numbered from left to right starting at 0. Rows are numbered from top to bottom starting at 0. /// + [UnsupportedOSPlatform("browser")] public static (int Left, int Top) GetCursorPosition() { return ConsolePal.GetCursorPosition(); @@ -415,12 +433,14 @@ public static string Title { [SupportedOSPlatform("windows")] get { return ConsolePal.Title; } + [UnsupportedOSPlatform("browser")] set { ConsolePal.Title = value ?? throw new ArgumentNullException(nameof(value)); } } + [UnsupportedOSPlatform("browser")] public static void Beep() { ConsolePal.Beep(); @@ -449,6 +469,7 @@ public static void Clear() ConsolePal.Clear(); } + [UnsupportedOSPlatform("browser")] public static void SetCursorPosition(int left, int top) { // Basic argument validation. The PAL implementation may provide further validation. @@ -460,6 +481,7 @@ public static void SetCursorPosition(int left, int top) ConsolePal.SetCursorPosition(left, top); } + [UnsupportedOSPlatform("browser")] public static event ConsoleCancelEventHandler? CancelKeyPress { add @@ -493,17 +515,20 @@ public static event ConsoleCancelEventHandler? CancelKeyPress } } + [UnsupportedOSPlatform("browser")] public static bool TreatControlCAsInput { get { return ConsolePal.TreatControlCAsInput; } set { ConsolePal.TreatControlCAsInput = value; } } + [UnsupportedOSPlatform("browser")] public static Stream OpenStandardInput() { return ConsolePal.OpenStandardInput(); } + [UnsupportedOSPlatform("browser")] public static Stream OpenStandardInput(int bufferSize) { // bufferSize is ignored, other than in argument validation, even in the .NET Framework @@ -544,6 +569,7 @@ public static Stream OpenStandardError(int bufferSize) return OpenStandardError(); } + [UnsupportedOSPlatform("browser")] public static void SetIn(TextReader newIn) { CheckNonNull(newIn, nameof(newIn)); @@ -590,12 +616,14 @@ private static void CheckNonNull(object obj, string paramName) // the inlined console writelines from them. // [MethodImplAttribute(MethodImplOptions.NoInlining)] + [UnsupportedOSPlatform("browser")] public static int Read() { return In.Read(); } [MethodImplAttribute(MethodImplOptions.NoInlining)] + [UnsupportedOSPlatform("browser")] public static string? ReadLine() { return In.ReadLine(); From 571f09a178407fc977afc749a1e066eca6654100 Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Tue, 25 Aug 2020 09:40:13 -0400 Subject: [PATCH 03/11] Mark System.Diagnostics.FileVersionInfo as unsupported on Browser (#41271) Co-authored-by: Mitchell Hwang --- .../System.Diagnostics.FileVersionInfo/Directory.Build.props | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/System.Diagnostics.FileVersionInfo/Directory.Build.props b/src/libraries/System.Diagnostics.FileVersionInfo/Directory.Build.props index 63f02a0f817ef..ce244cbea5619 100644 --- a/src/libraries/System.Diagnostics.FileVersionInfo/Directory.Build.props +++ b/src/libraries/System.Diagnostics.FileVersionInfo/Directory.Build.props @@ -2,5 +2,7 @@ Microsoft + true + browser \ No newline at end of file From 324a800f9e32c0a4b17cabad939a17db57ccbd47 Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Fri, 4 Sep 2020 12:21:48 -0400 Subject: [PATCH 04/11] Mark System.Diagnostics.Process unsupported at assembly level (#41694) Co-authored-by: Mitchell Hwang --- src/libraries/System.Diagnostics.Process/Directory.Build.props | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/System.Diagnostics.Process/Directory.Build.props b/src/libraries/System.Diagnostics.Process/Directory.Build.props index d68d22c1b917f..ce244cbea5619 100644 --- a/src/libraries/System.Diagnostics.Process/Directory.Build.props +++ b/src/libraries/System.Diagnostics.Process/Directory.Build.props @@ -3,5 +3,6 @@ Microsoft true + browser \ No newline at end of file From 00d5416890aa17bbd94442f550deaf16f8ac9f48 Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Fri, 4 Sep 2020 13:19:46 -0400 Subject: [PATCH 05/11] [wasm] Mark System.IO.Compression APIs as unsupported on Browser (#41683) * [wasm] System.IO.Compression.Brotli enable platform attributes * Mark System.IO.Compression.Brotli unsupported at assembly level Co-authored-by: Mitchell Hwang --- .../System.IO.Compression.Brotli/Directory.Build.props | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/System.IO.Compression.Brotli/Directory.Build.props b/src/libraries/System.IO.Compression.Brotli/Directory.Build.props index 8cda5782c1d13..f3f5769f93616 100644 --- a/src/libraries/System.IO.Compression.Brotli/Directory.Build.props +++ b/src/libraries/System.IO.Compression.Brotli/Directory.Build.props @@ -2,5 +2,7 @@ ECMA + true + browser \ No newline at end of file From 639edfa72e465866068efca2f38465f4f93dfb33 Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Fri, 4 Sep 2020 15:57:31 -0400 Subject: [PATCH 06/11] [wasm] Mark System.IO.FileSystem.Watcher APIs as unsupported on Browser (#41682) * [wasm] System.IO.FileSystem.Watcher enable platform attributes * Mark System.IO.FileSystem.Watcher unsupported at assembly level Co-authored-by: Mitchell Hwang --- .../System.IO.FileSystem.Watcher/Directory.Build.props | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/System.IO.FileSystem.Watcher/Directory.Build.props b/src/libraries/System.IO.FileSystem.Watcher/Directory.Build.props index 63f02a0f817ef..ce244cbea5619 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/Directory.Build.props +++ b/src/libraries/System.IO.FileSystem.Watcher/Directory.Build.props @@ -2,5 +2,7 @@ Microsoft + true + browser \ No newline at end of file From 00f82dc6d7d9db5883390332f6f664515a92c43c Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Fri, 4 Sep 2020 16:09:09 -0400 Subject: [PATCH 07/11] [wasm] Mark System.IO.IsolatedStorage APIs as unsupported on Browser (#41700) * [wasm] System.IO.IsolatedStorage enable platform attributes * Mark System.IO.IsolatedStorage Unsupported at assembly level Co-authored-by: Mitchell Hwang --- src/libraries/System.IO.IsolatedStorage/Directory.Build.props | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/System.IO.IsolatedStorage/Directory.Build.props b/src/libraries/System.IO.IsolatedStorage/Directory.Build.props index 63f02a0f817ef..ce244cbea5619 100644 --- a/src/libraries/System.IO.IsolatedStorage/Directory.Build.props +++ b/src/libraries/System.IO.IsolatedStorage/Directory.Build.props @@ -2,5 +2,7 @@ Microsoft + true + browser \ No newline at end of file From d74950fb4782b80c40f2fbac690a9d3e46063488 Mon Sep 17 00:00:00 2001 From: Maxim Lipnin Date: Thu, 20 Aug 2020 12:23:21 +0300 Subject: [PATCH 08/11] Mark some System.Net.* APIs as unsupported on Browser WASM (#40924) --- src/libraries/System.Net.Mail/Directory.Build.props | 2 ++ .../System.Net.NetworkInformation/Directory.Build.props | 2 ++ src/libraries/System.Net.Ping/Directory.Build.props | 2 ++ src/libraries/System.Net.Requests/Directory.Build.props | 2 ++ src/libraries/System.Net.Security/Directory.Build.props | 2 ++ src/libraries/System.Net.Sockets/Directory.Build.props | 1 + src/libraries/System.Net.WebClient/Directory.Build.props | 2 ++ 7 files changed, 13 insertions(+) diff --git a/src/libraries/System.Net.Mail/Directory.Build.props b/src/libraries/System.Net.Mail/Directory.Build.props index bdcfca3b543cb..4784967b7f86a 100644 --- a/src/libraries/System.Net.Mail/Directory.Build.props +++ b/src/libraries/System.Net.Mail/Directory.Build.props @@ -2,5 +2,7 @@ Open + true + browser \ No newline at end of file diff --git a/src/libraries/System.Net.NetworkInformation/Directory.Build.props b/src/libraries/System.Net.NetworkInformation/Directory.Build.props index 63f02a0f817ef..ce244cbea5619 100644 --- a/src/libraries/System.Net.NetworkInformation/Directory.Build.props +++ b/src/libraries/System.Net.NetworkInformation/Directory.Build.props @@ -2,5 +2,7 @@ Microsoft + true + browser \ No newline at end of file diff --git a/src/libraries/System.Net.Ping/Directory.Build.props b/src/libraries/System.Net.Ping/Directory.Build.props index 63f02a0f817ef..ce244cbea5619 100644 --- a/src/libraries/System.Net.Ping/Directory.Build.props +++ b/src/libraries/System.Net.Ping/Directory.Build.props @@ -2,5 +2,7 @@ Microsoft + true + browser \ No newline at end of file diff --git a/src/libraries/System.Net.Requests/Directory.Build.props b/src/libraries/System.Net.Requests/Directory.Build.props index 63f02a0f817ef..ce244cbea5619 100644 --- a/src/libraries/System.Net.Requests/Directory.Build.props +++ b/src/libraries/System.Net.Requests/Directory.Build.props @@ -2,5 +2,7 @@ Microsoft + true + browser \ No newline at end of file diff --git a/src/libraries/System.Net.Security/Directory.Build.props b/src/libraries/System.Net.Security/Directory.Build.props index 63f02a0f817ef..ce244cbea5619 100644 --- a/src/libraries/System.Net.Security/Directory.Build.props +++ b/src/libraries/System.Net.Security/Directory.Build.props @@ -2,5 +2,7 @@ Microsoft + true + browser \ No newline at end of file diff --git a/src/libraries/System.Net.Sockets/Directory.Build.props b/src/libraries/System.Net.Sockets/Directory.Build.props index d68d22c1b917f..ce244cbea5619 100644 --- a/src/libraries/System.Net.Sockets/Directory.Build.props +++ b/src/libraries/System.Net.Sockets/Directory.Build.props @@ -3,5 +3,6 @@ Microsoft true + browser \ No newline at end of file diff --git a/src/libraries/System.Net.WebClient/Directory.Build.props b/src/libraries/System.Net.WebClient/Directory.Build.props index bdcfca3b543cb..4784967b7f86a 100644 --- a/src/libraries/System.Net.WebClient/Directory.Build.props +++ b/src/libraries/System.Net.WebClient/Directory.Build.props @@ -2,5 +2,7 @@ Open + true + browser \ No newline at end of file From 4a888d3645e04b3e9d09a203b34b6c13699d84aa Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Tue, 8 Sep 2020 19:24:09 -0400 Subject: [PATCH 09/11] [wasm] Mark System.Threading.ThreadPool unsupported on Browser (#41891) * System.Threading.ThreadPool enable platform attributes * Mark System.Threading.ThreadPool APIs unsupported on browser * System.Threading.ThreadPool Add Unsupported attribute to other ThreadPool files * Remove Unsupported attributes from BindHandle * Add windows Supported Attribute to BindHandle Co-authored-by: Mitchell Hwang --- .../src/System/Threading/ThreadPool.CoreCLR.cs | 3 +++ .../src/System/Threading/ThreadPool.Portable.cs | 2 ++ .../src/System/Threading/ThreadPool.cs | 9 +++++++++ .../System.Threading.ThreadPool/Directory.Build.props | 1 + .../ref/System.Threading.ThreadPool.cs | 10 ++++++++++ .../src/System/Threading/ThreadPool.Browser.Mono.cs | 2 ++ .../src/System/Threading/ThreadPool.Mono.cs | 2 ++ 7 files changed, 29 insertions(+) diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.cs index 59fecc735dd7b..86b6e4443cad8 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.cs @@ -14,6 +14,7 @@ using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; using System.Runtime.InteropServices; +using System.Runtime.Versioning; namespace System.Threading { @@ -159,6 +160,7 @@ private bool ValidHandle() => private static extern bool UnregisterWaitNative(IntPtr handle, SafeHandle? waitObject); } + [UnsupportedOSPlatform("browser")] public sealed class RegisteredWaitHandle : MarshalByRefObject { private readonly RegisteredWaitHandleSafe internalRegisteredWait; @@ -352,6 +354,7 @@ public static bool BindHandle(IntPtr osHandle) return BindIOCompletionCallbackNative(osHandle); } + [SupportedOSPlatform("windows")] public static bool BindHandle(SafeHandle osHandle) { if (osHandle == null) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.cs index 83ef4df898c02..7b49045defd23 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using Microsoft.Win32.SafeHandles; +using System.Runtime.Versioning; namespace System.Threading { @@ -13,6 +14,7 @@ namespace System.Threading /// /// An object representing the registration of a via . /// + [UnsupportedOSPlatform("browser")] public sealed class RegisteredWaitHandle : MarshalByRefObject { internal RegisteredWaitHandle(WaitHandle waitHandle, _ThreadPoolWaitOrTimerCallback callbackHelper, diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.cs index 4bcf665b9a6ca..55b149d893686 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.cs @@ -17,6 +17,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading.Tasks; +using System.Runtime.Versioning; using Internal.Runtime.CompilerServices; namespace System.Threading @@ -950,6 +951,7 @@ public static partial class ThreadPool }; [CLSCompliant(false)] + [UnsupportedOSPlatform("browser")] public static RegisteredWaitHandle RegisterWaitForSingleObject( WaitHandle waitObject, WaitOrTimerCallback callBack, @@ -964,6 +966,7 @@ public static RegisteredWaitHandle RegisterWaitForSingleObject( } [CLSCompliant(false)] + [UnsupportedOSPlatform("browser")] public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( WaitHandle waitObject, WaitOrTimerCallback callBack, @@ -977,6 +980,7 @@ public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( return RegisterWaitForSingleObject(waitObject, callBack, state, millisecondsTimeOutInterval, executeOnlyOnce, false); } + [UnsupportedOSPlatform("browser")] public static RegisteredWaitHandle RegisterWaitForSingleObject( WaitHandle waitObject, WaitOrTimerCallback callBack, @@ -990,6 +994,7 @@ public static RegisteredWaitHandle RegisterWaitForSingleObject( return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, true); } + [UnsupportedOSPlatform("browser")] public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( WaitHandle waitObject, WaitOrTimerCallback callBack, @@ -1003,6 +1008,7 @@ public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, false); } + [UnsupportedOSPlatform("browser")] public static RegisteredWaitHandle RegisterWaitForSingleObject( WaitHandle waitObject, WaitOrTimerCallback callBack, @@ -1018,6 +1024,7 @@ public static RegisteredWaitHandle RegisterWaitForSingleObject( return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, true); } + [UnsupportedOSPlatform("browser")] public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( WaitHandle waitObject, WaitOrTimerCallback callBack, @@ -1033,6 +1040,7 @@ public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, false); } + [UnsupportedOSPlatform("browser")] public static RegisteredWaitHandle RegisterWaitForSingleObject( WaitHandle waitObject, WaitOrTimerCallback callBack, @@ -1049,6 +1057,7 @@ bool executeOnlyOnce return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)tm, executeOnlyOnce, true); } + [UnsupportedOSPlatform("browser")] public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( WaitHandle waitObject, WaitOrTimerCallback callBack, diff --git a/src/libraries/System.Threading.ThreadPool/Directory.Build.props b/src/libraries/System.Threading.ThreadPool/Directory.Build.props index 63f02a0f817ef..d68d22c1b917f 100644 --- a/src/libraries/System.Threading.ThreadPool/Directory.Build.props +++ b/src/libraries/System.Threading.ThreadPool/Directory.Build.props @@ -2,5 +2,6 @@ Microsoft + true \ No newline at end of file diff --git a/src/libraries/System.Threading.ThreadPool/ref/System.Threading.ThreadPool.cs b/src/libraries/System.Threading.ThreadPool/ref/System.Threading.ThreadPool.cs index b815c818c9492..5d4212129c175 100644 --- a/src/libraries/System.Threading.ThreadPool/ref/System.Threading.ThreadPool.cs +++ b/src/libraries/System.Threading.ThreadPool/ref/System.Threading.ThreadPool.cs @@ -10,6 +10,7 @@ public partial interface IThreadPoolWorkItem { void Execute(); } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public sealed partial class RegisteredWaitHandle : System.MarshalByRefObject { internal RegisteredWaitHandle() { } @@ -22,6 +23,7 @@ public static partial class ThreadPool public static int ThreadCount { get { throw null; } } [System.ObsoleteAttribute("ThreadPool.BindHandle(IntPtr) has been deprecated. Please use ThreadPool.BindHandle(SafeHandle) instead.", false)] public static bool BindHandle(System.IntPtr osHandle) { throw null; } + [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static bool BindHandle(System.Runtime.InteropServices.SafeHandle osHandle) { throw null; } public static void GetAvailableThreads(out int workerThreads, out int completionPortThreads) { throw null; } public static void GetMaxThreads(out int workerThreads, out int completionPortThreads) { throw null; } @@ -29,10 +31,14 @@ public static partial class ThreadPool public static bool QueueUserWorkItem(System.Threading.WaitCallback callBack) { throw null; } public static bool QueueUserWorkItem(System.Threading.WaitCallback callBack, object? state) { throw null; } public static bool QueueUserWorkItem(System.Action callBack, TState state, bool preferLocal) { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static System.Threading.RegisteredWaitHandle RegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, int millisecondsTimeOutInterval, bool executeOnlyOnce) { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static System.Threading.RegisteredWaitHandle RegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, long millisecondsTimeOutInterval, bool executeOnlyOnce) { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static System.Threading.RegisteredWaitHandle RegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, System.TimeSpan timeout, bool executeOnlyOnce) { throw null; } [System.CLSCompliantAttribute(false)] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static System.Threading.RegisteredWaitHandle RegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, uint millisecondsTimeOutInterval, bool executeOnlyOnce) { throw null; } public static bool SetMaxThreads(int workerThreads, int completionPortThreads) { throw null; } public static bool SetMinThreads(int workerThreads, int completionPortThreads) { throw null; } @@ -41,10 +47,14 @@ public static partial class ThreadPool public static bool UnsafeQueueUserWorkItem(System.Threading.IThreadPoolWorkItem callBack, bool preferLocal) { throw null; } public static bool UnsafeQueueUserWorkItem(System.Threading.WaitCallback callBack, object? state) { throw null; } public static bool UnsafeQueueUserWorkItem(System.Action callBack, TState state, bool preferLocal) { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, int millisecondsTimeOutInterval, bool executeOnlyOnce) { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, long millisecondsTimeOutInterval, bool executeOnlyOnce) { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, System.TimeSpan timeout, bool executeOnlyOnce) { throw null; } [System.CLSCompliantAttribute(false)] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, uint millisecondsTimeOutInterval, bool executeOnlyOnce) { throw null; } } public delegate void WaitCallback(object? state); diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/ThreadPool.Browser.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/ThreadPool.Browser.Mono.cs index 179e2f7a43c98..e71edb9c10f8a 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/ThreadPool.Browser.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/ThreadPool.Browser.Mono.cs @@ -4,11 +4,13 @@ using System.Diagnostics; using System.Collections.Generic; using System.Runtime.CompilerServices; +using System.Runtime.Versioning; using System.Diagnostics.CodeAnalysis; using Microsoft.Win32.SafeHandles; namespace System.Threading { + [UnsupportedOSPlatform("browser")] public sealed class RegisteredWaitHandle : MarshalByRefObject { internal RegisteredWaitHandle(WaitHandle waitHandle, _ThreadPoolWaitOrTimerCallback callbackHelper, diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/ThreadPool.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/ThreadPool.Mono.cs index 49ee8ce9b8bd6..11b23df388812 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Threading/ThreadPool.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Threading/ThreadPool.Mono.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.InteropServices; +using System.Runtime.Versioning; namespace System.Threading { @@ -32,6 +33,7 @@ public static bool BindHandle(IntPtr osHandle) throw new PlatformNotSupportedException(SR.Arg_PlatformNotSupported); // Replaced by ThreadPoolBoundHandle.BindHandle } + [SupportedOSPlatform("windows")] public static bool BindHandle(SafeHandle osHandle) { throw new PlatformNotSupportedException(SR.Arg_PlatformNotSupported); // Replaced by ThreadPoolBoundHandle.BindHandle From 070552735e2a95a758a790450d9df6ae725b6995 Mon Sep 17 00:00:00 2001 From: Maxim Lipnin Date: Wed, 9 Sep 2020 02:24:22 +0300 Subject: [PATCH 10/11] Mark System.Net.WebSockets.ClientWebSocketOptions APIs as unsupported on Browser (#41963) * Mark System.Net.WebSockets.ClientWebSocketOptions APIs as unsupported on Browser * Add the attributes to non-browser version of ClientWebSocketOptions class to avoid build error * Add using * Include platform attributes --- .../Directory.Build.props | 1 + .../ref/System.Net.WebSockets.Client.cs | 10 ++++++++++ .../BrowserWebSockets/ClientWebSocketOptions.cs | 11 +++++++++++ .../System/Net/WebSockets/ClientWebSocketOptions.cs | 11 +++++++++++ 4 files changed, 33 insertions(+) diff --git a/src/libraries/System.Net.WebSockets.Client/Directory.Build.props b/src/libraries/System.Net.WebSockets.Client/Directory.Build.props index 63f02a0f817ef..d68d22c1b917f 100644 --- a/src/libraries/System.Net.WebSockets.Client/Directory.Build.props +++ b/src/libraries/System.Net.WebSockets.Client/Directory.Build.props @@ -2,5 +2,6 @@ Microsoft + true \ No newline at end of file diff --git a/src/libraries/System.Net.WebSockets.Client/ref/System.Net.WebSockets.Client.cs b/src/libraries/System.Net.WebSockets.Client/ref/System.Net.WebSockets.Client.cs index 2d7ea3172807b..cee3a5170b862 100644 --- a/src/libraries/System.Net.WebSockets.Client/ref/System.Net.WebSockets.Client.cs +++ b/src/libraries/System.Net.WebSockets.Client/ref/System.Net.WebSockets.Client.cs @@ -27,16 +27,26 @@ public override void Dispose() { } public sealed partial class ClientWebSocketOptions { internal ClientWebSocketOptions() { } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Security.Cryptography.X509Certificates.X509CertificateCollection ClientCertificates { get { throw null; } set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Net.CookieContainer? Cookies { get { throw null; } set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Net.ICredentials? Credentials { get { throw null; } set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.TimeSpan KeepAliveInterval { get { throw null; } set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Net.IWebProxy? Proxy { get { throw null; } set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public System.Net.Security.RemoteCertificateValidationCallback? RemoteCertificateValidationCallback { get { throw null; } set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public bool UseDefaultCredentials { get { throw null; } set { } } public void AddSubProtocol(string subProtocol) { } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public void SetBuffer(int receiveBufferSize, int sendBufferSize) { } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public void SetBuffer(int receiveBufferSize, int sendBufferSize, System.ArraySegment buffer) { } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public void SetRequestHeader(string headerName, string? headerValue) { } } } diff --git a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/ClientWebSocketOptions.cs b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/ClientWebSocketOptions.cs index e61fced8ca1dc..85b0f025b4650 100644 --- a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/ClientWebSocketOptions.cs +++ b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/ClientWebSocketOptions.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Runtime.Versioning; using System.Security.Cryptography.X509Certificates; namespace System.Net.WebSockets @@ -17,42 +18,49 @@ internal ClientWebSocketOptions() #region HTTP Settings + [UnsupportedOSPlatform("browser")] // Note that some headers are restricted like Host. public void SetRequestHeader(string headerName, string headerValue) { throw new PlatformNotSupportedException(); } + [UnsupportedOSPlatform("browser")] public bool UseDefaultCredentials { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } + [UnsupportedOSPlatform("browser")] public System.Net.ICredentials Credentials { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } + [UnsupportedOSPlatform("browser")] public System.Net.IWebProxy Proxy { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } + [UnsupportedOSPlatform("browser")] public X509CertificateCollection ClientCertificates { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } + [UnsupportedOSPlatform("browser")] public System.Net.Security.RemoteCertificateValidationCallback RemoteCertificateValidationCallback { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } + [UnsupportedOSPlatform("browser")] public System.Net.CookieContainer Cookies { get => throw new PlatformNotSupportedException(); @@ -85,17 +93,20 @@ public void AddSubProtocol(string subProtocol) internal List RequestedSubProtocols => _requestedSubProtocols ??= new List(); + [UnsupportedOSPlatform("browser")] public TimeSpan KeepAliveInterval { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } + [UnsupportedOSPlatform("browser")] public void SetBuffer(int receiveBufferSize, int sendBufferSize) { throw new PlatformNotSupportedException(); } + [UnsupportedOSPlatform("browser")] public void SetBuffer(int receiveBufferSize, int sendBufferSize, ArraySegment buffer) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/ClientWebSocketOptions.cs b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/ClientWebSocketOptions.cs index 4c17af9342433..a7609a0ff0905 100644 --- a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/ClientWebSocketOptions.cs +++ b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/ClientWebSocketOptions.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Net.Security; +using System.Runtime.Versioning; using System.Security.Cryptography.X509Certificates; using System.Threading; @@ -29,6 +30,7 @@ internal ClientWebSocketOptions() { } // prevent external instantiation #region HTTP Settings + [UnsupportedOSPlatform("browser")] // Note that some headers are restricted like Host. public void SetRequestHeader(string headerName, string? headerValue) { @@ -42,6 +44,7 @@ public void SetRequestHeader(string headerName, string? headerValue) internal List RequestedSubProtocols => _requestedSubProtocols ??= new List(); + [UnsupportedOSPlatform("browser")] public bool UseDefaultCredentials { get => _useDefaultCredentials; @@ -52,6 +55,7 @@ public bool UseDefaultCredentials } } + [UnsupportedOSPlatform("browser")] public ICredentials? Credentials { get => _credentials; @@ -62,6 +66,7 @@ public ICredentials? Credentials } } + [UnsupportedOSPlatform("browser")] public IWebProxy? Proxy { get => _proxy; @@ -72,6 +77,7 @@ public IWebProxy? Proxy } } + [UnsupportedOSPlatform("browser")] public X509CertificateCollection ClientCertificates { get => _clientCertificates ??= new X509CertificateCollection(); @@ -82,6 +88,7 @@ public X509CertificateCollection ClientCertificates } } + [UnsupportedOSPlatform("browser")] public RemoteCertificateValidationCallback? RemoteCertificateValidationCallback { get => _remoteCertificateValidationCallback; @@ -92,6 +99,7 @@ public RemoteCertificateValidationCallback? RemoteCertificateValidationCallback } } + [UnsupportedOSPlatform("browser")] public CookieContainer? Cookies { get => _cookies; @@ -123,6 +131,7 @@ public void AddSubProtocol(string subProtocol) subprotocols.Add(subProtocol); } + [UnsupportedOSPlatform("browser")] public TimeSpan KeepAliveInterval { get => _keepAliveInterval; @@ -142,6 +151,7 @@ public TimeSpan KeepAliveInterval internal int ReceiveBufferSize => _receiveBufferSize; internal ArraySegment? Buffer => _buffer; + [UnsupportedOSPlatform("browser")] public void SetBuffer(int receiveBufferSize, int sendBufferSize) { ThrowIfReadOnly(); @@ -159,6 +169,7 @@ public void SetBuffer(int receiveBufferSize, int sendBufferSize) _buffer = null; } + [UnsupportedOSPlatform("browser")] public void SetBuffer(int receiveBufferSize, int sendBufferSize, ArraySegment buffer) { ThrowIfReadOnly(); From 43d59ca0fcf4f87a016afef80f5353119a80340a Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Tue, 8 Sep 2020 19:24:33 -0400 Subject: [PATCH 11/11] [wasm] Mark System.Net.NameResolution Unsupported at assembly level (#41985) Co-authored-by: Mitchell Hwang --- src/libraries/System.Net.NameResolution/Directory.Build.props | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/System.Net.NameResolution/Directory.Build.props b/src/libraries/System.Net.NameResolution/Directory.Build.props index 63f02a0f817ef..ce244cbea5619 100644 --- a/src/libraries/System.Net.NameResolution/Directory.Build.props +++ b/src/libraries/System.Net.NameResolution/Directory.Build.props @@ -2,5 +2,7 @@ Microsoft + true + browser \ No newline at end of file