Remove DefaultAssemblyPartDiscoveryProvider.GetAssemblyName

Fixes #4366
This commit is contained in:
Pranav K 2016-04-03 10:30:59 -07:00
Родитель 330e98d1fc
Коммит 701869fd53
1 изменённых файлов: 2 добавлений и 22 удалений

Просмотреть файл

@ -4,7 +4,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Microsoft.AspNetCore.Mvc.ApplicationParts; using Microsoft.AspNetCore.Mvc.ApplicationParts;
@ -15,8 +14,6 @@ namespace Microsoft.AspNetCore.Mvc.Internal
// Discovers assemblies that are part of the MVC application using the DependencyContext. // Discovers assemblies that are part of the MVC application using the DependencyContext.
public static class DefaultAssemblyPartDiscoveryProvider public static class DefaultAssemblyPartDiscoveryProvider
{ {
private const string NativeImageSufix = ".ni";
internal static HashSet<string> ReferenceAssemblies { get; } = new HashSet<string>(StringComparer.Ordinal) internal static HashSet<string> ReferenceAssemblies { get; } = new HashSet<string>(StringComparer.Ordinal)
{ {
"Microsoft.AspNetCore.Mvc", "Microsoft.AspNetCore.Mvc",
@ -51,9 +48,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal
} }
return GetCandidateLibraries(dependencyContext) return GetCandidateLibraries(dependencyContext)
.SelectMany(library => library.RuntimeAssemblyGroups.GetDefaultGroup().AssetPaths) .SelectMany(library => library.GetDefaultAssemblyNames(dependencyContext))
.Select(Load) .Select(Assembly.Load);
.Where(assembly => assembly != null);
} }
// Returns a list of libraries that references the assemblies in <see cref="ReferenceAssemblies"/>. // Returns a list of libraries that references the assemblies in <see cref="ReferenceAssemblies"/>.
@ -70,22 +66,6 @@ namespace Microsoft.AspNetCore.Mvc.Internal
return dependencyContext.RuntimeLibraries.Where(IsCandidateLibrary); return dependencyContext.RuntimeLibraries.Where(IsCandidateLibrary);
} }
private static Assembly Load(string assetPath)
{
var name = Path.GetFileNameWithoutExtension(assetPath);
if (name != null)
{
if (name.EndsWith(NativeImageSufix, StringComparison.OrdinalIgnoreCase))
{
name = name.Substring(0, name.Length - NativeImageSufix.Length);
}
return Assembly.Load(new AssemblyName(name));
}
return null;
}
private static bool IsCandidateLibrary(RuntimeLibrary library) private static bool IsCandidateLibrary(RuntimeLibrary library)
{ {
Debug.Assert(ReferenceAssemblies != null); Debug.Assert(ReferenceAssemblies != null);