MethodImplAttributes 枚举

定义

指定方法实现的属性的标志。

此枚举支持其成员值的按位组合。

此 API 支持产品基础结构,不能在代码中直接使用。

public enum class MethodImplAttributes
public enum MethodImplAttributes
[System.Flags]
[System.Serializable]
public enum MethodImplAttributes
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum MethodImplAttributes
type MethodImplAttributes = 
[<System.Flags>]
[<System.Serializable>]
type MethodImplAttributes = 
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type MethodImplAttributes = 
Public Enum MethodImplAttributes
继承
MethodImplAttributes
属性

字段

名称 说明
IL 0

指定方法实现采用Microsoft中间语言(MSIL)。

Managed 0

指定该方法在托管代码中实现。

Native 1

指定方法实现是本机的。

OPTIL 2

指定方法实现采用优化中间语言(OPTIL)。

CodeTypeMask 3

指定有关代码类型的标志。

Runtime 3

指定方法实现由运行时提供。

ManagedMask 4

指定该方法是在托管代码还是非托管代码中实现。

Unmanaged 4

指定该方法在非托管代码中实现。

NoInlining 8

指定方法不能内联。

ForwardRef 16

指定未定义该方法。

Synchronized 32

指定该方法通过正文进行单线程处理。 静态方法 (Shared in Visual Basic) 锁定类型,而实例方法锁定实例。 还可以将 C# lock 语句或 Visual Basic SyncLock 语句用于此目的。

NoOptimization 64

指定在调试可能的代码生成问题时,该方法不会由实时 (JIT) 编译器或本机代码生成(请参阅 Ngen.exe)进行优化。

PreserveSig 128

指定方法签名的导出方式与声明完全相同。

AggressiveInlining 256

指定应尽可能将方法内联。

AggressiveOptimization 512

指定应尽可能优化方法。

SecurityMitigations 1024

此成员保留供将来使用。 它已在 .NET Framework 4.8 中引入。

InternalCall 4096

指定内部调用。

Async 8192
MaxMethodImplVal 65535

指定范围检查值。

注解

这些属性使用按位 OR 操作进行组合,如下所示:

代码实现掩码:

  • CodeTypeMask

  • IL

  • Native

  • OPTIL

  • Runtime

托管掩码:

  • ManagedMask

  • Unmanaged

  • Managed

实现信息和互操作掩码:

  • ForwardRef

  • PreserveSig

  • InternalCall

  • Synchronized

  • NoInlining

  • NoOptimization

  • MaxMethodImplVal

  • SecurityMitigations (从 .NET Framework 4.8 开始可用。

Note

建议不要对公共类型锁定实例或类型进行锁定, Synchronized 因为除你自己的代码外,还可以锁定公共类型和实例。 这可能会导致死锁或其他同步问题。

适用于

另请参阅