From c71bbb976be7c2f06357abd4913b1773d4cd4fed Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Thu, 18 Mar 2021 12:15:21 -0700 Subject: [PATCH 1/3] Update SDK to bring unified assembly changes --- global.json | 4 +- .../AzureADAuthenticationBuilderExtensions.cs | 22 ----- ...spNetCore.Authentication.AzureAD.UI.csproj | 2 +- ...etCore.Authentication.AzureADB2C.UI.csproj | 2 +- .../FunctionalTests/WebAuthenticationTests.cs | 6 -- .../UI/src/IdentityBuilderUIExtensions.cs | 83 +------------------ .../Microsoft.AspNetCore.Identity.UI.csproj | 3 +- .../AssemblyInfo.ApplicationParts.cs | 6 -- .../Infrastructure/ServerFactory.cs | 72 +--------------- .../ControllersFromServicesWebSite/Startup.cs | 5 +- src/SignalR/clients/ts/yarn.lock | 4 + 11 files changed, 12 insertions(+), 197 deletions(-) delete mode 100644 src/Identity/UI/src/Properties/AssemblyInfo.ApplicationParts.cs create mode 100644 src/SignalR/clients/ts/yarn.lock diff --git a/global.json b/global.json index f229375d1bf4..52fd8e9710df 100644 --- a/global.json +++ b/global.json @@ -1,9 +1,9 @@ { "sdk": { - "version": "6.0.100-preview.3.21160.5" + "version": "6.0.100-preview.3.21168.5" }, "tools": { - "dotnet": "6.0.100-preview.3.21160.5", + "dotnet": "6.0.100-preview.3.21168.5", "runtimes": { "dotnet/x64": [ "2.1.25", diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADAuthenticationBuilderExtensions.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADAuthenticationBuilderExtensions.cs index dcc93dd7dea3..9da2925a1a7a 100644 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADAuthenticationBuilderExtensions.cs +++ b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADAuthenticationBuilderExtensions.cs @@ -198,34 +198,12 @@ void TryAddMapping(AzureADSchemeOptions o) private static void AddAdditionalMvcApplicationParts(IServiceCollection services) { - var additionalParts = GetAdditionalParts(); var mvcBuilder = services .AddMvc() .ConfigureApplicationPartManager(apm => { - foreach (var part in additionalParts) - { - if (!apm.ApplicationParts.Any(ap => HasSameName(ap.Name, part.Name))) - { - apm.ApplicationParts.Add(part); - } - } - apm.FeatureProviders.Add(new AzureADAccountControllerFeatureProvider()); }); - - bool HasSameName(string left, string right) => string.Equals(left, right, StringComparison.Ordinal); - } - - private static IEnumerable GetAdditionalParts() - { - var thisAssembly = typeof(AzureADAuthenticationBuilderExtensions).Assembly; - var relatedAssemblies = RelatedAssemblyAttribute.GetRelatedAssemblies(thisAssembly, throwOnError: true); - - foreach (var reference in relatedAssemblies) - { - yield return new CompiledRazorAssemblyPart(reference); - } } } } diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Microsoft.AspNetCore.Authentication.AzureAD.UI.csproj b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Microsoft.AspNetCore.Authentication.AzureAD.UI.csproj index 86f2ac73d86d..d523f6c9616a 100644 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Microsoft.AspNetCore.Authentication.AzureAD.UI.csproj +++ b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Microsoft.AspNetCore.Authentication.AzureAD.UI.csproj @@ -6,8 +6,8 @@ $(DefaultNetCoreTargetFramework) aspnetcore;authentication;AzureAD true - Microsoft.AspNetCore.Mvc.ApplicationParts.NullApplicationPartFactory, Microsoft.AspNetCore.Mvc.Core true + RS0016 diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj index e92ddfff11d7..83f08b97c1cd 100644 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj +++ b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj @@ -6,8 +6,8 @@ $(DefaultNetCoreTargetFramework) aspnetcore;authentication;AzureADB2C true - Microsoft.AspNetCore.Mvc.ApplicationParts.NullApplicationPartFactory, Microsoft.AspNetCore.Mvc.Core true + RS0016 diff --git a/src/Azure/AzureAD/test/FunctionalTests/WebAuthenticationTests.cs b/src/Azure/AzureAD/test/FunctionalTests/WebAuthenticationTests.cs index d724ee2561fd..572ed87113f0 100644 --- a/src/Azure/AzureAD/test/FunctionalTests/WebAuthenticationTests.cs +++ b/src/Azure/AzureAD/test/FunctionalTests/WebAuthenticationTests.cs @@ -31,14 +31,8 @@ public WebAuthenticationTests(WebApplicationFactory fixture) public static TheoryData NotAddedEndpoints => new TheoryData() { - "/AzureAD/Account/AccessDenied", - "/AzureAD/Account/Error", - "/AzureAD/Account/SignedOut", "/AzureAD/Account/SignIn", "/AzureAD/Account/SignOut", - "/AzureADB2C/Account/AccessDenied", - "/AzureADB2C/Account/Error", - "/AzureADB2C/Account/SignedOut", "/AzureADB2C/Account/SignIn", "/AzureADB2C/Account/ResetPassword", "/AzureADB2C/Account/EditProfile", diff --git a/src/Identity/UI/src/IdentityBuilderUIExtensions.cs b/src/Identity/UI/src/IdentityBuilderUIExtensions.cs index 426c3d58facb..a6d78938573b 100644 --- a/src/Identity/UI/src/IdentityBuilderUIExtensions.cs +++ b/src/Identity/UI/src/IdentityBuilderUIExtensions.cs @@ -34,7 +34,7 @@ public static class IdentityBuilderUIExtensions public static IdentityBuilder AddDefaultUI(this IdentityBuilder builder) { builder.AddSignInManager(); - AddRelatedParts(builder); + builder.Services.AddMvc(); builder.Services.ConfigureOptions( typeof(IdentityDefaultUIConfigureOptions<>) @@ -44,87 +44,6 @@ public static IdentityBuilder AddDefaultUI(this IdentityBuilder builder) return builder; } - private static readonly IDictionary _assemblyMap = - new Dictionary() - { - [UIFramework.Bootstrap4] = "Microsoft.AspNetCore.Identity.UI.Views.V4", - }; - - private static void AddRelatedParts(IdentityBuilder builder) - { - var mvcBuilder = builder.Services - .AddMvc() - .ConfigureApplicationPartManager(partManager => - { - // We try to resolve the UI framework that was used by looking at the entry assembly. - // When an app runs, the entry assembly will point to the built app. In some rare cases - // (functional testing) the app assembly will be different, and we'll try to locate it through - // the same mechanism that MVC uses today. - // Finally, if for some reason we aren't able to find the assembly, we'll use our default value - // (Bootstrap4) - if (!TryResolveUIFramework(Assembly.GetEntryAssembly(), out var framework) && - !TryResolveUIFramework(GetApplicationAssembly(builder), out framework)) - { - framework = default; - } - - var thisAssembly = typeof(IdentityBuilderUIExtensions).Assembly; - var relatedAssemblies = RelatedAssemblyAttribute.GetRelatedAssemblies(thisAssembly, throwOnError: true); - var relatedParts = relatedAssemblies.ToDictionary( - ra => ra, - CompiledRazorAssemblyApplicationPartFactory.GetDefaultApplicationParts); - - var selectedFrameworkAssembly = _assemblyMap[framework]; - - foreach (var kvp in relatedParts) - { - var assemblyName = kvp.Key.GetName().Name; - if (!IsAssemblyForFramework(selectedFrameworkAssembly, assemblyName)) - { - RemoveParts(partManager, kvp.Value); - } - else - { - AddParts(partManager, kvp.Value); - } - } - - bool IsAssemblyForFramework(string frameworkAssembly, string assemblyName) => - string.Equals(assemblyName, frameworkAssembly, StringComparison.OrdinalIgnoreCase); - - void RemoveParts( - ApplicationPartManager manager, - IEnumerable partsToRemove) - { - for (var i = 0; i < manager.ApplicationParts.Count; i++) - { - var part = manager.ApplicationParts[i]; - if (partsToRemove.Any(p => string.Equals( - p.Name, - part.Name, - StringComparison.OrdinalIgnoreCase))) - { - manager.ApplicationParts.Remove(part); - } - } - } - - void AddParts( - ApplicationPartManager manager, - IEnumerable partsToAdd) - { - foreach (var part in partsToAdd) - { - if (!manager.ApplicationParts.Any(p => p.GetType() == part.GetType() && - string.Equals(p.Name, part.Name, StringComparison.OrdinalIgnoreCase))) - { - manager.ApplicationParts.Add(part); - } - } - } - }); - } - private static Assembly GetApplicationAssembly(IdentityBuilder builder) { // Whis is the same logic that MVC follows to find the application assembly. diff --git a/src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj b/src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj index ceebc2861397..7145be2cc9aa 100644 --- a/src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj +++ b/src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj @@ -6,10 +6,9 @@ $(DefaultNetCoreTargetFramework) true aspnetcore;identity;membership;razorpages - Microsoft.AspNetCore.Mvc.ApplicationParts.NullApplicationPartFactory, Microsoft.AspNetCore.Mvc.Core false true - Microsoft.AspNetCore.Identity.UI.Views.V4 + RS0016 true true diff --git a/src/Identity/UI/src/Properties/AssemblyInfo.ApplicationParts.cs b/src/Identity/UI/src/Properties/AssemblyInfo.ApplicationParts.cs deleted file mode 100644 index 85889305bf0c..000000000000 --- a/src/Identity/UI/src/Properties/AssemblyInfo.ApplicationParts.cs +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.AspNetCore.Mvc.ApplicationParts; - -[assembly: RelatedAssembly("Microsoft.AspNetCore.Identity.UI.Views.V4")] \ No newline at end of file diff --git a/src/Identity/test/Identity.FunctionalTests/Infrastructure/ServerFactory.cs b/src/Identity/test/Identity.FunctionalTests/Infrastructure/ServerFactory.cs index c921df9289ea..adb5ecd6ca1d 100644 --- a/src/Identity/test/Identity.FunctionalTests/Infrastructure/ServerFactory.cs +++ b/src/Identity/test/Identity.FunctionalTests/Infrastructure/ServerFactory.cs @@ -62,7 +62,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) } private void UpdateApplicationParts(IWebHostBuilder builder) => - builder.ConfigureServices(services => AddRelatedParts(services, BootstrapFrameworkVersion)); + builder.ConfigureServices(services => services.AddMvc()); private void UpdateStaticAssets(IWebHostBuilder builder) { @@ -150,75 +150,5 @@ protected override void Dispose(bool disposing) base.Dispose(disposing); } - - private static void AddRelatedParts(IServiceCollection services, string framework) - { - var _assemblyMap = - new Dictionary() - { - [UIFramework.Bootstrap4] = "Microsoft.AspNetCore.Identity.UI.Views.V4", - }; - - var mvcBuilder = services - .AddMvc() - .ConfigureApplicationPartManager(partManager => - { - var thisAssembly = typeof(IdentityBuilderUIExtensions).Assembly; - var relatedAssemblies = RelatedAssemblyAttribute.GetRelatedAssemblies(thisAssembly, throwOnError: true); - var relatedParts = relatedAssemblies.ToDictionary( - ra => ra, - CompiledRazorAssemblyApplicationPartFactory.GetDefaultApplicationParts); - - var selectedFrameworkAssembly = _assemblyMap[UIFramework.Bootstrap4]; - - foreach (var kvp in relatedParts) - { - var assemblyName = kvp.Key.GetName().Name; - if (!IsAssemblyForFramework(selectedFrameworkAssembly, assemblyName)) - { - RemoveParts(partManager, kvp.Value); - } - else - { - AddParts(partManager, kvp.Value); - } - } - - bool IsAssemblyForFramework(string frameworkAssembly, string assemblyName) => - string.Equals(assemblyName, frameworkAssembly, StringComparison.OrdinalIgnoreCase); - - void RemoveParts( - ApplicationPartManager manager, - IEnumerable partsToRemove) - { - for (var i = 0; i < manager.ApplicationParts.Count; i++) - { - var part = manager.ApplicationParts[i]; - if (partsToRemove.Any(p => string.Equals( - p.Name, - part.Name, - StringComparison.OrdinalIgnoreCase))) - { - manager.ApplicationParts.Remove(part); - } - } - } - - void AddParts( - ApplicationPartManager manager, - IEnumerable partsToAdd) - { - foreach (var part in partsToAdd) - { - if (!manager.ApplicationParts.Any(p => p.GetType() == part.GetType() && - string.Equals(p.Name, part.Name, StringComparison.OrdinalIgnoreCase))) - { - manager.ApplicationParts.Add(part); - } - } - } - }); - } - } } diff --git a/src/Mvc/test/WebSites/ControllersFromServicesWebSite/Startup.cs b/src/Mvc/test/WebSites/ControllersFromServicesWebSite/Startup.cs index f5e55e015e1f..4193dac080d3 100644 --- a/src/Mvc/test/WebSites/ControllersFromServicesWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/ControllersFromServicesWebSite/Startup.cs @@ -32,10 +32,7 @@ public void ConfigureServices(IServiceCollection services) typeof(ComponentFromServicesViewComponent), typeof(InServicesTagHelper))); - var relatedAssenbly = RelatedAssemblyAttribute - .GetRelatedAssemblies(GetType().Assembly, throwOnError: true) - .SingleOrDefault(); - foreach (var part in CompiledRazorAssemblyApplicationPartFactory.GetDefaultApplicationParts(relatedAssenbly)) + foreach (var part in CompiledRazorAssemblyApplicationPartFactory.GetDefaultApplicationParts(Assembly.GetExecutingAssembly())) { manager.ApplicationParts.Add(part); } diff --git a/src/SignalR/clients/ts/yarn.lock b/src/SignalR/clients/ts/yarn.lock new file mode 100644 index 000000000000..fb57ccd13afb --- /dev/null +++ b/src/SignalR/clients/ts/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + From 0571adb6ac161a094690c0a826f0999ed2d0a6ea Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Thu, 18 Mar 2021 21:25:44 -0700 Subject: [PATCH 2/3] Update SDK to pick up Razor pages fix --- global.json | 4 ++-- .../src/Microsoft.AspNetCore.Authentication.AzureAD.UI.csproj | 1 - .../Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj | 1 - src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj | 1 - 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/global.json b/global.json index 52fd8e9710df..65f08217fd69 100644 --- a/global.json +++ b/global.json @@ -1,9 +1,9 @@ { "sdk": { - "version": "6.0.100-preview.3.21168.5" + "version": "6.0.100-preview.3.21168.19" }, "tools": { - "dotnet": "6.0.100-preview.3.21168.5", + "dotnet": "6.0.100-preview.3.21168.19", "runtimes": { "dotnet/x64": [ "2.1.25", diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Microsoft.AspNetCore.Authentication.AzureAD.UI.csproj b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Microsoft.AspNetCore.Authentication.AzureAD.UI.csproj index d523f6c9616a..9cb7d3729484 100644 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Microsoft.AspNetCore.Authentication.AzureAD.UI.csproj +++ b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Microsoft.AspNetCore.Authentication.AzureAD.UI.csproj @@ -7,7 +7,6 @@ aspnetcore;authentication;AzureAD true true - RS0016 diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj index 83f08b97c1cd..871fd3501977 100644 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj +++ b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj @@ -7,7 +7,6 @@ aspnetcore;authentication;AzureADB2C true true - RS0016 diff --git a/src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj b/src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj index 7145be2cc9aa..55d14d6fe15f 100644 --- a/src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj +++ b/src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj @@ -8,7 +8,6 @@ aspnetcore;identity;membership;razorpages false true - RS0016 true true From 319bad689d29132849acea721036cb10da944d18 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 19 Mar 2021 07:19:56 -0700 Subject: [PATCH 3/3] Fixup test --- src/Mvc/test/Mvc.FunctionalTests/RazorPagesNamespaceTest.cs | 6 +++--- src/Mvc/test/Mvc.FunctionalTests/RazorPagesTest.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Mvc/test/Mvc.FunctionalTests/RazorPagesNamespaceTest.cs b/src/Mvc/test/Mvc.FunctionalTests/RazorPagesNamespaceTest.cs index 7af677832314..62b052508082 100644 --- a/src/Mvc/test/Mvc.FunctionalTests/RazorPagesNamespaceTest.cs +++ b/src/Mvc/test/Mvc.FunctionalTests/RazorPagesNamespaceTest.cs @@ -29,9 +29,9 @@ public async Task Page_DefaultNamespace_IfUnset() var content = await Client.GetStringAsync("http://localhost/DefaultNamespace"); // Assert - Assert.Equal("AspNetCore", content.Trim()); + Assert.Equal("AspNetCoreGeneratedDocument", content.Trim()); } - + [Fact] public async Task Page_ImportedNamespace_UsedFromViewImports() { @@ -41,7 +41,7 @@ public async Task Page_ImportedNamespace_UsedFromViewImports() // Assert Assert.Equal("CustomNamespace.Nested.Folder", content.Trim()); } - + [Fact] public async Task Page_OverrideNamespace_SetByPage() { diff --git a/src/Mvc/test/Mvc.FunctionalTests/RazorPagesTest.cs b/src/Mvc/test/Mvc.FunctionalTests/RazorPagesTest.cs index b9c54570dcf5..88a5bddd83d0 100644 --- a/src/Mvc/test/Mvc.FunctionalTests/RazorPagesTest.cs +++ b/src/Mvc/test/Mvc.FunctionalTests/RazorPagesTest.cs @@ -932,8 +932,8 @@ public async Task PagePropertiesAreInjected() // Arrange var expected = @"Microsoft.AspNetCore.Mvc.Routing.UrlHelper -Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper`1[AspNetCore.InjectedPageProperties] -Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary`1[AspNetCore.InjectedPageProperties]"; +Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper`1[AspNetCoreGeneratedDocument.InjectedPageProperties] +Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary`1[AspNetCoreGeneratedDocument.InjectedPageProperties]"; // Act var response = await Client.GetStringAsync("InjectedPageProperties");