提交 0c80fd77 编写于 作者: S Sam Harwell

Use GlobalAssemblyCache helper to locate assemblies directly in the GAC

上级 8f0699aa
......@@ -441,7 +441,7 @@ internal static IAssemblyName ToAssemblyNameObject(AssemblyName name)
throw new ArgumentException(Scripting.ScriptingResources.InvalidCharactersInAssemblyName, nameof(name));
#elif WORKSPACE_DESKTOP
#elif WORKSPACE_DESKTOP || EDITOR_FEATURES
throw new ArgumentException(Microsoft.CodeAnalysis.WorkspaceDesktopResources.Invalid_characters_in_assembly_name, nameof(name));
......@@ -471,7 +471,7 @@ internal static IAssemblyName ToAssemblyNameObject(AssemblyName name)
throw new ArgumentException(Microsoft.CodeAnalysis.Scripting.ScriptingResources.InvalidCharactersInAssemblyName, nameof(name));
#elif WORKSPACE_DESKTOP
#elif WORKSPACE_DESKTOP || EDITOR_FEATURES
throw new ArgumentException(Microsoft.CodeAnalysis.WorkspaceDesktopResources.Invalid_characters_in_assembly_name, nameof(name));
......
......@@ -9,6 +9,7 @@
<AssemblyName>Microsoft.CodeAnalysis.EditorFeatures</AssemblyName>
<TargetFramework>net46</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>$(DefineConstants);EDITOR_FEATURES</DefineConstants>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\Compilers\Core\Portable\CodeAnalysis.csproj" />
......@@ -94,6 +95,12 @@
<InternalsVisibleToFSharp Include="FSharp.Editor" />
<InternalsVisibleToMoq Include="DynamicProxyGenAssembly2" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Compilers\Shared\GlobalAssemblyCacheHelpers\ClrGlobalAssemblyCache.cs" Link="Shared\GlobalAssemblyCacheHelpers\ClrGlobalAssemblyCache.cs" />
<Compile Include="..\..\Compilers\Shared\GlobalAssemblyCacheHelpers\FusionAssemblyIdentity.cs" Link="Shared\GlobalAssemblyCacheHelpers\FusionAssemblyIdentity.cs" />
<Compile Include="..\..\Compilers\Shared\GlobalAssemblyCacheHelpers\GlobalAssemblyCache.cs" Link="Shared\GlobalAssemblyCacheHelpers\GlobalAssemblyCache.cs" />
<Compile Include="..\..\Compilers\Shared\GlobalAssemblyCacheHelpers\MonoGlobalAssemblyCache.cs" Link="Shared\GlobalAssemblyCacheHelpers\MonoGlobalAssemblyCache.cs" />
</ItemGroup>
<ItemGroup>
<Compile Update="EditorFeaturesResources.Designer.cs">
<DependentUpon>EditorFeaturesResources.resx</DependentUpon>
......
......@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
......@@ -200,13 +201,10 @@ private async Task<Document> DecompileSymbolAsync(Document temporaryDocument, IS
var isReferenceAssembly = symbol.ContainingAssembly.GetAttributes().Any(attribute => attribute.AttributeClass.Name == nameof(ReferenceAssemblyAttribute));
if (isReferenceAssembly)
{
// Attempt to resolve the assembly via the current process' binding path
try
{
var fullAssemblyName = symbol.ContainingAssembly.Identity.GetDisplayName();
var loadedAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(x => x.FullName == fullAssemblyName);
var assembly = loadedAssembly ?? Assembly.ReflectionOnlyLoad(fullAssemblyName);
assemblyLocation = assembly.Location;
GlobalAssemblyCache.Instance.ResolvePartialName(fullAssemblyName, out assemblyLocation, preferredCulture: CultureInfo.CurrentCulture);
}
catch (Exception e) when (FatalError.ReportWithoutCrashUnlessCanceled(e))
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册