语言

SupportedOSPlatformGuardAttribute 类

定义

使用受支持的平台名称和可选版本对自定义防护字段、属性或方法进行注释。 可以应用多个属性来指示多个受支持平台的防护。

public ref class SupportedOSPlatformGuardAttribute sealed : System::Runtime::Versioning::OSPlatformAttribute
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Method | System.AttributeTargets.Property, AllowMultiple=true, Inherited=false)]
public sealed class SupportedOSPlatformGuardAttribute : System.Runtime.Versioning.OSPlatformAttribute
[<System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Method | System.AttributeTargets.Property, AllowMultiple=true, Inherited=false)>]
type SupportedOSPlatformGuardAttribute = class
    inherit OSPlatformAttribute
Public NotInheritable Class SupportedOSPlatformGuardAttribute
Inherits OSPlatformAttribute
继承
SupportedOSPlatformGuardAttribute
属性

注解

调用方可以应用于 SupportedOSPlatformGuardAttribute 字段、属性或方法,并在条件或断言中使用该成员安全地调用特定于平台的 API。 字段或属性类型或方法返回类型必须是布尔值。

常见的平台名称包括android、browser、freebsd、iostvosmacoslinuxmaccatalyst、wasi、和。 watchoswindows 对于支持版本检查的平台,平台名称可以包含一个版本,例如 windows10.0。 有关详细信息,请参阅 平台兼容性分析器。

构造函数

名称 说明
SupportedOSPlatformGuardAttribute(String)

为指定的受支持的 OS 平台初始化特性类的新实例 SupportedOSPlatformGuardAttribute 。

属性

名称 说明
PlatformName

获取属性应用于的平台的名称和可选版本。

(继承自 OSPlatformAttribute)
TypeId

在派生类中实现时,获取此 Attribute的唯一标识符。

(继承自 Attribute)

方法

名称 说明
Equals(Object)

返回一个值,该值指示此实例是否等于指定对象。

(继承自 Attribute)
GetHashCode()

返回此实例的哈希代码。

(继承自 Attribute)
GetType()

获取当前实例的 Type。

(继承自 Object)
IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否为派生类的默认值。

(继承自 Attribute)
Match(Object)

在派生类中重写时,返回一个值,该值指示此实例是否等于指定对象。

(继承自 Attribute)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

适用于