diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index b1d0afdbf6..32a39ca5b4 100644 --- a/NuGetPackageVerifier.json +++ b/NuGetPackageVerifier.json @@ -8,6 +8,15 @@ "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/build/dependencies.props b/build/dependencies.props index 2abf38e87b..f0b3a197ec 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -8,7 +8,7 @@ 2.1.0-preview2-30406 2.1.0-preview2-30406 2.1.0-preview2-30406 - 2.1.0-preview2-30406 + 2.1.0-a-preview2-application-part-18617 2.1.0-preview2-30406 2.1.0-preview2-30406 2.1.0-preview2-30406 diff --git a/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CAuthenticationBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CAuthenticationBuilderExtensions.cs index ab4b0240e8..bd1adf382b 100644 --- a/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CAuthenticationBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CAuthenticationBuilderExtensions.cs @@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Authentication /// . /// /// The . - public static AuthenticationBuilder AddAzureADB2CBearer(this AuthenticationBuilder builder, Action configureOptions) => + public static AuthenticationBuilder AddAzureADB2CBearer(this AuthenticationBuilder builder, Action configureOptions) => builder.AddAzureADB2CBearer( AzureADB2CDefaults.BearerAuthenticationScheme, AzureADB2CDefaults.JwtBearerAuthenticationScheme, @@ -49,7 +49,8 @@ namespace Microsoft.AspNetCore.Authentication this AuthenticationBuilder builder, string scheme, string jwtBearerScheme, - Action configureOptions) { + Action configureOptions) + { builder.AddPolicyScheme(scheme, displayName: null, configureOptions: o => { @@ -190,27 +191,22 @@ namespace Microsoft.AspNetCore.Authentication private static void AddAdditionalMvcApplicationParts(IServiceCollection services) { var thisAssembly = typeof(AzureADB2CAuthenticationBuilderExtensions).Assembly; - var additionalReferences = thisAssembly - .GetCustomAttributes() - .Where(am => string.Equals(am.Key, "Microsoft.AspNetCore.Mvc.AdditionalReference")) - .Select(am => am.Value.Split(',')[0]) - .ToArray(); + var relatedAssemblies = RelatedAssemblyAttribute.GetRelatedAssemblies(thisAssembly, throwOnError: true); var mvcBuilder = services .AddMvc() .AddRazorPagesOptions(o => o.AllowAreas = true) .ConfigureApplicationPartManager(apm => { - foreach (var reference in additionalReferences) + foreach (var reference in relatedAssemblies) { - var fileName = Path.GetFileName(reference); - var filePath = Path.Combine(Path.GetDirectoryName(thisAssembly.Location), fileName); - var additionalAssembly = LoadAssembly(filePath); - // This needs to change to additional assembly part. - var additionalPart = new AdditionalAssemblyPart(additionalAssembly); - if (!apm.ApplicationParts.Any(ap => HasSameName(ap.Name, additionalPart.Name))) + var factory = (AzureADB2CPartFactory)ApplicationPartFactory.GetApplicationPartFactory(reference); + foreach (var additionalPart in factory.CreateApplicationParts()) { - apm.ApplicationParts.Add(additionalPart); + if (!apm.ApplicationParts.Any(ap => HasSameName(ap.Name, additionalPart.Name))) + { + apm.ApplicationParts.Add(additionalPart); + } } } @@ -219,29 +215,5 @@ namespace Microsoft.AspNetCore.Authentication bool HasSameName(string left, string right) => string.Equals(left, right, StringComparison.Ordinal); } - - private static Assembly LoadAssembly(string filePath) - { - Assembly viewsAssembly = null; - if (File.Exists(filePath)) - { - try - { - viewsAssembly = Assembly.LoadFile(filePath); - } - catch (FileLoadException) - { - throw new InvalidOperationException("Unable to load the precompiled views assembly in " + - $"'{filePath}'."); - } - } - else - { - throw new InvalidOperationException("Could not find the precompiled views assembly for 'Microsoft.AspNetCore.Authentication.AzureADB2C.UI' at " + - $"'{filePath}'."); - } - - return viewsAssembly; - } } } diff --git a/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CPartFactory.cs b/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CPartFactory.cs new file mode 100644 index 0000000000..13542e6529 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CPartFactory.cs @@ -0,0 +1,23 @@ +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 new file mode 100644 index 0000000000..366487d552 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/AzureAdB2CViewsPartFactory.cs @@ -0,0 +1,15 @@ +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 3771304888..1d445fe8cd 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 @@ -1,7 +1,5 @@ - - 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. @@ -11,6 +9,7 @@ $(RazorTargetName).dll false true + Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureAdB2CViewsPartFactory, Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Views @@ -21,26 +20,8 @@ - - <_parameter1>Microsoft.AspNetCore.Mvc.AdditionalReference - <_parameter2>$(RazorTargetName).dll,false - + + - - - - $(IncludeRazorContentInPack) - - - - - - $(OutputPath)$(RazorTargetName).dll - - - - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.props b/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.props deleted file mode 100644 index 8864135350..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.props +++ /dev/null @@ -1,24 +0,0 @@ - - - true - - - - true - true - true - true - true - true - true - true - true - true - - - - - - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.targets b/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.targets deleted file mode 100644 index 216b7fc955..0000000000 --- a/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.targets +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - <_Parameter1>$(Company) - - - <_Parameter1>$(Configuration) - - - <_Parameter1>$(Copyright) - - - <_Parameter1>$(PrecompiledDescription) - - - <_Parameter1>$(FileVersion) - - - <_Parameter1>$(InformationalVersion) - - - <_Parameter1>$(Product) - - - <_Parameter1>$(PrecompiledAssemblyTitle) - - - <_Parameter1>$(AssemblyVersion) - - - <_Parameter1>$(NeutralLanguage) - - - <_Parameter1>BuildNumber - <_Parameter2>$(BuildNumber) - - - - - - - - $(IntermediateOutputPath)$(MSBuildProjectName).PrecompiledViews.AssemblyInfo$(DefaultLanguageSourceExtension) - $(IntermediateOutputPath)$(MSBuildProjectName).PrecompiledViews.AssemblyInfoInputs.cache - - - - - - - - - - - - - - - - - $(IntermediateOutputPath)$(MSBuildProjectName).PrecompiledViews.AssemblyInfo$(DefaultLanguageSourceExtension) - - - - - - - - - - - - - - - - \ 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 1269fbc713..2ecc708c52 100644 --- a/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI/Properties/AssemblyInfo.cs @@ -3,4 +3,5 @@ using System.Runtime.CompilerServices; -[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] \ No newline at end of file +[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 diff --git a/test/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Test/AzureAdB2CAuthenticationBuilderExtensionsTests.cs b/test/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Test/AzureAdB2CAuthenticationBuilderExtensionsTests.cs index cf2afe2513..d545047fe2 100644 --- a/test/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Test/AzureAdB2CAuthenticationBuilderExtensionsTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Test/AzureAdB2CAuthenticationBuilderExtensionsTests.cs @@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Authentication // Assert Assert.NotNull(provider.GetService()); Assert.NotNull(provider.GetService()); - Assert.NotNull(provider.GetService()); + Assert.NotNull(provider.GetService()); } [Fact] @@ -171,7 +171,7 @@ namespace Microsoft.AspNetCore.Authentication // Assert Assert.NotNull(provider.GetService()); - Assert.NotNull(provider.GetService()); + Assert.NotNull(provider.GetService()); } [Fact]