From 722cac7b9fe83503d1c8eaf100565d4aa23103f2 Mon Sep 17 00:00:00 2001 From: Vitek Karas Date: Fri, 24 Aug 2018 22:37:44 -0700 Subject: [PATCH] Very small cleanup of various comments and code formatting (dotnet/coreclr#19665) * Very small cleanpu of various comments and code formatting Fixed couple of comments to match the code and the wording. Fixed indentation in several places. Removed unused local variable in AppDomain::BindAssemblySpec * Remove unused enum in the binder Commit migrated from https://github.com/dotnet/coreclr/commit/3fca50a36e62a7433d7601d805d38de6baee7951 --- .../src/System/Reflection/Assembly.CoreCLR.cs | 13 ++++------ .../System/Runtime/Loader/AssemblyLoadContext.cs | 1 - src/coreclr/src/binder/assemblybinder.cpp | 12 ---------- .../binder/clrprivbinderassemblyloadcontext.cpp | 2 +- src/coreclr/src/binder/clrprivbindercoreclr.cpp | 28 +++++++++++----------- src/coreclr/src/vm/appdomain.cpp | 4 +--- 6 files changed, 21 insertions(+), 39 deletions(-) diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs index 6de94d4..e18eef7 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs @@ -158,9 +158,8 @@ namespace System.Reflection } // Loads the assembly with a COFF based IMAGE containing - // an emitted assembly. The assembly is loaded into the domain - // of the caller. The second parameter is the raw bytes - // representing the symbol store that matches the assembly. + // an emitted assembly. The assembly is loaded into a fully isolated ALC with resolution fully deferred to the AssemblyLoadContext.Default. + // The second parameter is the raw bytes representing the symbol store that matches the assembly. [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public static Assembly Load(byte[] rawAssembly, byte[] rawSymbolStore) @@ -203,9 +202,7 @@ namespace System.Reflection return result; } - /* - * Get the assembly that the current code is running from. - */ + // Get the assembly that the current code is running from. [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public static Assembly GetExecutingAssembly() { @@ -216,9 +213,9 @@ namespace System.Reflection [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public static Assembly GetCallingAssembly() { - // LookForMyCallersCaller is not guarantee to return the correct stack frame + // LookForMyCallersCaller is not guaranteed to return the correct stack frame // because of inlining, tail calls, etc. As a result GetCallingAssembly is not - // ganranteed to return the correct result. We should document it as such. + // guaranteed to return the correct result. It's also documented as such. StackCrawlMark stackMark = StackCrawlMark.LookForMyCallersCaller; return RuntimeAssembly.GetExecutingAssembly(ref stackMark); } diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs index 746d397..5738786 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs @@ -190,7 +190,6 @@ namespace System.Runtime.Loader } // Basic validation has succeeded - lets try to load the NI image. - // Ask LoadFile to load the specified assembly in the DefaultContext RuntimeAssembly loadedAssembly = null; LoadFromPath(m_pNativeAssemblyLoadContext, assemblyPath, nativeImagePath, JitHelpers.GetObjectHandleOnStack(ref loadedAssembly)); return loadedAssembly; diff --git a/src/coreclr/src/binder/assemblybinder.cpp b/src/coreclr/src/binder/assemblybinder.cpp index 7c0aa80..85005be 100644 --- a/src/coreclr/src/binder/assemblybinder.cpp +++ b/src/coreclr/src/binder/assemblybinder.cpp @@ -61,18 +61,6 @@ extern BOOL RuntimeCanUseAppPathAssemblyResolver(DWORD adid); namespace BINDER_SPACE { - typedef enum - { - kVersionIgnore, - kVersionExact, - kVersionServiceRollForward, - kVersionFeatureRollForward, - kVersionFeatureExact, - kVersionFeatureHighest, - kVersionFeatureLowestHigher, - kVersionFeatureHighestLower - } VersionMatchMode; - namespace { BOOL fAssemblyBinderInitialized = FALSE; diff --git a/src/coreclr/src/binder/clrprivbinderassemblyloadcontext.cpp b/src/coreclr/src/binder/clrprivbinderassemblyloadcontext.cpp index e1ecdc8..e981314 100644 --- a/src/coreclr/src/binder/clrprivbinderassemblyloadcontext.cpp +++ b/src/coreclr/src/binder/clrprivbinderassemblyloadcontext.cpp @@ -45,7 +45,7 @@ HRESULT CLRPrivBinderAssemblyLoadContext::BindAssemblyByNameWorker(BINDER_SPACE: } HRESULT CLRPrivBinderAssemblyLoadContext::BindAssemblyByName(IAssemblyName *pIAssemblyName, - ICLRPrivAssembly **ppAssembly) + ICLRPrivAssembly **ppAssembly) { HRESULT hr = S_OK; VALIDATE_ARG_RET(pIAssemblyName != nullptr && ppAssembly != nullptr); diff --git a/src/coreclr/src/binder/clrprivbindercoreclr.cpp b/src/coreclr/src/binder/clrprivbindercoreclr.cpp index 051389c..9bad805 100644 --- a/src/coreclr/src/binder/clrprivbindercoreclr.cpp +++ b/src/coreclr/src/binder/clrprivbindercoreclr.cpp @@ -80,18 +80,18 @@ HRESULT CLRPrivBinderCoreCLR::BindAssemblyByName(IAssemblyName *pIAssemblyNa INT_PTR pManagedAssemblyLoadContext = GetManagedAssemblyLoadContext(); if (pManagedAssemblyLoadContext != NULL) { - hr = AssemblyBinder::BindUsingHostAssemblyResolver(pManagedAssemblyLoadContext, pAssemblyName, pIAssemblyName, - NULL, &pCoreCLRFoundAssembly); - if (SUCCEEDED(hr)) - { - // We maybe returned an assembly that was bound to a different AssemblyLoadContext instance. - // In such a case, we will not overwrite the binding context (which would be wrong since it would not - // be present in the cache of the current binding context). - if (pCoreCLRFoundAssembly->GetBinder() == NULL) - { - pCoreCLRFoundAssembly->SetBinder(this); - } - } + hr = AssemblyBinder::BindUsingHostAssemblyResolver(pManagedAssemblyLoadContext, pAssemblyName, pIAssemblyName, + NULL, &pCoreCLRFoundAssembly); + if (SUCCEEDED(hr)) + { + // We maybe returned an assembly that was bound to a different AssemblyLoadContext instance. + // In such a case, we will not overwrite the binding context (which would be wrong since it would not + // be present in the cache of the current binding context). + if (pCoreCLRFoundAssembly->GetBinder() == NULL) + { + pCoreCLRFoundAssembly->SetBinder(this); + } + } } } #endif // !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE) @@ -109,8 +109,8 @@ Exit:; #if !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE) HRESULT CLRPrivBinderCoreCLR::BindUsingPEImage( /* in */ PEImage *pPEImage, - /* in */ BOOL fIsNativeImage, - /* [retval][out] */ ICLRPrivAssembly **ppAssembly) + /* in */ BOOL fIsNativeImage, + /* [retval][out] */ ICLRPrivAssembly **ppAssembly) { HRESULT hr = S_OK; diff --git a/src/coreclr/src/vm/appdomain.cpp b/src/coreclr/src/vm/appdomain.cpp index f1c7d0a..388aded 100644 --- a/src/coreclr/src/vm/appdomain.cpp +++ b/src/coreclr/src/vm/appdomain.cpp @@ -7025,8 +7025,6 @@ EndTry2:; { bool fAddFileToCache = false; - BOOL fIsWellKnown = FALSE; - // Use CoreClr's fusion alternative CoreBindResult bindResult; @@ -7068,7 +7066,7 @@ EndTry2:; AddFileToCache(pSpec, result, TRUE /*fAllowFailure*/); } } - else if (!fIsWellKnown) + else { _ASSERTE(fThrowOnFileNotFound == FALSE); -- 2.7.4