From 103680193d2f61308103a113bd2dac97e0206c99 Mon Sep 17 00:00:00 2001 From: Ryan Byington Date: Tue, 21 Apr 2015 16:15:59 -0700 Subject: [PATCH] Update framework assembly for System.Uri WinRT projection from System.dll to Internal.Uri.dll For NetCore for CoreCLR System.Uri was moved from System.dll to Internal.Uri.dll. This change updates the WinRT projection for this change. This is a temporary workaround while we investigate a complete fix and will break phone and .NET 4.6 scenarios. [tfs-changeset: 1457678] --- src/inc/winrtprojectedtypes.h | 2 +- src/md/winmd/adapter.cpp | 2 +- src/md/winmd/inc/adapter.h | 3 +++ src/vm/appdomain.cpp | 27 ++++++++++++++++++++++++++- src/vm/appdomain.hpp | 1 + 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/inc/winrtprojectedtypes.h b/src/inc/winrtprojectedtypes.h index 1404938..f8e0d11 100644 --- a/src/inc/winrtprojectedtypes.h +++ b/src/inc/winrtprojectedtypes.h @@ -140,7 +140,7 @@ DEFINE_PROJECTED_STRUCT ("Windows.Foundation", "Point", DEFINE_PROJECTED_STRUCT ("Windows.Foundation", "Rect", "Windows.Foundation", "Rect", SystemRuntimeWindowsRuntime, SystemRuntimeWindowsRuntime, Windows_Foundation_Rect, Windows_Foundation_Rect_clr, STRUCT_FIELDS(W("Single"), W("Single"), W("Single"), W("Single"))) DEFINE_PROJECTED_STRUCT ("Windows.Foundation", "Size", "Windows.Foundation", "Size", SystemRuntimeWindowsRuntime, SystemRuntimeWindowsRuntime, Windows_Foundation_Size, Windows_Foundation_Size_clr, STRUCT_FIELDS(W("Single"), W("Single"))) DEFINE_PROJECTED_STRUCT ("Windows.Foundation", "TimeSpan", "System", "TimeSpan", Mscorlib, SystemRuntime, Windows_Foundation_TimeSpan, System_TimeSpan, STRUCT_FIELDS(W("Int64"))) -DEFINE_PROJECTED_RUNTIMECLASS("Windows.Foundation", "Uri", "System", "Uri", System, SystemRuntime, Windows_Foundation_Uri, System_Uri, "Windows.Foundation.IUriRuntimeClass", __uuidof(ABI::Windows::Foundation::IUriRuntimeClass)) +DEFINE_PROJECTED_RUNTIMECLASS("Windows.Foundation", "Uri", "System", "Uri", InternalUri, SystemRuntime, Windows_Foundation_Uri, System_Uri, "Windows.Foundation.IUriRuntimeClass", __uuidof(ABI::Windows::Foundation::IUriRuntimeClass)) DEFINE_PROJECTED_INTERFACE ("Windows.Foundation", "IClosable", "System", "IDisposable", Mscorlib, SystemRuntime, Windows_Foundation_IClosable, System_IDisposable, PIID(0x30d5a829, 0x7fa4, 0x4026, {0x83, 0xbb, 0xd7, 0x5b, 0xae, 0x4e, 0xa9, 0x9e})) diff --git a/src/md/winmd/adapter.cpp b/src/md/winmd/adapter.cpp index 0a93f88..64cc25c 100644 --- a/src/md/winmd/adapter.cpp +++ b/src/md/winmd/adapter.cpp @@ -1134,7 +1134,7 @@ void WinMDAdapter::GetExtraAssemblyRefProps(FrameworkAssemblyIndex index, else #endif { - if (index == FrameworkAssembly_SystemNumericsVectors) + if (index == FrameworkAssembly_SystemNumericsVectors || index == FrameworkAssembly_InternalUri) { *ppPublicKeytoken = s_pbContractPublicKeyToken; *pTokenLength = sizeof(s_pbContractPublicKeyToken); diff --git a/src/md/winmd/inc/adapter.h b/src/md/winmd/inc/adapter.h index 8b1be4c..14a26b5 100644 --- a/src/md/winmd/inc/adapter.h +++ b/src/md/winmd/inc/adapter.h @@ -87,6 +87,7 @@ public: FrameworkAssembly_SystemRuntimeWindowsRuntime, FrameworkAssembly_SystemRuntimeWindowsRuntimeUIXaml, FrameworkAssembly_SystemNumericsVectors, + FrameworkAssembly_InternalUri, FrameworkAssembly_Count, }; @@ -633,6 +634,8 @@ public: return "System.Runtime.WindowsRuntime.UI.Xaml"; case FrameworkAssembly_SystemNumericsVectors: return "System.Numerics.Vectors"; + case FrameworkAssembly_InternalUri: + return "Internal.Uri"; default: _ASSERTE(!"Invalid AssemblyRef token!"); return NULL; diff --git a/src/vm/appdomain.cpp b/src/vm/appdomain.cpp index 9188c26..4c02f35 100644 --- a/src/vm/appdomain.cpp +++ b/src/vm/appdomain.cpp @@ -4869,6 +4869,7 @@ AppDomain::AppDomain() m_pSystemRuntimeWindowsRuntimeDll = nullptr; m_pSystemRuntimeWindowsRuntimeUIXamlDll = nullptr; m_pSystemNumericsVectors = nullptr; + m_pInternalUri = nullptr; #endif // FEATURE_COMINTEROP m_pUMEntryThunkCache = NULL; @@ -5949,6 +5950,11 @@ bool AppDomain::FindRedirectedAssembly(Assembly* pAssembly, WinMDAdapter::Framew *pIndex = WinMDAdapter::FrameworkAssembly_SystemNumericsVectors; return true; } + else if (pDomainAssembly == m_pInternalUri) + { + *pIndex = WinMDAdapter::FrameworkAssembly_InternalUri; + return true; + } return false; } @@ -5964,7 +5970,7 @@ BOOL AppDomain::FindRedirectedAssemblyFromIndexIfLoaded(WinMDAdapter::FrameworkA LIMITED_METHOD_CONTRACT; // If new redirected assemblies are added, this function probably needs to be updated - C_ASSERT(WinMDAdapter::FrameworkAssembly_Count == 5); + C_ASSERT(WinMDAdapter::FrameworkAssembly_Count == 6); DomainAssembly * pDomainAssembly = NULL; @@ -5989,6 +5995,10 @@ BOOL AppDomain::FindRedirectedAssemblyFromIndexIfLoaded(WinMDAdapter::FrameworkA { pDomainAssembly = m_pSystemNumericsVectors; } + else if (index == WinMDAdapter::FrameworkAssembly_InternalUri) + { + pDomainAssembly = m_pInternalUri; + } if (pDomainAssembly != NULL) { @@ -6108,6 +6118,21 @@ void AppDomain::AddAssembly(DomainAssembly * assem) } } } + if (m_pInternalUri == nullptr) + { + PEAssembly *pPEAssembly = assem->GetFile(); + + if (strcmp("Internal.Uri", pPEAssembly->GetSimpleName()) == 0) + { + DWORD cbPublicKey; + const BYTE *pbPublicKey = static_cast(pPEAssembly->GetPublicKey(&cbPublicKey)); + + if (cbPublicKey == sizeof(s_pbContractPublicKey) && memcmp(pbPublicKey, s_pbContractPublicKey, cbPublicKey) == 0) + { + m_pInternalUri = assem; + } + } + } #endif // FEATURE_COMINTEROP } diff --git a/src/vm/appdomain.hpp b/src/vm/appdomain.hpp index 4840b90..49e6a72 100644 --- a/src/vm/appdomain.hpp +++ b/src/vm/appdomain.hpp @@ -3413,6 +3413,7 @@ private: PTR_DomainAssembly m_pSystemRuntimeWindowsRuntimeDll; // System.Runtime.WindowsRuntime.dll loaded into this domain PTR_DomainAssembly m_pSystemRuntimeWindowsRuntimeUIXamlDll; // System.Runtime.WindowsRuntime.UI.Xaml.dll loaded into this domain PTR_DomainAssembly m_pSystemNumericsVectors; // System.Numerics.Vectors.dll loaded into this domain + PTR_DomainAssembly m_pInternalUri; // Internal.Uri.dll loaded into this domain public: BOOL FindRedirectedAssemblyFromIndexIfLoaded(WinMDAdapter::FrameworkAssemblyIndex index, Assembly** ppAssembly); -- 2.7.4