Skip to content

Add description to RequiresPreviewFeaturesAttribute #56498

@JamesNK

Description

@JamesNK

It would be nice if there was a way to provide a description with RequiresPreviewFeaturesAttribute, like you can with ObsoleteAttribute. The description would show up in analyzers/build warnings.

A description would provide more information about why a feature is in preview and what a user should keep in mind if they choose to use the feature.

For example, HTTP/3 in .NET 6 is preview. Kind of detail we want to pass on when someone sees this warning:

  • What scenarios HTTP/3 does and doesn't support in .NET 6.
  • How to mitigate an app if HTTP/3 is turned on and problems are found.

API Proposal

namespace System.Runtime.Versioning
{
    public sealed class RequiresPreviewFeaturesAttribute : Attribute
    {
        // Existing
        // public RequiresPreviewFeaturesAttribute();
        public RequiresPreviewFeaturesAttribute(string message);
        public string Message { get; }
        public string Url { get; set; }
    }
}

Note: The URL property allows us to surface the URL directly via the Roslyn diagnostic, so that people can click the diagnostic ID in the error list, rather than copy & pasting the URL.

API Usage

 namespace Microsoft.AspNetCore.Server.Kestrel.Core
 {
     [Flags]
     public enum HttpProtocols
     {
         Http1 = 0x1,
         Http2 = 0x2,
         Http1AndHttp2 = Http1 | Http2,
+        [RequiresPreviewFeatures("Kestrel HTTP3 support for .NET 6 is in preview", Url = "https://aka.ms/kestrel-http3")]
         Http3 = 0x4,
+        [RequiresPreviewFeatures("Kestrel HTTP3 support for .NET 6 is in preview", Url = "https://aka.ms/kestrel-http3")]
         Http1AndHttp2AndHttp3 = Http1 | Http2 | Http3
     }
 }

Metadata

Metadata

Assignees

Labels

api-approvedAPI was approved in API review, it can be implementedarea-System.RuntimeblockingMarks issues that we want to fast track in order to unblock other important work

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions