Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/5.0-rc2] Backport Browser Unsupported Attribute Changes Properly #42071

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;

namespace System.Threading
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -352,6 +354,7 @@ public static bool BindHandle(IntPtr osHandle)
return BindIOCompletionCallbackNative(osHandle);
}

[SupportedOSPlatform("windows")]
public static bool BindHandle(SafeHandle osHandle)
{
if (osHandle == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<StrongNameKeyId>Microsoft</StrongNameKeyId>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -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; }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.ComponentModel.Design;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.Versioning;
using System.Threading;

namespace System.ComponentModel
Expand Down Expand Up @@ -116,6 +117,7 @@ private static void CacheProvider(Type type, LicenseProvider provider)
/// creationContext
/// as the context in which the licensed instance can be used.
/// </summary>
[UnsupportedOSPlatform("browser")]
public static object CreateWithContext(Type type, LicenseContext creationContext)
{
return CreateWithContext(type, creationContext, Array.Empty<object>());
Expand All @@ -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.
/// </summary>
[UnsupportedOSPlatform("browser")]
public static object CreateWithContext(Type type, LicenseContext creationContext, object[] args)
{
object created = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Collections.Specialized;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.Versioning;
using System.Text;

namespace System.ComponentModel
Expand Down Expand Up @@ -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).
/// </summary>
[UnsupportedOSPlatform("browser")]
public object Clone()
{
MaskedTextProvider clonedProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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.
/// </summary>
[UnsupportedOSPlatform("browser")]
public virtual object CreateInstance(IServiceProvider provider, Type objectType, Type[] argTypes, object[] args)
{
if (_parent != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Reflection;
using System.Runtime.Versioning;
using System.Threading;

namespace System.ComponentModel
Expand Down Expand Up @@ -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.
/// </summary>
[UnsupportedOSPlatform("browser")]
public static object CreateInstance(IServiceProvider provider, Type objectType, Type[] argTypes, object[] args)
{
if (objectType == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.ComponentModel.Design.Serialization;
using System.Globalization;
using System.Reflection;
using System.Runtime.Versioning;

namespace System.Security.Authentication.ExtendedProtection
{
Expand All @@ -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))
Expand Down
35 changes: 28 additions & 7 deletions src/libraries/System.Console/ref/System.Console.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,60 +8,81 @@ 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) { }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
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")]
Expand Down
Loading