Merge branch 'rel/2.0.0-preview2' into dev

This commit is contained in:
Chris R 2017-06-02 12:23:47 -07:00
commit a2962d54f1
18 changed files with 34 additions and 354 deletions

View File

@ -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

View File

@ -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": {}
}
},

View File

@ -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;
@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration
/// 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)
{
}
@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration
/// </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)
{
}
@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration
/// <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())
{
}
@ -72,7 +72,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration
/// 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>();
@ -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

View File

@ -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.

View File

@ -1,17 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;netstandard2.0</TargetFrameworks>
<PackageTags>aspnetcore;certificates</PackageTags>
<Description>Helpers for loading certificates from configuration.</Description>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(AspNetCoreVersion)" />
</ItemGroup>
</Project>

View File

@ -29,20 +29,6 @@ namespace Microsoft.AspNetCore.Hosting
/// </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.
@ -73,23 +59,5 @@ namespace Microsoft.AspNetCore.Hosting
/// <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);
}
}

View File

@ -20,10 +20,5 @@ namespace Microsoft.AspNetCore.Hosting
/// 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; }
}
}

View File

@ -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)",
@ -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"
}
]

View File

@ -25,13 +25,11 @@ namespace Microsoft.AspNetCore.Hosting
{
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>
@ -41,7 +39,6 @@ namespace Microsoft.AspNetCore.Hosting
{
_hostingEnvironment = new HostingEnvironment();
_configureServicesDelegates = new List<Action<WebHostBuilderContext, IServiceCollection>>();
_configureLoggingDelegates = new List<Action<WebHostBuilderContext, ILoggerFactory>>();
_configureAppConfigurationBuilderDelegates = new List<Action<WebHostBuilderContext, IConfigurationBuilder>>();
_config = new ConfigurationBuilder()
@ -89,41 +86,6 @@ namespace Microsoft.AspNetCore.Hosting
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.
@ -157,35 +119,6 @@ namespace Microsoft.AspNetCore.Hosting
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>
@ -311,19 +244,6 @@ namespace Microsoft.AspNetCore.Hosting
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);
@ -332,6 +252,7 @@ namespace Microsoft.AspNetCore.Hosting
services.AddTransient<IHttpContextFactory, HttpContextFactory>();
services.AddScoped<IMiddlewareFactory, MiddlewareFactory>();
services.AddOptions();
services.AddLogging();
// Conjure up a RequestServices
services.AddTransient<IStartupFilter, AutoRequestServicesStartupFilter>();
@ -385,9 +306,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<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));

View File

@ -111,11 +111,11 @@ namespace Microsoft.AspNetCore.Hosting
/// Adds a delegate for configuring the provided <see cref="LoggerFactory"/>. This may be called multiple times.
/// </summary>
/// <param name="hostBuilder">The <see cref="IWebHostBuilder" /> to configure.</param>
/// <param name="configureLogging">The delegate that configures the <see cref="LoggerFactory"/>.</param>
/// <param name="configureLogging">The delegate that configures the <see cref="ILoggingBuilder"/>.</param>
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
public static IWebHostBuilder ConfigureLogging(this IWebHostBuilder hostBuilder, Action<LoggerFactory> configureLogging)
public static IWebHostBuilder ConfigureLogging(this IWebHostBuilder hostBuilder, Action<ILoggingBuilder> configureLogging)
{
return hostBuilder.ConfigureLogging<LoggerFactory>((_, loggerFactory) => configureLogging(loggerFactory));
return hostBuilder.ConfigureServices(collection => collection.AddLogging(configureLogging));
}
/// <summary>
@ -124,24 +124,9 @@ namespace Microsoft.AspNetCore.Hosting
/// <param name="hostBuilder">The <see cref="IWebHostBuilder" /> to configure.</param>
/// <param name="configureLogging">The delegate that configures the <see cref="LoggerFactory"/>.</param>
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
public static IWebHostBuilder ConfigureLogging(this IWebHostBuilder hostBuilder, Action<WebHostBuilderContext, LoggerFactory> configureLogging)
public static IWebHostBuilder ConfigureLogging(this IWebHostBuilder hostBuilder, Action<WebHostBuilderContext, ILoggingBuilder> configureLogging)
{
return hostBuilder.ConfigureLogging(configureLogging);
}
/// <summary>
/// Adds a delegate for configuring the provided <see cref="ILoggerFactory"/>. This may be called multiple times.
/// </summary>
/// <param name="hostBuilder">The <see cref="IWebHostBuilder" /> to configure.</param>
/// <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>
public static IWebHostBuilder ConfigureLogging<T>(this IWebHostBuilder hostBuilder, Action<T> configureLogging) where T : ILoggerFactory
{
return hostBuilder.ConfigureLogging<T>((_, factory) => configureLogging(factory));
return hostBuilder.ConfigureServices((context, collection) => collection.AddLogging(builder => configureLogging(context, builder)));
}
}
}
}

View File

@ -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"
}
]
]

View File

@ -19,10 +19,12 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Certificates.Configuration\Microsoft.AspNetCore.Certificates.Configuration.csproj" />
<Compile Include="..\..\shared\Microsoft.AspNetCore.Certificates.Configuration.Sources\**\*.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
<PackageReference Include="Moq" Version="$(MoqVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />

View File

@ -3,5 +3,4 @@
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Certificates.Configuration.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]

View File

@ -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<ConsoleLoggerProvider>(level => level >= LogLevel.Warning);
})
.UseStartup("Microsoft.AspNetCore.Hosting.TestSites");

View File

@ -204,7 +204,6 @@ namespace Microsoft.AspNetCore.Hosting
{
Assert.NotNull(context.HostingEnvironment);
Assert.NotNull(context.Configuration);
Assert.NotNull(context.LoggerFactory);
configurationCallbackCalled = true;
options.ValidateScopes = true;
});
@ -213,22 +212,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<StartupNoServices>();
using (var host = (WebHost)hostBuilder.Build())
{
Assert.Same(loggerFactory, host.Services.GetService<ILoggerFactory>());
}
}
[Fact]
public void MultipleConfigureLoggingInvokedInOrder()
{
@ -251,46 +234,6 @@ namespace Microsoft.AspNetCore.Hosting
}
}
[Fact]
public void UseLoggerFactoryDelegateIsHonored()
{
var loggerFactory = new LoggerFactory();
var hostBuilder = new WebHostBuilder()
.UseLoggerFactory(_ => loggerFactory)
.UseServer(new TestServer())
.UseStartup<StartupNoServices>();
using (var host = (WebHost)hostBuilder.Build())
{
Assert.Same(loggerFactory, host.Services.GetService<ILoggerFactory>());
}
}
[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<StartupNoServices>();
using (var host = (WebHost)hostBuilder.Build())
{
Assert.Equal(2, callCount);
Assert.Same(loggerFactory, host.Services.GetService<ILoggerFactory>());
}
}
[Fact]
public void HostingContextContainsAppConfigurationDuringConfigureLogging()
{
@ -331,62 +274,6 @@ namespace Microsoft.AspNetCore.Hosting
using (hostBuilder.Build()) { }
}
[Fact]
public void ConfigureLoggingCalledIfLoggerFactoryTypeMatches()
{
var callCount = 0;
var hostBuilder = new WebHostBuilder()
.UseLoggerFactory(_ => new SubLoggerFactory())
.ConfigureLogging<CustomLoggerFactory>(factory =>
{
Assert.Equal(0, callCount++);
})
.UseServer(new TestServer())
.UseStartup<StartupNoServices>();
using (hostBuilder.Build())
{
Assert.Equal(1, callCount);
}
}
[Fact]
public void ConfigureLoggingNotCalledIfLoggerFactoryTypeDoesNotMatches()
{
var callCount = 0;
var hostBuilder = new WebHostBuilder()
.UseLoggerFactory(_ => new NonSubLoggerFactory())
.ConfigureLogging<CustomLoggerFactory>(factory =>
{
Assert.Equal(0, callCount++);
})
.UseServer(new TestServer())
.UseStartup<StartupNoServices>();
using (hostBuilder.Build())
{
Assert.Equal(0, callCount);
}
}
[Fact]
public void CanUseCustomLoggerFactory()
{
var hostBuilder = new WebHostBuilder()
.UseLoggerFactory(_ => new CustomLoggerFactory())
.ConfigureLogging<CustomLoggerFactory>(factory =>
{
factory.CustomConfigureMethod();
})
.UseServer(new TestServer())
.UseStartup<StartupNoServices>();
using (var host = (WebHost)hostBuilder.Build())
{
Assert.IsType(typeof(CustomLoggerFactory), host.Services.GetService<ILoggerFactory>());
}
}
[Fact]
public void ThereIsAlwaysConfiguration()
{
@ -793,52 +680,6 @@ namespace Microsoft.AspNetCore.Hosting
}
}
[Fact]
public void Build_PassesSameAutoCreatedILoggerFactoryEverywhere()
{
var builder = CreateWebHostBuilder();
var server = new TestServer();
using (var host = builder.UseServer(server)
.UseStartup<StartupWithILoggerFactory>()
.Build())
{
var startup = host.Services.GetService<StartupWithILoggerFactory>();
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<StartupWithILoggerFactory>()
.Build())
{
var startup = host.Services.GetService<StartupWithILoggerFactory>();
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<StartupWithILoggerFactory>()
.Build()) { }
Assert.False(factory.Disposed);
}
[Fact]
public void Build_DoesNotOverrideILoggerFactorySetByConfigureServices()
{