|
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
| 2 | +// The .NET Foundation licenses this file to you under the MIT license. |
| 3 | + |
| 4 | +#if !NET |
| 5 | +namespace System.Diagnostics.CodeAnalysis; |
| 6 | + |
| 7 | +/// <summary> |
| 8 | +/// Indicates that an API is experimental and it may change in the future. |
| 9 | +/// </summary> |
| 10 | +/// <remarks> |
| 11 | +/// This attribute allows call sites to be flagged with a diagnostic that indicates that an experimental |
| 12 | +/// feature is used. Authors can use this attribute to ship preview features in their assemblies. |
| 13 | +/// </remarks> |
| 14 | +[AttributeUsage(AttributeTargets.Assembly | |
| 15 | + AttributeTargets.Module | |
| 16 | + AttributeTargets.Class | |
| 17 | + AttributeTargets.Struct | |
| 18 | + AttributeTargets.Enum | |
| 19 | + AttributeTargets.Constructor | |
| 20 | + AttributeTargets.Method | |
| 21 | + AttributeTargets.Property | |
| 22 | + AttributeTargets.Field | |
| 23 | + AttributeTargets.Event | |
| 24 | + AttributeTargets.Interface | |
| 25 | + AttributeTargets.Delegate, Inherited = false)] |
| 26 | +internal sealed class ExperimentalAttribute : Attribute |
| 27 | +{ |
| 28 | + /// <summary> |
| 29 | + /// Initializes a new instance of the <see cref="ExperimentalAttribute"/> class, specifying the ID that the compiler will use |
| 30 | + /// when reporting a use of the API the attribute applies to. |
| 31 | + /// </summary> |
| 32 | + /// <param name="diagnosticId">The ID that the compiler will use when reporting a use of the API the attribute applies to.</param> |
| 33 | + public ExperimentalAttribute(string diagnosticId) |
| 34 | + { |
| 35 | + DiagnosticId = diagnosticId; |
| 36 | + } |
| 37 | + |
| 38 | + /// <summary> |
| 39 | + /// Gets the ID that the compiler will use when reporting a use of the API the attribute applies to. |
| 40 | + /// </summary> |
| 41 | + /// <value>The unique diagnostic ID.</value> |
| 42 | + /// <remarks> |
| 43 | + /// The diagnostic ID is shown in build output for warnings and errors. |
| 44 | + /// <para>This property represents the unique ID that can be used to suppress the warnings or errors, if needed.</para> |
| 45 | + /// </remarks> |
| 46 | + public string DiagnosticId { get; } |
| 47 | + |
| 48 | + /// <summary> |
| 49 | + /// Gets or sets an optional message associated with the experimental attribute. |
| 50 | + /// </summary> |
| 51 | + /// <value>The message that provides additional information about the experimental feature.</value> |
| 52 | + /// <remarks> |
| 53 | + /// This message can be used to provide more context or guidance about the experimental feature. |
| 54 | + /// </remarks> |
| 55 | + public string? Message { get; set; } |
| 56 | + |
| 57 | + /// <summary> |
| 58 | + /// Gets or sets the URL for corresponding documentation. |
| 59 | + /// The API accepts a format string instead of an actual URL, creating a generic URL that includes the diagnostic ID. |
| 60 | + /// </summary> |
| 61 | + /// <value>The format string that represents a URL to corresponding documentation.</value> |
| 62 | + /// <remarks>An example format string is <c>https://contoso.com/obsoletion-warnings/{0}</c>.</remarks> |
| 63 | + public string? UrlFormat { get; set; } |
| 64 | +} |
| 65 | +#endif |
0 commit comments