diff options
author | dotnet-bot <dotnet-bot@microsoft.com> | 2015-05-06 23:43:46 -0700 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2015-05-07 12:03:00 -0700 |
commit | 484a2cf0b0c4e304a5093ec26e07fe41f8896c3c (patch) | |
tree | 348b56df4cdb235bb87ba9bc9118711c8db13bfd /src/md | |
parent | c6efc7047edb38075310cfef8ea28b91717b8108 (diff) | |
download | coreclr-484a2cf0b0c4e304a5093ec26e07fe41f8896c3c.tar.gz coreclr-484a2cf0b0c4e304a5093ec26e07fe41f8896c3c.tar.bz2 coreclr-484a2cf0b0c4e304a5093ec26e07fe41f8896c3c.zip |
Merge changes from parent branch
[tfs-changeset: 1466545]
Diffstat (limited to 'src/md')
-rw-r--r-- | src/md/winmd/adapter.cpp | 55 | ||||
-rw-r--r-- | src/md/winmd/inc/adapter.h | 11 | ||||
-rw-r--r-- | src/md/winmd/winmdimport.cpp | 2 | ||||
-rw-r--r-- | src/md/winmd/winmdinternalimportro.cpp | 6 |
4 files changed, 64 insertions, 10 deletions
diff --git a/src/md/winmd/adapter.cpp b/src/md/winmd/adapter.cpp index 45c695c1d3..1be4e0a07b 100644 --- a/src/md/winmd/adapter.cpp +++ b/src/md/winmd/adapter.cpp @@ -207,6 +207,7 @@ WinMDAdapter::WinMDAdapter(IMDCommon *pRawMDCommon) , m_redirectedTypeSpecSigMemoTable(pRawMDCommon->GetMetaModelCommonRO()->CommonGetRowCount(mdtTypeSpec), NULL) , m_redirectedMethodSpecSigMemoTable(pRawMDCommon->GetMetaModelCommonRO()->CommonGetRowCount(mdtMethodSpec), NULL) , m_mangledTypeNameTable(pRawMDCommon->GetMetaModelCommonRO()->CommonGetRowCount(mdtTypeDef), NULL) + , m_extraAssemblyRefCount(-1) { m_rawAssemblyRefCount = pRawMDCommon->GetMetaModelCommonRO()->CommonGetRowCount(mdtAssemblyRef); m_pRedirectedVersionString = NULL; @@ -1095,6 +1096,60 @@ HRESULT WinMDAdapter::ModifyExportedTypeName( //------------------------------------------------------------------------------ +// We must optionaly add an assembly ref for System.Numerics.Vectors.dll since this assembly is not available +// on downlevel platforms. +// +// This function assumes that System.Numerics.Vectors.dll is the last assembly that +// we add so if we find a reference then we return ContractAssembly_Count otherwise we return +// ContractAssembly_Count - 1. +int WinMDAdapter::GetExtraAssemblyRefCount() +{ + HRESULT hr; + + if (m_extraAssemblyRefCount == -1) + { + mdAssemblyRef tkSystemNumericsVectors = TokenFromRid(m_rawAssemblyRefCount + ContractAssembly_SystemNumericsVectors + 1, mdtAssemblyRef); + ULONG cTypeRefRecs = m_pRawMetaModelCommonRO->CommonGetRowCount(mdtTypeRef); + BOOL systemNumericsVectorsTypeFound = FALSE; + + for (ULONG i = 1; i <= cTypeRefRecs; i++) + { + mdToken tkResolutionScope; + mdTypeRef tkTypeRef = TokenFromRid(i, mdtTypeRef); + + // Get the resolution scope(AssemblyRef) token for the type. GetTypeRefProps does the type redirection. + IfFailGo(GetTypeRefProps(tkTypeRef, nullptr, nullptr, &tkResolutionScope)); + + if (tkResolutionScope == tkSystemNumericsVectors) + { + systemNumericsVectorsTypeFound = TRUE; + break; + } + } + + if (systemNumericsVectorsTypeFound) + { + m_extraAssemblyRefCount = ContractAssembly_Count; + } + else + { + m_extraAssemblyRefCount = ContractAssembly_Count - 1; + } + } + +ErrExit: + if (m_extraAssemblyRefCount == -1) + { + // Setting m_extraAssemblyRefCount to ContractAssembly_Count so that this function returns a stable value and + // that if there is a System.Numerics type ref that it does not have a dangling assembly ref + m_extraAssemblyRefCount = ContractAssembly_Count; + } + + return m_extraAssemblyRefCount; +} + +//------------------------------------------------------------------------------ + /*static*/ void WinMDAdapter::GetExtraAssemblyRefProps(FrameworkAssemblyIndex index, LPCSTR* ppName, diff --git a/src/md/winmd/inc/adapter.h b/src/md/winmd/inc/adapter.h index 87fc410a77..748d65d473 100644 --- a/src/md/winmd/inc/adapter.h +++ b/src/md/winmd/inc/adapter.h @@ -102,7 +102,8 @@ public: ContractAssembly_SystemObjectModel, ContractAssembly_SystemRuntimeWindowsRuntime, ContractAssembly_SystemRuntimeWindowsRuntimeUIXaml, - ContractAssembly_SystemNumericsVectors, + ContractAssembly_SystemNumericsVectors, // GetExtraAssemblyRefCount assumes SystemNumericsVectors is the last assembly. + // If you add an assembly you must update GetActualExtraAssemblyRefCount. ContractAssembly_Count, }; @@ -120,10 +121,7 @@ public: WinMDTypeKind_Runtimeclass, }; - static int GetExtraAssemblyRefCount() - { - return ContractAssembly_Count; - } + int GetExtraAssemblyRefCount(); // Factory and destructor static HRESULT Create(IMDCommon *pRawMDCommon, /*[out]*/ WinMDAdapter **ppAdapter); @@ -813,7 +811,8 @@ private: //----------------------------------------------------------------------------------- mdAssemblyRef m_assemblyRefMscorlib; BOOL m_fReferencesMscorlibV4; // m_assemblyRefMscorlib is a version=4.0.0.0 AssemblyRef - ULONG m_rawAssemblyRefCount; // the saw assembly ref count not including the extra ones. + ULONG m_rawAssemblyRefCount; // the raw assembly ref count not including the extra ones. + LONG m_extraAssemblyRefCount; // the assembly ref count to return from IMetaDataAssemblyImport::EnumAssemblyRefs private: diff --git a/src/md/winmd/winmdimport.cpp b/src/md/winmd/winmdimport.cpp index ace02c262b..b0a229dbb0 100644 --- a/src/md/winmd/winmdimport.cpp +++ b/src/md/winmd/winmdimport.cpp @@ -1661,7 +1661,7 @@ class WinMDImport : public IMetaDataImport2 _ASSERTE(phInternalEnum->m_EnumType == MDSimpleEnum); _ASSERTE( phInternalEnum->m_ulCount == m_pWinMDAdapter->GetRawAssemblyRefCount()); - int n = WinMDAdapter::GetExtraAssemblyRefCount(); + int n = m_pWinMDAdapter->GetExtraAssemblyRefCount(); phInternalEnum->m_ulCount += n; phInternalEnum->u.m_ulEnd += n; diff --git a/src/md/winmd/winmdinternalimportro.cpp b/src/md/winmd/winmdinternalimportro.cpp index 1d82e13aeb..b4a448dd27 100644 --- a/src/md/winmd/winmdinternalimportro.cpp +++ b/src/md/winmd/winmdinternalimportro.cpp @@ -160,7 +160,7 @@ class WinMDInternalImportRO : public IMDInternalImport, IWinMDImport, IMetaModel { if (tkKind == mdtAssemblyRef) { - return m_pRawInternalImport->GetCountWithTokenKind(tkKind) + WinMDAdapter::GetExtraAssemblyRefCount(); + return m_pRawInternalImport->GetCountWithTokenKind(tkKind) + m_pWinMDAdapter->GetExtraAssemblyRefCount(); } else { @@ -297,7 +297,7 @@ class WinMDInternalImportRO : public IMDInternalImport, IWinMDImport, IMetaModel if (tkKind == mdtAssemblyRef) { _ASSERTE( phEnum->m_ulCount == m_pWinMDAdapter->GetRawAssemblyRefCount()); - int n = WinMDAdapter::GetExtraAssemblyRefCount(); + int n = m_pWinMDAdapter->GetExtraAssemblyRefCount(); phEnum->m_ulCount += n; phEnum->u.m_ulEnd += n; } @@ -320,7 +320,7 @@ ErrExit: if (tkKind == mdtAssemblyRef) { _ASSERTE( phEnum->m_ulCount == m_pWinMDAdapter->GetRawAssemblyRefCount()); - int n = WinMDAdapter::GetExtraAssemblyRefCount(); + int n = m_pWinMDAdapter->GetExtraAssemblyRefCount(); phEnum->m_ulCount += n; phEnum->u.m_ulEnd += n; } |