From 701869fd5378c827ac62e05478e758da75bd3b11 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Sun, 3 Apr 2016 10:30:59 -0700 Subject: [PATCH] Remove DefaultAssemblyPartDiscoveryProvider.GetAssemblyName Fixes #4366 --- .../DefaultAssemblyPartDiscoveryProvider.cs | 24 ++----------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/DefaultAssemblyPartDiscoveryProvider.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/DefaultAssemblyPartDiscoveryProvider.cs index 75a58a376e..bfe682e881 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/DefaultAssemblyPartDiscoveryProvider.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/DefaultAssemblyPartDiscoveryProvider.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.IO; using System.Linq; using System.Reflection; 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. public static class DefaultAssemblyPartDiscoveryProvider { - private const string NativeImageSufix = ".ni"; - internal static HashSet ReferenceAssemblies { get; } = new HashSet(StringComparer.Ordinal) { "Microsoft.AspNetCore.Mvc", @@ -51,9 +48,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal } return GetCandidateLibraries(dependencyContext) - .SelectMany(library => library.RuntimeAssemblyGroups.GetDefaultGroup().AssetPaths) - .Select(Load) - .Where(assembly => assembly != null); + .SelectMany(library => library.GetDefaultAssemblyNames(dependencyContext)) + .Select(Assembly.Load); } // Returns a list of libraries that references the assemblies in . @@ -70,22 +66,6 @@ namespace Microsoft.AspNetCore.Mvc.Internal 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) { Debug.Assert(ReferenceAssemblies != null);