MethodBuilder.SetImplementationFlags(MethodImplAttributes) メソッド

定義

このメソッドの実装フラグを取得または設定します。

public:
 void SetImplementationFlags(System::Reflection::MethodImplAttributes attributes);
public void SetImplementationFlags (System.Reflection.MethodImplAttributes attributes);
member this.SetImplementationFlags : System.Reflection.MethodImplAttributes -> unit
Public Sub SetImplementationFlags (attributes As MethodImplAttributes)

パラメーター

attributes
MethodImplAttributes

設定する実装フラグ。

例外

含まれている型は、CreateType() を使用して以前に作成されています。

- または -

現在のメソッドでは、IsGenericMethod プロパティは true ですが、IsGenericMethodDefinition プロパティは false です。

次のコード サンプルは、メソッド本体での MSIL の SetImplementationFlags 実装を記述するための メソッドのコンテキストでの使用を示しています。

array<Type^>^ temp0 = { int::typeid, int::typeid };
MethodBuilder^ myMthdBuilder = myTypeBuilder->DefineMethod( "MyMethod",
                               MethodAttributes::Public,
                               CallingConventions::HasThis,
                               int::typeid,
                               temp0 );

// Specifies that the dynamic method declared above has a an MSIL implementation,
// is managed, synchronized (single-threaded) through the body, and that it
// cannot be inlined.

myMthdBuilder->SetImplementationFlags( (MethodImplAttributes)(
                                        MethodImplAttributes::IL |
                                        MethodImplAttributes::Managed |
                                        MethodImplAttributes::Synchronized |
                                        MethodImplAttributes::NoInlining) );

// Create an ILGenerator for the MethodBuilder and emit MSIL here ...
MethodBuilder myMthdBuilder = myTypeBuilder.DefineMethod("MyMethod",
                    MethodAttributes.Public,
                    CallingConventions.HasThis,
                    typeof(int),
                    new Type[] { typeof(int),
                             typeof(int) });	

// Specifies that the dynamic method declared above has a an MSIL implementation,
    // is managed, synchronized (single-threaded) through the body, and that it
// cannot be inlined.

myMthdBuilder.SetImplementationFlags(MethodImplAttributes.IL |
                     MethodImplAttributes.Managed |
                     MethodImplAttributes.Synchronized |
                     MethodImplAttributes.NoInlining);

// Create an ILGenerator for the MethodBuilder and emit MSIL here ...
Dim myMthdBuilder As MethodBuilder = myTypeBuilder.DefineMethod("MyMethod", _
                 MethodAttributes.Public, _
                 CallingConventions.HasThis, _
                 GetType(Integer), _
                 New Type() {GetType(Integer), GetType(Integer)})

' Specifies that the dynamic method declared above has a an MSIL implementation,
' is managed, synchronized (single-threaded) through the body, and that it 
' cannot be inlined.

myMthdBuilder.SetImplementationFlags((MethodImplAttributes.IL Or _
                  MethodImplAttributes.Managed Or _
                  MethodImplAttributes.Synchronized Or _
                  MethodImplAttributes.NoInlining))

' Create an ILGenerator for the MethodBuilder and emit MSIL here ...

注釈

メソッドと メソッドを SetImplementationFlags 組み合わせて使用する SetCustomAttribute 場合は、潜在的な相互作用に注意してください。 たとえば、 メソッドを SetCustomAttribute 使用して 属性を追加すると、 DllImportAttribute フラグも設定されます MethodImplAttributes.PreserveSig 。 その後、 メソッドを SetImplementationFlags 呼び出すと、 PreserveSig フラグが上書きされます。 この回避方法は次の 2 とおりあります。

適用対象