}
else
{
- _ASSERTE(pInfoModule = pMethod->GetModule());
+ _ASSERTE(pInfoModule == pMethod->GetModule());
}
if (!ownerType.HasInstantiation())
{
_ASSERTE(pResolvedToken->cbMethodSpec > 1);
- if (*(BYTE*)pResolvedToken->pMethodSpec != (BYTE)IMAGE_CEE_CS_CALLCONV_GENERICINST)
+ // Copy the pResolvedToken->pMethodSpec, inserting ELEMENT_TYPE_MODULE_ZAPSIG in front of each type parameter in needed
+ SigParser sigParser(pResolvedToken->pMethodSpec);
+ BYTE callingConvention;
+ IfFailThrow(sigParser.GetByte(&callingConvention));
+ if (callingConvention != (BYTE)IMAGE_CEE_CS_CALLCONV_GENERICINST)
+ {
ThrowHR(COR_E_BADIMAGEFORMAT);
+ }
+
+ ULONG numGenArgs;
+ IfFailThrow(sigParser.GetData(&numGenArgs));
+ pSigBuilder->AppendData(numGenArgs);
+
+ DWORD moduleIndex;
+ bool addModuleZapSig = (IsReadyToRunCompilation() && pMethod->GetModule()->IsInCurrentVersionBubble() && pInfoModule != (Module *) pResolvedToken->tokenScope);
+ if (addModuleZapSig)
+ {
+ moduleIndex = (*((EncodeModuleCallback)pfnEncodeModule))(pEncodeModuleContext, (Module *) pResolvedToken->tokenScope);
+ }
- pSigBuilder->AppendBlob((PVOID)(((BYTE*)pResolvedToken->pMethodSpec) + 1), pResolvedToken->cbMethodSpec - 1);
+ while (numGenArgs != 0)
+ {
+ if (addModuleZapSig)
+ {
+ pSigBuilder->AppendElementType((CorElementType)ELEMENT_TYPE_MODULE_ZAPSIG);
+ pSigBuilder->AppendData(moduleIndex);
+ }
+
+ PCCOR_SIGNATURE typeSigStart = sigParser.GetPtr();
+ IfFailThrow(sigParser.SkipExactlyOne());
+ PCCOR_SIGNATURE typeSigEnd = sigParser.GetPtr();
+ pSigBuilder->AppendBlob((PVOID)typeSigStart, typeSigEnd - typeSigStart);
+ numGenArgs--;
+ }
}
else
{