Skip to content

Commit dcf46c5

Browse files
committed
Add RequiresPreviewFeaturesAttribute
1 parent 72a0290 commit dcf46c5

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// <auto-generated/>
2+
#pragma warning disable
3+
#nullable enable annotations
4+
5+
// Licensed to the .NET Foundation under one or more agreements.
6+
// The .NET Foundation licenses this file to you under the MIT license.
7+
8+
namespace System.Runtime.Versioning
9+
{
10+
[AttributeUsage(AttributeTargets.Assembly |
11+
AttributeTargets.Module |
12+
AttributeTargets.Class |
13+
AttributeTargets.Interface |
14+
AttributeTargets.Delegate |
15+
AttributeTargets.Struct |
16+
AttributeTargets.Enum |
17+
AttributeTargets.Constructor |
18+
AttributeTargets.Method |
19+
AttributeTargets.Property |
20+
AttributeTargets.Field |
21+
AttributeTargets.Event, Inherited = false)]
22+
internal sealed class RequiresPreviewFeaturesAttribute : Attribute
23+
{
24+
/// <summary>
25+
/// Initializes a new instance of the <see cref="RequiresPreviewFeaturesAttribute"/> class.
26+
/// </summary>
27+
public RequiresPreviewFeaturesAttribute() { }
28+
29+
/// <summary>
30+
/// Initializes a new instance of the <see cref="RequiresPreviewFeaturesAttribute"/> class with the specified message.
31+
/// </summary>
32+
/// <param name="message">An optional message associated with this attribute instance.</param>
33+
public RequiresPreviewFeaturesAttribute(string? message)
34+
{
35+
Message = message;
36+
}
37+
38+
/// <summary>
39+
/// Returns the optional message associated with this attribute instance.
40+
/// </summary>
41+
public string? Message { get; }
42+
43+
/// <summary>
44+
/// Returns the optional URL associated with this attribute instance.
45+
/// </summary>
46+
public string? Url { get; set; }
47+
}
48+
}

tests/PolySharp.Tests/LanguageFeatures.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Diagnostics.CodeAnalysis;
33
using System.Runtime.CompilerServices;
4+
using System.Runtime.Versioning;
45

56
namespace PolySharp.Tests;
67

@@ -81,6 +82,11 @@ public bool TakeValue([NotNullWhen(true)] out string? value)
8182

8283
return true;
8384
}
85+
86+
[RequiresPreviewFeatures]
87+
public void PreviewApi()
88+
{
89+
}
8490
}
8591

8692
internal class TestClassWithRequiredMembers

0 commit comments

Comments
 (0)