From 32ac9c8deb1af0d4691bcb42f435761198f7489d Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Sun, 29 Sep 2024 20:57:37 +0300 Subject: [PATCH] Copy .NET 9 attribute sources from `dotnet/runtime`. --- ...tics.CodeAnalysis.FeatureGuardAttribute.cs | 40 +++++++++++++++++++ ...alysis.FeatureSwitchDefinitionAttribute.cs | 39 ++++++++++++++++++ ...DisableUserUnhandledExceptionsAttribute.cs | 15 +++++++ ...eropServices.WasmImportLinkageAttribute.cs | 20 ++++++++++ ...ces.OverloadResolutionPriorityAttribute.cs | 26 ++++++++++++ ...mpilerServices.ParamCollectionAttribute.cs | 13 ++++++ 6 files changed, 153 insertions(+) create mode 100644 src/PolySharp.SourceGenerators/EmbeddedResources/RuntimeSupported/System.Diagnostics.CodeAnalysis.FeatureGuardAttribute.cs create mode 100644 src/PolySharp.SourceGenerators/EmbeddedResources/RuntimeSupported/System.Diagnostics.CodeAnalysis.FeatureSwitchDefinitionAttribute.cs create mode 100644 src/PolySharp.SourceGenerators/EmbeddedResources/RuntimeSupported/System.Diagnostics.DebuggerDisableUserUnhandledExceptionsAttribute.cs create mode 100644 src/PolySharp.SourceGenerators/EmbeddedResources/RuntimeSupported/System.Runtime.InteropServices.WasmImportLinkageAttribute.cs create mode 100644 src/PolySharp.SourceGenerators/EmbeddedResources/System.Runtime.CompilerServices.OverloadResolutionPriorityAttribute.cs create mode 100644 src/PolySharp.SourceGenerators/EmbeddedResources/System.Runtime.CompilerServices.ParamCollectionAttribute.cs diff --git a/src/PolySharp.SourceGenerators/EmbeddedResources/RuntimeSupported/System.Diagnostics.CodeAnalysis.FeatureGuardAttribute.cs b/src/PolySharp.SourceGenerators/EmbeddedResources/RuntimeSupported/System.Diagnostics.CodeAnalysis.FeatureGuardAttribute.cs new file mode 100644 index 0000000..d843850 --- /dev/null +++ b/src/PolySharp.SourceGenerators/EmbeddedResources/RuntimeSupported/System.Diagnostics.CodeAnalysis.FeatureGuardAttribute.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Diagnostics.CodeAnalysis +{ + /// + /// Indicates that the specified public static boolean get-only property + /// guards access to the specified feature. + /// + /// + /// Analyzers can use this to prevent warnings on calls to code that is + /// annotated as requiring that feature, when the callsite is guarded by a + /// call to the property. + /// + [AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = true)] +#if SYSTEM_PRIVATE_CORELIB + public +#else + internal +#endif + sealed class FeatureGuardAttribute : Attribute + { + /// + /// Initializes a new instance of the class + /// with the specified feature type. + /// + /// + /// The type that represents the feature guarded by the property. + /// + public FeatureGuardAttribute(Type featureType) + { + FeatureType = featureType; + } + + /// + /// The type that represents the feature guarded by the property. + /// + public Type FeatureType { get; } + } +} \ No newline at end of file diff --git a/src/PolySharp.SourceGenerators/EmbeddedResources/RuntimeSupported/System.Diagnostics.CodeAnalysis.FeatureSwitchDefinitionAttribute.cs b/src/PolySharp.SourceGenerators/EmbeddedResources/RuntimeSupported/System.Diagnostics.CodeAnalysis.FeatureSwitchDefinitionAttribute.cs new file mode 100644 index 0000000..c87e5b0 --- /dev/null +++ b/src/PolySharp.SourceGenerators/EmbeddedResources/RuntimeSupported/System.Diagnostics.CodeAnalysis.FeatureSwitchDefinitionAttribute.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Diagnostics.CodeAnalysis +{ + /// + /// Indicates that the specified public static boolean get-only property + /// corresponds to the feature switch specified by name. + /// + /// + /// IL rewriters and compilers can use this to substitute the return value + /// of the specified property with the value of the feature switch. + /// + [AttributeUsage(AttributeTargets.Property, Inherited = false)] +#if SYSTEM_PRIVATE_CORELIB + public +#else + internal +#endif + sealed class FeatureSwitchDefinitionAttribute : Attribute + { + /// + /// Initializes a new instance of the class + /// with the specified feature switch name. + /// + /// + /// The name of the feature switch that provides the value for the specified property. + /// + public FeatureSwitchDefinitionAttribute(string switchName) + { + SwitchName = switchName; + } + + /// + /// The name of the feature switch that provides the value for the specified property. + /// + public string SwitchName { get; } + } +} \ No newline at end of file diff --git a/src/PolySharp.SourceGenerators/EmbeddedResources/RuntimeSupported/System.Diagnostics.DebuggerDisableUserUnhandledExceptionsAttribute.cs b/src/PolySharp.SourceGenerators/EmbeddedResources/RuntimeSupported/System.Diagnostics.DebuggerDisableUserUnhandledExceptionsAttribute.cs new file mode 100644 index 0000000..2bea1e0 --- /dev/null +++ b/src/PolySharp.SourceGenerators/EmbeddedResources/RuntimeSupported/System.Diagnostics.DebuggerDisableUserUnhandledExceptionsAttribute.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Diagnostics +{ + /// + /// If a .NET Debugger is attached which supports the Debugger.BreakForUserUnhandledException(Exception) API, + /// this attribute will prevent the debugger from breaking on user-unhandled exceptions when the + /// exception is caught by a method with this attribute, unless BreakForUserUnhandledException is called. + /// + [AttributeUsage(AttributeTargets.Method)] + public sealed class DebuggerDisableUserUnhandledExceptionsAttribute : Attribute + { + } +} \ No newline at end of file diff --git a/src/PolySharp.SourceGenerators/EmbeddedResources/RuntimeSupported/System.Runtime.InteropServices.WasmImportLinkageAttribute.cs b/src/PolySharp.SourceGenerators/EmbeddedResources/RuntimeSupported/System.Runtime.InteropServices.WasmImportLinkageAttribute.cs new file mode 100644 index 0000000..17e794a --- /dev/null +++ b/src/PolySharp.SourceGenerators/EmbeddedResources/RuntimeSupported/System.Runtime.InteropServices.WasmImportLinkageAttribute.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Runtime.InteropServices +{ + /// + /// Specifies that the P/Invoke marked with this attribute should be linked in as a WASM import. + /// + /// + /// See https://webassembly.github.io/spec/core/syntax/modules.html#imports. + /// + [AttributeUsage(AttributeTargets.Method, Inherited = false)] + public sealed class WasmImportLinkageAttribute : Attribute + { + /// + /// Instance constructor. + /// + public WasmImportLinkageAttribute() { } + } +} \ No newline at end of file diff --git a/src/PolySharp.SourceGenerators/EmbeddedResources/System.Runtime.CompilerServices.OverloadResolutionPriorityAttribute.cs b/src/PolySharp.SourceGenerators/EmbeddedResources/System.Runtime.CompilerServices.OverloadResolutionPriorityAttribute.cs new file mode 100644 index 0000000..b4f28b4 --- /dev/null +++ b/src/PolySharp.SourceGenerators/EmbeddedResources/System.Runtime.CompilerServices.OverloadResolutionPriorityAttribute.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Runtime.CompilerServices +{ + /// + /// Specifies the priority of a member in overload resolution. When unspecified, the default priority is 0. + /// + [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property, AllowMultiple = false, Inherited = false)] + public sealed class OverloadResolutionPriorityAttribute : Attribute + { + /// + /// Initializes a new instance of the class. + /// + /// The priority of the attributed member. Higher numbers are prioritized, lower numbers are deprioritized. 0 is the default if no attribute is present. + public OverloadResolutionPriorityAttribute(int priority) + { + Priority = priority; + } + + /// + /// The priority of the member. + /// + public int Priority { get; } + } +} \ No newline at end of file diff --git a/src/PolySharp.SourceGenerators/EmbeddedResources/System.Runtime.CompilerServices.ParamCollectionAttribute.cs b/src/PolySharp.SourceGenerators/EmbeddedResources/System.Runtime.CompilerServices.ParamCollectionAttribute.cs new file mode 100644 index 0000000..fb47660 --- /dev/null +++ b/src/PolySharp.SourceGenerators/EmbeddedResources/System.Runtime.CompilerServices.ParamCollectionAttribute.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Runtime.CompilerServices +{ + /// + /// Indicates that a method will allow a variable number of arguments in its invocation. + /// + [AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)] + public sealed class ParamCollectionAttribute : Attribute + { + } +} \ No newline at end of file