Repository: dotnet/runtime
File: src/coreclr/vm/dllimport.cpp (C++)

Code before:

        // make the stub IMAGE_CEE_CS_CALLCONV_DEFAULT
        *new_sig &= ~IMAGE_CEE_CS_CALLCONV_MASK;
        *new_sig |= IMAGE_CEE_CS_CALLCONV_DEFAULT;

        signature = Signature(new_sig, signature.GetRawSigLen());
    }
    else
    {
        _ASSERTE(pMD->IsPInvoke());
        dwStubFlags |= PINVOKESTUB_FL_CONVSIGASVARARG;

        // vararg P/Invoke must be cdecl
        unmgdCallConv = CorInfoCallConvExtension::C;
    }

    mdMethodDef md = mdMethodDefNil;
    CorNativeLinkFlags nlFlags = nlfNone;
    CorNativeLinkType nlType = nltAnsi;

    if (pMD != NULL)
    {
        PInvokeStaticSigInfo sigInfo(pMD);

        // unmanaged vararg signatures should never be marked as async.
        // We don't support generating a interop IL stub for an async method.
        // Instead, we should generate an async variant stub that calls the task-returning interop stub.
        if (pMD->IsAsyncMethod())
            ThrowHR(COR_E_NOTSUPPORTED);

        md = pMD->GetMemberDef();
        nlFlags = sigInfo.GetLinkFlags();
        nlType  = sigInfo.GetCharSet();
    }

    StubSigDesc sigDesc(pMD, signature, pVASigCookie->pModule, pVASigCookie->pLoaderModule);
    sigDesc.InitTypeContext(pVASigCookie->classInst, pVASigCookie->methodInst);

    MethodDesc* pStubMD = PInvoke::CreateCLRToNativeILStub(&sigDesc,
                                    nlType,
                                    nlFlags,
                                    unmgdCallConv,
                                    dwStubFlags);

    pTempILStub = JitILStub(pStubMD);

    InterlockedCompareExchangeT<PCODE>(&pVASigCookie->pPInvokeILStub,
                                                    pTempILStub,
                                                    (PCODE)NULL);

    UNINSTALL_UNWIND_AND_CONTINUE_HANDLER;

Review comment (suggestion):
Missing article 'an' before 'interop'. The comment should read "We don't support generating an interop IL stub" for grammatical correctness.
```suggestion
        // We don't support generating an interop IL stub for an async method.
```

Code after:

        // make the stub IMAGE_CEE_CS_CALLCONV_DEFAULT
        *new_sig &= ~IMAGE_CEE_CS_CALLCONV_MASK;
        *new_sig |= IMAGE_CEE_CS_CALLCONV_DEFAULT;

        signature = Signature(new_sig, signature.GetRawSigLen());
    }
    else
    {
        _ASSERTE(pMD->IsPInvoke());
        dwStubFlags |= PINVOKESTUB_FL_CONVSIGASVARARG;

        // vararg P/Invoke must be cdecl
        unmgdCallConv = CorInfoCallConvExtension::C;
    }

    mdMethodDef md = mdMethodDefNil;
    CorNativeLinkFlags nlFlags = nlfNone;
    CorNativeLinkType nlType = nltAnsi;

    if (pMD != NULL)
    {
        _ASSERTE(pMD->IsPInvoke());
        _ASSERTE(!pMD->IsAsyncMethod());
        PInvokeStaticSigInfo sigInfo(pMD);

        md = pMD->GetMemberDef();
        nlFlags = sigInfo.GetLinkFlags();
        nlType  = sigInfo.GetCharSet();
    }

    StubSigDesc sigDesc(pMD, signature, pVASigCookie->pModule, pVASigCookie->pLoaderModule);
    sigDesc.InitTypeContext(pVASigCookie->classInst, pVASigCookie->methodInst);

    MethodDesc* pStubMD = PInvoke::CreateCLRToNativeILStub(&sigDesc,
                                    nlType,
                                    nlFlags,
                                    unmgdCallConv,
                                    dwStubFlags);

    pTempILStub = JitILStub(pStubMD);

    InterlockedCompareExchangeT<PCODE>(&pVASigCookie->pPInvokeILStub,
                                                    pTempILStub,
                                                    (PCODE)NULL);

    UNINSTALL_UNWIND_AND_CONTINUE_HANDLER;
    UNINSTALL_MANAGED_EXCEPTION_DISPATCHER;
}

EXTERN_C void STDCALL VarargPInvokeStubWorker(TransitionBlock* pTransitionBlock, VASigCookie *pVASigCookie, MethodDesc *pMD)