Skip to content

Commit

Permalink
Copy .NET 9 attribute sources from dotnet/runtime.
Browse files Browse the repository at this point in the history
  • Loading branch information
teo-tsirpanis authored and Sergio0694 committed Nov 19, 2024
1 parent d519f71 commit 32ac9c8
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Indicates that the specified public static boolean get-only property
/// guards access to the specified feature.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
[AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
#if SYSTEM_PRIVATE_CORELIB
public
#else
internal
#endif
sealed class FeatureGuardAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="FeatureGuardAttribute"/> class
/// with the specified feature type.
/// </summary>
/// <param name="featureType">
/// The type that represents the feature guarded by the property.
/// </param>
public FeatureGuardAttribute(Type featureType)
{
FeatureType = featureType;
}

/// <summary>
/// The type that represents the feature guarded by the property.
/// </summary>
public Type FeatureType { get; }
}
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Indicates that the specified public static boolean get-only property
/// corresponds to the feature switch specified by name.
/// </summary>
/// <remarks>
/// IL rewriters and compilers can use this to substitute the return value
/// of the specified property with the value of the feature switch.
/// </remarks>
[AttributeUsage(AttributeTargets.Property, Inherited = false)]
#if SYSTEM_PRIVATE_CORELIB
public
#else
internal
#endif
sealed class FeatureSwitchDefinitionAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="FeatureSwitchDefinitionAttribute"/> class
/// with the specified feature switch name.
/// </summary>
/// <param name="switchName">
/// The name of the feature switch that provides the value for the specified property.
/// </param>
public FeatureSwitchDefinitionAttribute(string switchName)
{
SwitchName = switchName;
}

/// <summary>
/// The name of the feature switch that provides the value for the specified property.
/// </summary>
public string SwitchName { get; }
}
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// 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.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public sealed class DebuggerDisableUserUnhandledExceptionsAttribute : Attribute
{
}
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Specifies that the P/Invoke marked with this attribute should be linked in as a WASM import.
/// </summary>
/// <remarks>
/// See https://webassembly.github.io/spec/core/syntax/modules.html#imports.
/// </remarks>
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
public sealed class WasmImportLinkageAttribute : Attribute
{
/// <summary>
/// Instance constructor.
/// </summary>
public WasmImportLinkageAttribute() { }
}
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Specifies the priority of a member in overload resolution. When unspecified, the default priority is 0.
/// </summary>
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
public sealed class OverloadResolutionPriorityAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="OverloadResolutionPriorityAttribute"/> class.
/// </summary>
/// <param name="priority">The priority of the attributed member. Higher numbers are prioritized, lower numbers are deprioritized. 0 is the default if no attribute is present.</param>
public OverloadResolutionPriorityAttribute(int priority)
{
Priority = priority;
}

/// <summary>
/// The priority of the member.
/// </summary>
public int Priority { get; }
}
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Indicates that a method will allow a variable number of arguments in its invocation.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)]
public sealed class ParamCollectionAttribute : Attribute
{
}
}

0 comments on commit 32ac9c8

Please sign in to comment.