diff --git a/src/Microsoft.AspNetCore.Mvc/MvcServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Mvc/MvcServiceCollectionExtensions.cs index b7baee8634..037bcdd2d3 100644 --- a/src/Microsoft.AspNetCore.Mvc/MvcServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc/MvcServiceCollectionExtensions.cs @@ -2,6 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Reflection; using Microsoft.AspNetCore.Mvc; @@ -59,15 +61,15 @@ namespace Microsoft.Extensions.DependencyInjection private static void AddDefaultFrameworkParts(ApplicationPartManager partManager) { var mvcTagHelpersAssembly = typeof(InputTagHelper).GetTypeInfo().Assembly; - if(!partManager.ApplicationParts.OfType().Any(p => p.Assembly == mvcTagHelpersAssembly)) + if (!partManager.ApplicationParts.OfType().Any(p => p.Assembly == mvcTagHelpersAssembly)) { - partManager.ApplicationParts.Add(new AssemblyPart(mvcTagHelpersAssembly)); + partManager.ApplicationParts.Add(new FrameworkAssemblyPart(mvcTagHelpersAssembly)); } - + var mvcRazorAssembly = typeof(UrlResolutionTagHelper).GetTypeInfo().Assembly; - if(!partManager.ApplicationParts.OfType().Any(p => p.Assembly == mvcRazorAssembly)) + if (!partManager.ApplicationParts.OfType().Any(p => p.Assembly == mvcRazorAssembly)) { - partManager.ApplicationParts.Add(new AssemblyPart(mvcRazorAssembly)); + partManager.ApplicationParts.Add(new FrameworkAssemblyPart(mvcRazorAssembly)); } } @@ -94,5 +96,16 @@ namespace Microsoft.Extensions.DependencyInjection return builder; } + + [DebuggerDisplay("{Name}")] + private class FrameworkAssemblyPart : AssemblyPart, ICompilationReferencesProvider + { + public FrameworkAssemblyPart(Assembly assembly) + : base(assembly) + { + } + + IEnumerable ICompilationReferencesProvider.GetReferencePaths() => Enumerable.Empty(); + } } } diff --git a/test/WebSites/BasicWebSite/Controllers/HomeController.cs b/test/WebSites/BasicWebSite/Controllers/HomeController.cs index 454aca34b8..5d5fb11525 100644 --- a/test/WebSites/BasicWebSite/Controllers/HomeController.cs +++ b/test/WebSites/BasicWebSite/Controllers/HomeController.cs @@ -129,7 +129,7 @@ namespace BasicWebSite.Controllers // Ensures that the entry assembly part is marked correctly. var assemblyPartMetadata = applicationPartManager .ApplicationParts - .Where(part => part.GetType() == typeof(AssemblyPart)) + .OfType() .Select(part => part.Name) .ToArray();