DefaultAssemblyPartDiscoveryProvider.IsCandidateLibrary should not look at types in Mvc assemblies

Fixes #4363
This commit is contained in:
Pranav K 2016-04-03 14:49:09 -07:00
parent 4b348699c8
commit c66c408c15
2 changed files with 28 additions and 1 deletions

View File

@ -69,7 +69,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal
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));
}
}
}

View File

@ -73,6 +73,32 @@ namespace Microsoft.AspNetCore.Mvc.Internal
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.