Skip to content

Commit 7620535

Browse files
authored
add FeatureGuardAttribute (#249)
1 parent a6261f8 commit 7620535

File tree

4 files changed

+50
-2
lines changed

4 files changed

+50
-2
lines changed

apiCount.include.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
**API count: 402**
1+
**API count: 404**

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The package targets `netstandard2.0` and is designed to support the following ru
1212
* `net5.0`, `net6.0`, `net7.0`, `net8.0`, `net9.0`
1313

1414

15-
**API count: 402**<!-- singleLineInclude: apiCount. path: /apiCount.include.md -->
15+
**API count: 404**<!-- singleLineInclude: apiCount. path: /apiCount.include.md -->
1616

1717

1818
**See [Milestones](../../milestones?state=closed) for release notes.**

src/Consume/Consume.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class Consume
4848
type = typeof(NotNullWhenAttribute);
4949
type = typeof(CallerArgumentExpressionAttribute);
5050
type = typeof(IsExternalInit);
51+
type = typeof(FeatureGuardAttribute);
5152
type = typeof(ModuleInitializerAttribute);
5253
type = typeof(RequiredMemberAttribute);
5354
type = typeof(SetsRequiredMembersAttribute);
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// <auto-generated />
2+
#pragma warning disable
3+
4+
#if !NET9_0_OR_GREATER
5+
6+
namespace System.Diagnostics.CodeAnalysis;
7+
8+
using Diagnostics;
9+
using Diagnostics.CodeAnalysis;
10+
using Link = ComponentModel.DescriptionAttribute;
11+
12+
13+
/// <summary>
14+
/// Indicates that the specified public static boolean get-only property
15+
/// guards access to the specified feature.
16+
/// </summary>
17+
/// <remarks>
18+
/// Analyzers can use this to prevent warnings on calls to code that is
19+
/// annotated as requiring that feature, when the callsite is guarded by a
20+
/// call to the property.
21+
/// </remarks>
22+
[ExcludeFromCodeCoverage]
23+
[DebuggerNonUserCode]
24+
[AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
25+
//Link:https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.featureguardattribute
26+
#if PolyPublic
27+
public
28+
#endif
29+
sealed class FeatureGuardAttribute : Attribute
30+
{
31+
/// <summary>
32+
/// Initializes a new instance of the <see cref="FeatureGuardAttribute"/> class
33+
/// with the specified feature type.
34+
/// </summary>
35+
/// <param name="featureType">
36+
/// The type that represents the feature guarded by the property.
37+
/// </param>
38+
public FeatureGuardAttribute(Type featureType) =>
39+
FeatureType = featureType;
40+
41+
/// <summary>
42+
/// The type that represents the feature guarded by the property.
43+
/// </summary>
44+
public Type FeatureType { get; }
45+
}
46+
47+
#endif

0 commit comments

Comments
 (0)