Skip to content

Commit

Permalink
feat: Add Message property to ExperimentalAttribute (#108216)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergey Papikyan <[email protected]>
Co-authored-by: Tanner Gooding <[email protected]>
  • Loading branch information
3 people authored Nov 26, 2024
1 parent b4923b3 commit abee177
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ public ExperimentalAttribute(string diagnosticId)
/// </remarks>
public string DiagnosticId { get; }

/// <summary>
/// Gets or sets an optional message associated with the experimental attribute.
/// </summary>
/// <value>The message that provides additional information about the experimental feature.</value>
/// <remarks>
/// This message can be used to provide more context or guidance about the experimental feature.
/// </remarks>
public string? Message { get; set; }

/// <summary>
/// Gets or sets the URL for corresponding documentation.
/// The API accepts a format string instead of an actual URL, creating a generic URL that includes the diagnostic ID.
Expand Down
1 change: 1 addition & 0 deletions src/libraries/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8913,6 +8913,7 @@ public sealed partial class ExperimentalAttribute : System.Attribute
{
public ExperimentalAttribute(string diagnosticId) { }
public string DiagnosticId { get { throw null; } }
public string? Message { get { throw null; } set { } }
public string? UrlFormat { get { throw null; } set { } }
}
[System.AttributeUsageAttribute(System.AttributeTargets.Property, Inherited=false, AllowMultiple=true)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,20 @@ public void TestSetUrlFormat(string urlFormat)
Assert.Equal("diagnosticId", attr.DiagnosticId);
Assert.Equal(urlFormat, attr.UrlFormat);
}

[Theory]
[InlineData(null)]
[InlineData("")]
[InlineData("This is an experimental feature")]
public void TestSetMessage(string message)
{
var attribute = new ExperimentalAttribute("diagnosticId")
{
Message = message
};

Assert.Equal("diagnosticId", attribute.DiagnosticId);
Assert.Equal(message, attribute.Message);
}
}
}

0 comments on commit abee177

Please sign in to comment.