Addendum for FEATURE_APPX_BINDER
authordanmosemsft <danmose@microsoft.com>
Mon, 13 Feb 2017 03:15:47 +0000 (19:15 -0800)
committerdanmosemsft <danmose@microsoft.com>
Mon, 13 Feb 2017 03:15:47 +0000 (19:15 -0800)
src/vm/appdomain.hpp
src/vm/clrprivbinderappx.cpp [deleted file]
src/vm/clrprivbinderappx.h [deleted file]
src/vm/clrprivbinderloadfile.cpp [deleted file]
src/vm/clrprivbinderwinrt.cpp

index f698c8f..9bf43b8 100644 (file)
@@ -1396,7 +1396,7 @@ protected:
     // Information regarding the managed standard interfaces.
     MngStdInterfacesInfo        *m_pMngStdInterfacesInfo;
     
-    // WinRT binder (only in classic = non-AppX; AppX has the WinRT binder inside code:CLRPrivBinderAppX)
+    // WinRT binder
     PTR_CLRPrivBinderWinRT m_pWinRtBinder;
 #endif // FEATURE_COMINTEROP
 
diff --git a/src/vm/clrprivbinderappx.cpp b/src/vm/clrprivbinderappx.cpp
deleted file mode 100644 (file)
index 2e5ca85..0000000
+++ /dev/null
@@ -1,1054 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-
-
-#include "common.h" // precompiled header
-#include "assemblyusagelogmanager.h"
-
-//=====================================================================================================================
-#include "clrprivbinderappx.h"
-//CLRPrivBinderAppX * CLRPrivBinderAppX::s_pSingleton = nullptr;
-SPTR_IMPL_INIT(CLRPrivBinderAppX, CLRPrivBinderAppX, s_pSingleton, nullptr);
-
-#ifndef DACCESS_COMPILE
-//=====================================================================================================================
-#include "appxutil.h"
-#include "clrprivbinderutil.h"
-#include "fusionlogging.h"
-#include "clrprivtypecachewinrt.h"
-#include "fusionp.h"
-
-using namespace CLRPrivBinderUtil;
-
-//=====================================================================================================================
-CLRPrivBinderAppX::CLRPrivBinderAppX(LPCWSTR * rgwzAltPath, UINT cAltPaths)
-    : m_MapReadLock(CrstCLRPrivBinderMaps,
-                static_cast<CrstFlags>(CRST_DEBUG_ONLY_CHECK_FORBID_SUSPEND_THREAD |
-                                       CRST_GC_NOTRIGGER_WHEN_TAKEN |
-                                       CRST_DEBUGGER_THREAD |
-                                       // FindAssemblyBySpec complicates matters, which needs to take the m_MapReadLock.
-                                       // But FindAssemblyBySpec cannot switch to preemptive mode, as that would trigger
-                                       // a GC. Since this is a leaf lock, and since it does not make any calls out of
-                                       // the runtime, this lock can be taken in cooperative mode if the locked scope is
-                                       // also marked as ForbidSuspend (since FindAssemblyBySpec can be called by
-                                       // the debugger and the profiler). TODO: it would be nice to be able to specify
-                                       // this flag for just the specific places where it is necessary rather than for
-                                       // the lock as a whole.
-                                       CRST_UNSAFE_ANYMODE)),
-      m_MapWriteLock(CrstCLRPrivBinderMapsAdd, CRST_DEFAULT),
-      m_cAltPaths(cAltPaths),
-      m_fCanUseNativeImages(TRUE),
-      m_pParentBinder(nullptr),
-      m_pFusionBinder(nullptr),
-      m_pWinRTBinder(nullptr),
-
-      // Note: the first CLRPrivBinderAppX object is created prior to runtime startup, so this code cannot call
-      // AppX::IsAppXDesignMode; however, FindAssemblyBySpec cannot call IsAppXDesignMode either because that would
-      // cause a GC_TRIGGERS violation for the GetAssemblyIfLoaded scenario. However this doesn't matter because
-      // the assembly map will be empty until at least the first call to BindAssemblyByName is made, at which point
-      // a call to IsAppXDesignMode can be made. Thus, we default to the most conversative setting and overwrite this
-      // value in BindAssemblyByName.
-      m_fusionBindingScope(CLRPrivBinderFusion::kBindingScope_FrameworkSubset)
-{
-    STANDARD_VM_CONTRACT;
-
-    // Copy altpaths
-    if (cAltPaths > 0)
-    {
-        m_rgAltPathsHolder = new NewArrayHolder<WCHAR>[cAltPaths];
-        m_rgAltPaths = new WCHAR *[cAltPaths];
-
-        for (UINT iAltPath = 0; iAltPath < cAltPaths; iAltPath++)
-        {
-            size_t cchAltPath = wcslen(rgwzAltPath[iAltPath]);
-            m_rgAltPathsHolder[iAltPath] = m_rgAltPaths[iAltPath] = new WCHAR[cchAltPath + 1];
-            wcscpy_s(m_rgAltPaths[iAltPath], cchAltPath + 1, rgwzAltPath[iAltPath]);
-        }
-    }
-
-}
-
-//=====================================================================================================================
-CLRPrivBinderFusion::BindingScope CLRPrivBinderAppX::GetFusionBindingScope()
-{
-    WRAPPER_NO_CONTRACT;
-
-    m_fusionBindingScope = (AppX::IsAppXDesignMode() || (m_pParentBinder != nullptr))
-                           ? CLRPrivBinderFusion::kBindingScope_FrameworkAll
-                           : CLRPrivBinderFusion::kBindingScope_FrameworkSubset;
-
-    return m_fusionBindingScope;
-}
-
-//=====================================================================================================================
-CLRPrivBinderAppX::~CLRPrivBinderAppX()
-{
-    WRAPPER_NO_CONTRACT;
-    
-    m_NameToAssemblyMap.RemoveAll();
-    AssemblyUsageLogManager::UnRegisterBinderFromUsageLog((UINT_PTR)this);
-    
-    clr::SafeRelease(m_pWinRTBinder);
-}
-
-//=====================================================================================================================
-CLRPrivBinderAppX * 
-CLRPrivBinderAppX::GetOrCreateBinder()
-{
-    STANDARD_VM_CONTRACT;
-    HRESULT hr = S_OK;
-
-    if (s_pSingleton == nullptr)
-    {
-        ReleaseHolder<IAssemblyUsageLog> pNewUsageLog;
-        IfFailThrow(AssemblyUsageLogManager::GetUsageLogForContext(W("App"), AppX::GetHeadPackageMoniker(), &pNewUsageLog));
-
-        ReleaseHolder<CLRPrivBinderAppX> pBinder;
-        pBinder = clr::SafeAddRef(new CLRPrivBinderAppX(nullptr, 0));
-        
-        pBinder->m_pFusionBinder = clr::SafeAddRef(new CLRPrivBinderFusion());
-        
-        CLRPrivTypeCacheWinRT * pWinRtTypeCache = CLRPrivTypeCacheWinRT::GetOrCreateTypeCache();
-        pBinder->m_pWinRTBinder = clr::SafeAddRef(new CLRPrivBinderWinRT(
-            pBinder, 
-            pWinRtTypeCache, 
-            nullptr,    // rgwzAltPath
-            0,          // cAltPaths
-            CLRPrivBinderWinRT::NamespaceResolutionKind_WindowsAPI, 
-            TRUE // fCanUseNativeImages
-            ));
-        
-        if (InterlockedCompareExchangeT<decltype(s_pSingleton)>(&s_pSingleton, pBinder, nullptr) == nullptr)
-            pBinder.SuppressRelease();
-
-        // Register binder with usagelog infrastructure.
-        UINT_PTR binderId;
-        IfFailThrow(pBinder->GetBinderID(&binderId));
-        IfFailThrow(AssemblyUsageLogManager::RegisterBinderWithUsageLog(binderId, pNewUsageLog));
-        
-        // Create and register WinRT usage log
-        ReleaseHolder<IAssemblyUsageLog> pNewWinRTUsageLog;
-        IfFailThrow(AssemblyUsageLogManager::GetUsageLogForContext(W("WinRT"), AppX::GetHeadPackageMoniker(), &pNewWinRTUsageLog));
-
-        UINT_PTR winRTBinderId;
-        IfFailThrow(pBinder->m_pWinRTBinder->GetBinderID(&winRTBinderId));
-        IfFailThrow(AssemblyUsageLogManager::RegisterBinderWithUsageLog(winRTBinderId, pNewWinRTUsageLog));
-    }
-
-    return s_pSingleton;
-}
-
-//=====================================================================================================================
-// Used only for designer binding context
-CLRPrivBinderAppX * CLRPrivBinderAppX::CreateParentedBinder(
-    ICLRPrivBinder *         pParentBinder, 
-    CLRPrivTypeCacheWinRT *  pWinRtTypeCache,
-    LPCWSTR *                rgwzAltPath, 
-    UINT                     cAltPaths,
-    BOOL                     fCanUseNativeImages)
-{
-    STANDARD_VM_CONTRACT;
-    HRESULT hr = S_OK;
-
-    ReleaseHolder<CLRPrivBinderAppX> pBinder;
-    pBinder = clr::SafeAddRef(new CLRPrivBinderAppX(rgwzAltPath, cAltPaths));
-
-    pBinder->m_pParentBinder = clr::SafeAddRef(pParentBinder);
-    pBinder->m_fCanUseNativeImages = fCanUseNativeImages;
-    
-    // We want to share FusionBinder with pParentBinder (which bubbles up through the chain of binders to the global AppXBinder code:s_pSingleton)
-    // Ideally we would get the FusionBinder from pParentBinder (via casting to a new interface). It is much easier just to fetch it from 
-    // the global AppX binder directly
-    pBinder->m_pFusionBinder = clr::SafeAddRef(s_pSingleton->GetFusionBinder());
-    
-    if (cAltPaths > 0)
-    {
-        pBinder->m_pWinRTBinder = clr::SafeAddRef(new CLRPrivBinderWinRT(
-            pBinder, 
-            pWinRtTypeCache, 
-            rgwzAltPath, 
-            cAltPaths, 
-            CLRPrivBinderWinRT::NamespaceResolutionKind_WindowsAPI,
-            fCanUseNativeImages));
-    }
-
-    pBinder.SuppressRelease();
-    return pBinder;
-}
-
-//=====================================================================================================================
-HRESULT CLRPrivBinderAppX::BindAppXAssemblyByNameWorker(
-    IAssemblyName * pIAssemblyName,
-    DWORD dwAppXBindFlags,
-    CLRPrivAssemblyAppX ** ppAssembly)
-{
-    STANDARD_VM_CONTRACT;
-    HRESULT hr = S_OK;
-
-    fusion::logging::StatusScope logStatus(0, ID_FUSLOG_BINDING_STATUS_IMMERSIVE, &hr);
-
-    VALIDATE_ARG_RET(pIAssemblyName != nullptr);
-    VALIDATE_ARG_RET((dwAppXBindFlags & ABF_BindIL) == ABF_BindIL);
-    VALIDATE_ARG_RET(ppAssembly != nullptr);
-
-    DWORD dwContentType = AssemblyContentType_Default;
-    IfFailRet(hr = fusion::util::GetProperty(pIAssemblyName, ASM_NAME_CONTENT_TYPE, &dwContentType));
-    if ((hr == S_OK) && (dwContentType != AssemblyContentType_Default))
-    {
-        IfFailRet(CLR_E_BIND_UNRECOGNIZED_IDENTITY_FORMAT);
-    }
-
-    ReleaseHolder<CLRPrivAssemblyAppX> pAssembly;
-
-    // Get the simple name.
-    WCHAR wzSimpleName[_MAX_PATH];
-    DWORD cchSimpleName = _MAX_PATH;
-    IfFailRet(pIAssemblyName->GetName(&cchSimpleName, wzSimpleName));
-
-    {   // Look for previous successful bind. Host callouts are now forbidden.
-        ForbidSuspendThreadCrstHolder lock(&m_MapReadLock);
-        pAssembly = clr::SafeAddRef(m_NameToAssemblyMap.Lookup(wzSimpleName));
-    }
-
-    if (pAssembly == nullptr)
-    {
-        ReleaseHolder<ICLRPrivResource> pResourceIL;
-        ReleaseHolder<ICLRPrivResource> pResourceNI;
-
-        // Create assembly identity using the simple name. For successful binds this will be updated
-        // with the full assembly identity in the VerifyBind callback.
-        NewHolder<AssemblyIdentity> pIdentity = new AssemblyIdentity();
-        IfFailRet(pIdentity->Initialize(wzSimpleName));
-
-        //
-        // Check the head package first to see if this matches an EXE, then check
-        // all packages to see if this matches a DLL.
-        //
-        WCHAR wzFilePath[_MAX_PATH];
-        {
-            hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
-
-            if (FAILED(hr))
-            {
-                // Create simple name with .EXE extension
-                WCHAR wzSimpleFileName[_MAX_PATH];
-                wcscpy_s(wzSimpleFileName, NumItems(wzSimpleFileName), wzSimpleName);
-                wcscat_s(wzSimpleFileName, NumItems(wzSimpleFileName), W(".EXE"));
-
-                // Search for the file using AppX::FileFileInCurrentPackage helper.
-                UINT32 cchFilePath = NumItems(wzFilePath);
-                hr = AppX::FindFileInCurrentPackage(
-                        wzSimpleFileName,
-                        &cchFilePath,
-                        wzFilePath,
-                        PACKAGE_FILTER_CLR_DEFAULT,
-                        (PCWSTR *)(void *)m_rgAltPaths,
-                        m_cAltPaths,
-                        m_pParentBinder != NULL ? AppX::FindFindInPackageFlags_SkipCurrentPackageGraph : AppX::FindFindInPackageFlags_None);
-            }
-
-            if (FAILED(hr))
-            {
-                // Create simple name with .DLL extension
-                WCHAR wzSimpleFileName[_MAX_PATH];
-                wcscpy_s(wzSimpleFileName, NumItems(wzSimpleFileName), wzSimpleName);
-                wcscat_s(wzSimpleFileName, NumItems(wzSimpleFileName), W(".DLL"));
-
-                // Search for the file using AppX::FileFileInCurrentPackage helper
-                UINT32 cchFilePath = NumItems(wzFilePath);
-                hr = AppX::FindFileInCurrentPackage(
-                        wzSimpleFileName,
-                        &cchFilePath,
-                        wzFilePath,
-                        PACKAGE_FILTER_CLR_DEFAULT,
-                        (PCWSTR *)(void *)m_rgAltPaths,
-                        m_cAltPaths,
-                        m_pParentBinder != NULL ? AppX::FindFindInPackageFlags_SkipCurrentPackageGraph : AppX::FindFindInPackageFlags_None);
-            }
-
-            if (SUCCEEDED(hr))
-            {
-                fusion::logging::LogMessage(0, ID_FUSLOG_BINDING_STATUS_FOUND, wzFilePath);
-            }
-            else
-            {
-                // Cache the bind failure result before returning. Careful not to overwrite the bind result with the cache insertion result.
-                HRESULT hrResult = hr;
-                IfFailRet(CacheBindResult(pIdentity, hr));
-                if (hr == S_OK)
-                {   // Cache now owns identity object lifetime.
-                    pIdentity.SuppressRelease();
-                }
-                hr = hrResult;
-            }
-            IfFailRet(hr);
-        }
-
-        NewHolder<CLRPrivResourcePathImpl> pResourcePath = new CLRPrivResourcePathImpl(wzFilePath);
-        IfFailRet(pResourcePath->QueryInterface(__uuidof(ICLRPrivResource), (LPVOID*)&pResourceIL));
-        pResourcePath.SuppressRelease();
-
-        // Create an IBindResult and provide it to the new CLRPrivAssemblyAppX object.
-        ReleaseHolder<IBindResult> pIBindResult = ToInterface<IBindResult>(
-            new CLRPrivAssemblyBindResultWrapper(pIAssemblyName, wzFilePath, m_pFingerprintFactory));
-
-
-        // Create the new CLRPrivAssemblyAppX object.
-        NewHolder<CLRPrivAssemblyAppX> pAssemblyObj =
-            new CLRPrivAssemblyAppX(pIdentity, this, pResourceIL, pIBindResult);
-
-        //
-        // Check cache. If someone beat us then use it instead; otherwise add new ICLRPrivAssembly.
-        //
-        do
-        {
-            // Because the read lock must be taken within a ForbidSuspend region, use AddInPhases.
-            if (m_NameToAssemblyMap.CheckAddInPhases<ForbidSuspendThreadCrstHolder, CrstHolder>(
-                    pAssemblyObj, m_MapReadLock, m_MapWriteLock, pAssemblyObj.GetValue()))
-            {
-                {   // Careful not to allow the cache insertion result to overwrite the bind result.
-                    HRESULT hrResult = hr;
-                    IfFailRet(CacheBindResult(pIdentity, hr));
-                    if (hr == S_OK)
-                    {   // Cache now owns identity object lifetime, but ~CLRPrivBinderAssembly
-                        // can also remove the identity from the cache prior to cache deletion.
-                        pIdentity.SuppressRelease();
-                    }
-                    hr = hrResult;
-                }
-                
-                pAssembly = pAssemblyObj.Extract();
-            }
-            else
-            {
-                ForbidSuspendThreadCrstHolder lock(&m_MapReadLock);
-                pAssembly = clr::SafeAddRef(m_NameToAssemblyMap.Lookup(wzSimpleName));
-            }
-        }
-        while (pAssembly == nullptr); // Keep looping until we find the existing one, or add a new one
-    }
-
-    _ASSERTE(pAssembly != nullptr);
-
-    if (((dwAppXBindFlags & ABF_BindNI) == ABF_BindNI) && 
-        m_fCanUseNativeImages)
-    {
-        //
-        // Look to see if there's a native image available.
-        //
-
-        // Fire BindingNgenPhaseStart ETW event if enabled.
-        {
-            InlineSString<128> ssAssemblyName;
-            FireEtwBindingNgenPhaseStart(
-                (AppDomain::GetCurrentDomain()->GetId().m_dwId),
-                LOADCTX_TYPE_HOSTED,
-                ETWFieldUnused,
-                ETWLoaderLoadTypeNotAvailable,
-                NULL,
-                FusionBind::GetAssemblyNameDisplayName(pIAssemblyName, ssAssemblyName, ASM_DISPLAYF_FULL).GetUnicode(),
-                GetClrInstanceId());
-        }
-
-        ReleaseHolder<IBindResult> pIBindResultIL;
-        IfFailRet(pAssembly->GetIBindResult(&pIBindResultIL));
-        _ASSERTE(pIBindResultIL != nullptr);
-
-        NewArrayHolder<WCHAR> wzZapSet = DuplicateStringThrowing(g_pConfig->ZapSet());
-        NativeConfigData cfgData = {
-            wzZapSet,
-            PEFile::GetNativeImageConfigFlags()
-        };
-
-        IfFailRet(BindToNativeAssembly(
-            pIBindResultIL, &cfgData, static_cast<IBindContext*>(this), fusion::logging::GetCurrentFusionBindLog()));
-
-        // Ensure that the native image found above in BindToNativeAssembly is reported as existing in the CLRPrivAssembly object
-        if (hr == S_OK)
-        {
-            ReleaseHolder<ICLRPrivResource> pNIImageResource;
-            // This will make GetAvailableImageTypes return that a native image exists.
-            IfFailRet(pAssembly->GetImageResource(ASSEMBLY_IMAGE_TYPE_NATIVE, NULL, &pNIImageResource));
-#ifdef _DEBUG
-            DWORD dwImageTypes;
-
-            _ASSERTE(SUCCEEDED(pAssembly->GetAvailableImageTypes(&dwImageTypes)));
-            _ASSERTE((dwImageTypes & ASSEMBLY_IMAGE_TYPE_NATIVE) == ASSEMBLY_IMAGE_TYPE_NATIVE);
-#endif
-        }
-
-        // Fire BindingNgenPhaseEnd ETW event if enabled.
-        {
-            InlineSString<128> ssAssemblyName;
-            FireEtwBindingNgenPhaseEnd(
-                (AppDomain::GetCurrentDomain()->GetId().m_dwId),
-                LOADCTX_TYPE_HOSTED,
-                ETWFieldUnused,
-                ETWLoaderLoadTypeNotAvailable,
-                NULL,
-                FusionBind::GetAssemblyNameDisplayName(pIAssemblyName, ssAssemblyName, ASM_DISPLAYF_FULL).GetUnicode(),
-                GetClrInstanceId());
-        }
-
-        // BindToNativeAssembly can return S_FALSE, but this could be misleading.
-        if (hr == S_FALSE)
-            hr = S_OK;
-    }
-
-    if (SUCCEEDED(hr))
-    {
-        *ppAssembly = pAssembly.Extract();
-    }
-
-    return hr;
-}
-
-//=====================================================================================================================
-HRESULT CLRPrivBinderAppX::BindAppXAssemblyByName(
-    IAssemblyName * pIAssemblyName,
-    DWORD dwAppXBindFlags,
-    ICLRPrivAssembly ** ppPrivAssembly)
-{
-    STANDARD_VM_CONTRACT;
-    HRESULT hr = S_OK;
-
-    ReleaseHolder<CLRPrivAssemblyAppX> pAppXAssembly;
-    IfFailRet(BindAppXAssemblyByNameWorker(pIAssemblyName, dwAppXBindFlags, &pAppXAssembly));
-    IfFailRet(pAppXAssembly->QueryInterface(__uuidof(ICLRPrivAssembly), (LPVOID*)ppPrivAssembly));
-
-    return hr;
-}
-
-//=====================================================================================================================
-HRESULT CLRPrivBinderAppX::PreBindAppXAssemblyByName(
-    IAssemblyName * pIAssemblyName,
-    DWORD           dwAppXBindFlags,
-    IBindResult **  ppIBindResult)
-{
-    STANDARD_VM_CONTRACT;
-    HRESULT hr = S_OK;
-
-    VALIDATE_ARG_RET(pIAssemblyName != nullptr);
-    VALIDATE_ARG_RET(ppIBindResult != nullptr);
-
-
-    ReleaseHolder<CLRPrivAssemblyAppX> pAppXAssembly;
-    IfFailRet(BindAppXAssemblyByNameWorker(pIAssemblyName, dwAppXBindFlags, &pAppXAssembly));
-    IfFailRet(pAppXAssembly->GetIBindResult(ppIBindResult));
-
-    return hr;
-}
-
-//=====================================================================================================================
-HRESULT CLRPrivBinderAppX::FindAssemblyBySpec(
-    LPVOID pvAppDomain,
-    LPVOID pvAssemblySpec,
-    HRESULT * pResult,
-    ICLRPrivAssembly ** ppAssembly)
-{
-    CONTRACTL
-    {
-        NOTHROW;
-        GC_NOTRIGGER;
-        FORBID_FAULT;
-        MODE_ANY;
-        CAN_TAKE_LOCK;
-    }
-    CONTRACTL_END
-
-    HRESULT hr = S_OK;
-
-    AppDomain* pAppDomain = reinterpret_cast<AppDomain*>(pvAppDomain);
-    AssemblySpec* pAssemblySpec = reinterpret_cast<AssemblySpec*>(pvAssemblySpec);
-    VALIDATE_PTR_RET(pAppDomain);
-    VALIDATE_PTR_RET(pAssemblySpec);
-    VALIDATE_PTR_RET(pResult);
-    VALIDATE_PTR_RET(ppAssembly);
-
-    //
-    // Follow the same order as a bind.
-    //
-
-    hr = CLR_E_BIND_UNRECOGNIZED_IDENTITY_FORMAT;
-
-    if (FAILED(hr))
-    {
-        _ASSERTE(m_pFusionBinder != nullptr);
-        hr = m_pFusionBinder->FindFusionAssemblyBySpec(pAppDomain, pAssemblySpec, m_fusionBindingScope, pResult, ppAssembly);
-    }
-
-    // See comment in code:CLRPrivBinderAppX::BindAssemblyByName for explanation of this conditional.
-    if (hr == CLR_E_BIND_UNRECOGNIZED_IDENTITY_FORMAT)
-    {
-        if (FAILED(hr) && (m_pWinRTBinder != nullptr))
-        {
-            hr = m_pWinRTBinder->FindWinRTAssemblyBySpec(pAppDomain, pAssemblySpec, pResult, ppAssembly);
-        }
-
-        if (FAILED(hr))
-        {
-            AssemblyIdentity refId;
-            IfFailRet(refId.Initialize(pAssemblySpec));
-            bool fCheckParent = false;
-
-            {   // Check for a previously-recorded bind. Host callouts are now forbidden.
-                ForbidSuspendThreadCrstHolder lock(&m_MapReadLock);
-                BindingRecordMap::element_t const * pKeyVal = m_BindingRecordMap.LookupPtr(&refId);
-
-                if (pKeyVal != nullptr)
-                {
-                    //
-                    // Previous bind occurred. If a failure result is cached then the binder would
-                    // have tried the parent binder (if available) before returning.
-                    //
-
-                    AssemblyIdentity const & defId(*pKeyVal->Key());
-                    BindingRecord const & record(pKeyVal->Value());
-
-                    *ppAssembly = nullptr;
-                    *pResult = record.hr;
-
-                    if (SUCCEEDED(*pResult))
-                    {
-                        //
-                        // Previous bind succeeded. Get the corresponding ICLRPrivAssembly.
-                        //
-
-                        // Check this binder for a match. Host callouts are now forbidden.
-                        CLRPrivAssemblyAppX* pPrivAssembly = m_NameToAssemblyMap.Lookup(defId.Name);
-
-                        if (pPrivAssembly == nullptr)
-                        {
-                            _ASSERTE_MSG(false, "Should never see success value and a null CLRPrivAssemblyAppX pointer.");
-                            return (*pResult = E_UNEXPECTED);
-                        }
-
-                        _ASSERTE(pPrivAssembly->m_pIdentity != nullptr);
-                        _ASSERTE(pPrivAssembly->m_pIdentity == &defId);
-
-                        // Now check that the version and PKT values are compatible.
-                        *pResult = CLRPrivBinderUtil::VerifyBind(refId, *pPrivAssembly->m_pIdentity);
-
-                        if (SUCCEEDED(*pResult))
-                        {
-                            VERIFY(SUCCEEDED(pPrivAssembly->QueryInterface(__uuidof(ICLRPrivAssembly), (LPVOID*)ppAssembly)));
-                        }
-
-                        return S_OK;
-                    }
-                    else
-                    {
-                        //
-                        // Previous bind failed. Check the parent binder (if available), but do it outside of this binder's lock.
-                        //
-
-                        fCheckParent = true;
-                    }
-                }
-                else
-                {
-                    //
-                    // No previous bind occurred. Do not check the parent binder since this could result
-                    // in an incorrect bind (if this binder would have bound to a different assembly).
-                    //
-
-                    return E_FAIL;
-                }
-            }
-
-            if (fCheckParent && m_pParentBinder != nullptr)
-            {   // Check the parent (shared designer context) for a match.
-                hr = m_pParentBinder->FindAssemblyBySpec(pAppDomain, pAssemblySpec, pResult, ppAssembly);
-            }
-        }
-    }
-
-    // There are three possibilities upon exit:
-    //   1. Cache lookup failed, in which case FAILED(hr) == true
-    //   2. A binding failure was cached, in which case (1) == false && FAILED(*pResult) == true
-    //   3. A binding success was cached, in which case we must find an assembly:
-    //      (1) == false && (2) == false && *ppAssembly != nullptr
-    _ASSERTE(FAILED(hr) || FAILED(*pResult) || *ppAssembly != nullptr);
-    return hr;
-}
-
-//=====================================================================================================================
-// Record the binding result to support cache-based lookups (using ICLRPrivCachedBinder::FindAssemblyBySpec).
-
-HRESULT CLRPrivBinderAppX::CacheBindResult(
-    AssemblyIdentity *      pIdentity,  // On success, will assume object lifetime ownership.
-    HRESULT                 hrResult)
-{
-    STANDARD_VM_CONTRACT;
-
-    HRESULT hr = S_OK;
-
-    VALIDATE_PTR_RET(pIdentity);
-
-    // Initialize the binding record.
-    BindingRecord rec = { hrResult };
-    BindingRecordMap::element_t newEntry(pIdentity, rec);
-
-    // Because the read lock must be taken within a ForbidSusped region, use CheckAddInPhases.
-    if (m_BindingRecordMap.CheckAddInPhases<ForbidSuspendThreadCrstHolder, CrstHolder>(
-            newEntry, m_MapReadLock, m_MapWriteLock))
-    {
-        // Indicates that this identity object was cached.
-        // Caller relinquishes object ownership.
-        return S_OK;
-    }
-    else
-    {
-        // Pre-existing entry was found.
-
-#ifdef _DEBUG
-        ForbidSuspendThreadCrstHolder lock(&m_MapReadLock);
-        auto pExistingEntry = m_BindingRecordMap.LookupPtr(pIdentity);
-        if (pExistingEntry != nullptr)
-        {
-            // It's possible for racing threads to try to cache their results;
-            // just make sure that they got the same HRESULT.
-            _ASSERTE(pExistingEntry->Value().hr == rec.hr);
-        }
-#endif
-
-        // Indicates that previous entry existed, and this identity object was not cached.
-        // Caller retains object ownership.
-        hr = S_FALSE;
-    }
-
-    return hr;
-}
-
-//=====================================================================================================================
-// Implements code:ICLRPrivBinder::BindAssemblyByName
-
-HRESULT CLRPrivBinderAppX::BindAssemblyByName(
-    IAssemblyName * pAssemblyName,
-    ICLRPrivAssembly ** ppAssembly)
-{
-    STANDARD_BIND_CONTRACT;
-    BinderHRESULT hr = S_OK;
-    ReleaseHolder<ICLRPrivAssembly> pResult;
-
-    VALIDATE_ARG_RET(pAssemblyName != nullptr && ppAssembly != nullptr);
-
-    EX_TRY
-    {
-        hr = CLR_E_BIND_UNRECOGNIZED_IDENTITY_FORMAT;
-
-        if (FAILED(hr))
-        {
-            _ASSERTE(m_pFusionBinder != nullptr);
-            hr = m_pFusionBinder->BindFusionAssemblyByName(pAssemblyName, GetFusionBindingScope(), &pResult);
-        }
-
-        //
-        // The fusion binder returns CLR_E_BIND_UNRECOGNIZED_IDENTITY_FORMAT only if it did not
-        // recognize pAssemblyName as a FX assembly. Only then should other binders be consulted
-        // (otherwise applications would be able to copy arbitrary FX assemblies into their AppX
-        // package and use them directly).
-        //
-
-        if (hr == CLR_E_BIND_UNRECOGNIZED_IDENTITY_FORMAT)
-        {
-            if (FAILED(hr) && (m_pWinRTBinder != nullptr))
-            {
-                hr = m_pWinRTBinder->BindWinRTAssemblyByName(pAssemblyName, &pResult);
-            }
-
-            if (FAILED(hr))
-            {
-                hr = BindAppXAssemblyByName(pAssemblyName, ABF_Default, &pResult);
-            }
-
-            if (FAILED(hr) && (m_pParentBinder != nullptr))
-            {
-                hr = m_pParentBinder->BindAssemblyByName(pAssemblyName, &pResult);
-            }
-
-            _ASSERTE(FAILED(hr) || pResult != nullptr);
-        }
-    }
-    EX_CATCH_HRESULT(hr);
-
-    // Return if either the bind or the bind cache fails.
-    IfFailRet(hr);
-
-    // Success.
-    *ppAssembly = pResult.Extract();
-    return hr;
-}
-
-//=====================================================================================================================
-// Implements code:IBindContext::PreBind
-HRESULT CLRPrivBinderAppX::PreBind(
-    IAssemblyName * pIAssemblyName, 
-    DWORD           dwPreBindFlags, 
-    IBindResult **  ppIBindResult)
-{
-    STANDARD_BIND_CONTRACT;
-    BinderHRESULT hr = S_OK;
-
-    VALIDATE_ARG_RET((dwPreBindFlags & ~(PRE_BIND_APPLY_POLICY)) == 0);
-    VALIDATE_ARG_RET(pIAssemblyName != nullptr && ppIBindResult != nullptr);
-
-    // Assert that we are only working with binder that supports Native Images context bits.
-    _ASSERTE(m_fCanUseNativeImages);
-
-    EX_TRY
-    {
-        hr = CLR_E_BIND_UNRECOGNIZED_IDENTITY_FORMAT;
-
-        if (FAILED(hr))
-        {
-            hr = m_pFusionBinder->PreBindFusionAssemblyByName(pIAssemblyName, dwPreBindFlags, ppIBindResult);
-        }
-
-        if (FAILED(hr) && (m_pWinRTBinder != nullptr))
-        {
-            hr = m_pWinRTBinder->BindWinRTAssemblyByName(pIAssemblyName, ppIBindResult, TRUE);
-        }
-
-        if (FAILED(hr))
-        {
-            hr = PreBindAppXAssemblyByName(pIAssemblyName, ABF_BindIL, ppIBindResult);
-        }
-    }
-    EX_CATCH_HRESULT(hr);
-    
-    if (FAILED(hr) && (m_pParentBinder != nullptr))
-    {
-        ReleaseHolder<IBindContext> pParentBindContext;
-        hr = m_pParentBinder->QueryInterface(__uuidof(IBindContext), (LPVOID *)&pParentBindContext);
-        if (SUCCEEDED(hr))
-        {
-            hr = pParentBindContext->PreBind(pIAssemblyName, dwPreBindFlags, ppIBindResult);
-        }
-    }
-    
-    return hr;
-}
-
-//=====================================================================================================================
-UINT_PTR CLRPrivBinderAppX::GetBinderID()
-{
-    LIMITED_METHOD_CONTRACT;
-    return reinterpret_cast<UINT_PTR>(this);
-}
-
-//=====================================================================================================================
-// Implements code:ICLRPrivBinder::GetBinderID
-HRESULT CLRPrivBinderAppX::GetBinderID(
-    UINT_PTR *pBinderId)
-{
-    LIMITED_METHOD_CONTRACT;
-
-    *pBinderId = GetBinderID();
-    return S_OK;
-}
-
-//=====================================================================================================================
-// Implements code:IBindContext::IsDefaultContext
-HRESULT CLRPrivBinderAppX::IsDefaultContext()
-{
-    LIMITED_METHOD_CONTRACT;
-    return S_OK;
-}
-
-//=====================================================================================================================
-// Implements code:ICLRPrivWinRtTypeBinder::FindAssemblyForWinRtTypeIfLoaded
-// Finds Assembly * for type in AppDomain * if it is loaded.
-// Returns NULL if assembly is not loaded or type is not found.
-// 
-void * 
-CLRPrivBinderAppX::FindAssemblyForWinRtTypeIfLoaded(
-    void *  pAppDomain, 
-    LPCUTF8 szNamespace, 
-    LPCUTF8 szClassName)
-{
-    CONTRACTL
-    {
-        NOTHROW;
-        GC_NOTRIGGER;
-        FORBID_FAULT;
-        MODE_ANY;
-    }
-    CONTRACTL_END
-    
-    void * pAssembly = nullptr;
-    if (m_pWinRTBinder != nullptr)
-    {
-        pAssembly = (void *)m_pWinRTBinder->FindAssemblyForTypeIfLoaded(
-            dac_cast<PTR_AppDomain>((AppDomain *)pAppDomain), 
-            szNamespace, 
-            szClassName);
-    }
-    
-    if ((pAssembly == nullptr) && (m_pParentBinder != nullptr))
-    {
-        ReleaseHolder<ICLRPrivWinRtTypeBinder> pParentBinder = 
-                ToInterface_NoThrow<ICLRPrivWinRtTypeBinder>(m_pParentBinder.GetValue());
-        // Parent binder should be another instance of code:CLRPrivBinderAppX class that implements the interface
-        _ASSERTE(pParentBinder != nullptr);
-        
-        pAssembly = pParentBinder->FindAssemblyForWinRtTypeIfLoaded(
-            pAppDomain, 
-            szNamespace, 
-            szClassName);
-    }
-    
-    return pAssembly;
-}
-
-//=====================================================================================================================
-CLRPrivAssemblyAppX::CLRPrivAssemblyAppX(
-    CLRPrivBinderUtil::AssemblyIdentity * pIdentity,
-    CLRPrivBinderAppX *pBinder,
-    ICLRPrivResource *pIResourceIL,
-    IBindResult * pIBindResult)
-    : m_pIdentity(pIdentity),
-      m_pBinder(nullptr),
-      m_pIResourceIL(nullptr),
-      m_pIResourceNI(nullptr),
-      m_pIBindResult(nullptr)
-{
-    STANDARD_VM_CONTRACT;
-
-    VALIDATE_PTR_THROW(pIdentity);
-    VALIDATE_PTR_THROW(pBinder);
-    VALIDATE_PTR_THROW(pIResourceIL);
-    VALIDATE_PTR_THROW(pIBindResult);
-
-    m_pBinder = clr::SafeAddRef(pBinder);
-    m_pIResourceIL = clr::SafeAddRef(pIResourceIL);
-    m_pIBindResult = clr::SafeAddRef(pIBindResult);
-}
-
-//=====================================================================================================================
-CLRPrivAssemblyAppX::~CLRPrivAssemblyAppX()
-{
-    LIMITED_METHOD_CONTRACT;
-    clr::SafeRelease(m_pIResourceNI);
-}
-
-//=====================================================================================================================
-LPCWSTR CLRPrivAssemblyAppX::GetSimpleName() const
-{
-    LIMITED_METHOD_CONTRACT;
-    return m_pIdentity->Name;
-}
-
-//=====================================================================================================================
-// Implements code:IUnknown::Release
-ULONG CLRPrivAssemblyAppX::Release()
-{
-    LIMITED_METHOD_CONTRACT;
-    STATIC_CONTRACT_CAN_TAKE_LOCK;
-    _ASSERTE(m_cRef > 0);
-
-    ULONG cRef;
-    
-    {
-        // To achieve proper lifetime semantics, the name to assembly map elements' CLRPrivAssemblyAppX 
-        // instances are not ref counted. We cannot allow discovery of the object via m_NameToAssemblyMap 
-        // when the ref count is 0 (to prevent another thread to AddRef and Release it back to 0 in parallel).
-        // All uses of the map are guarded by the map lock, so we have to decrease the ref count under that 
-        // lock (to avoid the chance that 2 threads are running Release to ref count 0 at once).
-        // Host callouts are now forbidden.
-        ForbidSuspendThreadCrstHolder lock(&m_pBinder->m_MapReadLock);
-        
-        cRef = InterlockedDecrement(&m_cRef);
-        if (cRef == 0)
-        {
-            m_pBinder->m_NameToAssemblyMap.Remove(GetSimpleName());
-            m_pBinder->m_BindingRecordMap.Remove(m_pIdentity);
-        }
-    }
-
-    if (cRef == 0)
-    {
-        delete this;
-    }
-    
-    return cRef;
-}
-
-//=====================================================================================================================
-// Implements code:ICLRPrivBinder::BindAssemblyByName
-HRESULT CLRPrivAssemblyAppX::BindAssemblyByName(
-    IAssemblyName * pAssemblyName,
-    ICLRPrivAssembly ** ppAssembly)
-{
-    WRAPPER_NO_CONTRACT;
-
-    return m_pBinder->BindAssemblyByName(
-        pAssemblyName,
-        ppAssembly);
-}
-
-//=====================================================================================================================
-// Implements code:ICLRPrivBinder::GetBinderID
-HRESULT CLRPrivAssemblyAppX::GetBinderID(
-    UINT_PTR *pBinderId)
-{
-    WRAPPER_NO_CONTRACT;
-    return m_pBinder->GetBinderID(
-        pBinderId);
-}
-
-//=====================================================================================================================
-// Implements code:ICLRPrivAssembly::IsShareable
-HRESULT CLRPrivAssemblyAppX::IsShareable(
-    BOOL * pbIsShareable)
-{
-    LIMITED_METHOD_CONTRACT;
-
-    VALIDATE_ARG_RET(pbIsShareable != nullptr);
-
-    *pbIsShareable = FALSE;
-    return S_OK;
-}
-
-//=====================================================================================================================
-// Implements code:ICLRPrivAssembly::GetAvailableImageTypes
-HRESULT CLRPrivAssemblyAppX::GetAvailableImageTypes(
-    LPDWORD pdwImageTypes)
-{
-    LIMITED_METHOD_CONTRACT;
-
-    VALIDATE_ARG_RET(pdwImageTypes != nullptr);
-
-    *pdwImageTypes = 0;
-
-    if (m_pIResourceIL != nullptr)
-        *pdwImageTypes |= ASSEMBLY_IMAGE_TYPE_IL;
-
-    if (m_pIResourceNI != nullptr)
-        *pdwImageTypes |= ASSEMBLY_IMAGE_TYPE_NATIVE;
-
-    return S_OK;
-}
-
-//=====================================================================================================================
-static ICLRPrivResource* GetResourceForBindResult(
-    IBindResult * pIBindResult)
-{
-    STANDARD_VM_CONTRACT;
-    VALIDATE_ARG_THROW(pIBindResult != nullptr);
-
-    WCHAR wzPath[_MAX_PATH];
-    DWORD cchPath = NumItems(wzPath);
-    ReleaseHolder<IAssemblyLocation> pIAssemLoc;
-    IfFailThrow(pIBindResult->GetAssemblyLocation(&pIAssemLoc));
-    IfFailThrow(pIAssemLoc->GetPath(wzPath, &cchPath));
-    return ToInterface<ICLRPrivResource>(new CLRPrivResourcePathImpl(wzPath));
-}
-
-//=====================================================================================================================
-// Implements code:ICLRPrivAssembly::GetImageResource
-HRESULT CLRPrivAssemblyAppX::GetImageResource(
-    DWORD dwImageType,
-    DWORD * pdwImageType,
-    ICLRPrivResource ** ppIResource)
-{
-    STANDARD_BIND_CONTRACT;
-    HRESULT hr = S_OK;
-
-    VALIDATE_ARG_RET(ppIResource != nullptr && m_pIBindResult != nullptr);
-
-    EX_TRY
-    {
-        DWORD _dwImageType;
-        if (pdwImageType == nullptr)
-            pdwImageType = &_dwImageType;
-
-        if ((dwImageType & ASSEMBLY_IMAGE_TYPE_NATIVE) == ASSEMBLY_IMAGE_TYPE_NATIVE)
-        {
-            ReleaseHolder<IBindResult> pIBindResultNI;
-            if (m_pIResourceNI == nullptr)
-            {
-                if (SUCCEEDED(hr = m_pIBindResult->GetNativeImage(&pIBindResultNI, nullptr)) && pIBindResultNI != nullptr)
-                {
-                    ReleaseHolder<ICLRPrivResource> pResourceNI = GetResourceForBindResult(pIBindResultNI);
-                    if (InterlockedCompareExchangeT<ICLRPrivResource *>(&m_pIResourceNI, pResourceNI, nullptr) == nullptr)
-                        pResourceNI.SuppressRelease();
-                }
-                else
-                {
-                    IfFailGo(CLR_E_BIND_IMAGE_UNAVAILABLE);
-                }
-            }
-
-            *ppIResource = clr::SafeAddRef(m_pIResourceNI);
-            *pdwImageType = ASSEMBLY_IMAGE_TYPE_NATIVE;
-        }
-        else if ((dwImageType & ASSEMBLY_IMAGE_TYPE_IL) == ASSEMBLY_IMAGE_TYPE_IL)
-        {
-            *ppIResource = clr::SafeAddRef(m_pIResourceIL);
-            *pdwImageType = ASSEMBLY_IMAGE_TYPE_IL;
-        }
-        else
-        {
-            hr = CLR_E_BIND_IMAGE_UNAVAILABLE;
-        }
-
-    ErrExit:
-        ;
-    }
-    EX_CATCH_HRESULT(hr);
-
-    return hr;
-}
-
-
-//=====================================================================================================================
-// Implements code:ICLRPrivBinder::VerifyBind
-HRESULT CLRPrivBinderAppX::VerifyBind(
-    IAssemblyName *pAssemblyName,
-    ICLRPrivAssembly *pAssembly,
-    ICLRPrivAssemblyInfo *pAssemblyInfo)
-{
-    STANDARD_BIND_CONTRACT;
-
-    HRESULT hr = S_OK;
-
-    VALIDATE_ARG_RET(pAssemblyName!= nullptr && pAssemblyInfo != nullptr);
-
-    UINT_PTR binderID;
-    IfFailRet(pAssembly->GetBinderID(&binderID));
-
-    if (binderID != GetBinderID())
-    {
-        return pAssembly->VerifyBind(pAssemblyName, pAssembly, pAssemblyInfo);
-    }
-
-    return CLRPrivBinderUtil::VerifyBind(pAssemblyName, pAssemblyInfo);
-}
-
-//=====================================================================================================================
-/*static*/
-LPCWSTR CLRPrivBinderAppX::NameToAssemblyMapTraits::GetKey(CLRPrivAssemblyAppX *pAssemblyAppX)
-{
-    WRAPPER_NO_CONTRACT;
-    _ASSERT(pAssemblyAppX != nullptr);
-    return pAssemblyAppX->GetSimpleName();
-}
-
-//=====================================================================================================================
-HRESULT CLRPrivAssemblyAppX::GetIBindResult(
-    IBindResult ** ppIBindResult)
-{
-    STANDARD_VM_CONTRACT;
-
-    VALIDATE_ARG_RET(ppIBindResult != nullptr);
-    VALIDATE_CONDITION(m_pIBindResult != nullptr, return E_UNEXPECTED);
-
-    *ppIBindResult = clr::SafeAddRef(m_pIBindResult);
-
-    return S_OK;
-}
-
-#endif // !DACCESS_COMPILE
diff --git a/src/vm/clrprivbinderappx.h b/src/vm/clrprivbinderappx.h
deleted file mode 100644 (file)
index db1ebec..0000000
+++ /dev/null
@@ -1,360 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-
-
-#pragma once
-
-#include "holder.h"
-#include "internalunknownimpl.h"
-#include "shash.h"
-#include "fusion.h"
-#include "clrprivbinding.h"
-#include "clrprivruntimebinders.h"
-#include "clrprivbinderfusion.h"
-#include "clrprivbinderwinrt.h"
-
-//=====================================================================================================================
-// Forward declarations
-class CLRPrivBinderAppX;
-class CLRPrivAssemblyAppX;
-
-class DomainAssembly;
-
-// Forward declaration of helper class used in native image binding.
-class CLRPrivAssemblyAppX_NIWrapper;
-
-typedef DPTR(CLRPrivBinderAppX) PTR_CLRPrivBinderAppX;
-
-//=====================================================================================================================
-class CLRPrivBinderAppX : 
-    public IUnknownCommon<ICLRPrivBinder, IBindContext, ICLRPrivWinRtTypeBinder>
-{
-    friend class CLRPrivAssemblyAppX;
-
-public:
-    //=============================================================================================
-    // ICLRPrivBinder methods
-
-    // Implements code:ICLRPrivBinder::BindAssemblyByName
-    STDMETHOD(BindAssemblyByName)(
-        IAssemblyName * pAssemblyName,
-        ICLRPrivAssembly ** ppAssembly);
-
-    // Implements code:ICLRPrivBinder::VerifyBind
-    STDMETHOD(VerifyBind)(
-        IAssemblyName *pAssemblyName,
-        ICLRPrivAssembly *pAssembly,
-        ICLRPrivAssemblyInfo *pAssemblyInfo);
-
-    // Implements code:ICLRPrivBinder::GetBinderFlags
-    STDMETHOD(GetBinderFlags)(
-        DWORD *pBinderFlags)
-    {
-        LIMITED_METHOD_CONTRACT;
-
-        if (pBinderFlags == NULL)
-            return E_INVALIDARG;
-
-        *pBinderFlags = m_pParentBinder != NULL ? BINDER_DESIGNER_BINDING_CONTEXT : BINDER_NONE;
-        return S_OK;
-    }
-
-    // Implements code:ICLRPrivBinder::GetBinderID
-    STDMETHOD(GetBinderID)(
-        UINT_PTR *pBinderId);
-    
-    STDMETHOD(FindAssemblyBySpec)(
-        LPVOID pvAppDomain,
-        LPVOID pvAssemblySpec,
-        HRESULT * pResult,
-        ICLRPrivAssembly ** ppAssembly);
-
-    //=============================================================================================
-    // ICLRPrivWinRtTypeBinder methods
-    
-    // Implements code:ICLRPrivWinRtTypeBinder::FindAssemblyForWinRtTypeIfLoaded
-    STDMETHOD_(void *, FindAssemblyForWinRtTypeIfLoaded)(
-        void *  pAppDomain, 
-        LPCUTF8 szNamespace, 
-        LPCUTF8 szClassName);
-    
-    //=============================================================================================
-    // IBindContext methods
-
-    // Implements code:IBindContext::PreBind
-    STDMETHOD(PreBind)(
-        IAssemblyName  *pIAssemblyName,
-        DWORD           dwPreBindFlags,
-        IBindResult   **ppIBindResult);
-
-    // Implements code:IBindContext::IsDefaultContext
-    STDMETHOD(IsDefaultContext)();
-
-    //=============================================================================================
-    // Class methods
-
-    //---------------------------------------------------------------------------------------------
-    static
-    CLRPrivBinderAppX * GetOrCreateBinder();
-    
-    static 
-    PTR_CLRPrivBinderAppX GetBinderOrNull()
-    {
-        LIMITED_METHOD_DAC_CONTRACT;
-        return s_pSingleton;
-    }
-    
-    static 
-    CLRPrivBinderAppX * CreateParentedBinder(
-        ICLRPrivBinder *        pParentBinder, 
-        CLRPrivTypeCacheWinRT * pWinRtTypeCache, 
-        LPCWSTR *               rgwzAltPath, 
-        UINT                    cAltPaths,
-        BOOL                    fCanUseNativeImages);
-    
-    //---------------------------------------------------------------------------------------------
-    ~CLRPrivBinderAppX();
-
-    //---------------------------------------------------------------------------------------------
-    enum AppXBindFlags
-    {
-        ABF_BindIL      = 1,
-        ABF_BindNI      = 2,
-        ABF_Default     = ABF_BindIL | ABF_BindNI,
-    };
-
-    //---------------------------------------------------------------------------------------------
-    CLRPrivBinderFusion * GetFusionBinder()
-    {
-        LIMITED_METHOD_CONTRACT;
-        return m_pFusionBinder;
-    }
-    
-    PTR_CLRPrivBinderWinRT GetWinRtBinder()
-    {
-        LIMITED_METHOD_DAC_CONTRACT;
-        return m_pWinRTBinder;
-    }
-    
-private:
-    //---------------------------------------------------------------------------------------------
-    // Binds within AppX packages only. BindAssemblyByName takes care of delegating to Fusion
-    // when needed.
-    HRESULT BindAppXAssemblyByNameWorker(
-        IAssemblyName * pIAssemblyName,
-        DWORD dwAppXBindFlags,
-        CLRPrivAssemblyAppX ** ppAssembly);
-
-    //---------------------------------------------------------------------------------------------
-    // Binds within AppX packages only. BindAssemblyByName takes care of delegating to Fusion
-    // when needed.
-    HRESULT BindAppXAssemblyByName(
-        IAssemblyName * pIAssemblyName,
-        DWORD dwAppXBindFlags,
-        ICLRPrivAssembly ** ppPrivAssembly);
-
-    //---------------------------------------------------------------------------------------------
-    // Binds within AppX packages only. PreBindAssemblyByName takes care of delegating to Fusion
-    // when needed.
-    HRESULT PreBindAppXAssemblyByName(
-        IAssemblyName * pIAssemblyName,
-        DWORD dwAppXBindFlags,
-        IBindResult ** ppIBindResult);
-
-    //---------------------------------------------------------------------------------------------
-    UINT_PTR GetBinderID();
-
-    //---------------------------------------------------------------------------------------------
-    CLRPrivBinderAppX(LPCWSTR *rgwzAltPath, UINT cAltPaths);
-
-    //---------------------------------------------------------------------------------------------
-    HRESULT CheckGetAppXRT();
-
-    //---------------------------------------------------------------------------------------------
-    HRESULT CacheBindResult(
-        CLRPrivBinderUtil::AssemblyIdentity *   pIdentity,
-        HRESULT                                 hrResult);
-    
-    //---------------------------------------------------------------------------------------------
-    CLRPrivBinderFusion::BindingScope GetFusionBindingScope();
-
-    //---------------------------------------------------------------------------------------------
-    Crst              m_MapReadLock;
-    Crst              m_MapWriteLock;
-
-    //---------------------------------------------------------------------------------------------
-    // Identity to CLRPrivBinderAppX map
-    struct NameToAssemblyMapTraits : public StringSHashTraits<CLRPrivAssemblyAppX, WCHAR, CaseInsensitiveStringCompareHash<WCHAR> >
-    {
-        static LPCWSTR GetKey(CLRPrivAssemblyAppX *pAssemblyAppX);
-    };
-    typedef SHash<NameToAssemblyMapTraits> NameToAssemblyMap;
-
-    NameToAssemblyMap m_NameToAssemblyMap;
-
-    //---------------------------------------------------------------------------------------------
-    // Binding record map, used by cache lookup requests.
-    struct BindingRecord
-    {
-        // This stores the result of the original bind request.
-        HRESULT hr;
-    };
-
-    struct BindingRecordMapTraits : public MapSHashTraits<CLRPrivBinderUtil::AssemblyIdentity*, BindingRecord>
-    {
-        typedef MapSHashTraits<CLRPrivBinderUtil::AssemblyIdentity*, BindingRecord> base_t;
-        typedef base_t::element_t element_t;
-        typedef base_t::count_t count_t;
-        typedef base_t::key_t;
-
-        static count_t Hash(key_t k) 
-        {
-            return HashiString(k->Name);
-        }
-
-        static BOOL Equals(key_t k1, key_t k2)
-        {
-            return SString::_wcsicmp(k1->Name, k2->Name) == 0;
-        }
-
-        static const bool s_DestructPerEntryCleanupAction = true;
-        static inline void OnDestructPerEntryCleanupAction(element_t const & e)
-        {
-            delete [] e.Key();
-        }
-    };
-    typedef SHash<BindingRecordMapTraits> BindingRecordMap;
-
-    BindingRecordMap m_BindingRecordMap;
-
-    //---------------------------------------------------------------------------------------------
-    NewArrayHolder< NewArrayHolder<WCHAR> > m_rgAltPathsHolder;
-    NewArrayHolder< WCHAR* >                m_rgAltPaths;
-    UINT                                    m_cAltPaths;
-
-
-    //---------------------------------------------------------------------------------------------
-    // ParentBinder is set only in designer binding context (forms a chain of binders)
-    ReleaseHolder<ICLRPrivBinder>      m_pParentBinder;
-    
-    ReleaseHolder<CLRPrivBinderFusion> m_pFusionBinder;
-    PTR_CLRPrivBinderWinRT             m_pWinRTBinder;
-    
-    //---------------------------------------------------------------------------------------------
-    //static CLRPrivBinderAppX * s_pSingleton;
-    SPTR_DECL(CLRPrivBinderAppX, s_pSingleton);
-
-    //---------------------------------------------------------------------------------------------
-    // Cache the binding scope in the constructor so that there is no need to call into a WinRT
-    // API in a GC_NOTRIGGER scope later on.
-    CLRPrivBinderFusion::BindingScope   m_fusionBindingScope;
-};  // class CLRPrivBinderAppX
-
-
-//=====================================================================================================================
-class CLRPrivAssemblyAppX :
-    public IUnknownCommon<ICLRPrivAssembly>
-{
-    friend class CLRPrivBinderAppX;
-
-public:
-    //---------------------------------------------------------------------------------------------
-    CLRPrivAssemblyAppX(
-        CLRPrivBinderUtil::AssemblyIdentity * pIdentity,
-        CLRPrivBinderAppX *pBinder,
-        ICLRPrivResource *pIResourceIL,
-        IBindResult * pIBindResult);
-
-    //---------------------------------------------------------------------------------------------
-    ~CLRPrivAssemblyAppX();
-
-    //---------------------------------------------------------------------------------------------
-    // Implements code:IUnknown::Release
-    STDMETHOD_(ULONG, Release)();
-
-    //---------------------------------------------------------------------------------------------
-    LPCWSTR GetSimpleName() const;
-
-    //=============================================================================================
-    // ICLRPrivBinder interface methods
-    
-    // Implements code:ICLRPrivBinder::BindAssemblyByName
-    STDMETHOD(BindAssemblyByName)(
-        IAssemblyName * pAssemblyName,
-        ICLRPrivAssembly ** ppAssembly);
-
-    // Implements code:ICLRPrivBinder::VerifyBind
-    STDMETHOD(VerifyBind)(
-        IAssemblyName *pAssemblyName,
-        ICLRPrivAssembly *pAssembly,
-        ICLRPrivAssemblyInfo *pAssemblyInfo)
-    {
-        STANDARD_BIND_CONTRACT;
-
-        HRESULT hr = S_OK;
-
-        VALIDATE_PTR_RET(pAssemblyName);
-        VALIDATE_PTR_RET(pAssembly);
-        VALIDATE_PTR_RET(pAssemblyInfo);
-
-        // Re-initialize the assembly identity with full identity contained in metadata.
-        IfFailRet(m_pIdentity->Initialize(pAssemblyInfo));
-
-        return m_pBinder->VerifyBind(pAssemblyName, pAssembly, pAssemblyInfo);
-    }
-
-    // Implements code:ICLRPrivBinder::GetBinderFlags
-    STDMETHOD(GetBinderFlags)(
-        DWORD *pBinderFlags)
-    {
-        LIMITED_METHOD_CONTRACT;
-        return m_pBinder->GetBinderFlags(pBinderFlags);
-    }
-
-    // Implements code:ICLRPrivBinder::GetBinderID
-    STDMETHOD(GetBinderID)(
-        UINT_PTR *pBinderId);
-
-    // Implements code:ICLRPrivBinder::FindAssemblyBySpec
-    STDMETHOD(FindAssemblyBySpec)(
-        LPVOID pvAppDomain,
-        LPVOID pvAssemblySpec,
-        HRESULT * pResult,
-        ICLRPrivAssembly ** ppAssembly)
-    { STATIC_CONTRACT_WRAPPER; return m_pBinder->FindAssemblyBySpec(pvAppDomain, pvAssemblySpec, pResult, ppAssembly); }
-
-    //=============================================================================================
-    // ICLRPrivAssembly interface methods
-    
-    // Implements code:ICLRPrivAssembly::IsShareable
-    STDMETHOD(IsShareable)(
-        BOOL * pbIsShareable);
-
-    // Implements code:ICLRPrivAssembly::GetAvailableImageTypes
-    STDMETHOD(GetAvailableImageTypes)(
-        LPDWORD pdwImageTypes);
-
-    // Implements code:ICLRPrivAssembly::GetImageResource
-    STDMETHOD(GetImageResource)(
-        DWORD dwImageType,
-        DWORD *pdwImageType,
-        ICLRPrivResource ** ppIResource);
-
-    //---------------------------------------------------------------------------------------------
-    HRESULT GetIBindResult(
-        IBindResult ** ppIBindResult);
-
-private:
-    CLRPrivBinderUtil::AssemblyIdentity * m_pIdentity;
-    
-    ReleaseHolder<CLRPrivBinderAppX>      m_pBinder;
-
-    ReleaseHolder<ICLRPrivResource>       m_pIResourceIL;
-    // This cannot be a holder as there can be a race to assign to it.
-    ICLRPrivResource *                    m_pIResourceNI;
-
-    ReleaseHolder<IBindResult>            m_pIBindResult;
-};
-
diff --git a/src/vm/clrprivbinderloadfile.cpp b/src/vm/clrprivbinderloadfile.cpp
deleted file mode 100644 (file)
index 20d0568..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-
-
-#include "common.h" // precompiled header
-#include "clrprivbinderutil.h"
-#include "clrprivbinderloadfile.h"
-#include "clrprivbinderfusion.h"
-#include "clrprivbinderappx.h"
-#include "fusionlogging.h"
-
-using namespace CLRPrivBinderUtil;
-
-#ifndef DACCESS_COMPILE
-
-using namespace CLRPrivBinderUtil;
-using clr::SafeAddRef;
-using clr::SafeRelease;
-
-//=====================================================================================================================
-CLRPrivBinderLoadFile * CLRPrivBinderLoadFile::s_pSingleton = nullptr;
-
-
-//=====================================================================================================================
-CLRPrivBinderLoadFile * CLRPrivBinderLoadFile::GetOrCreateBinder()
-{
-    STANDARD_VM_CONTRACT;
-    HRESULT hr = S_OK;
-
-    if (s_pSingleton == nullptr)
-    {
-        ReleaseHolder<CLRPrivBinderLoadFile> pBinder = SafeAddRef(new CLRPrivBinderLoadFile());
-        
-        CLRPrivBinderAppX *   pAppXBinder = CLRPrivBinderAppX::GetOrCreateBinder();
-        CLRPrivBinderFusion * pFusionBinder = pAppXBinder->GetFusionBinder();
-        
-        pBinder->m_pFrameworkBinder = SafeAddRef(pFusionBinder);
-        _ASSERTE(pBinder->m_pFrameworkBinder != nullptr);
-        
-        if (InterlockedCompareExchangeT<decltype(s_pSingleton)>(&s_pSingleton, pBinder, nullptr) == nullptr)
-            pBinder.SuppressRelease();
-    }
-    
-    return s_pSingleton;
-}
-
-//=====================================================================================================================
-CLRPrivBinderLoadFile::CLRPrivBinderLoadFile()
-{
-    STANDARD_VM_CONTRACT;
-}
-
-//=====================================================================================================================
-CLRPrivBinderLoadFile::~CLRPrivBinderLoadFile()
-{
-    WRAPPER_NO_CONTRACT;
-}
-
-//=====================================================================================================================
-STDMETHODIMP CLRPrivBinderLoadFile::BindAssemblyExplicit(
-        PEImage* pImage,
-        IAssemblyName **ppAssemblyName,
-        ICLRPrivAssembly ** ppAssembly)
-{
-    STANDARD_BIND_CONTRACT;
-    PRECONDITION(AppDomain::GetCurrentDomain()->IsDefaultDomain());
-    VALIDATE_ARG_RET(pImage != nullptr);
-    VALIDATE_ARG_RET(ppAssemblyName != nullptr);
-    VALIDATE_ARG_RET(ppAssembly != nullptr);
-
-    HRESULT hr = S_OK;
-
-    fusion::logging::StatusScope logStatus(0, ID_FUSLOG_BINDING_STATUS_LOAD_FILE, &hr);
-
-    ReleaseHolder<IAssemblyName> pAssemblyName;
-    ReleaseHolder<ICLRPrivAssembly> pAssembly;
-
-    EX_TRY
-    {
-        // check if a framework assembly
-        {
-            AssemblySpec spec;
-            mdAssembly a;
-            IfFailThrow(pImage->GetMDImport()->GetAssemblyFromScope(&a));
-            spec.InitializeSpec(a, pImage->GetMDImport(), NULL, false);
-            IfFailThrow(spec.CreateFusionName(&pAssemblyName));
-        }
-
-        hr = IfTransientFailThrow(m_pFrameworkBinder->BindFusionAssemblyByName(
-                pAssemblyName, 
-                CLRPrivBinderFusion::kBindingScope_FrameworkSubset, 
-                &pAssembly));
-        if (FAILED(hr)) // not a Framework assembly
-        {
-            ReleaseHolder<CLRPrivResourcePathImpl> pPathResource =
-                clr::SafeAddRef(new CLRPrivResourcePathImpl(pImage->GetPath().GetUnicode()));
-            pAssembly = clr::SafeAddRef(new CLRPrivAssemblyLoadFile(this, m_pFrameworkBinder, pPathResource));
-
-            hr = S_OK;
-        }
-    }
-    EX_CATCH_HRESULT(hr);
-
-    if (SUCCEEDED(hr))
-    {
-        *ppAssemblyName = pAssemblyName.Extract();
-        *ppAssembly = pAssembly.Extract();
-    }
-
-    return hr;
-};
-
-//=====================================================================================================================
-STDMETHODIMP CLRPrivBinderLoadFile::BindAssemblyByName(
-    IAssemblyName * pAssemblyName,
-    ICLRPrivAssembly ** ppAssembly)
-{
-    WRAPPER_NO_CONTRACT;
-    _ASSERTE(!"No parentless binds are allowed in NEITHER context");
-    return E_NOTIMPL;
-};
-
-//=====================================================================================================================
-STDMETHODIMP CLRPrivBinderLoadFile::VerifyBind(
-    IAssemblyName *pAssemblyName,
-    ICLRPrivAssembly *pAssembly,
-    ICLRPrivAssemblyInfo *pAssemblyInfo)
-{
-    WRAPPER_NO_CONTRACT;
-    // TODO: move ublic Key verification here, once we are willing to fully convert to hosted model
-    _ASSERTE(!"CLRPrivAssemblyLoadFile::VerifyBind");
-    return E_NOTIMPL; // we don't care about anything here...
-};
-
-//=====================================================================================================================
-HRESULT CLRPrivBinderLoadFile::GetBinderID(
-    UINT_PTR *pBinderId)
-{
-    LIMITED_METHOD_CONTRACT;
-
-    *pBinderId = (UINT_PTR)this;
-    return S_OK;
-}
-
-//==========================================================================
-CLRPrivAssemblyLoadFile::CLRPrivAssemblyLoadFile(
-    CLRPrivBinderLoadFile* pBinder,
-    CLRPrivBinderFusion* pFrameworkBinder,
-    CLRPrivBinderUtil::CLRPrivResourcePathImpl* pPathResource)
-    : m_pBinder(SafeAddRef(pBinder))
-    , m_pFrameworkBinder(SafeAddRef(pFrameworkBinder))
-    , m_pPathResource(SafeAddRef(pPathResource))
-{
-    STANDARD_VM_CONTRACT;
-    VALIDATE_ARG_THROW(pBinder != nullptr);
-    VALIDATE_ARG_THROW(pFrameworkBinder != nullptr);
-    VALIDATE_ARG_THROW(pPathResource != nullptr);
-}
-
-//=====================================================================================================================
-STDMETHODIMP CLRPrivAssemblyLoadFile::BindAssemblyByName(
-    IAssemblyName * pAssemblyName,
-    ICLRPrivAssembly ** ppAssembly)
-{
-    STANDARD_BIND_CONTRACT;
-    HRESULT hr = S_OK;
-
-    EX_TRY
-    {
-        hr = m_pFrameworkBinder->BindFusionAssemblyByName(
-                pAssemblyName, 
-                CLRPrivBinderFusion::kBindingScope_FrameworkSubset, 
-                ppAssembly);
-        if (FAILED(hr) && !Exception::IsTransient(hr)) // not a Framework assembly
-        {
-            *ppAssembly = RaiseAssemblyResolveEvent(pAssemblyName, this);
-            if (*ppAssembly == NULL)
-            {
-                hr = COR_E_FILENOTFOUND;
-            }
-            else
-            {
-                (*ppAssembly)->AddRef();
-                hr = S_OK;
-            }
-        }
-    }
-    EX_CATCH_HRESULT(hr);
-
-    return hr;
-};
-
-//=====================================================================================================================
-HRESULT CLRPrivAssemblyLoadFile::GetBinderID(
-    UINT_PTR *pBinderId)
-{
-    LIMITED_METHOD_CONTRACT;
-    return m_pBinder->GetBinderID(pBinderId);
-}
-
-//=====================================================================================================================
-STDMETHODIMP CLRPrivAssemblyLoadFile::VerifyBind(
-    IAssemblyName *pAssemblyName,
-    ICLRPrivAssembly *pAssembly,
-    ICLRPrivAssemblyInfo *pAssemblyInfo)
-{
-    STANDARD_BIND_CONTRACT;
-    return S_OK;
-};
-
-//=====================================================================================================================
-HRESULT CLRPrivAssemblyLoadFile::IsShareable(
-    BOOL * pbIsShareable)
-{
-    LIMITED_METHOD_CONTRACT;
-
-    VALIDATE_ARG_RET(pbIsShareable != nullptr);
-
-    *pbIsShareable = FALSE;   // no sharing for loadfile
-    return S_OK;
-}
-
-//=====================================================================================================================
-HRESULT CLRPrivAssemblyLoadFile::GetAvailableImageTypes(
-    LPDWORD pdwImageTypes)
-{
-    LIMITED_METHOD_CONTRACT;
-    VALIDATE_ARG_RET(pdwImageTypes != nullptr);
-    PRECONDITION(m_pPathResource != nullptr);
-
-    *pdwImageTypes = ASSEMBLY_IMAGE_TYPE_IL;
-
-    return S_OK;
-}
-
-
-//=====================================================================================================================
-HRESULT CLRPrivAssemblyLoadFile::GetImageResource(
-    DWORD dwImageType,
-    DWORD *pdwImageType,
-    ICLRPrivResource ** ppIResource)
-{
-    LIMITED_METHOD_CONTRACT;
-    VALIDATE_ARG_RET(pdwImageType != nullptr);
-    VALIDATE_ARG_RET(ppIResource != nullptr);
-
-    *ppIResource = nullptr;
-
-    HRESULT hr = S_OK;
-    if ((dwImageType & ASSEMBLY_IMAGE_TYPE_NATIVE) == ASSEMBLY_IMAGE_TYPE_NATIVE)
-    {
-        return CLR_E_BIND_IMAGE_UNAVAILABLE;
-    }
-
-    *pdwImageType = ASSEMBLY_IMAGE_TYPE_IL;
-    *ppIResource = clr::SafeAddRef(m_pPathResource);
-
-    return S_OK;
-}
-
-#endif // !DACCESS_COMPILE
-
index b682000..f73d01a 100644 (file)
@@ -179,8 +179,6 @@ CLRPrivBinderWinRT::GetOrCreateBinder(
     STANDARD_VM_CONTRACT;
     HRESULT hr = S_OK;
 
-    // This should be allocated directly by CLRPrivBinderAppX in the AppX scenario.
-
     if (s_pSingleton == nullptr)
     {
         ReleaseHolder<CLRPrivBinderWinRT> pBinder;