Merge branch 'release' into dev

This commit is contained in:
Pranav K 2016-04-26 10:18:15 -07:00
commit abe6dd5692
5 changed files with 6 additions and 44 deletions

View File

@ -15,7 +15,6 @@ using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.PlatformAbstractions;
namespace Microsoft.AspNetCore.Hosting.Internal
{
@ -165,10 +164,9 @@ namespace Microsoft.AspNetCore.Hosting.Internal
logger.ApplicationError(ex);
// Generate an HTML error page.
var runtimeEnv = _applicationServices.GetRequiredService<IRuntimeEnvironment>();
var hostingEnv = _applicationServices.GetRequiredService<IHostingEnvironment>();
var showDetailedErrors = hostingEnv.IsDevelopment() || _options.DetailedErrors;
var errorBytes = StartupExceptionPage.GenerateErrorHtml(showDetailedErrors, runtimeEnv, ex);
var errorBytes = StartupExceptionPage.GenerateErrorHtml(showDetailedErrors, ex);
return context =>
{

View File

@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Hosting
private static readonly string _errorExceptionFormatString = GetResourceString("GenericError_Exception.html");
private static readonly string _errorFooterFormatString = GetResourceString("GenericError_Footer.html");
public static byte[] GenerateErrorHtml(bool showDetails, IRuntimeEnvironment runtimeEnvironment, Exception exception)
public static byte[] GenerateErrorHtml(bool showDetails, Exception exception)
{
// Build the message for each error
var builder = new StringBuilder();
@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Hosting
}
// Generate the footer
var footer = showDetails ? GenerateFooterEncoded(runtimeEnvironment) : null;
var footer = showDetails ? GenerateFooterEncoded() : null;
// And generate the full markup
return Encoding.UTF8.GetBytes(string.Format(CultureInfo.InvariantCulture, _errorPageFormatString, builder, rawExceptionDetails, footer));
@ -230,8 +230,9 @@ namespace Microsoft.AspNetCore.Hosting
}
}
private static string GenerateFooterEncoded(IRuntimeEnvironment environment)
private static string GenerateFooterEncoded()
{
var environment = PlatformServices.Default.Runtime;
var runtimeType = HtmlEncodeAndReplaceLineBreaks(environment.RuntimeType);
#if NETCOREAPP1_0 || NETSTANDARD1_3
var systemRuntimeAssembly = typeof(System.ComponentModel.DefaultValueAttribute).GetTypeInfo().Assembly;

View File

@ -133,8 +133,7 @@ namespace Microsoft.AspNetCore.Hosting
{
_options = new WebHostOptions(_config);
var defaultPlatformServices = PlatformServices.Default;
var appEnvironment = defaultPlatformServices.Application;
var appEnvironment = PlatformServices.Default.Application;
var contentRootPath = ResolveContentRootPath(_options.ContentRootPath, appEnvironment.ApplicationBasePath);
var applicationName = _options.ApplicationName ?? appEnvironment.ApplicationName;
@ -174,9 +173,6 @@ namespace Microsoft.AspNetCore.Hosting
// Ensure object pooling is available everywhere.
services.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
services.AddSingleton(defaultPlatformServices.Application);
services.AddSingleton(defaultPlatformServices.Runtime);
if (!string.IsNullOrEmpty(_options.ServerAssembly))
{
// Add the server

View File

@ -1,24 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.Extensions.PlatformAbstractions;
namespace Microsoft.AspNetCore.Hosting.Fakes
{
public class RuntimeEnvironment : IRuntimeEnvironment
{
public string OperatingSystem { get; } = "TestOs";
public string OperatingSystemVersion { get; } = "TestOsVersion";
public string RuntimeArchitecture { get; } = "TestArch";
public string RuntimeType { get; } = "TestRuntime";
public string RuntimeVersion { get; } = "TestRuntimeVersion";
public string RuntimePath { get; } = "TestRuntimePath";
public Platform OperatingSystemPlatform => Platform.Unknown;
}
}

View File

@ -440,9 +440,6 @@ namespace Microsoft.AspNetCore.Hosting
var hostingEnv = host.Services.GetService<IHostingEnvironment>();
Assert.Equal("Microsoft.AspNetCore.Hosting.Tests", hostingEnv.ApplicationName);
var appEnv = host.Services.GetService<IApplicationEnvironment>();
Assert.Equal(PlatformServices.Default.Application.ApplicationName, appEnv.ApplicationName);
Assert.Equal(PlatformServices.Default.Application.ApplicationBasePath, appEnv.ApplicationBasePath);
}
[Fact]
@ -457,9 +454,6 @@ namespace Microsoft.AspNetCore.Hosting
var hostingEnv = host.Services.GetService<IHostingEnvironment>();
Assert.Equal("Microsoft.AspNetCore.Hosting.Tests.NonExistent", hostingEnv.ApplicationName);
var appEnv = host.Services.GetService<IApplicationEnvironment>();
Assert.Equal(PlatformServices.Default.Application.ApplicationName, appEnv.ApplicationName);
Assert.Equal(PlatformServices.Default.Application.ApplicationBasePath, appEnv.ApplicationBasePath);
}
[Fact]
@ -474,9 +468,6 @@ namespace Microsoft.AspNetCore.Hosting
var hostingEnv = host.Services.GetService<IHostingEnvironment>();
Assert.Equal("Microsoft.AspNetCore.Hosting.Tests.NonExistent", hostingEnv.ApplicationName);
var appEnv = host.Services.GetService<IApplicationEnvironment>();
Assert.Equal(PlatformServices.Default.Application.ApplicationName, appEnv.ApplicationName);
Assert.Equal(PlatformServices.Default.Application.ApplicationBasePath, appEnv.ApplicationBasePath);
}
[Fact]