Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Message property to ExperimentalAttribute #108216

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -8869,6 +8869,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);
}
}
}