Skip to content

Commit abee177

Browse files
I-SER-ISergey Papikyantannergooding
authored
feat: Add Message property to ExperimentalAttribute (#108216)
Co-authored-by: Sergey Papikyan <s.papikyan@tinkoff.ru> Co-authored-by: Tanner Gooding <tagoo@outlook.com>
1 parent b4923b3 commit abee177

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/ExperimentalAttribute.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ public ExperimentalAttribute(string diagnosticId)
4949
/// </remarks>
5050
public string DiagnosticId { get; }
5151

52+
/// <summary>
53+
/// Gets or sets an optional message associated with the experimental attribute.
54+
/// </summary>
55+
/// <value>The message that provides additional information about the experimental feature.</value>
56+
/// <remarks>
57+
/// This message can be used to provide more context or guidance about the experimental feature.
58+
/// </remarks>
59+
public string? Message { get; set; }
60+
5261
/// <summary>
5362
/// Gets or sets the URL for corresponding documentation.
5463
/// The API accepts a format string instead of an actual URL, creating a generic URL that includes the diagnostic ID.

src/libraries/System.Runtime/ref/System.Runtime.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8913,6 +8913,7 @@ public sealed partial class ExperimentalAttribute : System.Attribute
89138913
{
89148914
public ExperimentalAttribute(string diagnosticId) { }
89158915
public string DiagnosticId { get { throw null; } }
8916+
public string? Message { get { throw null; } set { } }
89168917
public string? UrlFormat { get { throw null; } set { } }
89178918
}
89188919
[System.AttributeUsageAttribute(System.AttributeTargets.Property, Inherited=false, AllowMultiple=true)]

src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Diagnostics/CodeAnalysis/ExperimentalAttributeTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,20 @@ public void TestSetUrlFormat(string urlFormat)
3636
Assert.Equal("diagnosticId", attr.DiagnosticId);
3737
Assert.Equal(urlFormat, attr.UrlFormat);
3838
}
39+
40+
[Theory]
41+
[InlineData(null)]
42+
[InlineData("")]
43+
[InlineData("This is an experimental feature")]
44+
public void TestSetMessage(string message)
45+
{
46+
var attribute = new ExperimentalAttribute("diagnosticId")
47+
{
48+
Message = message
49+
};
50+
51+
Assert.Equal("diagnosticId", attribute.DiagnosticId);
52+
Assert.Equal(message, attribute.Message);
53+
}
3954
}
4055
}

0 commit comments

Comments
 (0)