From 0f0c88b8cd2ba4f5833e68db85d48980f01c5b7d Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Fri, 2 Jun 2017 08:33:37 -0700 Subject: [PATCH 1/2] React to logging in DI changes (#1089) --- .../IWebHostBuilder.cs | 32 ---- .../WebHostBuilderContext.cs | 5 - .../breakingchanges.netcore.json | 19 +-- .../WebHostBuilder.cs | 84 +-------- .../WebHostBuilderExtensions.cs | 27 +-- .../breakingchanges.netcore.json | 7 +- .../Program.cs | 4 +- .../WebHostBuilderTests.cs | 159 ------------------ 8 files changed, 23 insertions(+), 314 deletions(-) diff --git a/src/Microsoft.AspNetCore.Hosting.Abstractions/IWebHostBuilder.cs b/src/Microsoft.AspNetCore.Hosting.Abstractions/IWebHostBuilder.cs index bb0659222d..2cf3bc1163 100644 --- a/src/Microsoft.AspNetCore.Hosting.Abstractions/IWebHostBuilder.cs +++ b/src/Microsoft.AspNetCore.Hosting.Abstractions/IWebHostBuilder.cs @@ -29,20 +29,6 @@ namespace Microsoft.AspNetCore.Hosting /// IWebHostBuilder ConfigureAppConfiguration(Action configureDelegate); - /// - /// Adds a delegate for configuring the provided . This may be called multiple times. - /// - /// The delegate that configures the . - /// - /// The type of to configure. - /// The delegate will not execute if the type provided does not match the used by the . - /// - /// The . - /// - /// The on the is uninitialized at this stage. - /// - IWebHostBuilder ConfigureLogging(Action configureLogging) where T : ILoggerFactory; - /// /// Adds a delegate for configuring additional services for the host or web application. This may be called /// multiple times. @@ -73,23 +59,5 @@ namespace Microsoft.AspNetCore.Hosting /// The value of the setting to add or replace. /// The . IWebHostBuilder UseSetting(string key, string value); - - /// - /// Specify the to be used by the web host. - /// - /// The to be used. - /// The . - IWebHostBuilder UseLoggerFactory(ILoggerFactory loggerFactory); - - /// - /// Adds a delegate to construct the that will be registered - /// as a singleton and used by the application. - /// - /// The delegate that constructs an - /// The . - /// - /// The on the is uninitialized at this stage. - /// - IWebHostBuilder UseLoggerFactory(Func createLoggerFactory); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Hosting.Abstractions/WebHostBuilderContext.cs b/src/Microsoft.AspNetCore.Hosting.Abstractions/WebHostBuilderContext.cs index 5a973abd0a..071479c7a8 100644 --- a/src/Microsoft.AspNetCore.Hosting.Abstractions/WebHostBuilderContext.cs +++ b/src/Microsoft.AspNetCore.Hosting.Abstractions/WebHostBuilderContext.cs @@ -20,10 +20,5 @@ namespace Microsoft.AspNetCore.Hosting /// The containing the merged configuration of the application and the . /// public IConfiguration Configuration { get; set; } - - /// - /// The configured on the . - /// - public ILoggerFactory LoggerFactory { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Hosting.Abstractions/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Hosting.Abstractions/breakingchanges.netcore.json index 4df8dcfa04..e523c48473 100644 --- a/src/Microsoft.AspNetCore.Hosting.Abstractions/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Hosting.Abstractions/breakingchanges.netcore.json @@ -9,21 +9,11 @@ "MemberId": "Microsoft.AspNetCore.Hosting.IWebHostBuilder ConfigureAppConfiguration(System.Action configureDelegate)", "Kind": "Addition" }, - { - "TypeId": "public interface Microsoft.AspNetCore.Hosting.IWebHostBuilder", - "MemberId": "Microsoft.AspNetCore.Hosting.IWebHostBuilder ConfigureLogging(System.Action configureLogging) where T0 : Microsoft.Extensions.Logging.ILoggerFactory", - "Kind": "Addition" - }, { "TypeId": "public interface Microsoft.AspNetCore.Hosting.IWebHostBuilder", "MemberId": "Microsoft.AspNetCore.Hosting.IWebHostBuilder ConfigureServices(System.Action configureServices)", "Kind": "Addition" }, - { - "TypeId": "public interface Microsoft.AspNetCore.Hosting.IWebHostBuilder", - "MemberId": "Microsoft.AspNetCore.Hosting.IWebHostBuilder UseLoggerFactory(System.Func createLoggerFactory)", - "Kind": "Addition" - }, { "TypeId": "public interface Microsoft.AspNetCore.Hosting.IWebHost : System.IDisposable", "MemberId": "System.Threading.Tasks.Task StartAsync(System.Threading.CancellationToken cancellationToken)", @@ -38,5 +28,10 @@ "TypeId": "public interface Microsoft.AspNetCore.Hosting.IWebHostBuilder", "MemberId": "Microsoft.AspNetCore.Hosting.IWebHostBuilder ConfigureLogging(System.Action configureLogging)", "Kind": "Removal" - } -] \ No newline at end of file + }, + { + "TypeId": "public interface Microsoft.AspNetCore.Hosting.IWebHostBuilder", + "MemberId": "Microsoft.AspNetCore.Hosting.IWebHostBuilder UseLoggerFactory(Microsoft.Extensions.Logging.ILoggerFactory loggerFactory)", + "Kind": "Removal" + } +] diff --git a/src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs b/src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs index 7774de93ab..a2057f9480 100644 --- a/src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs +++ b/src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs @@ -26,13 +26,11 @@ namespace Microsoft.AspNetCore.Hosting { private readonly IHostingEnvironment _hostingEnvironment; private readonly List> _configureServicesDelegates; - private readonly List> _configureLoggingDelegates; private IConfiguration _config; private WebHostOptions _options; private WebHostBuilderContext _context; private bool _webHostBuilt; - private Func _createLoggerFactoryDelegate; private List> _configureAppConfigurationBuilderDelegates; /// @@ -42,7 +40,6 @@ namespace Microsoft.AspNetCore.Hosting { _hostingEnvironment = new HostingEnvironment(); _configureServicesDelegates = new List>(); - _configureLoggingDelegates = new List>(); _configureAppConfigurationBuilderDelegates = new List>(); _config = new ConfigurationBuilder() @@ -90,41 +87,6 @@ namespace Microsoft.AspNetCore.Hosting return this; } - /// - /// Specify the to be used by the web host. - /// - /// The to be used. - /// The . - public IWebHostBuilder UseLoggerFactory(ILoggerFactory loggerFactory) - { - if (loggerFactory == null) - { - throw new ArgumentNullException(nameof(loggerFactory)); - } - - return UseLoggerFactory(_ => loggerFactory); - } - - /// - /// Adds a delegate to construct the that will be registered - /// as a singleton and used by the application. - /// - /// The delegate that constructs an - /// The . - /// - /// The on the is uninitialized at this stage. - /// - public IWebHostBuilder UseLoggerFactory(Func createLoggerFactory) - { - if (createLoggerFactory == null) - { - throw new ArgumentNullException(nameof(createLoggerFactory)); - } - - _createLoggerFactoryDelegate = createLoggerFactory; - return this; - } - /// /// Adds a delegate for configuring additional services for the host or web application. This may be called /// multiple times. @@ -158,35 +120,6 @@ namespace Microsoft.AspNetCore.Hosting return this; } - /// - /// Adds a delegate for configuring the provided . This may be called multiple times. - /// - /// The delegate that configures the . - /// - /// The type of to configure. - /// The delegate will not execute if the type provided does not match the used by the . - /// - /// The . - /// - /// The on the is uninitialized at this stage. - /// - public IWebHostBuilder ConfigureLogging(Action configureLogging) where T : ILoggerFactory - { - if (configureLogging == null) - { - throw new ArgumentNullException(nameof(configureLogging)); - } - - _configureLoggingDelegates.Add((context, factory) => - { - if (factory is T typedFactory) - { - configureLogging(context, typedFactory); - } - }); - return this; - } - /// /// Adds a delegate for configuring the that will construct an . /// @@ -313,19 +246,6 @@ namespace Microsoft.AspNetCore.Hosting services.AddSingleton(configuration); _context.Configuration = configuration; - // The configured ILoggerFactory is added as a singleton here. AddLogging below will not add an additional one. - var loggerFactory = _createLoggerFactoryDelegate?.Invoke(_context) ?? new LoggerFactory(); - services.AddSingleton(loggerFactory); - _context.LoggerFactory = loggerFactory; - - foreach (var configureLogging in _configureLoggingDelegates) - { - configureLogging(_context, loggerFactory); - } - - //This is required to add ILogger of T. - services.AddLogging(); - var listener = new DiagnosticListener("Microsoft.AspNetCore"); services.AddSingleton(listener); services.AddSingleton(listener); @@ -334,6 +254,7 @@ namespace Microsoft.AspNetCore.Hosting services.AddTransient(); services.AddScoped(); services.AddOptions(); + services.AddLogging(); // Conjure up a RequestServices services.AddTransient(); @@ -387,9 +308,6 @@ namespace Microsoft.AspNetCore.Hosting // can still manage their lifetime (disposal) shared instances with application services. // NOTE: This code overrides original services lifetime. Instances would always be singleton in // application container. - var loggerFactory = hostingServiceProvider.GetService(); - services.Replace(ServiceDescriptor.Singleton(typeof(ILoggerFactory), loggerFactory)); - var listener = hostingServiceProvider.GetService(); services.Replace(ServiceDescriptor.Singleton(typeof(DiagnosticListener), listener)); services.Replace(ServiceDescriptor.Singleton(typeof(DiagnosticSource), listener)); diff --git a/src/Microsoft.AspNetCore.Hosting/WebHostBuilderExtensions.cs b/src/Microsoft.AspNetCore.Hosting/WebHostBuilderExtensions.cs index 213664bc80..8427d51e77 100644 --- a/src/Microsoft.AspNetCore.Hosting/WebHostBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Hosting/WebHostBuilderExtensions.cs @@ -111,11 +111,11 @@ namespace Microsoft.AspNetCore.Hosting /// Adds a delegate for configuring the provided . This may be called multiple times. /// /// The to configure. - /// The delegate that configures the . + /// The delegate that configures the . /// The . - public static IWebHostBuilder ConfigureLogging(this IWebHostBuilder hostBuilder, Action configureLogging) + public static IWebHostBuilder ConfigureLogging(this IWebHostBuilder hostBuilder, Action configureLogging) { - return hostBuilder.ConfigureLogging((_, loggerFactory) => configureLogging(loggerFactory)); + return hostBuilder.ConfigureServices(collection => collection.AddLogging(configureLogging)); } /// @@ -124,24 +124,9 @@ namespace Microsoft.AspNetCore.Hosting /// The to configure. /// The delegate that configures the . /// The . - public static IWebHostBuilder ConfigureLogging(this IWebHostBuilder hostBuilder, Action configureLogging) + public static IWebHostBuilder ConfigureLogging(this IWebHostBuilder hostBuilder, Action configureLogging) { - return hostBuilder.ConfigureLogging(configureLogging); - } - - /// - /// Adds a delegate for configuring the provided . This may be called multiple times. - /// - /// The to configure. - /// The delegate that configures the . - /// - /// The type of to configure. - /// The delegate will not execute if the type provided does not match the used by the . - /// - /// The . - public static IWebHostBuilder ConfigureLogging(this IWebHostBuilder hostBuilder, Action configureLogging) where T : ILoggerFactory - { - return hostBuilder.ConfigureLogging((_, factory) => configureLogging(factory)); + return hostBuilder.ConfigureServices((context, collection) => collection.AddLogging(builder => configureLogging(context, builder))); } } -} \ No newline at end of file +} diff --git a/src/Microsoft.AspNetCore.Hosting/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Hosting/breakingchanges.netcore.json index 82a7ed2205..31999ebef1 100644 --- a/src/Microsoft.AspNetCore.Hosting/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Hosting/breakingchanges.netcore.json @@ -12,5 +12,10 @@ "TypeId": "public static class Microsoft.AspNetCore.Hosting.WebHostExtensions", "MemberId": "public static System.Void Run(this Microsoft.AspNetCore.Hosting.IWebHost host, System.Threading.CancellationToken token)", "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Hosting.WebHostBuilder : Microsoft.AspNetCore.Hosting.IWebHostBuilder", + "MemberId": "public Microsoft.AspNetCore.Hosting.IWebHostBuilder UseLoggerFactory(Microsoft.Extensions.Logging.ILoggerFactory loggerFactory)", + "Kind": "Removal" } -] \ No newline at end of file +] diff --git a/test/Microsoft.AspNetCore.Hosting.TestSites/Program.cs b/test/Microsoft.AspNetCore.Hosting.TestSites/Program.cs index 191df6714d..d3e284aa09 100644 --- a/test/Microsoft.AspNetCore.Hosting.TestSites/Program.cs +++ b/test/Microsoft.AspNetCore.Hosting.TestSites/Program.cs @@ -7,7 +7,9 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Server; using Microsoft.AspNetCore.Http.Features; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Console; namespace ServerComparison.TestSites { @@ -25,7 +27,7 @@ namespace ServerComparison.TestSites .ConfigureLogging((_, factory) => { factory.AddConsole(); - factory.AddFilter("Console", level => level >= LogLevel.Warning); + factory.AddFilter(level => level >= LogLevel.Warning); }) .UseStartup("Microsoft.AspNetCore.Hosting.TestSites"); diff --git a/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs b/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs index 9e33f7822d..3f1d4dc088 100644 --- a/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs +++ b/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs @@ -205,7 +205,6 @@ namespace Microsoft.AspNetCore.Hosting { Assert.NotNull(context.HostingEnvironment); Assert.NotNull(context.Configuration); - Assert.NotNull(context.LoggerFactory); configurationCallbackCalled = true; options.ValidateScopes = true; }); @@ -214,22 +213,6 @@ namespace Microsoft.AspNetCore.Hosting Assert.True(configurationCallbackCalled); } - [Fact] - public void UseLoggerFactoryHonored() - { - var loggerFactory = new LoggerFactory(); - - var hostBuilder = new WebHostBuilder() - .UseLoggerFactory(loggerFactory) - .UseServer(new TestServer()) - .UseStartup(); - - using (var host = (WebHost)hostBuilder.Build()) - { - Assert.Same(loggerFactory, host.Services.GetService()); - } - } - [Fact] public void MultipleConfigureLoggingInvokedInOrder() { @@ -252,46 +235,6 @@ namespace Microsoft.AspNetCore.Hosting } } - [Fact] - public void UseLoggerFactoryDelegateIsHonored() - { - var loggerFactory = new LoggerFactory(); - - var hostBuilder = new WebHostBuilder() - .UseLoggerFactory(_ => loggerFactory) - .UseServer(new TestServer()) - .UseStartup(); - - using (var host = (WebHost)hostBuilder.Build()) - { - Assert.Same(loggerFactory, host.Services.GetService()); - } - } - - [Fact] - public void UseLoggerFactoryFuncAndConfigureLoggingCompose() - { - var callCount = 0; //Verify that multiple configureLogging calls still compose correctly. - var loggerFactory = new LoggerFactory(); - var hostBuilder = new WebHostBuilder() - .UseLoggerFactory(_ => loggerFactory) - .ConfigureLogging(factory => - { - Assert.Equal(0, callCount++); - }) - .ConfigureLogging(factory => - { - Assert.Equal(1, callCount++); - }) - .UseServer(new TestServer()) - .UseStartup(); - using (var host = (WebHost)hostBuilder.Build()) - { - Assert.Equal(2, callCount); - Assert.Same(loggerFactory, host.Services.GetService()); - } - } - [Fact] public void HostingContextContainsAppConfigurationDuringConfigureLogging() { @@ -332,62 +275,6 @@ namespace Microsoft.AspNetCore.Hosting using (hostBuilder.Build()) { } } - [Fact] - public void ConfigureLoggingCalledIfLoggerFactoryTypeMatches() - { - var callCount = 0; - var hostBuilder = new WebHostBuilder() - .UseLoggerFactory(_ => new SubLoggerFactory()) - .ConfigureLogging(factory => - { - Assert.Equal(0, callCount++); - }) - .UseServer(new TestServer()) - .UseStartup(); - - using (hostBuilder.Build()) - { - Assert.Equal(1, callCount); - } - } - - [Fact] - public void ConfigureLoggingNotCalledIfLoggerFactoryTypeDoesNotMatches() - { - var callCount = 0; - var hostBuilder = new WebHostBuilder() - .UseLoggerFactory(_ => new NonSubLoggerFactory()) - .ConfigureLogging(factory => - { - Assert.Equal(0, callCount++); - }) - .UseServer(new TestServer()) - .UseStartup(); - - using (hostBuilder.Build()) - { - Assert.Equal(0, callCount); - } - } - - [Fact] - public void CanUseCustomLoggerFactory() - { - var hostBuilder = new WebHostBuilder() - .UseLoggerFactory(_ => new CustomLoggerFactory()) - .ConfigureLogging(factory => - { - factory.CustomConfigureMethod(); - }) - .UseServer(new TestServer()) - .UseStartup(); - - using (var host = (WebHost)hostBuilder.Build()) - { - Assert.IsType(typeof(CustomLoggerFactory), host.Services.GetService()); - } - } - [Fact] public void ThereIsAlwaysConfiguration() { @@ -794,52 +681,6 @@ namespace Microsoft.AspNetCore.Hosting } } - [Fact] - public void Build_PassesSameAutoCreatedILoggerFactoryEverywhere() - { - var builder = CreateWebHostBuilder(); - var server = new TestServer(); - using (var host = builder.UseServer(server) - .UseStartup() - .Build()) - { - var startup = host.Services.GetService(); - Assert.Equal(startup.ConfigureLoggerFactory, startup.ConstructorLoggerFactory); - } - } - - [Fact] - public void Build_PassesSamePassedILoggerFactoryEverywhere() - { - var factory = new LoggerFactory(); - var builder = CreateWebHostBuilder(); - var server = new TestServer(); - using (var host = builder.UseServer(server) - .UseLoggerFactory(factory) - .UseStartup() - .Build()) - { - var startup = host.Services.GetService(); - Assert.Equal(factory, startup.ConfigureLoggerFactory); - Assert.Equal(factory, startup.ConstructorLoggerFactory); - } - } - - [Fact] - public void Build_PassedILoggerFactoryNotDisposed() - { - var factory = new DisposableLoggerFactory(); - var builder = CreateWebHostBuilder(); - var server = new TestServer(); - - using (var host = builder.UseServer(server) - .UseLoggerFactory(factory) - .UseStartup() - .Build()) { } - - Assert.False(factory.Disposed); - } - [Fact] public void Build_DoesNotOverrideILoggerFactorySetByConfigureServices() { From 5e2bb55be0b4b6c83bdaba792447e4ea37c2a309 Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 31 May 2017 12:47:38 -0700 Subject: [PATCH 2/2] Change Certificates.Configuration to a Sources package --- Hosting.sln | 15 --------------- NuGetPackageVerifier.json | 1 + .../CertificateFileLoader.cs | 0 .../CertificateLoader.cs | 11 ++++++----- .../CertificateStoreLoader.cs | 2 +- .../ICertificateFileLoader.cs | 0 .../ICertificateStoreLoader.cs | 0 ...AspNetCore.Certificates.Configuration.csproj | 17 ----------------- ...Core.Certificates.Configuration.Tests.csproj | 4 +++- .../Properties/AssemblyInfo.cs | 1 - 10 files changed, 11 insertions(+), 40 deletions(-) rename {src/Microsoft.AspNetCore.Certificates.Configuration => shared/Microsoft.AspNetCore.Certificates.Configuration.Sources}/CertificateFileLoader.cs (100%) rename {src/Microsoft.AspNetCore.Certificates.Configuration => shared/Microsoft.AspNetCore.Certificates.Configuration.Sources}/CertificateLoader.cs (95%) rename {src/Microsoft.AspNetCore.Certificates.Configuration => shared/Microsoft.AspNetCore.Certificates.Configuration.Sources}/CertificateStoreLoader.cs (97%) rename {src/Microsoft.AspNetCore.Certificates.Configuration => shared/Microsoft.AspNetCore.Certificates.Configuration.Sources}/ICertificateFileLoader.cs (100%) rename {src/Microsoft.AspNetCore.Certificates.Configuration => shared/Microsoft.AspNetCore.Certificates.Configuration.Sources}/ICertificateStoreLoader.cs (100%) delete mode 100644 src/Microsoft.AspNetCore.Certificates.Configuration/Microsoft.AspNetCore.Certificates.Configuration.csproj rename {src/Microsoft.AspNetCore.Certificates.Configuration => test/Microsoft.AspNetCore.Certificates.Configuration.Tests}/Properties/AssemblyInfo.cs (58%) diff --git a/Hosting.sln b/Hosting.sln index f61f83d717..e89e3ecc6a 100644 --- a/Hosting.sln +++ b/Hosting.sln @@ -34,8 +34,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Hostin EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Hosting.WindowsServices", "src\Microsoft.AspNetCore.Hosting.WindowsServices\Microsoft.AspNetCore.Hosting.WindowsServices.csproj", "{9C93A93B-270A-4785-8F41-46C38DC33825}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Certificates.Configuration", "src\Microsoft.AspNetCore.Certificates.Configuration\Microsoft.AspNetCore.Certificates.Configuration.csproj", "{A911A891-EAC5-4AA1-B17E-B83A1BB1E8B4}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Certificates.Configuration.Tests", "test\Microsoft.AspNetCore.Certificates.Configuration.Tests\Microsoft.AspNetCore.Certificates.Configuration.Tests.csproj", "{AB0B7394-278D-4838-A59C-276ED88D00CC}" EndProject Global @@ -196,18 +194,6 @@ Global {9C93A93B-270A-4785-8F41-46C38DC33825}.Release|Mixed Platforms.Build.0 = Release|Any CPU {9C93A93B-270A-4785-8F41-46C38DC33825}.Release|x86.ActiveCfg = Release|Any CPU {9C93A93B-270A-4785-8F41-46C38DC33825}.Release|x86.Build.0 = Release|Any CPU - {A911A891-EAC5-4AA1-B17E-B83A1BB1E8B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A911A891-EAC5-4AA1-B17E-B83A1BB1E8B4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A911A891-EAC5-4AA1-B17E-B83A1BB1E8B4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {A911A891-EAC5-4AA1-B17E-B83A1BB1E8B4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {A911A891-EAC5-4AA1-B17E-B83A1BB1E8B4}.Debug|x86.ActiveCfg = Debug|Any CPU - {A911A891-EAC5-4AA1-B17E-B83A1BB1E8B4}.Debug|x86.Build.0 = Debug|Any CPU - {A911A891-EAC5-4AA1-B17E-B83A1BB1E8B4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A911A891-EAC5-4AA1-B17E-B83A1BB1E8B4}.Release|Any CPU.Build.0 = Release|Any CPU - {A911A891-EAC5-4AA1-B17E-B83A1BB1E8B4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {A911A891-EAC5-4AA1-B17E-B83A1BB1E8B4}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {A911A891-EAC5-4AA1-B17E-B83A1BB1E8B4}.Release|x86.ActiveCfg = Release|Any CPU - {A911A891-EAC5-4AA1-B17E-B83A1BB1E8B4}.Release|x86.Build.0 = Release|Any CPU {AB0B7394-278D-4838-A59C-276ED88D00CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AB0B7394-278D-4838-A59C-276ED88D00CC}.Debug|Any CPU.Build.0 = Debug|Any CPU {AB0B7394-278D-4838-A59C-276ED88D00CC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -238,7 +224,6 @@ Global {39D3B138-37DB-4D03-A5A0-3F2B02EFC671} = {FEB39027-9158-4DE2-997F-7ADAEF8188D0} {96BC7EEA-64D9-4DA5-8E87-1C18CBFE7D12} = {E0497F39-AFFB-4819-A116-E39E361915AB} {9C93A93B-270A-4785-8F41-46C38DC33825} = {E0497F39-AFFB-4819-A116-E39E361915AB} - {A911A891-EAC5-4AA1-B17E-B83A1BB1E8B4} = {E0497F39-AFFB-4819-A116-E39E361915AB} {AB0B7394-278D-4838-A59C-276ED88D00CC} = {FEB39027-9158-4DE2-997F-7ADAEF8188D0} EndGlobalSection EndGlobal diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index cfea4cf163..48868ff057 100644 --- a/NuGetPackageVerifier.json +++ b/NuGetPackageVerifier.json @@ -4,6 +4,7 @@ // Don't run any rules for packages that don't ship. ], "packages": { + "Microsoft.AspNetCore.Certificates.Configuration.Sources": {}, "Microsoft.AspNetCore.Server.IntegrationTesting": {} } }, diff --git a/src/Microsoft.AspNetCore.Certificates.Configuration/CertificateFileLoader.cs b/shared/Microsoft.AspNetCore.Certificates.Configuration.Sources/CertificateFileLoader.cs similarity index 100% rename from src/Microsoft.AspNetCore.Certificates.Configuration/CertificateFileLoader.cs rename to shared/Microsoft.AspNetCore.Certificates.Configuration.Sources/CertificateFileLoader.cs diff --git a/src/Microsoft.AspNetCore.Certificates.Configuration/CertificateLoader.cs b/shared/Microsoft.AspNetCore.Certificates.Configuration.Sources/CertificateLoader.cs similarity index 95% rename from src/Microsoft.AspNetCore.Certificates.Configuration/CertificateLoader.cs rename to shared/Microsoft.AspNetCore.Certificates.Configuration.Sources/CertificateLoader.cs index 03c2f8885f..83c786344c 100644 --- a/src/Microsoft.AspNetCore.Certificates.Configuration/CertificateLoader.cs +++ b/shared/Microsoft.AspNetCore.Certificates.Configuration.Sources/CertificateLoader.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration /// /// A helper class to load certificates from files and certificate stores based on data. /// - public class CertificateLoader + internal class CertificateLoader { private readonly IConfiguration _certificatesConfiguration; private readonly string _environmentName; @@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration /// Creates a new instance of that can load certificate references from configuration. /// /// An with information about certificates. - public CertificateLoader(IConfiguration certificatesConfiguration) + internal CertificateLoader(IConfiguration certificatesConfiguration) : this(certificatesConfiguration, null, null) { } @@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration /// /// An with information about certificates. /// An instance. - public CertificateLoader(IConfiguration certificatesConfiguration, ILoggerFactory loggerFactory) + internal CertificateLoader(IConfiguration certificatesConfiguration, ILoggerFactory loggerFactory) : this(certificatesConfiguration, loggerFactory, null) { } @@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration /// An with information about certificates. /// An instance. /// The name of the environment the application is running in. - public CertificateLoader(IConfiguration certificatesConfiguration, ILoggerFactory loggerFactory, string environmentName) + internal CertificateLoader(IConfiguration certificatesConfiguration, ILoggerFactory loggerFactory, string environmentName) : this(certificatesConfiguration, loggerFactory, environmentName, new CertificateFileLoader(), new CertificateStoreLoader()) { } @@ -72,7 +72,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration /// by name, or one or more inline certificate specifications. /// /// One or more loaded certificates. - public IEnumerable Load(IConfigurationSection certificateConfiguration) + internal IEnumerable Load(IConfigurationSection certificateConfiguration) { var certificateNames = certificateConfiguration.Value; var certificates = new List(); @@ -182,6 +182,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration #if NETCOREAPP2_0 ?? TryLoad(X509KeyStorageFlags.EphemeralKeySet, out error) #elif NETSTANDARD2_0 +#elif NET461 #else #error target frameworks need to be updated #endif diff --git a/src/Microsoft.AspNetCore.Certificates.Configuration/CertificateStoreLoader.cs b/shared/Microsoft.AspNetCore.Certificates.Configuration.Sources/CertificateStoreLoader.cs similarity index 97% rename from src/Microsoft.AspNetCore.Certificates.Configuration/CertificateStoreLoader.cs rename to shared/Microsoft.AspNetCore.Certificates.Configuration.Sources/CertificateStoreLoader.cs index 1329fd4475..c5af4e3fb6 100644 --- a/src/Microsoft.AspNetCore.Certificates.Configuration/CertificateStoreLoader.cs +++ b/shared/Microsoft.AspNetCore.Certificates.Configuration.Sources/CertificateStoreLoader.cs @@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration /// /// Loads certificates from certificate stores. /// - public class CertificateStoreLoader : ICertificateStoreLoader + internal class CertificateStoreLoader : ICertificateStoreLoader { /// /// Load a ceritificate from the given store location. diff --git a/src/Microsoft.AspNetCore.Certificates.Configuration/ICertificateFileLoader.cs b/shared/Microsoft.AspNetCore.Certificates.Configuration.Sources/ICertificateFileLoader.cs similarity index 100% rename from src/Microsoft.AspNetCore.Certificates.Configuration/ICertificateFileLoader.cs rename to shared/Microsoft.AspNetCore.Certificates.Configuration.Sources/ICertificateFileLoader.cs diff --git a/src/Microsoft.AspNetCore.Certificates.Configuration/ICertificateStoreLoader.cs b/shared/Microsoft.AspNetCore.Certificates.Configuration.Sources/ICertificateStoreLoader.cs similarity index 100% rename from src/Microsoft.AspNetCore.Certificates.Configuration/ICertificateStoreLoader.cs rename to shared/Microsoft.AspNetCore.Certificates.Configuration.Sources/ICertificateStoreLoader.cs diff --git a/src/Microsoft.AspNetCore.Certificates.Configuration/Microsoft.AspNetCore.Certificates.Configuration.csproj b/src/Microsoft.AspNetCore.Certificates.Configuration/Microsoft.AspNetCore.Certificates.Configuration.csproj deleted file mode 100644 index 5275d54e04..0000000000 --- a/src/Microsoft.AspNetCore.Certificates.Configuration/Microsoft.AspNetCore.Certificates.Configuration.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - netcoreapp2.0;netstandard2.0 - aspnetcore;certificates - Helpers for loading certificates from configuration. - true - - - - - - - - diff --git a/test/Microsoft.AspNetCore.Certificates.Configuration.Tests/Microsoft.AspNetCore.Certificates.Configuration.Tests.csproj b/test/Microsoft.AspNetCore.Certificates.Configuration.Tests/Microsoft.AspNetCore.Certificates.Configuration.Tests.csproj index a72b7d129d..71f5753dc5 100644 --- a/test/Microsoft.AspNetCore.Certificates.Configuration.Tests/Microsoft.AspNetCore.Certificates.Configuration.Tests.csproj +++ b/test/Microsoft.AspNetCore.Certificates.Configuration.Tests/Microsoft.AspNetCore.Certificates.Configuration.Tests.csproj @@ -19,10 +19,12 @@ - + + + diff --git a/src/Microsoft.AspNetCore.Certificates.Configuration/Properties/AssemblyInfo.cs b/test/Microsoft.AspNetCore.Certificates.Configuration.Tests/Properties/AssemblyInfo.cs similarity index 58% rename from src/Microsoft.AspNetCore.Certificates.Configuration/Properties/AssemblyInfo.cs rename to test/Microsoft.AspNetCore.Certificates.Configuration.Tests/Properties/AssemblyInfo.cs index 61148132fc..3337ebeac2 100644 --- a/src/Microsoft.AspNetCore.Certificates.Configuration/Properties/AssemblyInfo.cs +++ b/test/Microsoft.AspNetCore.Certificates.Configuration.Tests/Properties/AssemblyInfo.cs @@ -3,5 +3,4 @@ using System.Runtime.CompilerServices; -[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Certificates.Configuration.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] \ No newline at end of file