Fixing runtime info middleware on coreclr
Also adding more information like OS, runtime type and architecture to the info page.
This commit is contained in:
parent
3b2ded5652
commit
b27c6fc1e2
|
|
@ -75,7 +75,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// > k ef migration add [migration name]
|
||||
/// > dnx . ef migration add [migration name]
|
||||
/// </summary>
|
||||
internal static string DatabaseErrorPage_AddMigrationCommand
|
||||
{
|
||||
|
|
@ -83,7 +83,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// > k ef migration add [migration name]
|
||||
/// > dnx . ef migration add [migration name]
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPage_AddMigrationCommand()
|
||||
{
|
||||
|
|
@ -203,7 +203,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// > k ef migration apply
|
||||
/// > dnx . ef migration apply
|
||||
/// </summary>
|
||||
internal static string DatabaseErrorPage_ApplyMigrationsCommand
|
||||
{
|
||||
|
|
@ -211,7 +211,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// > k ef migration apply
|
||||
/// > dnx . ef migration apply
|
||||
/// </summary>
|
||||
internal static string FormatDatabaseErrorPage_ApplyMigrationsCommand()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -586,6 +586,118 @@ namespace Microsoft.AspNet.Diagnostics
|
|||
return GetString("ErrorPageHtml_CompilationException");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Operating System:
|
||||
/// </summary>
|
||||
internal static string RuntimeInfoPage_OperatingSystem
|
||||
{
|
||||
get { return GetString("RuntimeInfoPage_OperatingSystem"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Operating System:
|
||||
/// </summary>
|
||||
internal static string FormatRuntimeInfoPage_OperatingSystem()
|
||||
{
|
||||
return GetString("RuntimeInfoPage_OperatingSystem");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runtime Architecture:
|
||||
/// </summary>
|
||||
internal static string RuntimeInfoPage_RuntimeArchitecture
|
||||
{
|
||||
get { return GetString("RuntimeInfoPage_RuntimeArchitecture"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runtime Architecture:
|
||||
/// </summary>
|
||||
internal static string FormatRuntimeInfoPage_RuntimeArchitecture()
|
||||
{
|
||||
return GetString("RuntimeInfoPage_RuntimeArchitecture");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runtime Type:
|
||||
/// </summary>
|
||||
internal static string RuntimeInfoPage_RuntimeType
|
||||
{
|
||||
get { return GetString("RuntimeInfoPage_RuntimeType"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runtime Type:
|
||||
/// </summary>
|
||||
internal static string FormatRuntimeInfoPage_RuntimeType()
|
||||
{
|
||||
return GetString("RuntimeInfoPage_RuntimeType");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Could not determine the operating system.
|
||||
/// </summary>
|
||||
internal static string RuntimeInfoPage_OperatingSystemFail
|
||||
{
|
||||
get { return GetString("RuntimeInfoPage_OperatingSystemFail"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Could not determine the operating system.
|
||||
/// </summary>
|
||||
internal static string FormatRuntimeInfoPage_OperatingSystemFail()
|
||||
{
|
||||
return GetString("RuntimeInfoPage_OperatingSystemFail");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Could not determine the runtime architecture.
|
||||
/// </summary>
|
||||
internal static string RuntimeInfoPage_RuntimeArchitectureFail
|
||||
{
|
||||
get { return GetString("RuntimeInfoPage_RuntimeArchitectureFail"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Could not determine the runtime architecture.
|
||||
/// </summary>
|
||||
internal static string FormatRuntimeInfoPage_RuntimeArchitectureFail()
|
||||
{
|
||||
return GetString("RuntimeInfoPage_RuntimeArchitectureFail");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Could not determine the runtime type.
|
||||
/// </summary>
|
||||
internal static string RuntimeInfoPage_RuntimeTypeFail
|
||||
{
|
||||
get { return GetString("RuntimeInfoPage_RuntimeTypeFail"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Could not determine the runtime type.
|
||||
/// </summary>
|
||||
internal static string FormatRuntimeInfoPage_RuntimeTypeFail()
|
||||
{
|
||||
return GetString("RuntimeInfoPage_RuntimeTypeFail");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Environment:
|
||||
/// </summary>
|
||||
internal static string RuntimeInfoPage_Environment
|
||||
{
|
||||
get { return GetString("RuntimeInfoPage_Environment"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Environment:
|
||||
/// </summary>
|
||||
internal static string FormatRuntimeInfoPage_Environment()
|
||||
{
|
||||
return GetString("RuntimeInfoPage_Environment");
|
||||
}
|
||||
|
||||
private static string GetString(string name, params string[] formatterNames)
|
||||
{
|
||||
var value = _resourceManager.GetString(name);
|
||||
|
|
|
|||
|
|
@ -233,4 +233,25 @@
|
|||
<data name="ErrorPageHtml_CompilationException" xml:space="preserve">
|
||||
<value>An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately.</value>
|
||||
</data>
|
||||
<data name="RuntimeInfoPage_OperatingSystem" xml:space="preserve">
|
||||
<value>Operating System:</value>
|
||||
</data>
|
||||
<data name="RuntimeInfoPage_RuntimeArchitecture" xml:space="preserve">
|
||||
<value>Runtime Architecture:</value>
|
||||
</data>
|
||||
<data name="RuntimeInfoPage_RuntimeType" xml:space="preserve">
|
||||
<value>Runtime Type:</value>
|
||||
</data>
|
||||
<data name="RuntimeInfoPage_OperatingSystemFail" xml:space="preserve">
|
||||
<value>Could not determine the operating system.</value>
|
||||
</data>
|
||||
<data name="RuntimeInfoPage_RuntimeArchitectureFail" xml:space="preserve">
|
||||
<value>Could not determine the runtime architecture.</value>
|
||||
</data>
|
||||
<data name="RuntimeInfoPage_RuntimeTypeFail" xml:space="preserve">
|
||||
<value>Could not determine the runtime type.</value>
|
||||
</data>
|
||||
<data name="RuntimeInfoPage_Environment" xml:space="preserve">
|
||||
<value>Environment:</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
@ -25,7 +25,8 @@ namespace Microsoft.AspNet.Builder
|
|||
[NotNull] RuntimeInfoPageOptions options)
|
||||
{
|
||||
var libraryManager = builder.ApplicationServices.GetService(typeof(ILibraryManager)) as ILibraryManager;
|
||||
return builder.Use(next => new RuntimeInfoMiddleware(next, options, libraryManager).Invoke);
|
||||
var runtimeEnvironment = builder.ApplicationServices.GetService(typeof(IRuntimeEnvironment)) as IRuntimeEnvironment;
|
||||
return builder.Use(next => new RuntimeInfoMiddleware(next, options, libraryManager, runtimeEnvironment).Invoke);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,12 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Diagnostics.Views;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.Framework.Runtime;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Microsoft.Framework.Runtime;
|
||||
|
||||
namespace Microsoft.AspNet.Diagnostics
|
||||
{
|
||||
|
|
@ -21,6 +18,7 @@ namespace Microsoft.AspNet.Diagnostics
|
|||
private readonly RequestDelegate _next;
|
||||
private readonly RuntimeInfoPageOptions _options;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IRuntimeEnvironment _runtimeEnvironment;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RuntimeInfoMiddleware"/> class
|
||||
|
|
@ -30,11 +28,13 @@ namespace Microsoft.AspNet.Diagnostics
|
|||
public RuntimeInfoMiddleware(
|
||||
[NotNull] RequestDelegate next,
|
||||
[NotNull] RuntimeInfoPageOptions options,
|
||||
[NotNull] ILibraryManager libraryManager)
|
||||
[NotNull] ILibraryManager libraryManager,
|
||||
[NotNull] IRuntimeEnvironment runtimeEnvironment)
|
||||
{
|
||||
_next = next;
|
||||
_options = options;
|
||||
_libraryManager = libraryManager;
|
||||
_runtimeEnvironment = runtimeEnvironment;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -59,16 +59,11 @@ namespace Microsoft.AspNet.Diagnostics
|
|||
{
|
||||
var model = new RuntimeInfoPageModel();
|
||||
model.References = _libraryManager.GetLibraries();
|
||||
model.Version = GetRuntimeVersion();
|
||||
|
||||
model.Version = _runtimeEnvironment.RuntimeVersion;
|
||||
model.OperatingSystem = _runtimeEnvironment.OperatingSystem;
|
||||
model.RuntimeType = _runtimeEnvironment.RuntimeType;
|
||||
model.RuntimeArchitecture = _runtimeEnvironment.RuntimeArchitecture;
|
||||
return model;
|
||||
}
|
||||
|
||||
private static string GetRuntimeVersion()
|
||||
{
|
||||
var klr = Assembly.Load(new AssemblyName("dnx.host"));
|
||||
var version = klr.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
|
||||
return version?.InformationalVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -70,32 +70,74 @@ using Microsoft.Framework.Runtime;
|
|||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</title>\r\n <style>\r\n body {\r\n font-family: 'Segoe UI', Tahoma, Arial, Helvetica, sans-serif;\r\n font-size: .813em;\r\n line-height: 1.4em;\r\n color: #222;\r\n}\r\n\r\nh1, h2, h3, h4, h5, th {\r\n font-weight: 100;\r\n}\r\n\r\nh1 {\r\n color: #44525e;\r\n margin: 15px 0 15px 0;\r\n}\r\n\r\nh2 {\r\n margin: 10px 5px 0 0;\r\n}\r\n\r\ntable .even{\r\n background-color: #f0f0f0;\r\n}\r\n\r\nth {\r\n font-size: 16px;\r\n}\r\n\r\n\r\n\r\n </style>\r" +
|
||||
"\n</head>\r\n<body>\r\n <h1>");
|
||||
"\n</head>\r\n<body>\r\n <h2>");
|
||||
#line 27 "RuntimeInfoPage.cshtml"
|
||||
Write(Resources.RuntimeInfoPage_RuntimeVersion);
|
||||
Write(Resources.RuntimeInfoPage_Environment);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</h1>\r\n <h2>");
|
||||
WriteLiteral("</h2>\r\n <p>");
|
||||
#line 28 "RuntimeInfoPage.cshtml"
|
||||
Write(string.IsNullOrWhiteSpace(Model.Version) ? Resources.RuntimeInfoPage_RuntimeVersionFail : Model.Version);
|
||||
Write(Resources.RuntimeInfoPage_OperatingSystem);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</h2>\r\n \r\n <h1>");
|
||||
WriteLiteral(" ");
|
||||
#line 28 "RuntimeInfoPage.cshtml"
|
||||
Write(string.IsNullOrWhiteSpace(Model.OperatingSystem) ? Resources.RuntimeInfoPage_OperatingSystemFail : Model.OperatingSystem);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</p>\r\n \r\n <p>");
|
||||
#line 30 "RuntimeInfoPage.cshtml"
|
||||
Write(Resources.RuntimeInfoPage_RuntimeVersion);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" ");
|
||||
#line 30 "RuntimeInfoPage.cshtml"
|
||||
Write(string.IsNullOrWhiteSpace(Model.Version) ? Resources.RuntimeInfoPage_RuntimeVersionFail : Model.Version);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</p>\r\n\r\n <p>");
|
||||
#line 32 "RuntimeInfoPage.cshtml"
|
||||
Write(Resources.RuntimeInfoPage_RuntimeArchitecture);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" ");
|
||||
#line 32 "RuntimeInfoPage.cshtml"
|
||||
Write(string.IsNullOrWhiteSpace(Model.RuntimeArchitecture) ? Resources.RuntimeInfoPage_RuntimeArchitectureFail : Model.RuntimeArchitecture);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</p>\r\n\r\n <p>");
|
||||
#line 34 "RuntimeInfoPage.cshtml"
|
||||
Write(Resources.RuntimeInfoPage_RuntimeType);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" ");
|
||||
#line 34 "RuntimeInfoPage.cshtml"
|
||||
Write(string.IsNullOrWhiteSpace(Model.RuntimeType) ? Resources.RuntimeInfoPage_RuntimeTypeFail : Model.RuntimeType);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</p>\r\n \r\n <h2>");
|
||||
#line 36 "RuntimeInfoPage.cshtml"
|
||||
Write(Resources.RuntimeInfoPage_Packages);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</h1>\r\n");
|
||||
#line 31 "RuntimeInfoPage.cshtml"
|
||||
WriteLiteral("</h2>\r\n");
|
||||
#line 37 "RuntimeInfoPage.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 31 "RuntimeInfoPage.cshtml"
|
||||
#line 37 "RuntimeInfoPage.cshtml"
|
||||
if (@Resources.RuntimeInfoPage_Packages == null)
|
||||
{
|
||||
|
||||
|
|
@ -103,13 +145,13 @@ using Microsoft.Framework.Runtime;
|
|||
#line hidden
|
||||
|
||||
WriteLiteral(" <h2>");
|
||||
#line 33 "RuntimeInfoPage.cshtml"
|
||||
#line 39 "RuntimeInfoPage.cshtml"
|
||||
Write(Resources.RuntimeInfoPage_PackagesFail);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</h2>\r\n");
|
||||
#line 34 "RuntimeInfoPage.cshtml"
|
||||
#line 40 "RuntimeInfoPage.cshtml"
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -119,44 +161,44 @@ using Microsoft.Framework.Runtime;
|
|||
|
||||
WriteLiteral(" <table>\r\n <thead>\r\n <tr>\r\n <" +
|
||||
"th>");
|
||||
#line 40 "RuntimeInfoPage.cshtml"
|
||||
#line 46 "RuntimeInfoPage.cshtml"
|
||||
Write(Resources.RuntimeInfoPage_PackageNameColumnName);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</th>\r\n <th>");
|
||||
#line 41 "RuntimeInfoPage.cshtml"
|
||||
#line 47 "RuntimeInfoPage.cshtml"
|
||||
Write(Resources.RuntimeInfoPage_PackageVersionColumnName);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</th>\r\n <th>");
|
||||
#line 42 "RuntimeInfoPage.cshtml"
|
||||
#line 48 "RuntimeInfoPage.cshtml"
|
||||
Write(Resources.RuntimeInfoPage_PackagePathColumnName);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n");
|
||||
#line 46 "RuntimeInfoPage.cshtml"
|
||||
#line 52 "RuntimeInfoPage.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 46 "RuntimeInfoPage.cshtml"
|
||||
#line 52 "RuntimeInfoPage.cshtml"
|
||||
bool even = false;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteral("\r\n");
|
||||
#line 47 "RuntimeInfoPage.cshtml"
|
||||
#line 53 "RuntimeInfoPage.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 47 "RuntimeInfoPage.cshtml"
|
||||
#line 53 "RuntimeInfoPage.cshtml"
|
||||
foreach (var package in Model.References.OrderBy(package => package.Name.ToLowerInvariant()))
|
||||
{
|
||||
|
||||
|
|
@ -164,40 +206,40 @@ using Microsoft.Framework.Runtime;
|
|||
#line hidden
|
||||
|
||||
WriteLiteral(" <tr");
|
||||
WriteAttribute("class", Tuple.Create(" class=\"", 1576), Tuple.Create("\"", 1604),
|
||||
Tuple.Create(Tuple.Create("", 1584), Tuple.Create<System.Object, System.Int32>(even?"even":"odd", 1584), false));
|
||||
WriteAttribute("class", Tuple.Create(" class=\"", 2160), Tuple.Create("\"", 2188),
|
||||
Tuple.Create(Tuple.Create("", 2168), Tuple.Create<System.Object, System.Int32>(even?"even":"odd", 2168), false));
|
||||
WriteLiteral(">\r\n <td>");
|
||||
#line 50 "RuntimeInfoPage.cshtml"
|
||||
#line 56 "RuntimeInfoPage.cshtml"
|
||||
Write(package.Name);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
#line 51 "RuntimeInfoPage.cshtml"
|
||||
#line 57 "RuntimeInfoPage.cshtml"
|
||||
Write(package.Version);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
#line 52 "RuntimeInfoPage.cshtml"
|
||||
#line 58 "RuntimeInfoPage.cshtml"
|
||||
Write(package.Path);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n </tr>\r\n");
|
||||
#line 54 "RuntimeInfoPage.cshtml"
|
||||
#line 60 "RuntimeInfoPage.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 54 "RuntimeInfoPage.cshtml"
|
||||
#line 60 "RuntimeInfoPage.cshtml"
|
||||
even = !even;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 54 "RuntimeInfoPage.cshtml"
|
||||
#line 60 "RuntimeInfoPage.cshtml"
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -205,7 +247,7 @@ using Microsoft.Framework.Runtime;
|
|||
#line hidden
|
||||
|
||||
WriteLiteral(" </tbody>\r\n </table>\r\n");
|
||||
#line 58 "RuntimeInfoPage.cshtml"
|
||||
#line 64 "RuntimeInfoPage.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
|
|
|
|||
|
|
@ -24,10 +24,16 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>@Resources.RuntimeInfoPage_RuntimeVersion</h1>
|
||||
<h2>@(string.IsNullOrWhiteSpace(Model.Version) ? Resources.RuntimeInfoPage_RuntimeVersionFail : Model.Version)</h2>
|
||||
<h2>@Resources.RuntimeInfoPage_Environment</h2>
|
||||
<p>@Resources.RuntimeInfoPage_OperatingSystem @(string.IsNullOrWhiteSpace(Model.OperatingSystem) ? Resources.RuntimeInfoPage_OperatingSystemFail : Model.OperatingSystem)</p>
|
||||
|
||||
<h1>@Resources.RuntimeInfoPage_Packages</h1>
|
||||
<p>@Resources.RuntimeInfoPage_RuntimeVersion @(string.IsNullOrWhiteSpace(Model.Version) ? Resources.RuntimeInfoPage_RuntimeVersionFail : Model.Version)</p>
|
||||
|
||||
<p>@Resources.RuntimeInfoPage_RuntimeArchitecture @(string.IsNullOrWhiteSpace(Model.RuntimeArchitecture) ? Resources.RuntimeInfoPage_RuntimeArchitectureFail : Model.RuntimeArchitecture)</p>
|
||||
|
||||
<p>@Resources.RuntimeInfoPage_RuntimeType @(string.IsNullOrWhiteSpace(Model.RuntimeType) ? Resources.RuntimeInfoPage_RuntimeTypeFail : Model.RuntimeType)</p>
|
||||
|
||||
<h2>@Resources.RuntimeInfoPage_Packages</h2>
|
||||
@if (@Resources.RuntimeInfoPage_Packages == null)
|
||||
{
|
||||
<h2>@Resources.RuntimeInfoPage_PackagesFail</h2>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.Framework.Runtime;
|
||||
|
||||
namespace Microsoft.AspNet.Diagnostics.Views
|
||||
|
|
@ -12,6 +10,12 @@ namespace Microsoft.AspNet.Diagnostics.Views
|
|||
{
|
||||
public string Version { get; internal set; }
|
||||
|
||||
public string OperatingSystem { get; internal set; }
|
||||
|
||||
public string RuntimeArchitecture { get; internal set; }
|
||||
|
||||
public string RuntimeType { get; internal set; }
|
||||
|
||||
public IEnumerable<ILibraryInformation> References { get; internal set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -54,9 +54,6 @@ namespace PageGenerator
|
|||
Console.WriteLine();
|
||||
Console.WriteLine("{0} files successfully generated.", fileCount);
|
||||
Console.WriteLine();
|
||||
|
||||
Console.Write("Press enter to close application...");
|
||||
Console.ReadLine();
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetCshtmlFiles(string path)
|
||||
|
|
|
|||
|
|
@ -46,6 +46,12 @@ namespace Microsoft.AspNet.Diagnostics.Tests
|
|||
var libraryManagerMock = new Mock<ILibraryManager>(MockBehavior.Strict);
|
||||
libraryManagerMock.Setup(l => l.GetLibraries()).Returns(libraries);
|
||||
|
||||
var runtimeEnvironmentMock = new Mock<IRuntimeEnvironment>(MockBehavior.Strict);
|
||||
runtimeEnvironmentMock.Setup(r => r.OperatingSystem).Returns("Windows");
|
||||
runtimeEnvironmentMock.Setup(r => r.RuntimeArchitecture).Returns("x64");
|
||||
runtimeEnvironmentMock.Setup(r => r.RuntimeType).Returns("clr");
|
||||
runtimeEnvironmentMock.Setup(r => r.RuntimeVersion).Returns("1.0.0");
|
||||
|
||||
RequestDelegate next = _ =>
|
||||
{
|
||||
return Task.FromResult<object>(null);
|
||||
|
|
@ -54,13 +60,17 @@ namespace Microsoft.AspNet.Diagnostics.Tests
|
|||
var middleware = new RuntimeInfoMiddleware(
|
||||
next,
|
||||
new RuntimeInfoPageOptions(),
|
||||
libraryManagerMock.Object);
|
||||
libraryManagerMock.Object,
|
||||
runtimeEnvironmentMock.Object);
|
||||
|
||||
// Act
|
||||
var model = middleware.CreateRuntimeInfoModel();
|
||||
|
||||
// Assert
|
||||
Assert.False(string.IsNullOrWhiteSpace(model.Version));
|
||||
Assert.Equal("1.0.0", model.Version);
|
||||
Assert.Equal("Windows", model.OperatingSystem);
|
||||
Assert.Equal("clr", model.RuntimeType);
|
||||
Assert.Equal("x64", model.RuntimeArchitecture);
|
||||
Assert.Same(libraries, model.References);
|
||||
}
|
||||
|
||||
|
|
@ -69,6 +79,7 @@ namespace Microsoft.AspNet.Diagnostics.Tests
|
|||
{
|
||||
// Arrange
|
||||
var libraryManagerMock = new Mock<ILibraryManager>(MockBehavior.Strict);
|
||||
var runtimeEnvironmentMock = new Mock<IRuntimeEnvironment>(MockBehavior.Strict);
|
||||
|
||||
RequestDelegate next = _ =>
|
||||
{
|
||||
|
|
@ -78,7 +89,8 @@ namespace Microsoft.AspNet.Diagnostics.Tests
|
|||
var middleware = new RuntimeInfoMiddleware(
|
||||
next,
|
||||
new RuntimeInfoPageOptions(),
|
||||
libraryManagerMock.Object);
|
||||
libraryManagerMock.Object,
|
||||
runtimeEnvironmentMock.Object);
|
||||
|
||||
var contextMock = new Mock<HttpContext>(MockBehavior.Strict);
|
||||
contextMock
|
||||
|
|
@ -102,6 +114,12 @@ namespace Microsoft.AspNet.Diagnostics.Tests
|
|||
new FakeLibraryInformation() { Name ="LibInfo2", Version = "1.0.0-beta2", Path = "Path2" },
|
||||
});
|
||||
|
||||
var runtimeEnvironmentMock = new Mock<IRuntimeEnvironment>(MockBehavior.Strict);
|
||||
runtimeEnvironmentMock.Setup(r => r.OperatingSystem).Returns("Windows");
|
||||
runtimeEnvironmentMock.Setup(r => r.RuntimeArchitecture).Returns("x64");
|
||||
runtimeEnvironmentMock.Setup(r => r.RuntimeType).Returns("clr");
|
||||
runtimeEnvironmentMock.Setup(r => r.RuntimeVersion).Returns("1.0.0");
|
||||
|
||||
RequestDelegate next = _ =>
|
||||
{
|
||||
return Task.FromResult<object>(null);
|
||||
|
|
@ -110,7 +128,8 @@ namespace Microsoft.AspNet.Diagnostics.Tests
|
|||
var middleware = new RuntimeInfoMiddleware(
|
||||
next,
|
||||
new RuntimeInfoPageOptions(),
|
||||
libraryManagerMock.Object);
|
||||
libraryManagerMock.Object,
|
||||
runtimeEnvironmentMock.Object);
|
||||
|
||||
var buffer = new byte[4096];
|
||||
using (var responseStream = new MemoryStream(buffer))
|
||||
|
|
@ -132,12 +151,16 @@ namespace Microsoft.AspNet.Diagnostics.Tests
|
|||
// Assert
|
||||
string response = Encoding.UTF8.GetString(buffer);
|
||||
|
||||
Assert.True(response.Contains("<td>LibInfo1</td>"));
|
||||
Assert.True(response.Contains("<td>1.0.0-beta1</td>"));
|
||||
Assert.True(response.Contains("<td>Path1</td>"));
|
||||
Assert.True(response.Contains("<td>LibInfo2</td>"));
|
||||
Assert.True(response.Contains("<td>1.0.0-beta2</td>"));
|
||||
Assert.True(response.Contains("<td>Path2</td>"));
|
||||
Assert.Contains("<p>Runtime Version: 1.0.0</p>", response);
|
||||
Assert.Contains("<p>Operating System: Windows</p>", response);
|
||||
Assert.Contains("<p>Runtime Architecture: x64</p>", response);
|
||||
Assert.Contains("<p>Runtime Type: clr</p>", response);
|
||||
Assert.Contains("<td>LibInfo1</td>", response);
|
||||
Assert.Contains("<td>1.0.0-beta1</td>", response);
|
||||
Assert.Contains("<td>Path1</td>", response);
|
||||
Assert.Contains("<td>LibInfo2</td>", response);
|
||||
Assert.Contains("<td>1.0.0-beta2</td>", response);
|
||||
Assert.Contains("<td>Path2</td>", response);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -150,6 +173,12 @@ namespace Microsoft.AspNet.Diagnostics.Tests
|
|||
new FakeLibraryInformation() { Name ="LibInfo1", Version = "1.0.0-beta1", Path = "Path1" },
|
||||
});
|
||||
|
||||
var runtimeEnvironmentMock = new Mock<IRuntimeEnvironment>(MockBehavior.Strict);
|
||||
runtimeEnvironmentMock.Setup(r => r.OperatingSystem).Returns("Windows");
|
||||
runtimeEnvironmentMock.Setup(r => r.RuntimeArchitecture).Returns("x64");
|
||||
runtimeEnvironmentMock.Setup(r => r.RuntimeType).Returns("clr");
|
||||
runtimeEnvironmentMock.Setup(r => r.RuntimeVersion).Returns("1.0.0");
|
||||
|
||||
RequestDelegate next = _ =>
|
||||
{
|
||||
return Task.FromResult<object>(null);
|
||||
|
|
@ -158,7 +187,8 @@ namespace Microsoft.AspNet.Diagnostics.Tests
|
|||
var middleware = new RuntimeInfoMiddleware(
|
||||
next,
|
||||
new RuntimeInfoPageOptions(),
|
||||
libraryManagerMock.Object);
|
||||
libraryManagerMock.Object,
|
||||
runtimeEnvironmentMock.Object);
|
||||
|
||||
var buffer = new byte[4096];
|
||||
using (var responseStream = new MemoryStream(buffer))
|
||||
|
|
|
|||
Loading…
Reference in New Issue