* Remove libraries from RuntimeInfoMiddleware
This commit is contained in:
parent
7e47449f85
commit
886c33f200
|
|
@ -7,10 +7,10 @@
|
|||
"emitEntryPoint": true
|
||||
},
|
||||
"commands": {
|
||||
"web": "DeveloperExceptionPageSample"
|
||||
"web": "DeveloperExceptionPageSample"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {},
|
||||
"dnxcore50": {}
|
||||
"dnx451": { },
|
||||
"dnxcore50": { }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,12 +43,11 @@ namespace Microsoft.AspNet.Builder
|
|||
throw new ArgumentNullException(nameof(configureOptions));
|
||||
}
|
||||
|
||||
var libraryManager = app.ApplicationServices.GetService(typeof(ILibraryManager)) as ILibraryManager;
|
||||
var runtimeEnvironment = app.ApplicationServices.GetService(typeof(IRuntimeEnvironment)) as IRuntimeEnvironment;
|
||||
var options = new RuntimeInfoPageOptions();
|
||||
configureOptions(options);
|
||||
|
||||
return app.Use(next => new RuntimeInfoMiddleware(next, options, libraryManager, runtimeEnvironment).Invoke);
|
||||
return app.Use(next => new RuntimeInfoMiddleware(next, options, runtimeEnvironment).Invoke);
|
||||
}
|
||||
|
||||
public static IApplicationBuilder UseRuntimeInfoPage(
|
||||
|
|
@ -64,10 +63,8 @@ namespace Microsoft.AspNet.Builder
|
|||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
var libraryManager = app.ApplicationServices.GetService(typeof(ILibraryManager)) as ILibraryManager;
|
||||
var runtimeEnvironment = app.ApplicationServices.GetService(typeof(IRuntimeEnvironment)) as IRuntimeEnvironment;
|
||||
|
||||
return app.Use(next => new RuntimeInfoMiddleware(next, options, libraryManager, runtimeEnvironment).Invoke);
|
||||
return app.Use(next => new RuntimeInfoMiddleware(next, options, runtimeEnvironment).Invoke);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Diagnostics.Views;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
|
@ -17,7 +16,6 @@ namespace Microsoft.AspNet.Diagnostics
|
|||
{
|
||||
private readonly RequestDelegate _next;
|
||||
private readonly RuntimeInfoPageOptions _options;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IRuntimeEnvironment _runtimeEnvironment;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -28,7 +26,6 @@ namespace Microsoft.AspNet.Diagnostics
|
|||
public RuntimeInfoMiddleware(
|
||||
RequestDelegate next,
|
||||
RuntimeInfoPageOptions options,
|
||||
ILibraryManager libraryManager,
|
||||
IRuntimeEnvironment runtimeEnvironment)
|
||||
{
|
||||
if (next == null)
|
||||
|
|
@ -41,11 +38,6 @@ namespace Microsoft.AspNet.Diagnostics
|
|||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
if (libraryManager == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(libraryManager));
|
||||
}
|
||||
|
||||
if (runtimeEnvironment == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(runtimeEnvironment));
|
||||
|
|
@ -53,7 +45,6 @@ namespace Microsoft.AspNet.Diagnostics
|
|||
|
||||
_next = next;
|
||||
_options = options;
|
||||
_libraryManager = libraryManager;
|
||||
_runtimeEnvironment = runtimeEnvironment;
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +69,6 @@ namespace Microsoft.AspNet.Diagnostics
|
|||
internal RuntimeInfoPageModel CreateRuntimeInfoModel()
|
||||
{
|
||||
var model = new RuntimeInfoPageModel();
|
||||
model.References = _libraryManager.GetLibraries();
|
||||
model.Version = _runtimeEnvironment.RuntimeVersion;
|
||||
model.OperatingSystem = _runtimeEnvironment.OperatingSystem;
|
||||
model.RuntimeType = _runtimeEnvironment.RuntimeType;
|
||||
|
|
|
|||
|
|
@ -81,8 +81,8 @@ WriteAttributeValue("", 456, CultureInfo.CurrentUICulture.TwoLetterISOLanguageNa
|
|||
|
||||
#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 <h2>");
|
||||
WriteLiteral("</title>\r\n <style>\r\n <%$ include: RuntimeInfoPage.css % >\r\n </style>" +
|
||||
"\r\n</head>\r\n<body>\r\n <h2>");
|
||||
#line 30 "RuntimeInfoPage.cshtml"
|
||||
Write(Resources.RuntimeInfoPage_Environment);
|
||||
|
||||
|
|
@ -136,135 +136,7 @@ WriteAttributeValue("", 456, CultureInfo.CurrentUICulture.TwoLetterISOLanguageNa
|
|||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</p>\r\n\r\n <h2>");
|
||||
#line 39 "RuntimeInfoPage.cshtml"
|
||||
Write(Resources.RuntimeInfoPage_Packages);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</h2>\r\n");
|
||||
#line 40 "RuntimeInfoPage.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 40 "RuntimeInfoPage.cshtml"
|
||||
if (@Resources.RuntimeInfoPage_Packages == null)
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteral(" <h2>");
|
||||
#line 42 "RuntimeInfoPage.cshtml"
|
||||
Write(Resources.RuntimeInfoPage_PackagesFail);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</h2>\r\n");
|
||||
#line 43 "RuntimeInfoPage.cshtml"
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteral(" <table>\r\n <thead>\r\n <tr>\r\n <" +
|
||||
"th>");
|
||||
#line 49 "RuntimeInfoPage.cshtml"
|
||||
Write(Resources.RuntimeInfoPage_PackageNameColumnName);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</th>\r\n <th>");
|
||||
#line 50 "RuntimeInfoPage.cshtml"
|
||||
Write(Resources.RuntimeInfoPage_PackageVersionColumnName);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</th>\r\n <th>");
|
||||
#line 51 "RuntimeInfoPage.cshtml"
|
||||
Write(Resources.RuntimeInfoPage_PackagePathColumnName);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n");
|
||||
#line 55 "RuntimeInfoPage.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 55 "RuntimeInfoPage.cshtml"
|
||||
bool even = false;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteral(" ");
|
||||
#line 56 "RuntimeInfoPage.cshtml"
|
||||
foreach (var package in Model.References.OrderBy(package => package.Name.ToLowerInvariant()))
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteral(" <tr");
|
||||
BeginWriteAttribute("class", " class=\"", 2229, "\"", 2257, 1);
|
||||
#line 58 "RuntimeInfoPage.cshtml"
|
||||
WriteAttributeValue("", 2237, even?"even":"odd", 2237, 20, false);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
EndWriteAttribute();
|
||||
WriteLiteral(">\r\n <td>");
|
||||
#line 59 "RuntimeInfoPage.cshtml"
|
||||
Write(package.Name);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
#line 60 "RuntimeInfoPage.cshtml"
|
||||
Write(package.Version);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
#line 61 "RuntimeInfoPage.cshtml"
|
||||
Write(package.Path);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n </tr>\r\n");
|
||||
#line 63 "RuntimeInfoPage.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 63 "RuntimeInfoPage.cshtml"
|
||||
even = !even;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 63 "RuntimeInfoPage.cshtml"
|
||||
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteral(" </tbody>\r\n </table>\r\n");
|
||||
#line 67 "RuntimeInfoPage.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteral("</body>\r\n</html>\r\n");
|
||||
WriteLiteral("</p>\r\n</body>\r\n</html>\r\n");
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
<meta charset="utf-8" />
|
||||
<title>@Resources.RuntimeInfoPage_Title</title>
|
||||
<style>
|
||||
<%$ include: RuntimeInfoPage.css %>
|
||||
<%$ include: RuntimeInfoPage.css % >
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
|
@ -35,35 +35,5 @@
|
|||
<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>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>@Resources.RuntimeInfoPage_PackageNameColumnName</th>
|
||||
<th>@Resources.RuntimeInfoPage_PackageVersionColumnName</th>
|
||||
<th>@Resources.RuntimeInfoPage_PackagePathColumnName</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@{ bool even = false; }
|
||||
@foreach (var package in Model.References.OrderBy(package => package.Name.ToLowerInvariant()))
|
||||
{
|
||||
<tr class="@(even?"even":"odd")">
|
||||
<td>@package.Name</td>
|
||||
<td>@package.Version</td>
|
||||
<td>@package.Path</td>
|
||||
</tr>
|
||||
@{ even = !even; }
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
// 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 System.Collections.Generic;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.AspNet.Diagnostics.Views
|
||||
{
|
||||
public class RuntimeInfoPageModel
|
||||
|
|
@ -15,7 +12,5 @@ namespace Microsoft.AspNet.Diagnostics.Views
|
|||
public string RuntimeArchitecture { get; internal set; }
|
||||
|
||||
public string RuntimeType { get; internal set; }
|
||||
|
||||
public IEnumerable<Library> References { get; internal set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -31,14 +31,6 @@ namespace Microsoft.AspNet.Diagnostics.Tests
|
|||
public void CreateRuntimeInfoModel_GetsTheVersionAndAllPackages()
|
||||
{
|
||||
// Arrage
|
||||
var libraries = new[] {
|
||||
new Library("LibInfo1", string.Empty, "Path1", string.Empty, Enumerable.Empty<string>(), Enumerable.Empty<AssemblyName>()),
|
||||
new Library("LibInfo2", string.Empty, "Path2", string.Empty, Enumerable.Empty<string>(), Enumerable.Empty<AssemblyName>())
|
||||
};
|
||||
|
||||
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");
|
||||
|
|
@ -53,7 +45,6 @@ namespace Microsoft.AspNet.Diagnostics.Tests
|
|||
var middleware = new RuntimeInfoMiddleware(
|
||||
next,
|
||||
new RuntimeInfoPageOptions(),
|
||||
libraryManagerMock.Object,
|
||||
runtimeEnvironmentMock.Object);
|
||||
|
||||
// Act
|
||||
|
|
@ -64,14 +55,12 @@ namespace Microsoft.AspNet.Diagnostics.Tests
|
|||
Assert.Equal("Windows", model.OperatingSystem);
|
||||
Assert.Equal("clr", model.RuntimeType);
|
||||
Assert.Equal("x64", model.RuntimeArchitecture);
|
||||
Assert.Same(libraries, model.References);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void Invoke_WithNonMatchingPath_IgnoresRequest()
|
||||
{
|
||||
// Arrange
|
||||
var libraryManagerMock = new Mock<ILibraryManager>(MockBehavior.Strict);
|
||||
var runtimeEnvironmentMock = new Mock<IRuntimeEnvironment>(MockBehavior.Strict);
|
||||
|
||||
RequestDelegate next = _ =>
|
||||
|
|
@ -82,7 +71,6 @@ namespace Microsoft.AspNet.Diagnostics.Tests
|
|||
var middleware = new RuntimeInfoMiddleware(
|
||||
next,
|
||||
new RuntimeInfoPageOptions(),
|
||||
libraryManagerMock.Object,
|
||||
runtimeEnvironmentMock.Object);
|
||||
|
||||
var contextMock = new Mock<HttpContext>(MockBehavior.Strict);
|
||||
|
|
@ -101,12 +89,6 @@ namespace Microsoft.AspNet.Diagnostics.Tests
|
|||
public async void Invoke_WithMatchingPath_ReturnsInfoPage()
|
||||
{
|
||||
// Arrange
|
||||
var libraryManagerMock = new Mock<ILibraryManager>(MockBehavior.Strict);
|
||||
libraryManagerMock.Setup(l => l.GetLibraries()).Returns(new[] {
|
||||
new Library("LibInfo1", "1.0.0-beta1", "Path1", string.Empty, Enumerable.Empty<string>(), Enumerable.Empty<AssemblyName>()),
|
||||
new Library("LibInfo2", "1.0.0-beta2", "Path2", string.Empty, Enumerable.Empty<string>(), Enumerable.Empty<AssemblyName>())
|
||||
});
|
||||
|
||||
var runtimeEnvironmentMock = new Mock<IRuntimeEnvironment>(MockBehavior.Strict);
|
||||
runtimeEnvironmentMock.Setup(r => r.OperatingSystem).Returns("Windows");
|
||||
runtimeEnvironmentMock.Setup(r => r.RuntimeArchitecture).Returns("x64");
|
||||
|
|
@ -121,7 +103,6 @@ namespace Microsoft.AspNet.Diagnostics.Tests
|
|||
var middleware = new RuntimeInfoMiddleware(
|
||||
next,
|
||||
new RuntimeInfoPageOptions(),
|
||||
libraryManagerMock.Object,
|
||||
runtimeEnvironmentMock.Object);
|
||||
|
||||
var buffer = new byte[4096];
|
||||
|
|
@ -148,12 +129,6 @@ namespace Microsoft.AspNet.Diagnostics.Tests
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue