Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Remove DefaultAssemblyPartDiscoveryProvider.GetAssemblyName #4401

Merged
merged 1 commit into from
Apr 3, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<string> ReferenceAssemblies { get; } = new HashSet<string>(StringComparer.Ordinal)
{
"Microsoft.AspNetCore.Mvc",
Expand Down Expand Up @@ -51,9 +48,8 @@ internal static IEnumerable<Assembly> GetCandidateAssemblies(Assembly entryAssem
}

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 <see cref="ReferenceAssemblies"/>.
Expand All @@ -70,22 +66,6 @@ internal static IEnumerable<RuntimeLibrary> GetCandidateLibraries(DependencyCont
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);
Expand Down