From 8f42ce8492fd924b6e2471b2b18c5f06e1ee7c47 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Thu, 22 Mar 2018 20:13:10 -0700 Subject: [PATCH] Application parts cleanups --- NuGetPackageVerifier.json | 9 ------- .../Properties/launchSettings.json | 4 +-- ...ureAdB2CAuthenticationBuilderExtensions.cs | 26 ++++++++++++------- .../AzureAdB2CPartFactory.cs | 23 ---------------- .../AzureAdB2CViewsPartFactory.cs | 15 ----------- ...etCore.Authentication.AzureADB2C.UI.csproj | 25 +++++++++++++----- .../Properties/AssemblyInfo.cs | 3 +-- 7 files changed, 38 insertions(+), 67 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CPartFactory.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CViewsPartFactory.cs diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index 32a39ca5b4..b1d0afdbf6 100644 --- a/NuGetPackageVerifier.json +++ b/NuGetPackageVerifier.json @@ -8,15 +8,6 @@ "Exclusions": { "DOC_MISSING": { "lib/netstandard2.0/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Views.dll": "This library contains precompiled views." - }, - "ASSEMBLY_DESCRIPTION": { - "lib/netstandard2.0/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Views.dll": "Enter justification" - }, - "NEUTRAL_RESOURCES_LANGUAGE": { - "lib/netstandard2.0/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Views.dll": "Enter justification" - }, - "SERVICING_ATTRIBUTE": { - "lib/netstandard2.0/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Views.dll": "Enter justification" } } } diff --git a/samples/AzureADB2CSample/Properties/launchSettings.json b/samples/AzureADB2CSample/Properties/launchSettings.json index d6c6715ec8..1ee213cd17 100644 --- a/samples/AzureADB2CSample/Properties/launchSettings.json +++ b/samples/AzureADB2CSample/Properties/launchSettings.json @@ -3,8 +3,8 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:59361/", - "sslPort": 0 + "applicationUrl": "http://localhost:59364/", + "sslPort": 44315 } }, "profiles": { diff --git a/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CAuthenticationBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CAuthenticationBuilderExtensions.cs index bd1adf382b..b133bc5c6f 100644 --- a/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CAuthenticationBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CAuthenticationBuilderExtensions.cs @@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Mvc.ApplicationParts; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; +using System.Collections.Generic; namespace Microsoft.AspNetCore.Authentication { @@ -190,23 +191,17 @@ namespace Microsoft.AspNetCore.Authentication private static void AddAdditionalMvcApplicationParts(IServiceCollection services) { - var thisAssembly = typeof(AzureADB2CAuthenticationBuilderExtensions).Assembly; - var relatedAssemblies = RelatedAssemblyAttribute.GetRelatedAssemblies(thisAssembly, throwOnError: true); - + var additionalParts = GetAdditionalParts(); var mvcBuilder = services .AddMvc() .AddRazorPagesOptions(o => o.AllowAreas = true) .ConfigureApplicationPartManager(apm => { - foreach (var reference in relatedAssemblies) + foreach (var part in additionalParts) { - var factory = (AzureADB2CPartFactory)ApplicationPartFactory.GetApplicationPartFactory(reference); - foreach (var additionalPart in factory.CreateApplicationParts()) + if (!apm.ApplicationParts.Any(ap => HasSameName(ap.Name, part.Name))) { - if (!apm.ApplicationParts.Any(ap => HasSameName(ap.Name, additionalPart.Name))) - { - apm.ApplicationParts.Add(additionalPart); - } + apm.ApplicationParts.Add(part); } } @@ -215,5 +210,16 @@ namespace Microsoft.AspNetCore.Authentication bool HasSameName(string left, string right) => string.Equals(left, right, StringComparison.Ordinal); } + + private static IEnumerable GetAdditionalParts() + { + var thisAssembly = typeof(AzureADB2CAuthenticationBuilderExtensions).Assembly; + var relatedAssemblies = RelatedAssemblyAttribute.GetRelatedAssemblies(thisAssembly, throwOnError: true); + + foreach (var reference in relatedAssemblies) + { + yield return new CompiledRazorAssemblyPart(reference); + } + } } } diff --git a/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CPartFactory.cs b/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CPartFactory.cs deleted file mode 100644 index 13542e6529..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CPartFactory.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using Microsoft.AspNetCore.Mvc.ApplicationParts; - -namespace Microsoft.AspNetCore.Authentication.AzureADB2C.UI -{ - /// - /// for Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Views.dll - /// - public abstract class AzureADB2CPartFactory : ApplicationPartFactory - { - /// - public override IEnumerable GetApplicationParts(Assembly assembly, string context) => - Array.Empty(); - - /// - /// Creates the list of for a given application. - /// - /// The list. - public abstract IEnumerable CreateApplicationParts(); - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CViewsPartFactory.cs b/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CViewsPartFactory.cs deleted file mode 100644 index 366487d552..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CViewsPartFactory.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.AspNetCore.Mvc.ApplicationParts; - -namespace Microsoft.AspNetCore.Authentication.AzureADB2C.UI -{ - internal class AzureAdB2CViewsPartFactory : AzureADB2CPartFactory - { - public override IEnumerable CreateApplicationParts() - { - yield return new CompiledRazorAssemblyPart(this.GetType().Assembly); - } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj b/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj index 1d445fe8cd..d9745bf094 100644 --- a/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj +++ b/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj @@ -2,14 +2,14 @@ ASP.NET Core Azure Active Directory B2C Integration provides components for easily integrating Azure Active Directory B2C authentication within your ASP.NET Core application. - Precompiled views assembly for the ASP.NET Core Azure Active Directory B2C Integration package. + Precompiled views assembly for the ASP.NET Core Azure Active Directory B2C Integration package. netstandard2.0 aspnetcore;authentication;AzureADB2C true $(RazorTargetName).dll false true - Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureAdB2CViewsPartFactory, Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Views + false @@ -19,9 +19,22 @@ - - - - + + + <_Parameter1>$(ViewAssemblyDescription) + + + <_Parameter1>BuildNumber + <_Parameter2>$(BuildNumber) + + + <_Parameter1>$(NeutralLanguage) + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/Properties/AssemblyInfo.cs index 2ecc708c52..1269fbc713 100644 --- a/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/Properties/AssemblyInfo.cs @@ -3,5 +3,4 @@ using System.Runtime.CompilerServices; -[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] -[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Views.dll, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] \ No newline at end of file +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] \ No newline at end of file