Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Commit

Permalink
Merge branch 'rel/2.0.0-preview2' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Tratcher committed Jun 2, 2017
2 parents 5bcc76d + 5e2bb55 commit a2962d5
Show file tree
Hide file tree
Showing 18 changed files with 34 additions and 354 deletions.
15 changes: 0 additions & 15 deletions Hosting.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions NuGetPackageVerifier.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration
/// <summary>
/// A helper class to load certificates from files and certificate stores based on <seealso cref="IConfiguration"/> data.
/// </summary>
public class CertificateLoader
internal class CertificateLoader
{
private readonly IConfiguration _certificatesConfiguration;
private readonly string _environmentName;
Expand All @@ -25,7 +25,7 @@ public class CertificateLoader
/// Creates a new instance of <see cref="CertificateLoader"/> that can load certificate references from configuration.
/// </summary>
/// <param name="certificatesConfiguration">An <see cref="IConfiguration"/> with information about certificates.</param>
public CertificateLoader(IConfiguration certificatesConfiguration)
internal CertificateLoader(IConfiguration certificatesConfiguration)
: this(certificatesConfiguration, null, null)
{
}
Expand All @@ -35,7 +35,7 @@ public CertificateLoader(IConfiguration certificatesConfiguration)
/// </summary>
/// <param name="certificatesConfiguration">An <see cref="IConfiguration"/> with information about certificates.</param>
/// <param name="loggerFactory">An <see cref="ILoggerFactory"/> instance.</param>
public CertificateLoader(IConfiguration certificatesConfiguration, ILoggerFactory loggerFactory)
internal CertificateLoader(IConfiguration certificatesConfiguration, ILoggerFactory loggerFactory)
: this(certificatesConfiguration, loggerFactory, null)
{
}
Expand All @@ -46,7 +46,7 @@ public CertificateLoader(IConfiguration certificatesConfiguration, ILoggerFactor
/// <param name="certificatesConfiguration">An <see cref="IConfiguration"/> with information about certificates.</param>
/// <param name="loggerFactory">An <see cref="ILoggerFactory"/> instance.</param>
/// <param name="environmentName">The name of the environment the application is running in.</param>
public CertificateLoader(IConfiguration certificatesConfiguration, ILoggerFactory loggerFactory, string environmentName)
internal CertificateLoader(IConfiguration certificatesConfiguration, ILoggerFactory loggerFactory, string environmentName)
: this(certificatesConfiguration, loggerFactory, environmentName, new CertificateFileLoader(), new CertificateStoreLoader())
{
}
Expand All @@ -72,7 +72,7 @@ internal CertificateLoader(
/// by name, or one or more inline certificate specifications.
/// </param>
/// <returns>One or more loaded certificates.</returns>
public IEnumerable<X509Certificate2> Load(IConfigurationSection certificateConfiguration)
internal IEnumerable<X509Certificate2> Load(IConfigurationSection certificateConfiguration)
{
var certificateNames = certificateConfiguration.Value;
var certificates = new List<X509Certificate2>();
Expand Down Expand Up @@ -182,6 +182,7 @@ public override X509Certificate2 Load()
#if NETCOREAPP2_0
?? TryLoad(X509KeyStorageFlags.EphemeralKeySet, out error)
#elif NETSTANDARD2_0
#elif NET461
#else
#error target frameworks need to be updated
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration
/// <summary>
/// Loads certificates from certificate stores.
/// </summary>
public class CertificateStoreLoader : ICertificateStoreLoader
internal class CertificateStoreLoader : ICertificateStoreLoader
{
/// <summary>
/// Load a ceritificate from the given store location.
Expand Down

This file was deleted.

32 changes: 0 additions & 32 deletions src/Microsoft.AspNetCore.Hosting.Abstractions/IWebHostBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,6 @@ public interface IWebHostBuilder
/// </remarks>
IWebHostBuilder ConfigureAppConfiguration(Action<WebHostBuilderContext, IConfigurationBuilder> configureDelegate);

/// <summary>
/// Adds a delegate for configuring the provided <see cref="ILoggerFactory"/>. This may be called multiple times.
/// </summary>
/// <param name="configureLogging">The delegate that configures the <see cref="ILoggerFactory"/>.</param>
/// <typeparam name="T">
/// The type of <see cref="ILoggerFactory"/> to configure.
/// The delegate will not execute if the type provided does not match the <see cref="ILoggerFactory"/> used by the <see cref="IWebHostBuilder"/>.
/// </typeparam>
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
/// <remarks>
/// The <see cref="ILoggerFactory"/> on the <see cref="WebHostBuilderContext"/> is uninitialized at this stage.
/// </remarks>
IWebHostBuilder ConfigureLogging<T>(Action<WebHostBuilderContext, T> configureLogging) where T : ILoggerFactory;

/// <summary>
/// Adds a delegate for configuring additional services for the host or web application. This may be called
/// multiple times.
Expand Down Expand Up @@ -73,23 +59,5 @@ public interface IWebHostBuilder
/// <param name="value">The value of the setting to add or replace.</param>
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
IWebHostBuilder UseSetting(string key, string value);

/// <summary>
/// Specify the <see cref="ILoggerFactory"/> to be used by the web host.
/// </summary>
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/> to be used.</param>
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
IWebHostBuilder UseLoggerFactory(ILoggerFactory loggerFactory);

/// <summary>
/// Adds a delegate to construct the <see cref="ILoggerFactory"/> that will be registered
/// as a singleton and used by the application.
/// </summary>
/// <param name="createLoggerFactory">The delegate that constructs an <see cref="IConfigurationBuilder" /></param>
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
/// <remarks>
/// The <see cref="ILoggerFactory"/> on the <see cref="WebHostBuilderContext"/> is uninitialized at this stage.
/// </remarks>
IWebHostBuilder UseLoggerFactory(Func<WebHostBuilderContext, ILoggerFactory> createLoggerFactory);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,5 @@ public class WebHostBuilderContext
/// The <see cref="IConfiguration" /> containing the merged configuration of the application and the <see cref="IWebHost" />.
/// </summary>
public IConfiguration Configuration { get; set; }

/// <summary>
/// The <see cref="ILoggerFactory" /> configured on the <see cref="IWebHost" />.
/// </summary>
public ILoggerFactory LoggerFactory { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,11 @@
"MemberId": "Microsoft.AspNetCore.Hosting.IWebHostBuilder ConfigureAppConfiguration(System.Action<Microsoft.AspNetCore.Hosting.WebHostBuilderContext, Microsoft.Extensions.Configuration.IConfigurationBuilder> configureDelegate)",
"Kind": "Addition"
},
{
"TypeId": "public interface Microsoft.AspNetCore.Hosting.IWebHostBuilder",
"MemberId": "Microsoft.AspNetCore.Hosting.IWebHostBuilder ConfigureLogging<T0>(System.Action<Microsoft.AspNetCore.Hosting.WebHostBuilderContext, T0> configureLogging) where T0 : Microsoft.Extensions.Logging.ILoggerFactory",
"Kind": "Addition"
},
{
"TypeId": "public interface Microsoft.AspNetCore.Hosting.IWebHostBuilder",
"MemberId": "Microsoft.AspNetCore.Hosting.IWebHostBuilder ConfigureServices(System.Action<Microsoft.AspNetCore.Hosting.WebHostBuilderContext, Microsoft.Extensions.DependencyInjection.IServiceCollection> configureServices)",
"Kind": "Addition"
},
{
"TypeId": "public interface Microsoft.AspNetCore.Hosting.IWebHostBuilder",
"MemberId": "Microsoft.AspNetCore.Hosting.IWebHostBuilder UseLoggerFactory(System.Func<Microsoft.AspNetCore.Hosting.WebHostBuilderContext, Microsoft.Extensions.Logging.ILoggerFactory> createLoggerFactory)",
"Kind": "Addition"
},
{
"TypeId": "public interface Microsoft.AspNetCore.Hosting.IWebHost : System.IDisposable",
"MemberId": "System.Threading.Tasks.Task StartAsync(System.Threading.CancellationToken cancellationToken)",
Expand All @@ -38,5 +28,10 @@
"TypeId": "public interface Microsoft.AspNetCore.Hosting.IWebHostBuilder",
"MemberId": "Microsoft.AspNetCore.Hosting.IWebHostBuilder ConfigureLogging(System.Action<Microsoft.Extensions.Logging.ILoggerFactory> configureLogging)",
"Kind": "Removal"
}
]
},
{
"TypeId": "public interface Microsoft.AspNetCore.Hosting.IWebHostBuilder",
"MemberId": "Microsoft.AspNetCore.Hosting.IWebHostBuilder UseLoggerFactory(Microsoft.Extensions.Logging.ILoggerFactory loggerFactory)",
"Kind": "Removal"
}
]
84 changes: 1 addition & 83 deletions src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ public class WebHostBuilder : IWebHostBuilder
{
private readonly IHostingEnvironment _hostingEnvironment;
private readonly List<Action<WebHostBuilderContext, IServiceCollection>> _configureServicesDelegates;
private readonly List<Action<WebHostBuilderContext, ILoggerFactory>> _configureLoggingDelegates;

private IConfiguration _config;
private WebHostOptions _options;
private WebHostBuilderContext _context;
private bool _webHostBuilt;
private Func<WebHostBuilderContext, ILoggerFactory> _createLoggerFactoryDelegate;
private List<Action<WebHostBuilderContext, IConfigurationBuilder>> _configureAppConfigurationBuilderDelegates;

/// <summary>
Expand All @@ -41,7 +39,6 @@ public WebHostBuilder()
{
_hostingEnvironment = new HostingEnvironment();
_configureServicesDelegates = new List<Action<WebHostBuilderContext, IServiceCollection>>();
_configureLoggingDelegates = new List<Action<WebHostBuilderContext, ILoggerFactory>>();
_configureAppConfigurationBuilderDelegates = new List<Action<WebHostBuilderContext, IConfigurationBuilder>>();

_config = new ConfigurationBuilder()
Expand Down Expand Up @@ -89,41 +86,6 @@ public IWebHostBuilder UseSetting(string key, string value)
return this;
}

/// <summary>
/// Specify the <see cref="ILoggerFactory"/> to be used by the web host.
/// </summary>
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/> to be used.</param>
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
public IWebHostBuilder UseLoggerFactory(ILoggerFactory loggerFactory)
{
if (loggerFactory == null)
{
throw new ArgumentNullException(nameof(loggerFactory));
}

return UseLoggerFactory(_ => loggerFactory);
}

/// <summary>
/// Adds a delegate to construct the <see cref="ILoggerFactory"/> that will be registered
/// as a singleton and used by the application.
/// </summary>
/// <param name="createLoggerFactory">The delegate that constructs an <see cref="IConfigurationBuilder" /></param>
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
/// <remarks>
/// The <see cref="ILoggerFactory"/> on the <see cref="WebHostBuilderContext"/> is uninitialized at this stage.
/// </remarks>
public IWebHostBuilder UseLoggerFactory(Func<WebHostBuilderContext, ILoggerFactory> createLoggerFactory)
{
if (createLoggerFactory == null)
{
throw new ArgumentNullException(nameof(createLoggerFactory));
}

_createLoggerFactoryDelegate = createLoggerFactory;
return this;
}

/// <summary>
/// Adds a delegate for configuring additional services for the host or web application. This may be called
/// multiple times.
Expand Down Expand Up @@ -157,35 +119,6 @@ public IWebHostBuilder ConfigureServices(Action<WebHostBuilderContext, IServiceC
return this;
}

/// <summary>
/// Adds a delegate for configuring the provided <see cref="ILoggerFactory"/>. This may be called multiple times.
/// </summary>
/// <param name="configureLogging">The delegate that configures the <see cref="ILoggerFactory"/>.</param>
/// <typeparam name="T">
/// The type of <see cref="ILoggerFactory"/> to configure.
/// The delegate will not execute if the type provided does not match the <see cref="ILoggerFactory"/> used by the <see cref="IWebHostBuilder"/>.
/// </typeparam>
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
/// <remarks>
/// The <see cref="ILoggerFactory"/> on the <see cref="WebHostBuilderContext"/> is uninitialized at this stage.
/// </remarks>
public IWebHostBuilder ConfigureLogging<T>(Action<WebHostBuilderContext, T> 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;
}

/// <summary>
/// Adds a delegate for configuring the <see cref="IConfigurationBuilder"/> that will construct an <see cref="IConfiguration"/>.
/// </summary>
Expand Down Expand Up @@ -311,19 +244,6 @@ private IServiceCollection BuildCommonServices(out AggregateException hostingSta
services.AddSingleton<IConfiguration>(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<DiagnosticListener>(listener);
services.AddSingleton<DiagnosticSource>(listener);
Expand All @@ -332,6 +252,7 @@ private IServiceCollection BuildCommonServices(out AggregateException hostingSta
services.AddTransient<IHttpContextFactory, HttpContextFactory>();
services.AddScoped<IMiddlewareFactory, MiddlewareFactory>();
services.AddOptions();
services.AddLogging();

// Conjure up a RequestServices
services.AddTransient<IStartupFilter, AutoRequestServicesStartupFilter>();
Expand Down Expand Up @@ -385,9 +306,6 @@ private void AddApplicationServices(IServiceCollection services, IServiceProvide
// 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<ILoggerFactory>();
services.Replace(ServiceDescriptor.Singleton(typeof(ILoggerFactory), loggerFactory));

var listener = hostingServiceProvider.GetService<DiagnosticListener>();
services.Replace(ServiceDescriptor.Singleton(typeof(DiagnosticListener), listener));
services.Replace(ServiceDescriptor.Singleton(typeof(DiagnosticSource), listener));
Expand Down
Loading

0 comments on commit a2962d5

Please sign in to comment.