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

DefaultAssemblyPartDiscoveryProvider.IsCandidateLibrary should not look at types i… #4378

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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 @@ -69,7 +69,8 @@ internal static IEnumerable<RuntimeLibrary> GetCandidateLibraries(DependencyCont
private static bool IsCandidateLibrary(RuntimeLibrary library)
{
Debug.Assert(ReferenceAssemblies != null);
return library.Dependencies.Any(dependency => ReferenceAssemblies.Contains(dependency.Name));
return !ReferenceAssemblies.Contains(library.Name) &&
library.Dependencies.Any(dependency => ReferenceAssemblies.Contains(dependency.Name));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,32 @@ public void GetCandidateLibraries_ReturnsLibrariesReferencingAnyMvcAssembly()
Assert.Equal(new[] { "Foo", "Bar", "Baz" }, candidates.Select(a => a.Name));
}

[Fact]
public void GetCandidateLibraries_SkipsMvcAssemblies()
{
// Arrange
var dependencyContext = new DependencyContext(
new TargetInfo("framework", "runtime", "signature", isPortable: true),
CompilationOptions.Default,
new CompilationLibrary[0],
new[]
{
GetLibrary("MvcSandbox", "Microsoft.AspNetCore.Mvc.Core", "Microsoft.AspNetCore.Mvc"),
GetLibrary("Microsoft.AspNetCore.Mvc.TagHelpers", "Microsoft.AspNetCore.Mvc.Razor"),
GetLibrary("Microsoft.AspNetCore.Mvc", "Microsoft.AspNetCore.Mvc.Abstractions", "Microsoft.AspNetCore.Mvc.Core"),
GetLibrary("Microsoft.AspNetCore.Mvc.Core", "Microsoft.AspNetCore.HttpAbstractions"),
GetLibrary("ControllersAssembly", "Microsoft.AspNetCore.Mvc"),

},
Enumerable.Empty<RuntimeFallbacks>());

// Act
var candidates = DefaultAssemblyPartDiscoveryProvider.GetCandidateLibraries(dependencyContext);

// Assert
Assert.Equal(new[] { "MvcSandbox", "ControllersAssembly" }, candidates.Select(a => a.Name));
}

// This test verifies DefaultAssemblyPartDiscoveryProvider.ReferenceAssemblies reflects the actual loadable assemblies
// of the libraries that Microsoft.AspNetCore.Mvc dependes on.
// If we add or remove dependencies, this test should be changed together.
Expand Down