类ExperimentalAttribute
表示API处于实验阶段,将来可能会发生变化。
命名空间: System 。诊断。 CodeAnalysis
程序集:Realm.dll
语法
[AttributeUsage(AttributeTargets.Assembly|AttributeTargets.Module|AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Constructor|AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Event|AttributeTargets.Interface|AttributeTargets.Delegate, Inherited = false)]
public sealed class ExperimentalAttribute : Attribute
备注
此属性允许使用诊断标记调用站点,表明使用了实验性功能。 作者可以使用此属性在其程序集中发布预览特征。
这是.NET 8中添加的实验属性的 polyfill。
构造函数
| 编辑本页 查看源代码ExperimentalAttribute(string)
初始化实验属性类的新实例,并指定编译器在报告属性所适用的API使用情况时使用的ID 。
声明
public ExperimentalAttribute(string diagnosticId)
参数
类型 | 名称 | 说明 |
---|---|---|
字符串 | DiagnosticId | 编译器在报告属性所适用的 API 的使用情况时使用的 ID。 |
属性
| 编辑本页 查看源代码DiagnosticId
获取编译器在报告属性所适用的 API 使用情况时使用的 ID。
声明
public string DiagnosticId { get; }
属性值
类型 | 说明 |
---|---|
字符串 | 唯一的诊断 ID。 |
备注
诊断 ID 显示在警告和错误的构建输出中。
此属性表示可用于抑制警告或错误的唯一ID (如果需要)。
UrlFormat
获取或设置相应文档的URL 。
该API 接受格式string 而不是实际的URL ,从而创建包含诊断URL 的通用ID 。
声明
public string? UrlFormat { get; set; }
属性值
类型 | 说明 |
---|---|
字符串 | 表示相应文档 的格式 。stringURL |
备注
格式string示例为 https://contoso.com/obsoletion-warnings/{0}
。