DefaultAssemblyPartDiscoveryProvider.IsCandidateLibrary should not look at types in Mvc assemblies
Fixes #4363
This commit is contained in:
parent
4b348699c8
commit
c66c408c15
|
|
@ -69,7 +69,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
private static bool IsCandidateLibrary(RuntimeLibrary library)
|
private static bool IsCandidateLibrary(RuntimeLibrary library)
|
||||||
{
|
{
|
||||||
Debug.Assert(ReferenceAssemblies != null);
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,32 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
Assert.Equal(new[] { "Foo", "Bar", "Baz" }, candidates.Select(a => a.Name));
|
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
|
// This test verifies DefaultAssemblyPartDiscoveryProvider.ReferenceAssemblies reflects the actual loadable assemblies
|
||||||
// of the libraries that Microsoft.AspNetCore.Mvc dependes on.
|
// of the libraries that Microsoft.AspNetCore.Mvc dependes on.
|
||||||
// If we add or remove dependencies, this test should be changed together.
|
// If we add or remove dependencies, this test should be changed together.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue