From c224a726f9959f95d948d172140d048aea1caadd Mon Sep 17 00:00:00 2001
From: Kiran Challa
Date: Mon, 29 Aug 2016 12:43:49 -0700
Subject: [PATCH] Moved PageGenerator to Razor repo and moved diagnostic view
page sources to Common.
---
DiagnosticsPages.sln | 28 +-
.../ElmPageMiddleware.cs | 3 +-
.../Views/DetailsPage.Designer.cs | 606 ++++++++
.../Views/DetailsPage.cshtml | 8 +-
.../Views/DetailsPageModel.cs | 2 +-
.../Views/LogPage.Designer.cs | 710 +++++++++
.../Views/LogPage.cshtml | 10 +-
.../Views/LogPageModel.cs | 2 +-
.../Views/{ => Obsolete}/DetailsPage.cs | 2 +-
.../Views/Obsolete/DetailsPage.cshtml | 258 ++++
.../Views/Obsolete/DetailsPage.css | 56 +
.../Views/Obsolete/DetailsPageModel.cs | 12 +
.../Views/{ => Obsolete}/LogPage.cs | 2 +-
.../Views/Obsolete/LogPage.cshtml | 263 ++++
.../Views/Obsolete/LogPage.css | 110 ++
.../Views/Obsolete/LogPageModel.cs | 16 +
.../Views/Obsolete/Shared.css | 39 +
.../project.json | 7 +
.../DatabaseErrorPageMiddleware.cs | 4 +-
.../Properties/AssemblyInfo.cs | 2 +
.../Views/DatabaseErrorPage.Designer.cs | 457 ++++++
.../Views/DatabaseErrorPage.cshtml | 4 +-
.../Views/DatabaseErrorPageModel.cs | 4 +-
.../Views/{ => Obsolete}/DatabaseErrorPage.cs | 10 +-
.../Views/Obsolete/DatabaseErrorPage.cshtml | 135 ++
.../Views/Obsolete/DatabaseErrorPageModel.cs | 73 +
.../project.json | 7 +
.../DeveloperExceptionPageMiddleware.cs | 120 +-
.../Views/CompilationErrorModel.cs | 7 +-
.../Views/CompilationErrorPage.Designer.cs | 817 +++++++++++
.../Views/CompilationErrorPage.cshtml | 1 +
.../Views/ErrorPage.Designer.cs | 1303 +++++++++++++++++
.../Views/ErrorPage.cshtml | 13 +-
.../Views/ErrorPageModel.cs | 7 +-
.../Views/Obsolete/CompilationErrorModel.cs | 26 +
.../{ => Obsolete}/CompilationErrorPage.cs | 2 +-
.../Obsolete/CompilationErrorPage.cshtml | 100 ++
.../Views/{ => Obsolete}/ErrorDetails.cs | 1 +
.../Views/{ => Obsolete}/ErrorPage.cs | 2 +-
.../Views/Obsolete/ErrorPage.cshtml | 262 ++++
.../Views/Obsolete/ErrorPage.css | 195 +++
.../Views/Obsolete/ErrorPage.js | 192 +++
.../Views/Obsolete/ErrorPageModel.cs | 43 +
.../Views/{ => Obsolete}/StackFrame.cs | 2 +
.../Views/{ => Obsolete}/StackFrameInfo.cs | 2 +
.../Views/{ => Obsolete}/WelcomePage.cs | 3 +-
.../Views/Obsolete/WelcomePage.cshtml | 196 +++
.../WelcomePage/Views/WelcomePage.Designer.cs | 372 +++++
.../WelcomePage/Views/WelcomePage.cshtml | 4 +-
.../WelcomePage/WelcomePageMiddleware.cs | 3 +-
.../project.json | 7 +
.../AttributeValue.cs | 1 +
.../BaseView.cs | 1 +
.../HelperResult.cs | 1 +
.../ClassLibraryWithPortablePdbs.xproj | 13 +-
.../ExceptionType.cs | 20 +
.../ClassLibraryWithPortablePdbs/project.json | 13 +
.../ApiConsistencyTestBase.cs | 2 +-
.../DatabaseErrorPageTest.cs | 4 +-
.../project.json | 5 +-
.../DeveloperExceptionPageMiddlewareTest.cs | 405 -----
.../ExceptionDetailsProviderTest.cs | 392 +++++
.../StackTraceTest.cs | 159 ++
.../project.json | 3 +-
tools/PageGenerator/Program.cs | 130 --
tools/PageGenerator/project.json | 18 -
66 files changed, 6941 insertions(+), 736 deletions(-)
create mode 100644 src/Microsoft.AspNetCore.Diagnostics.Elm/Views/DetailsPage.Designer.cs
create mode 100644 src/Microsoft.AspNetCore.Diagnostics.Elm/Views/LogPage.Designer.cs
rename src/Microsoft.AspNetCore.Diagnostics.Elm/Views/{ => Obsolete}/DetailsPage.cs (99%)
create mode 100644 src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/DetailsPage.cshtml
create mode 100644 src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/DetailsPage.css
create mode 100644 src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/DetailsPageModel.cs
rename src/Microsoft.AspNetCore.Diagnostics.Elm/Views/{ => Obsolete}/LogPage.cs (99%)
create mode 100644 src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/LogPage.cshtml
create mode 100644 src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/LogPage.css
create mode 100644 src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/LogPageModel.cs
create mode 100644 src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/Shared.css
create mode 100644 src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/DatabaseErrorPage.Designer.cs
rename src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/{ => Obsolete}/DatabaseErrorPage.cs (99%)
create mode 100644 src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/Obsolete/DatabaseErrorPage.cshtml
create mode 100644 src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/Obsolete/DatabaseErrorPageModel.cs
create mode 100644 src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.Designer.cs
create mode 100644 src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.Designer.cs
create mode 100644 src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/CompilationErrorModel.cs
rename src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/{ => Obsolete}/CompilationErrorPage.cs (99%)
create mode 100644 src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/CompilationErrorPage.cshtml
rename src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/{ => Obsolete}/ErrorDetails.cs (89%)
rename src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/{ => Obsolete}/ErrorPage.cs (99%)
create mode 100644 src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorPage.cshtml
create mode 100644 src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorPage.css
create mode 100644 src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorPage.js
create mode 100644 src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorPageModel.cs
rename src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/{ => Obsolete}/StackFrame.cs (94%)
rename src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/{ => Obsolete}/StackFrameInfo.cs (94%)
rename src/Microsoft.AspNetCore.Diagnostics/WelcomePage/Views/{ => Obsolete}/WelcomePage.cs (99%)
create mode 100644 src/Microsoft.AspNetCore.Diagnostics/WelcomePage/Views/Obsolete/WelcomePage.cshtml
create mode 100644 src/Microsoft.AspNetCore.Diagnostics/WelcomePage/Views/WelcomePage.Designer.cs
rename tools/PageGenerator/PageGenerator.xproj => test/ClassLibraryWithPortablePdbs/ClassLibraryWithPortablePdbs.xproj (54%)
create mode 100644 test/ClassLibraryWithPortablePdbs/ExceptionType.cs
create mode 100644 test/ClassLibraryWithPortablePdbs/project.json
create mode 100644 test/Microsoft.AspNetCore.Diagnostics.Tests/ExceptionDetailsProviderTest.cs
create mode 100644 test/Microsoft.AspNetCore.Diagnostics.Tests/StackTraceTest.cs
delete mode 100644 tools/PageGenerator/Program.cs
delete mode 100644 tools/PageGenerator/project.json
diff --git a/DiagnosticsPages.sln b/DiagnosticsPages.sln
index 31ddf911b2..2b442e391a 100644
--- a/DiagnosticsPages.sln
+++ b/DiagnosticsPages.sln
@@ -12,8 +12,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Diagno
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "DeveloperExceptionPageSample", "samples\DeveloperExceptionPageSample\DeveloperExceptionPageSample.xproj", "{589AC17F-9455-4764-8F82-FCD2AE58DA14}"
EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "PageGenerator", "tools\PageGenerator\PageGenerator.xproj", "{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}"
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F0557697-8D86-4DF3-A385-B0BFA9596189}"
ProjectSection(SolutionItems) = preProject
global.json = global.json
@@ -51,7 +49,7 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Diagno
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.DiagnosticsViewPage.Sources", "src\Microsoft.AspNetCore.DiagnosticsViewPage.Sources\Microsoft.AspNetCore.DiagnosticsViewPage.Sources.xproj", "{B9F08060-621F-4E1F-BDA8-9C4EA107E08A}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{B9729160-50A4-49C5-8BB2-4944492AEA30}"
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ClassLibraryWithPortablePdbs", "test\ClassLibraryWithPortablePdbs\ClassLibraryWithPortablePdbs.xproj", "{AA3661A1-CE8D-4597-ADFD-A5A30834E5D0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -93,16 +91,6 @@ Global
{589AC17F-9455-4764-8F82-FCD2AE58DA14}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{589AC17F-9455-4764-8F82-FCD2AE58DA14}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{589AC17F-9455-4764-8F82-FCD2AE58DA14}.Release|x86.ActiveCfg = Release|Any CPU
- {4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Debug|x86.ActiveCfg = Debug|Any CPU
- {4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Release|Any CPU.Build.0 = Release|Any CPU
- {4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Release|x86.ActiveCfg = Release|Any CPU
{994351B4-7B2A-4139-8B72-72C5BB5CC618}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{994351B4-7B2A-4139-8B72-72C5BB5CC618}.Debug|Any CPU.Build.0 = Debug|Any CPU
{994351B4-7B2A-4139-8B72-72C5BB5CC618}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@@ -279,6 +267,18 @@ Global
{B9F08060-621F-4E1F-BDA8-9C4EA107E08A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{B9F08060-621F-4E1F-BDA8-9C4EA107E08A}.Release|x86.ActiveCfg = Release|Any CPU
{B9F08060-621F-4E1F-BDA8-9C4EA107E08A}.Release|x86.Build.0 = Release|Any CPU
+ {AA3661A1-CE8D-4597-ADFD-A5A30834E5D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AA3661A1-CE8D-4597-ADFD-A5A30834E5D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AA3661A1-CE8D-4597-ADFD-A5A30834E5D0}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {AA3661A1-CE8D-4597-ADFD-A5A30834E5D0}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {AA3661A1-CE8D-4597-ADFD-A5A30834E5D0}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {AA3661A1-CE8D-4597-ADFD-A5A30834E5D0}.Debug|x86.Build.0 = Debug|Any CPU
+ {AA3661A1-CE8D-4597-ADFD-A5A30834E5D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AA3661A1-CE8D-4597-ADFD-A5A30834E5D0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AA3661A1-CE8D-4597-ADFD-A5A30834E5D0}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {AA3661A1-CE8D-4597-ADFD-A5A30834E5D0}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {AA3661A1-CE8D-4597-ADFD-A5A30834E5D0}.Release|x86.ActiveCfg = Release|Any CPU
+ {AA3661A1-CE8D-4597-ADFD-A5A30834E5D0}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -287,7 +287,6 @@ Global
{C5F59CBA-DF2D-4983-8CBB-11B6AF21B416} = {ACAA0157-A8C4-4152-93DE-90CCDF304087}
{68A1F0E1-ECCE-46D1-B20F-C43EE5B097DE} = {509A6F36-AD80-4A18-B5B1-717D38DFF29D}
{589AC17F-9455-4764-8F82-FCD2AE58DA14} = {ACAA0157-A8C4-4152-93DE-90CCDF304087}
- {4D4A785A-ECB9-4916-A88F-0FD306EE3B74} = {B9729160-50A4-49C5-8BB2-4944492AEA30}
{994351B4-7B2A-4139-8B72-72C5BB5CC618} = {2AF90579-B118-4583-AE88-672EFACB5BC4}
{427CDB36-78B0-4583-9EBC-7F283DE60355} = {ACAA0157-A8C4-4152-93DE-90CCDF304087}
{4F5A6A72-FFE4-49C4-B4C6-58132CFCB9FE} = {509A6F36-AD80-4A18-B5B1-717D38DFF29D}
@@ -303,5 +302,6 @@ Global
{B0166AED-738F-42EE-AF4D-C487C8B21521} = {2AF90579-B118-4583-AE88-672EFACB5BC4}
{BFDFE1E3-A6A9-4DAB-8939-1DA306FC69C8} = {2AF90579-B118-4583-AE88-672EFACB5BC4}
{B9F08060-621F-4E1F-BDA8-9C4EA107E08A} = {509A6F36-AD80-4A18-B5B1-717D38DFF29D}
+ {AA3661A1-CE8D-4597-ADFD-A5A30834E5D0} = {2AF90579-B118-4583-AE88-672EFACB5BC4}
EndGlobalSection
EndGlobal
diff --git a/src/Microsoft.AspNetCore.Diagnostics.Elm/ElmPageMiddleware.cs b/src/Microsoft.AspNetCore.Diagnostics.Elm/ElmPageMiddleware.cs
index 3acce7f05a..63dffd492f 100644
--- a/src/Microsoft.AspNetCore.Diagnostics.Elm/ElmPageMiddleware.cs
+++ b/src/Microsoft.AspNetCore.Diagnostics.Elm/ElmPageMiddleware.cs
@@ -3,9 +3,8 @@
using System;
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Diagnostics.Elm.Views;
+using Microsoft.AspNetCore.Diagnostics.Elm.RazorViews;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.Linq;
diff --git a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/DetailsPage.Designer.cs b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/DetailsPage.Designer.cs
new file mode 100644
index 0000000000..0dde472543
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/DetailsPage.Designer.cs
@@ -0,0 +1,606 @@
+namespace Microsoft.AspNetCore.Diagnostics.Elm.RazorViews
+{
+#line 1 "DetailsPage.cshtml"
+using System
+
+#line default
+#line hidden
+ ;
+#line 2 "DetailsPage.cshtml"
+using System.Globalization
+
+#line default
+#line hidden
+ ;
+#line 3 "DetailsPage.cshtml"
+using System.Linq
+
+#line default
+#line hidden
+ ;
+#line 4 "DetailsPage.cshtml"
+using Microsoft.AspNetCore.Diagnostics.Elm
+
+#line default
+#line hidden
+ ;
+#line 5 "DetailsPage.cshtml"
+using Microsoft.AspNetCore.Diagnostics.Elm.RazorViews
+
+#line default
+#line hidden
+ ;
+#line 6 "DetailsPage.cshtml"
+using Microsoft.Extensions.RazorViews
+
+#line default
+#line hidden
+ ;
+#line 7 "DetailsPage.cshtml"
+using Microsoft.Extensions.Logging
+
+#line default
+#line hidden
+ ;
+ using System.Threading.Tasks;
+
+ internal class DetailsPage : Microsoft.Extensions.RazorViews.BaseView
+ {
+#line 10 "DetailsPage.cshtml"
+
+ public DetailsPage(DetailsPageModel model)
+ {
+ Model = model;
+ }
+
+ public DetailsPageModel Model { get; set; }
+
+ public HelperResult LogRow(LogInfo log)
+ {
+ return new HelperResult((writer) =>
+ {
+ if (log.Severity >= Model.Options.MinLevel &&
+ (string.IsNullOrEmpty(Model.Options.NamePrefix) || log.Name.StartsWith(Model.Options.NamePrefix, StringComparison.Ordinal)))
+ {
+ WriteLiteralTo(writer, " \r\n ");
+ WriteTo(writer, string.Format("{0:MM/dd/yy}", log.Time));
+ WriteLiteralTo(writer, " \r\n ");
+ WriteTo(writer, string.Format("{0:H:mm:ss}", log.Time));
+ var severity = log.Severity.ToString().ToLowerInvariant();
+ WriteLiteralTo(writer, $" \r\n ");
+ WriteTo(writer, log.Severity);
+
+ WriteLiteralTo(writer, $" \r\n ");
+ WriteTo(writer, log.Name);
+
+ WriteLiteralTo(writer, $" \r\n ");
+ WriteTo(writer, log.Message);
+
+ WriteLiteralTo(writer, $" \r\n ");
+ WriteTo(writer, log.Exception);
+
+ WriteLiteralTo(writer, " \r\n \r\n");
+ }
+ });
+ }
+
+ public HelperResult Traverse(ScopeNode node)
+ {
+ return new HelperResult((writer) =>
+ {
+ var messageIndex = 0;
+ var childIndex = 0;
+ while (messageIndex < node.Messages.Count && childIndex < node.Children.Count)
+ {
+ if (node.Messages[messageIndex].Time < node.Children[childIndex].StartTime)
+ {
+ LogRow(node.Messages[messageIndex]);
+ messageIndex++;
+ }
+ else
+ {
+ Traverse(node.Children[childIndex]);
+ childIndex++;
+ }
+ }
+ if (messageIndex < node.Messages.Count)
+ {
+ for (var i = messageIndex; i < node.Messages.Count; i++)
+ {
+ LogRow(node.Messages[i]);
+ }
+ }
+ else
+ {
+ for (var i = childIndex; i < node.Children.Count; i++)
+ {
+ Traverse(node.Children[i]);
+ }
+ }
+ });
+ }
+
+#line default
+#line hidden
+ #line hidden
+ public DetailsPage()
+ {
+ }
+
+ #pragma warning disable 1998
+ public override async Task ExecuteAsync()
+ {
+ WriteLiteral("\r\n");
+#line 84 "DetailsPage.cshtml"
+
+ Response.ContentType = "text/html; charset=utf-8";
+
+#line default
+#line hidden
+
+ WriteLiteral(@"
+
+
+
+ ASP.NET Core Logs
+
+
+
+
+ ASP.NET Core Logs
+");
+#line 192 "DetailsPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 192 "DetailsPage.cshtml"
+
+ var context = Model.Activity?.HttpInfo;
+
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 195 "DetailsPage.cshtml"
+ if (context != null)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n \r\n \r\n\r\n \r\n Path \r\n ");
+#line 203 "DetailsPage.cshtml"
+ Write(context.Path);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n \r\n \r\n Host \r\n ");
+#line 207 "DetailsPage.cshtml"
+ Write(context.Host);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n \r\n \r\n Content Type \r\n ");
+#line 211 "DetailsPage.cshtml"
+ Write(context.ContentType);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n \r\n \r\n Method \r\n ");
+#line 215 "DetailsPage.cshtml"
+ Write(context.Method);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n \r\n \r\n Protocol \r\n ");
+#line 219 "DetailsPage.cshtml"
+ Write(context.Protocol);
+
+#line default
+#line hidden
+ WriteLiteral(@"
+
+
+ Headers
+
+
+
+
+ Variable
+ Value
+
+
+
+");
+#line 232 "DetailsPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 232 "DetailsPage.cshtml"
+ foreach (var header in context.Headers)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n ");
+#line 235 "DetailsPage.cshtml"
+ Write(header.Key);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n ");
+#line 236 "DetailsPage.cshtml"
+ Write(string.Join(";", header.Value));
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n \r\n");
+#line 238 "DetailsPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n
\r\n \r\n \r\n \r\n Status Code \r\n ");
+#line 245 "DetailsPage.cshtml"
+ Write(context.StatusCode);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n \r\n \r\n User \r\n ");
+#line 249 "DetailsPage.cshtml"
+ Write(context.User.Identity.Name);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n \r\n \r\n Claims \r\n \r\n");
+#line 254 "DetailsPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 254 "DetailsPage.cshtml"
+ if (context.User.Claims.Any())
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(@"
+
+
+ Issuer
+ Value
+
+
+
+");
+#line 264 "DetailsPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 264 "DetailsPage.cshtml"
+ foreach (var claim in context.User.Claims)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n ");
+#line 267 "DetailsPage.cshtml"
+ Write(claim.Issuer);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n ");
+#line 268 "DetailsPage.cshtml"
+ Write(claim.Value);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n \r\n");
+#line 270 "DetailsPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n
\r\n");
+#line 273 "DetailsPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n \r\n \r\n Scheme \r\n ");
+#line 278 "DetailsPage.cshtml"
+ Write(context.Scheme);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n \r\n \r\n Query \r\n ");
+#line 282 "DetailsPage.cshtml"
+ Write(context.Query.Value);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n \r\n \r\n Cookies \r\n \r\n");
+#line 287 "DetailsPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 287 "DetailsPage.cshtml"
+ if (context.Cookies.Any())
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(@"
+
+
+ Variable
+ Value
+
+
+
+");
+#line 297 "DetailsPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 297 "DetailsPage.cshtml"
+ foreach (var cookie in context.Cookies)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n ");
+#line 300 "DetailsPage.cshtml"
+ Write(cookie.Key);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n ");
+#line 301 "DetailsPage.cshtml"
+ Write(string.Join(";", cookie.Value));
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n \r\n");
+#line 303 "DetailsPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n
\r\n");
+#line 306 "DetailsPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n \r\n
\r\n");
+#line 310 "DetailsPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" Logs \r\n
+
+
+
+ Date
+ Time
+ Severity
+ Name
+ State
+ Error
+
+
+ ");
+#line 341 "DetailsPage.cshtml"
+ Write(Traverse(Model.Activity.Root));
+
+#line default
+#line hidden
+ WriteLiteral(@"
+
+
+
+");
+ }
+ #pragma warning restore 1998
+ }
+}
diff --git a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/DetailsPage.cshtml b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/DetailsPage.cshtml
index db56b731e1..f0519b8fee 100644
--- a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/DetailsPage.cshtml
+++ b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/DetailsPage.cshtml
@@ -2,8 +2,8 @@
@using System.Globalization
@using System.Linq
@using Microsoft.AspNetCore.Diagnostics.Elm
-@using Microsoft.AspNetCore.Diagnostics.Elm.Views
-@using Microsoft.AspNetCore.DiagnosticsViewPage.Views
+@using Microsoft.AspNetCore.Diagnostics.Elm.RazorViews
+@using Microsoft.Extensions.RazorViews
@using Microsoft.Extensions.Logging
@functions
@@ -82,7 +82,7 @@
}
}
@{
- Response.ContentType = "text/html";
+ Response.ContentType = "text/html; charset=utf-8";
}
@@ -91,7 +91,7 @@
ASP.NET Core Logs
diff --git a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/DetailsPageModel.cs b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/DetailsPageModel.cs
index 19304a5e43..1b9c2a64b0 100644
--- a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/DetailsPageModel.cs
+++ b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/DetailsPageModel.cs
@@ -1,6 +1,6 @@
using System;
-namespace Microsoft.AspNetCore.Diagnostics.Elm.Views
+namespace Microsoft.AspNetCore.Diagnostics.Elm.RazorViews
{
public class DetailsPageModel
{
diff --git a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/LogPage.Designer.cs b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/LogPage.Designer.cs
new file mode 100644
index 0000000000..1fa50b2f58
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/LogPage.Designer.cs
@@ -0,0 +1,710 @@
+namespace Microsoft.AspNetCore.Diagnostics.Elm.RazorViews
+{
+#line 1 "LogPage.cshtml"
+using System
+
+#line default
+#line hidden
+ ;
+#line 2 "LogPage.cshtml"
+using System.Collections.Generic
+
+#line default
+#line hidden
+ ;
+#line 3 "LogPage.cshtml"
+using System.Globalization
+
+#line default
+#line hidden
+ ;
+#line 4 "LogPage.cshtml"
+using System.Linq
+
+#line default
+#line hidden
+ ;
+#line 5 "LogPage.cshtml"
+using Microsoft.AspNetCore.Diagnostics.Elm
+
+#line default
+#line hidden
+ ;
+#line 6 "LogPage.cshtml"
+using Microsoft.AspNetCore.Diagnostics.Elm.RazorViews
+
+#line default
+#line hidden
+ ;
+#line 7 "LogPage.cshtml"
+using Microsoft.Extensions.RazorViews
+
+#line default
+#line hidden
+ ;
+#line 8 "LogPage.cshtml"
+using Microsoft.Extensions.Logging
+
+#line default
+#line hidden
+ ;
+ using System.Threading.Tasks;
+
+ internal class LogPage : Microsoft.Extensions.RazorViews.BaseView
+ {
+#line 11 "LogPage.cshtml"
+
+ public LogPage(LogPageModel model)
+ {
+ Model = model;
+ }
+
+ public LogPageModel Model { get; set; }
+
+ public HelperResult LogRow(LogInfo log, int level)
+ {
+ return new HelperResult((writer) =>
+ {
+ if (log.Severity >= Model.Options.MinLevel &&
+ (string.IsNullOrEmpty(Model.Options.NamePrefix) || log.Name.StartsWith(Model.Options.NamePrefix, StringComparison.Ordinal)))
+ {
+
+ WriteLiteralTo(writer, " \r\n ");
+ WriteTo(writer, string.Format("{0:MM/dd/yy}", log.Time));
+
+ WriteLiteralTo(writer, " \r\n ");
+ WriteTo(writer, string.Format("{0:H:mm:ss}", log.Time));
+
+ WriteLiteralTo(writer, $" \r\n ");
+ WriteTo(writer, log.Name);
+ var severity = log.Severity.ToString().ToLowerInvariant();
+ WriteLiteralTo(writer, $" \r\n ");
+ WriteTo(writer, log.Severity);
+
+ WriteLiteralTo(writer, $" \r\n \r\n");
+
+ for (var i = 0; i < level; i++)
+ {
+ WriteLiteralTo(writer, " \r\n");
+ }
+
+ WriteLiteralTo(writer, " ");
+ WriteTo(writer, log.Message);
+
+ WriteLiteralTo(writer, $"\r\n \r\n ");
+
+ WriteTo(writer, log.Exception);
+
+ WriteLiteralTo(writer, " \r\n \r\n");
+
+ }
+ });
+ }
+
+ public HelperResult Traverse(ScopeNode node, int level, Dictionary counts)
+ {
+ return new HelperResult((writer) => {
+ // print start of scope
+ WriteTo(writer, LogRow(new LogInfo()
+ {
+ Name = node.Name,
+ Time = node.StartTime,
+ Severity = LogLevel.Debug,
+ Message = "Beginning " + node.State,
+ }, level));
+
+ var messageIndex = 0;
+ var childIndex = 0;
+ while (messageIndex < node.Messages.Count && childIndex < node.Children.Count)
+ {
+ if (node.Messages[messageIndex].Time < node.Children[childIndex].StartTime)
+ {
+ WriteTo(writer, LogRow(node.Messages[messageIndex], level));
+
+ counts[node.Messages[messageIndex].Severity.ToString()]++;
+ messageIndex++;
+ }
+ else
+ {
+ WriteTo(writer, Traverse(node.Children[childIndex], level + 1, counts));
+ childIndex++;
+ }
+ }
+ if (messageIndex < node.Messages.Count)
+ {
+ for (var i = messageIndex; i < node.Messages.Count; i++)
+ {
+ WriteTo(writer, LogRow(node.Messages[i], level));
+ counts[node.Messages[i].Severity.ToString()]++;
+ }
+ }
+ else
+ {
+ for (var i = childIndex; i < node.Children.Count; i++)
+ {
+ WriteTo(writer, Traverse(node.Children[i], level + 1, counts));
+ }
+ }
+ // print end of scope
+ WriteTo(writer, LogRow(new LogInfo()
+ {
+ Name = node.Name,
+ Time = node.EndTime,
+ Severity = LogLevel.Debug,
+ Message = string.Format("Completed {0} in {1}ms", node.State, node.EndTime - node.StartTime)
+ }, level));
+ });
+ }
+
+#line default
+#line hidden
+ #line hidden
+ public LogPage()
+ {
+ }
+
+ #pragma warning disable 1998
+ public override async Task ExecuteAsync()
+ {
+ WriteLiteral("\r\n");
+#line 114 "LogPage.cshtml"
+
+ Response.ContentType = "text/html; charset=utf-8";
+
+#line default
+#line hidden
+
+ WriteLiteral(@"
+
+
+
+
+ ASP.NET Core Logs
+
+ \r\n\r\n\r\n ASP.NET Core Logs \r\n
+
+
+
+
+
+ Path
+ Method
+ Host
+ Status Code
+ Logs
+
+
+
+
+
+
+
+
+
+");
+#line 317 "LogPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 317 "LogPage.cshtml"
+ foreach (var activity in Model.Activities.Reverse())
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n \r\n");
+#line 321 "LogPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 321 "LogPage.cshtml"
+
+ var activityPath = Model.Path.Value + "/" + activity.Id;
+ if (activity.HttpInfo != null)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" \t");
+#line 325 "LogPage.cshtml"
+ Write(activity.HttpInfo.Path);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n ");
+#line 326 "LogPage.cshtml"
+ Write(activity.HttpInfo.Method);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n ");
+#line 327 "LogPage.cshtml"
+ Write(activity.HttpInfo.Host);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n ");
+#line 328 "LogPage.cshtml"
+ Write(activity.HttpInfo.StatusCode);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n");
+#line 329 "LogPage.cshtml"
+ }
+ else if (activity.RepresentsScope)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 332 "LogPage.cshtml"
+ Write(activity.Root.State);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n");
+#line 333 "LogPage.cshtml"
+ }
+ else
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" Non-scope Log \r\n");
+#line 337 "LogPage.cshtml"
+ }
+
+
+#line default
+#line hidden
+
+ WriteLiteral(@"
+
+
+
+ Date
+ Time
+ Name
+ Severity
+ State
+ Error^
+
+
+");
+#line 351 "LogPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 351 "LogPage.cshtml"
+
+ var counts = new Dictionary();
+ counts["Critical"] = 0;
+ counts["Error"] = 0;
+ counts["Warning"] = 0;
+ counts["Information"] = 0;
+ counts["Debug"] = 0;
+
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n");
+#line 360 "LogPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 360 "LogPage.cshtml"
+ if (!activity.RepresentsScope)
+ {
+ // message not within a scope
+ var logInfo = activity.Root.Messages.FirstOrDefault();
+
+
+#line default
+#line hidden
+
+#line 364 "LogPage.cshtml"
+ Write(LogRow(logInfo, 0));
+
+#line default
+#line hidden
+#line 364 "LogPage.cshtml"
+
+ counts[logInfo.Severity.ToString()] = 1;
+ }
+ else
+ {
+
+
+#line default
+#line hidden
+
+#line 369 "LogPage.cshtml"
+ Write(Traverse(activity.Root, 0, counts));
+
+#line default
+#line hidden
+#line 369 "LogPage.cshtml"
+
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n \r\n \r\n ");
+#line 374 "LogPage.cshtml"
+ Write(activity.Time.ToString("MM-dd-yyyy HH:mm:ss"));
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n");
+#line 375 "LogPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 375 "LogPage.cshtml"
+ foreach (var kvp in counts)
+ {
+ if (string.Equals("Debug", kvp.Key)) {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 378 "LogPage.cshtml"
+ Write(kvp.Value);
+
+#line default
+#line hidden
+ WriteLiteral(" ");
+#line 378 "LogPage.cshtml"
+ Write(kvp.Key);
+
+#line default
+#line hidden
+ WriteLiteral("v \r\n");
+#line 379 "LogPage.cshtml"
+ }
+ else
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 382 "LogPage.cshtml"
+ Write(kvp.Value);
+
+#line default
+#line hidden
+ WriteLiteral(" ");
+#line 382 "LogPage.cshtml"
+ Write(kvp.Key);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n");
+#line 383 "LogPage.cshtml"
+ }
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n \r\n
\r\n \r\n \r\n \r\n");
+#line 391 "LogPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(@"
+
+
+");
+ }
+ #pragma warning restore 1998
+ }
+}
diff --git a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/LogPage.cshtml b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/LogPage.cshtml
index b8e356df46..870a3579c5 100644
--- a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/LogPage.cshtml
+++ b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/LogPage.cshtml
@@ -3,8 +3,8 @@
@using System.Globalization
@using System.Linq
@using Microsoft.AspNetCore.Diagnostics.Elm
-@using Microsoft.AspNetCore.Diagnostics.Elm.Views
-@using Microsoft.AspNetCore.DiagnosticsViewPage.Views
+@using Microsoft.AspNetCore.Diagnostics.Elm.RazorViews
+@using Microsoft.Extensions.RazorViews
@using Microsoft.Extensions.Logging
@functions
@@ -111,8 +111,8 @@
});
}
}
-@{
- Response.ContentType = "text/html";
+@{
+ Response.ContentType = "text/html; charset=utf-8";
}
@@ -205,7 +205,7 @@
var counts = new Dictionary();
counts["Critical"] = 0;
counts["Error"] = 0;
- counts["Warning"] = 0;
+ counts["Warning"] = 0;
counts["Information"] = 0;
counts["Debug"] = 0;
}
diff --git a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/LogPageModel.cs b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/LogPageModel.cs
index f60b04fb44..46c20d9689 100644
--- a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/LogPageModel.cs
+++ b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/LogPageModel.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
-namespace Microsoft.AspNetCore.Diagnostics.Elm.Views
+namespace Microsoft.AspNetCore.Diagnostics.Elm.RazorViews
{
public class LogPageModel
{
diff --git a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/DetailsPage.cs b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/DetailsPage.cs
similarity index 99%
rename from src/Microsoft.AspNetCore.Diagnostics.Elm/Views/DetailsPage.cs
rename to src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/DetailsPage.cs
index dc0085f892..df09b8eca9 100644
--- a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/DetailsPage.cs
+++ b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/DetailsPage.cs
@@ -43,7 +43,7 @@ using Microsoft.Extensions.Logging
#line hidden
;
using System.Threading.Tasks;
-
+ [Obsolete("This type is for internal use only and will be removed in a future version.")]
public class DetailsPage : Microsoft.AspNetCore.DiagnosticsViewPage.Views.BaseView
{
#line 10 "DetailsPage.cshtml"
diff --git a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/DetailsPage.cshtml b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/DetailsPage.cshtml
new file mode 100644
index 0000000000..db56b731e1
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/DetailsPage.cshtml
@@ -0,0 +1,258 @@
+@using System
+@using System.Globalization
+@using System.Linq
+@using Microsoft.AspNetCore.Diagnostics.Elm
+@using Microsoft.AspNetCore.Diagnostics.Elm.Views
+@using Microsoft.AspNetCore.DiagnosticsViewPage.Views
+@using Microsoft.Extensions.Logging
+
+@functions
+{
+ public DetailsPage(DetailsPageModel model)
+ {
+ Model = model;
+ }
+
+ public DetailsPageModel Model { get; set; }
+
+ public HelperResult LogRow(LogInfo log)
+ {
+ return new HelperResult((writer) =>
+ {
+ if (log.Severity >= Model.Options.MinLevel &&
+ (string.IsNullOrEmpty(Model.Options.NamePrefix) || log.Name.StartsWith(Model.Options.NamePrefix, StringComparison.Ordinal)))
+ {
+ WriteLiteralTo(writer, " \r\n ");
+ WriteTo(writer, string.Format("{0:MM/dd/yy}", log.Time));
+ WriteLiteralTo(writer, " \r\n ");
+ WriteTo(writer, string.Format("{0:H:mm:ss}", log.Time));
+ var severity = log.Severity.ToString().ToLowerInvariant();
+ WriteLiteralTo(writer, $" \r\n ");
+ WriteTo(writer, log.Severity);
+
+ WriteLiteralTo(writer, $" \r\n ");
+ WriteTo(writer, log.Name);
+
+ WriteLiteralTo(writer, $" \r\n ");
+ WriteTo(writer, log.Message);
+
+ WriteLiteralTo(writer, $" \r\n ");
+ WriteTo(writer, log.Exception);
+
+ WriteLiteralTo(writer, " \r\n \r\n");
+ }
+ });
+ }
+
+ public HelperResult Traverse(ScopeNode node)
+ {
+ return new HelperResult((writer) =>
+ {
+ var messageIndex = 0;
+ var childIndex = 0;
+ while (messageIndex < node.Messages.Count && childIndex < node.Children.Count)
+ {
+ if (node.Messages[messageIndex].Time < node.Children[childIndex].StartTime)
+ {
+ LogRow(node.Messages[messageIndex]);
+ messageIndex++;
+ }
+ else
+ {
+ Traverse(node.Children[childIndex]);
+ childIndex++;
+ }
+ }
+ if (messageIndex < node.Messages.Count)
+ {
+ for (var i = messageIndex; i < node.Messages.Count; i++)
+ {
+ LogRow(node.Messages[i]);
+ }
+ }
+ else
+ {
+ for (var i = childIndex; i < node.Children.Count; i++)
+ {
+ Traverse(node.Children[i]);
+ }
+ }
+ });
+ }
+}
+@{
+ Response.ContentType = "text/html";
+}
+
+
+
+
+ ASP.NET Core Logs
+
+
+
+
+ ASP.NET Core Logs
+ @{
+ var context = Model.Activity?.HttpInfo;
+ }
+ @if (context != null)
+ {
+
+
+
+
+
+ Path
+ @context.Path
+
+
+ Host
+ @context.Host
+
+
+ Content Type
+ @context.ContentType
+
+
+ Method
+ @context.Method
+
+
+ Protocol
+ @context.Protocol
+
+
+ Headers
+
+
+
+ Status Code
+ @context.StatusCode
+
+
+ User
+ @context.User.Identity.Name
+
+
+ Claims
+
+ @if (context.User.Claims.Any())
+ {
+
+
+
+ Issuer
+ Value
+
+
+
+ @foreach (var claim in context.User.Claims)
+ {
+
+ @claim.Issuer
+ @claim.Value
+
+ }
+
+
+ }
+
+
+
+ Scheme
+ @context.Scheme
+
+
+ Query
+ @context.Query.Value
+
+
+ Cookies
+
+ @if (context.Cookies.Any())
+ {
+
+
+
+ Variable
+ Value
+
+
+
+ @foreach (var cookie in context.Cookies)
+ {
+
+ @cookie.Key
+ @string.Join(";", cookie.Value)
+
+ }
+
+
+ }
+
+
+
+ }
+ Logs
+
+
+
+
+ Date
+ Time
+ Severity
+ Name
+ State
+ Error
+
+
+ @Traverse(Model.Activity.Root)
+
+
+
+
\ No newline at end of file
diff --git a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/DetailsPage.css b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/DetailsPage.css
new file mode 100644
index 0000000000..d0803ebf3f
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/DetailsPage.css
@@ -0,0 +1,56 @@
+body {
+ font-size: 0.9em;
+ width: 90%;
+ margin: 0px auto;
+}
+
+h1 {
+ padding-bottom: 10px;
+}
+
+h2 {
+ font-weight: normal;
+}
+
+table {
+ border-spacing: 0px;
+ width: 100%;
+ border-collapse: collapse;
+ border: 1px solid black;
+ white-space: pre-wrap;
+}
+
+th {
+ font-family: Arial;
+}
+
+td, th {
+ padding: 8px;
+}
+
+#headerTable, #cookieTable {
+ border: none;
+ height: 100%;
+}
+
+#headerTd {
+ white-space: normal;
+}
+
+#label {
+ width: 20%;
+ border-right: 1px solid black;
+}
+
+#logs{
+ margin-top: 10px;
+ margin-bottom: 20px;
+}
+
+#logs>tbody>tr>td {
+ border-right: 1px dashed lightgray;
+}
+
+#logs>thead>tr>th {
+ border: 1px solid black;
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/DetailsPageModel.cs b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/DetailsPageModel.cs
new file mode 100644
index 0000000000..5ae8e15579
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/DetailsPageModel.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace Microsoft.AspNetCore.Diagnostics.Elm.Views
+{
+ [Obsolete("This type is for internal use only and will be removed in a future version.")]
+ public class DetailsPageModel
+ {
+ public ActivityContext Activity { get; set; }
+
+ public ViewOptions Options { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/LogPage.cs b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/LogPage.cs
similarity index 99%
rename from src/Microsoft.AspNetCore.Diagnostics.Elm/Views/LogPage.cs
rename to src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/LogPage.cs
index 21a46aed52..4108ebe4db 100644
--- a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/LogPage.cs
+++ b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/LogPage.cs
@@ -49,7 +49,7 @@ using Microsoft.Extensions.Logging
#line hidden
;
using System.Threading.Tasks;
-
+ [Obsolete("This type is for internal use only and will be removed in a future version.")]
public class LogPage : Microsoft.AspNetCore.DiagnosticsViewPage.Views.BaseView
{
#line 11 "LogPage.cshtml"
diff --git a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/LogPage.cshtml b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/LogPage.cshtml
new file mode 100644
index 0000000000..b8e356df46
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/LogPage.cshtml
@@ -0,0 +1,263 @@
+@using System
+@using System.Collections.Generic
+@using System.Globalization
+@using System.Linq
+@using Microsoft.AspNetCore.Diagnostics.Elm
+@using Microsoft.AspNetCore.Diagnostics.Elm.Views
+@using Microsoft.AspNetCore.DiagnosticsViewPage.Views
+@using Microsoft.Extensions.Logging
+
+@functions
+{
+ public LogPage(LogPageModel model)
+ {
+ Model = model;
+ }
+
+ public LogPageModel Model { get; set; }
+
+ public HelperResult LogRow(LogInfo log, int level)
+ {
+ return new HelperResult((writer) =>
+ {
+ if (log.Severity >= Model.Options.MinLevel &&
+ (string.IsNullOrEmpty(Model.Options.NamePrefix) || log.Name.StartsWith(Model.Options.NamePrefix, StringComparison.Ordinal)))
+ {
+
+ WriteLiteralTo(writer, " \r\n ");
+ WriteTo(writer, string.Format("{0:MM/dd/yy}", log.Time));
+
+ WriteLiteralTo(writer, " \r\n ");
+ WriteTo(writer, string.Format("{0:H:mm:ss}", log.Time));
+
+ WriteLiteralTo(writer, $" \r\n ");
+ WriteTo(writer, log.Name);
+ var severity = log.Severity.ToString().ToLowerInvariant();
+ WriteLiteralTo(writer, $" \r\n ");
+ WriteTo(writer, log.Severity);
+
+ WriteLiteralTo(writer, $" \r\n \r\n");
+
+ for (var i = 0; i < level; i++)
+ {
+ WriteLiteralTo(writer, " \r\n");
+ }
+
+ WriteLiteralTo(writer, " ");
+ WriteTo(writer, log.Message);
+
+ WriteLiteralTo(writer, $"\r\n \r\n ");
+
+ WriteTo(writer, log.Exception);
+
+ WriteLiteralTo(writer, " \r\n \r\n");
+
+ }
+ });
+ }
+
+ public HelperResult Traverse(ScopeNode node, int level, Dictionary counts)
+ {
+ return new HelperResult((writer) => {
+ // print start of scope
+ WriteTo(writer, LogRow(new LogInfo()
+ {
+ Name = node.Name,
+ Time = node.StartTime,
+ Severity = LogLevel.Debug,
+ Message = "Beginning " + node.State,
+ }, level));
+
+ var messageIndex = 0;
+ var childIndex = 0;
+ while (messageIndex < node.Messages.Count && childIndex < node.Children.Count)
+ {
+ if (node.Messages[messageIndex].Time < node.Children[childIndex].StartTime)
+ {
+ WriteTo(writer, LogRow(node.Messages[messageIndex], level));
+
+ counts[node.Messages[messageIndex].Severity.ToString()]++;
+ messageIndex++;
+ }
+ else
+ {
+ WriteTo(writer, Traverse(node.Children[childIndex], level + 1, counts));
+ childIndex++;
+ }
+ }
+ if (messageIndex < node.Messages.Count)
+ {
+ for (var i = messageIndex; i < node.Messages.Count; i++)
+ {
+ WriteTo(writer, LogRow(node.Messages[i], level));
+ counts[node.Messages[i].Severity.ToString()]++;
+ }
+ }
+ else
+ {
+ for (var i = childIndex; i < node.Children.Count; i++)
+ {
+ WriteTo(writer, Traverse(node.Children[i], level + 1, counts));
+ }
+ }
+ // print end of scope
+ WriteTo(writer, LogRow(new LogInfo()
+ {
+ Name = node.Name,
+ Time = node.EndTime,
+ Severity = LogLevel.Debug,
+ Message = string.Format("Completed {0} in {1}ms", node.State, node.EndTime - node.StartTime)
+ }, level));
+ });
+ }
+}
+@{
+ Response.ContentType = "text/html";
+}
+
+
+
+
+
+ ASP.NET Core Logs
+
+
+
+
+ ASP.NET Core Logs
+
+
+
+
+
+
+
+
+
+
+
+
+ @foreach (var activity in Model.Activities.Reverse())
+ {
+
+
+ @{
+ var activityPath = Model.Path.Value + "/" + activity.Id;
+ if (activity.HttpInfo != null)
+ {
+ @activity.HttpInfo.Path
+ @activity.HttpInfo.Method
+ @activity.HttpInfo.Host
+ @activity.HttpInfo.StatusCode
+ }
+ else if (activity.RepresentsScope)
+ {
+ @activity.Root.State
+ }
+ else
+ {
+ Non-scope Log
+ }
+ }
+
+
+
+ @{
+ var counts = new Dictionary();
+ counts["Critical"] = 0;
+ counts["Error"] = 0;
+ counts["Warning"] = 0;
+ counts["Information"] = 0;
+ counts["Debug"] = 0;
+ }
+
+ @if (!activity.RepresentsScope)
+ {
+ // message not within a scope
+ var logInfo = activity.Root.Messages.FirstOrDefault();
+ @LogRow(logInfo, 0)
+ counts[logInfo.Severity.ToString()] = 1;
+ }
+ else
+ {
+ @Traverse(activity.Root, 0, counts)
+ }
+
+
+
+ @activity.Time.ToString("MM-dd-yyyy HH:mm:ss")
+ @foreach (var kvp in counts)
+ {
+ if (string.Equals("Debug", kvp.Key)) {
+ @kvp.Value @kvp.Keyv
+ }
+ else
+ {
+ @kvp.Value @kvp.Key
+ }
+ }
+
+
+
+
+
+
+ }
+
+
+
+
\ No newline at end of file
diff --git a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/LogPage.css b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/LogPage.css
new file mode 100644
index 0000000000..420cc18121
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/LogPage.css
@@ -0,0 +1,110 @@
+body {
+ font-size: .813em;
+ white-space: nowrap;
+ margin: 20px;
+}
+
+col:nth-child(2n) {
+ background-color: #FAFAFA;
+}
+
+form {
+ display: inline-block;
+}
+
+h1 {
+ margin-left: 25px;
+}
+
+table {
+ margin: 0px auto;
+ border-collapse: collapse;
+ border-spacing: 0px;
+ table-layout: fixed;
+ width: 100%;
+}
+
+td, th {
+ padding: 4px;
+}
+
+thead {
+ font-size: 1em;
+ font-family: Arial;
+}
+
+tr {
+ height: 23px;
+}
+
+#requestHeader {
+ border-bottom: solid 1px gray;
+ border-top: solid 1px gray;
+ margin-bottom: 2px;
+ font-size: 1em;
+ line-height: 2em;
+}
+
+.collapse {
+ color: black;
+ float: right;
+ font-weight: normal;
+ width: 1em;
+}
+
+.date, .time {
+ width: 70px;
+}
+
+.logHeader {
+ border-bottom: 1px solid lightgray;
+ color: gray;
+ text-align: left;
+}
+
+.logState {
+ text-overflow: ellipsis;
+ overflow: hidden;
+}
+
+.logTd {
+ border-left: 1px solid gray;
+ padding: 0px;
+}
+
+.logs {
+ width: 80%;
+}
+
+.logRow:hover {
+ background-color: #D6F5FF;
+}
+
+.requestRow>td {
+ border-bottom: solid 1px gray;
+}
+
+.severity {
+ width: 80px;
+}
+
+.summary {
+ color: black;
+ line-height: 1.8em;
+}
+
+.summary>th {
+ font-weight: normal;
+}
+
+.tab {
+ margin-left: 30px;
+}
+
+#viewOptions {
+ margin: 20px;
+}
+
+#viewOptions > * {
+ margin: 5px;
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/LogPageModel.cs b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/LogPageModel.cs
new file mode 100644
index 0000000000..8041b21233
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/LogPageModel.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using Microsoft.AspNetCore.Http;
+
+namespace Microsoft.AspNetCore.Diagnostics.Elm.Views
+{
+ [Obsolete("This type is for internal use only and will be removed in a future version.")]
+ public class LogPageModel
+ {
+ public IEnumerable Activities { get; set; }
+
+ public ViewOptions Options { get; set; }
+
+ public PathString Path { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/Shared.css b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/Shared.css
new file mode 100644
index 0000000000..18c14c10d1
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics.Elm/Views/Obsolete/Shared.css
@@ -0,0 +1,39 @@
+body {
+ font-family: 'Segoe UI', Tahoma, Arial, Helvtica, sans-serif;
+ line-height: 1.4em;
+}
+
+h1 {
+ font-family: 'Segoe UI', Helvetica, sans-serif;
+ font-size: 2.5em;
+}
+
+td {
+ text-overflow: ellipsis;
+ overflow: hidden;
+}
+
+tr:nth-child(2n) {
+ background-color: #F6F6F6;
+}
+
+.critical {
+ background-color: red;
+ color: white;
+}
+
+.error {
+ color: red;
+}
+
+.information {
+ color: blue;
+}
+
+.debug {
+ color: black;
+}
+
+.warning {
+ color: orange;
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNetCore.Diagnostics.Elm/project.json b/src/Microsoft.AspNetCore.Diagnostics.Elm/project.json
index 7da8b4862e..7cf9b82cea 100644
--- a/src/Microsoft.AspNetCore.Diagnostics.Elm/project.json
+++ b/src/Microsoft.AspNetCore.Diagnostics.Elm/project.json
@@ -24,10 +24,17 @@
"type": "build",
"version": "1.1.0-*"
},
+ "Microsoft.Extensions.RazorViews.Sources": {
+ "type": "build",
+ "version": "1.1.0-*"
+ },
"Microsoft.AspNetCore.Http.Abstractions": "1.1.0-*",
"Microsoft.Extensions.Logging.Abstractions": "1.1.0-*",
"Microsoft.Extensions.Options": "1.1.0-*"
},
+ "tools": {
+ "RazorPageGenerator": "1.1.0-*"
+ },
"frameworks": {
"net451": {
"frameworkAssemblies": {
diff --git a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/DatabaseErrorPageMiddleware.cs b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/DatabaseErrorPageMiddleware.cs
index 4cb9ec39f4..297b3dc3ec 100644
--- a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/DatabaseErrorPageMiddleware.cs
+++ b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/DatabaseErrorPageMiddleware.cs
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Utilities;
-using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Views;
+using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.RazorViews;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
@@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
/// Delegate to execute the next piece of middleware in the request pipeline.
/// The to resolve services from.
///
- /// The for the application. This middleware both produces logging messages and
+ /// The for the application. This middleware both produces logging messages and
/// consumes them to detect database related exception.
///
/// The options to control what information is displayed on the error page.
diff --git a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Properties/AssemblyInfo.cs
index e3ae91c58b..cc2655f392 100644
--- a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Properties/AssemblyInfo.cs
+++ b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Properties/AssemblyInfo.cs
@@ -3,7 +3,9 @@
using System.Reflection;
using System.Resources;
+using System.Runtime.CompilerServices;
+[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyCompany("Microsoft Corporation.")]
diff --git a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/DatabaseErrorPage.Designer.cs b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/DatabaseErrorPage.Designer.cs
new file mode 100644
index 0000000000..eb5626daa6
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/DatabaseErrorPage.Designer.cs
@@ -0,0 +1,457 @@
+namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.RazorViews
+{
+#line 1 "DatabaseErrorPage.cshtml"
+using System
+
+#line default
+#line hidden
+ ;
+#line 2 "DatabaseErrorPage.cshtml"
+using System.Linq
+
+#line default
+#line hidden
+ ;
+#line 3 "DatabaseErrorPage.cshtml"
+using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
+
+#line default
+#line hidden
+ ;
+#line 4 "DatabaseErrorPage.cshtml"
+using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.RazorViews
+
+#line default
+#line hidden
+ ;
+ using System.Threading.Tasks;
+
+ internal class DatabaseErrorPage : Microsoft.Extensions.RazorViews.BaseView
+ {
+#line 11 "DatabaseErrorPage.cshtml"
+
+ public DatabaseErrorPageModel Model { get; set; }
+
+ public string UrlEncode(string content)
+ {
+ return UrlEncoder.Encode(content);
+ }
+
+ public string JavaScriptEncode(string content)
+ {
+ return JavaScriptEncoder.Encode(content);
+ }
+
+#line default
+#line hidden
+ #line hidden
+ public DatabaseErrorPage()
+ {
+ }
+
+ #pragma warning disable 1998
+ public override async Task ExecuteAsync()
+ {
+#line 5 "DatabaseErrorPage.cshtml"
+
+ Response.StatusCode = 500;
+ Response.ContentType = "text/html; charset=utf-8";
+ Response.ContentLength = null; // Clear any prior Content-Length
+
+#line default
+#line hidden
+
+ WriteLiteral(@"
+
+
+
+
+ Internal Server Error
+
+
+
+ ");
+#line 113 "DatabaseErrorPage.cshtml"
+ Write(Strings.DatabaseErrorPage_Title);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n \r\n");
+#line 115 "DatabaseErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 115 "DatabaseErrorPage.cshtml"
+ for (Exception ex = Model.Exception; ex != null; ex = ex.InnerException)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 117 "DatabaseErrorPage.cshtml"
+ Write(ex.GetType().Name);
+
+#line default
+#line hidden
+ WriteLiteral(": ");
+#line 117 "DatabaseErrorPage.cshtml"
+ Write(ex.Message);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n \r\n");
+#line 119 "DatabaseErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral("
\r\n \r\n\r\n");
+#line 123 "DatabaseErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 123 "DatabaseErrorPage.cshtml"
+ if (!Model.DatabaseExists && !Model.PendingMigrations.Any())
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 125 "DatabaseErrorPage.cshtml"
+ Write(Strings.FormatDatabaseErrorPage_NoDbOrMigrationsTitle(Model.ContextType.Name));
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n ");
+#line 126 "DatabaseErrorPage.cshtml"
+ Write(Strings.DatabaseErrorPage_NoDbOrMigrationsInfoPMC);
+
+#line default
+#line hidden
+ WriteLiteral("
\r\n ");
+#line 127 "DatabaseErrorPage.cshtml"
+ Write(Strings.DatabaseErrorPage_AddMigrationCommandPMC);
+
+#line default
+#line hidden
+ WriteLiteral("\r\n \r\n ");
+#line 129 "DatabaseErrorPage.cshtml"
+ Write(Strings.DatabaseErrorPage_ApplyMigrationsCommandPMC);
+
+#line default
+#line hidden
+ WriteLiteral("\r\n ");
+#line 130 "DatabaseErrorPage.cshtml"
+ Write(Strings.DatabaseErrorPage_NoDbOrMigrationsInfoCLI);
+
+#line default
+#line hidden
+ WriteLiteral("
\r\n ");
+#line 131 "DatabaseErrorPage.cshtml"
+ Write(Strings.DatabaseErrorPage_AddMigrationCommandCLI);
+
+#line default
+#line hidden
+ WriteLiteral("\r\n \r\n ");
+#line 133 "DatabaseErrorPage.cshtml"
+ Write(Strings.DatabaseErrorPage_ApplyMigrationsCommandCLI);
+
+#line default
+#line hidden
+ WriteLiteral("\r\n \r\n");
+#line 135 "DatabaseErrorPage.cshtml"
+ }
+ else if (Model.PendingMigrations.Any())
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n
");
+#line 139 "DatabaseErrorPage.cshtml"
+ Write(Strings.FormatDatabaseErrorPage_PendingMigrationsTitle(Model.ContextType.Name));
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n
");
+#line 140 "DatabaseErrorPage.cshtml"
+ Write(Strings.FormatDatabaseErrorPage_PendingMigrationsInfo(Model.ContextType.Name));
+
+#line default
+#line hidden
+ WriteLiteral("
\r\n\r\n
\r\n");
+#line 143 "DatabaseErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 143 "DatabaseErrorPage.cshtml"
+ foreach (var migration in Model.PendingMigrations)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 145 "DatabaseErrorPage.cshtml"
+ Write(migration);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n");
+#line 146 "DatabaseErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n\r\n
\r\n ");
+#line 150 "DatabaseErrorPage.cshtml"
+ Write(Strings.DatabaseErrorPage_ApplyMigrationsButton);
+
+#line default
+#line hidden
+ WriteLiteral(@"
+
+
+
+ \r\n\r\n
");
+#line 190 "DatabaseErrorPage.cshtml"
+ Write(Strings.DatabaseErrorPage_HowToApplyFromPMC);
+
+#line default
+#line hidden
+ WriteLiteral("
\r\n
");
+#line 191 "DatabaseErrorPage.cshtml"
+ Write(Strings.DatabaseErrorPage_ApplyMigrationsCommandPMC);
+
+#line default
+#line hidden
+ WriteLiteral("\r\n
");
+#line 192 "DatabaseErrorPage.cshtml"
+ Write(Strings.DatabaseErrorPage_HowToApplyFromCLI);
+
+#line default
+#line hidden
+ WriteLiteral("
\r\n
");
+#line 193 "DatabaseErrorPage.cshtml"
+ Write(Strings.DatabaseErrorPage_ApplyMigrationsCommandCLI);
+
+#line default
+#line hidden
+ WriteLiteral("\r\n
\r\n
\r\n");
+#line 196 "DatabaseErrorPage.cshtml"
+ }
+ else if (Model.PendingModelChanges)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n
");
+#line 200 "DatabaseErrorPage.cshtml"
+ Write(Strings.FormatDatabaseErrorPage_PendingChangesTitle(Model.ContextType.Name));
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n
");
+#line 201 "DatabaseErrorPage.cshtml"
+ Write(Strings.DatabaseErrorPage_PendingChangesInfoPMC);
+
+#line default
+#line hidden
+ WriteLiteral("
\r\n
");
+#line 202 "DatabaseErrorPage.cshtml"
+ Write(Strings.DatabaseErrorPage_AddMigrationCommandPMC);
+
+#line default
+#line hidden
+ WriteLiteral("\r\n
\r\n
");
+#line 204 "DatabaseErrorPage.cshtml"
+ Write(Strings.DatabaseErrorPage_ApplyMigrationsCommandPMC);
+
+#line default
+#line hidden
+ WriteLiteral("\r\n
");
+#line 205 "DatabaseErrorPage.cshtml"
+ Write(Strings.DatabaseErrorPage_PendingChangesInfoCLI);
+
+#line default
+#line hidden
+ WriteLiteral("
\r\n
");
+#line 206 "DatabaseErrorPage.cshtml"
+ Write(Strings.DatabaseErrorPage_AddMigrationCommandCLI);
+
+#line default
+#line hidden
+ WriteLiteral("\r\n
\r\n
");
+#line 208 "DatabaseErrorPage.cshtml"
+ Write(Strings.DatabaseErrorPage_ApplyMigrationsCommandCLI);
+
+#line default
+#line hidden
+ WriteLiteral("\r\n
\r\n
\r\n");
+#line 211 "DatabaseErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral("\r\n");
+ }
+ #pragma warning restore 1998
+ }
+}
diff --git a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/DatabaseErrorPage.cshtml b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/DatabaseErrorPage.cshtml
index c790b461eb..81c7df9276 100644
--- a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/DatabaseErrorPage.cshtml
+++ b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/DatabaseErrorPage.cshtml
@@ -1,10 +1,10 @@
@using System
@using System.Linq
@using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
-@using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Views
+@using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.RazorViews
@{
Response.StatusCode = 500;
- Response.ContentType = "text/html";
+ Response.ContentType = "text/html; charset=utf-8";
Response.ContentLength = null; // Clear any prior Content-Length
}
@functions
diff --git a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/DatabaseErrorPageModel.cs b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/DatabaseErrorPageModel.cs
index fecb511a38..99280314a2 100644
--- a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/DatabaseErrorPageModel.cs
+++ b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/DatabaseErrorPageModel.cs
@@ -7,9 +7,9 @@ using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Utilities;
using System;
using System.Collections.Generic;
-namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Views
+namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.RazorViews
{
- public class DatabaseErrorPageModel
+ internal class DatabaseErrorPageModel
{
private readonly Type _contextType;
private readonly Exception _exception;
diff --git a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/DatabaseErrorPage.cs b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/Obsolete/DatabaseErrorPage.cs
similarity index 99%
rename from src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/DatabaseErrorPage.cs
rename to src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/Obsolete/DatabaseErrorPage.cs
index 95820eb3dd..9d648a4a05 100644
--- a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/DatabaseErrorPage.cs
+++ b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/Obsolete/DatabaseErrorPage.cs
@@ -25,7 +25,7 @@ using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Views
#line hidden
;
using System.Threading.Tasks;
-
+ [Obsolete("This type is for internal use only and will be removed in a future version.")]
public class DatabaseErrorPage : Microsoft.AspNetCore.DiagnosticsViewPage.Views.BaseView
{
#line 11 "DatabaseErrorPage.cshtml"
@@ -53,7 +53,7 @@ using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Views
public override async Task ExecuteAsync()
{
#line 5 "DatabaseErrorPage.cshtml"
-
+
Response.StatusCode = 500;
Response.ContentType = "text/html";
Response.ContentLength = null; // Clear any prior Content-Length
@@ -69,7 +69,7 @@ using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Views
#line hidden
WriteLiteral("\r\n \r\n");
#line 37 "DatabaseErrorPage.cshtml"
-
+
#line default
#line hidden
@@ -102,7 +102,7 @@ using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Views
WriteLiteral("
\r\n \r\n\r\n");
#line 45 "DatabaseErrorPage.cshtml"
-
+
#line default
#line hidden
@@ -179,7 +179,7 @@ using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Views
#line hidden
WriteLiteral("
\r\n\r\n \r\n");
#line 65 "DatabaseErrorPage.cshtml"
-
+
#line default
#line hidden
diff --git a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/Obsolete/DatabaseErrorPage.cshtml b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/Obsolete/DatabaseErrorPage.cshtml
new file mode 100644
index 0000000000..c790b461eb
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/Obsolete/DatabaseErrorPage.cshtml
@@ -0,0 +1,135 @@
+@using System
+@using System.Linq
+@using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
+@using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Views
+@{
+ Response.StatusCode = 500;
+ Response.ContentType = "text/html";
+ Response.ContentLength = null; // Clear any prior Content-Length
+}
+@functions
+{
+ public DatabaseErrorPageModel Model { get; set; }
+
+ public string UrlEncode(string content)
+ {
+ return UrlEncoder.Encode(content);
+ }
+
+ public string JavaScriptEncode(string content)
+ {
+ return JavaScriptEncoder.Encode(content);
+ }
+}
+
+
+
+
+
+ Internal Server Error
+
+
+
+ @Strings.DatabaseErrorPage_Title
+
+ @for (Exception ex = Model.Exception; ex != null; ex = ex.InnerException)
+ {
+ @ex.GetType().Name: @ex.Message
+
+ }
+
+
+
+ @if (!Model.DatabaseExists && !Model.PendingMigrations.Any())
+ {
+ @Strings.FormatDatabaseErrorPage_NoDbOrMigrationsTitle(Model.ContextType.Name)
+ @Strings.DatabaseErrorPage_NoDbOrMigrationsInfoPMC
+ @Strings.DatabaseErrorPage_AddMigrationCommandPMC
+
+ @Strings.DatabaseErrorPage_ApplyMigrationsCommandPMC
+ @Strings.DatabaseErrorPage_NoDbOrMigrationsInfoCLI
+ @Strings.DatabaseErrorPage_AddMigrationCommandCLI
+
+ @Strings.DatabaseErrorPage_ApplyMigrationsCommandCLI
+
+ }
+ else if (Model.PendingMigrations.Any())
+ {
+
+
@Strings.FormatDatabaseErrorPage_PendingMigrationsTitle(Model.ContextType.Name)
+
@Strings.FormatDatabaseErrorPage_PendingMigrationsInfo(Model.ContextType.Name)
+
+
+ @foreach (var migration in Model.PendingMigrations)
+ {
+ @migration
+ }
+
+
+
+ @Strings.DatabaseErrorPage_ApplyMigrationsButton
+
+
+
+
+
+
@Strings.DatabaseErrorPage_HowToApplyFromPMC
+
@Strings.DatabaseErrorPage_ApplyMigrationsCommandPMC
+
@Strings.DatabaseErrorPage_HowToApplyFromCLI
+
@Strings.DatabaseErrorPage_ApplyMigrationsCommandCLI
+
+
+ }
+ else if (Model.PendingModelChanges)
+ {
+
+
@Strings.FormatDatabaseErrorPage_PendingChangesTitle(Model.ContextType.Name)
+
@Strings.DatabaseErrorPage_PendingChangesInfoPMC
+
@Strings.DatabaseErrorPage_AddMigrationCommandPMC
+
+
@Strings.DatabaseErrorPage_ApplyMigrationsCommandPMC
+
@Strings.DatabaseErrorPage_PendingChangesInfoCLI
+
@Strings.DatabaseErrorPage_AddMigrationCommandCLI
+
+
@Strings.DatabaseErrorPage_ApplyMigrationsCommandCLI
+
+
+ }
+
+
\ No newline at end of file
diff --git a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/Obsolete/DatabaseErrorPageModel.cs b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/Obsolete/DatabaseErrorPageModel.cs
new file mode 100644
index 0000000000..15c7ad66c9
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/Views/Obsolete/DatabaseErrorPageModel.cs
@@ -0,0 +1,73 @@
+// 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 JetBrains.Annotations;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Utilities;
+using System;
+using System.Collections.Generic;
+
+namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Views
+{
+ [Obsolete("This type is for internal use only and will be removed in a future version.")]
+ public class DatabaseErrorPageModel
+ {
+ private readonly Type _contextType;
+ private readonly Exception _exception;
+ private readonly bool _databaseExists;
+ private readonly bool _pendingModelChanges;
+ private readonly IEnumerable _pendingMigrations;
+ private readonly DatabaseErrorPageOptions _options;
+
+ public DatabaseErrorPageModel(
+ [NotNull] Type contextType,
+ [NotNull] Exception exception,
+ bool databaseExists,
+ bool pendingModelChanges,
+ [NotNull] IEnumerable pendingMigrations,
+ [NotNull] DatabaseErrorPageOptions options)
+ {
+ Check.NotNull(contextType, "contextType");
+ Check.NotNull(exception, "exception");
+ Check.NotNull(pendingMigrations, "pendingMigrations");
+ Check.NotNull(options, "options");
+
+ _contextType = contextType;
+ _exception = exception;
+ _databaseExists = databaseExists;
+ _pendingModelChanges = pendingModelChanges;
+ _pendingMigrations = pendingMigrations;
+ _options = options;
+ }
+
+ public virtual Type ContextType
+ {
+ get { return _contextType; }
+ }
+
+ public virtual Exception Exception
+ {
+ get { return _exception; }
+ }
+
+ public virtual bool DatabaseExists
+ {
+ get { return _databaseExists; }
+ }
+
+ public virtual bool PendingModelChanges
+ {
+ get { return _pendingModelChanges; }
+ }
+
+ public virtual IEnumerable PendingMigrations
+ {
+ get { return _pendingMigrations; }
+ }
+
+ public virtual DatabaseErrorPageOptions Options
+ {
+ get { return _options; }
+ }
+ }
+}
diff --git a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/project.json b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/project.json
index 0ba4ea398c..27235651f4 100644
--- a/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/project.json
+++ b/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore/project.json
@@ -25,9 +25,16 @@
"type": "build",
"version": "1.1.0-*"
},
+ "Microsoft.Extensions.RazorViews.Sources": {
+ "type": "build",
+ "version": "1.1.0-*"
+ },
"Microsoft.AspNetCore.Http.Abstractions": "1.1.0-*",
"Microsoft.EntityFrameworkCore.Relational": "1.1.0-*"
},
+ "tools": {
+ "RazorPageGenerator": "1.1.0-*"
+ },
"frameworks": {
"net451": {
"frameworkAssemblies": {
diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs
index d6a3f9f542..8296174a7b 100644
--- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs
+++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs
@@ -1,14 +1,12 @@
// 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;
using System.Collections.Generic;
-using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.Diagnostics.Views;
+using Microsoft.AspNetCore.Diagnostics.RazorViews;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.FileProviders;
@@ -28,6 +26,7 @@ namespace Microsoft.AspNetCore.Diagnostics
private readonly ILogger _logger;
private readonly IFileProvider _fileProvider;
private readonly System.Diagnostics.DiagnosticSource _diagnosticSource;
+ private readonly ExceptionDetailsProvider _exceptionDetailsProvider;
///
/// Initializes a new instance of the class
@@ -59,6 +58,7 @@ namespace Microsoft.AspNetCore.Diagnostics
_logger = loggerFactory.CreateLogger();
_fileProvider = _options.FileProvider ?? hostingEnvironment.ContentRootFileProvider;
_diagnosticSource = diagnosticSource;
+ _exceptionDetailsProvider = new ExceptionDetailsProvider(_fileProvider, _options.SourceCodeLineCount);
}
///
@@ -128,8 +128,8 @@ namespace Microsoft.AspNetCore.Diagnostics
foreach (var compilationFailure in compilationException.CompilationFailures)
{
- var stackFrames = new List();
- var errorDetails = new ErrorDetails
+ var stackFrames = new List();
+ var exceptionDetails = new ExceptionDetails
{
StackFrames = stackFrames,
ErrorMessage = compilationFailure.FailureSummary,
@@ -140,20 +140,20 @@ namespace Microsoft.AspNetCore.Diagnostics
foreach (var item in compilationFailure.Messages)
{
- var frame = new StackFrame
+ var frame = new StackFrameSourceCodeInfo
{
File = compilationFailure.SourceFilePath,
Line = item.StartLine,
Function = string.Empty
};
- ReadFrameContent(frame, fileContent, item.StartLine, item.EndLine);
+ _exceptionDetailsProvider.ReadFrameContent(frame, fileContent, item.StartLine, item.EndLine);
frame.ErrorDetails = item.Message;
stackFrames.Add(frame);
}
- model.ErrorDetails.Add(errorDetails);
+ model.ErrorDetails.Add(exceptionDetails);
}
var errorPage = new CompilationErrorPage
@@ -171,7 +171,7 @@ namespace Microsoft.AspNetCore.Diagnostics
var model = new ErrorPageModel
{
Options = _options,
- ErrorDetails = GetErrorDetails(ex).Reverse(),
+ ErrorDetails = _exceptionDetailsProvider.GetDetails(ex),
Query = request.Query,
Cookies = request.Cookies,
Headers = request.Headers
@@ -180,107 +180,5 @@ namespace Microsoft.AspNetCore.Diagnostics
var errorPage = new ErrorPage(model);
return errorPage.ExecuteAsync(context);
}
-
- private IEnumerable GetErrorDetails(Exception ex)
- {
- for (var scan = ex; scan != null; scan = scan.InnerException)
- {
- var stackTrace = ex.StackTrace;
- yield return new ErrorDetails
- {
- Error = scan,
- StackFrames = StackTraceHelper.GetFrames(ex)
- .Select(frame => GetStackFrame(frame.MethodDisplayInfo.ToString(), frame.FilePath, frame.LineNumber))
- };
- };
- }
-
- // make it internal to enable unit testing
- internal StackFrame GetStackFrame(string method, string filePath, int lineNumber)
- {
- var stackFrame = new StackFrame
- {
- Function = method,
- File = filePath,
- Line = lineNumber
- };
-
- if (string.IsNullOrEmpty(stackFrame.File))
- {
- return stackFrame;
- }
-
- IEnumerable lines = null;
- if (File.Exists(stackFrame.File))
- {
- lines = File.ReadLines(stackFrame.File);
- }
- else
- {
- // Handle relative paths and embedded files
- var fileInfo = _fileProvider.GetFileInfo(stackFrame.File);
- if (fileInfo.Exists)
- {
- // ReadLines doesn't accept a stream. Use ReadLines as its more efficient
- // relative to reading lines via stream reader
- if (!string.IsNullOrEmpty(fileInfo.PhysicalPath))
- {
- lines = File.ReadLines(fileInfo.PhysicalPath);
- }
- else
- {
- lines = ReadLines(fileInfo);
- }
- }
- }
-
- if (lines != null)
- {
- ReadFrameContent(stackFrame, lines, stackFrame.Line, stackFrame.Line);
- }
-
- return stackFrame;
- }
-
- // make it internal to enable unit testing
- internal void ReadFrameContent(
- StackFrame frame,
- IEnumerable allLines,
- int errorStartLineNumberInFile,
- int errorEndLineNumberInFile)
- {
- // Get the line boundaries in the file to be read and read all these lines at once into an array.
- var preErrorLineNumberInFile = Math.Max(errorStartLineNumberInFile - _options.SourceCodeLineCount, 1);
- var postErrorLineNumberInFile = errorEndLineNumberInFile + _options.SourceCodeLineCount;
- var codeBlock = allLines
- .Skip(preErrorLineNumberInFile - 1)
- .Take(postErrorLineNumberInFile - preErrorLineNumberInFile + 1)
- .ToArray();
-
- var numOfErrorLines = (errorEndLineNumberInFile - errorStartLineNumberInFile) + 1;
- var errorStartLineNumberInArray = errorStartLineNumberInFile - preErrorLineNumberInFile;
-
- frame.PreContextLine = preErrorLineNumberInFile;
- frame.PreContextCode = codeBlock.Take(errorStartLineNumberInArray).ToArray();
- frame.ContextCode = codeBlock
- .Skip(errorStartLineNumberInArray)
- .Take(numOfErrorLines)
- .ToArray();
- frame.PostContextCode = codeBlock
- .Skip(errorStartLineNumberInArray + numOfErrorLines)
- .ToArray();
- }
-
- private static IEnumerable ReadLines(IFileInfo fileInfo)
- {
- using (var reader = new StreamReader(fileInfo.CreateReadStream()))
- {
- string line;
- while ((line = reader.ReadLine()) != null)
- {
- yield return line;
- }
- }
- }
}
}
diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorModel.cs b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorModel.cs
index 17cf4f3881..195b303d11 100644
--- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorModel.cs
+++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorModel.cs
@@ -3,13 +3,14 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Builder;
+using Microsoft.Extensions.StackTrace.Sources;
-namespace Microsoft.AspNetCore.Diagnostics.Views
+namespace Microsoft.AspNetCore.Diagnostics.RazorViews
{
///
/// Holds data to be displayed on the compilation error page.
///
- public class CompilationErrorPageModel
+ internal class CompilationErrorPageModel
{
///
/// Options for what output to display.
@@ -19,6 +20,6 @@ namespace Microsoft.AspNetCore.Diagnostics.Views
///
/// Detailed information about each parse or compilation error.
///
- public IList ErrorDetails { get; } = new List();
+ public IList ErrorDetails { get; } = new List();
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.Designer.cs b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.Designer.cs
new file mode 100644
index 0000000000..4e3629dae8
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.Designer.cs
@@ -0,0 +1,817 @@
+namespace Microsoft.AspNetCore.Diagnostics.RazorViews
+{
+#line 1 "CompilationErrorPage.cshtml"
+using System
+
+#line default
+#line hidden
+ ;
+#line 2 "CompilationErrorPage.cshtml"
+using System.Globalization
+
+#line default
+#line hidden
+ ;
+#line 3 "CompilationErrorPage.cshtml"
+using System.Linq
+
+#line default
+#line hidden
+ ;
+#line 4 "CompilationErrorPage.cshtml"
+using System.Net
+
+#line default
+#line hidden
+ ;
+#line 5 "CompilationErrorPage.cshtml"
+using Microsoft.AspNetCore.Diagnostics
+
+#line default
+#line hidden
+ ;
+#line 6 "CompilationErrorPage.cshtml"
+using Microsoft.AspNetCore.Diagnostics.RazorViews
+
+#line default
+#line hidden
+ ;
+ using System.Threading.Tasks;
+
+ internal class CompilationErrorPage : Microsoft.Extensions.RazorViews.BaseView
+ {
+#line 8 "CompilationErrorPage.cshtml"
+
+ public CompilationErrorPageModel Model { get; set; }
+
+#line default
+#line hidden
+ #line hidden
+ public CompilationErrorPage()
+ {
+ }
+
+ #pragma warning disable 1998
+ public override async Task ExecuteAsync()
+ {
+#line 11 "CompilationErrorPage.cshtml"
+
+ Response.StatusCode = 500;
+ Response.ContentType = "text/html; charset=utf-8";
+ Response.ContentLength = null; // Clear any prior Content-Length
+
+#line default
+#line hidden
+
+ WriteLiteral("\r\n\r\n \r\n \r\n ");
+#line 20 "CompilationErrorPage.cshtml"
+ Write(Resources.ErrorPageHtml_Title);
+
+#line default
+#line hidden
+ WriteLiteral(@"
+
+
+
+ ");
+#line 221 "CompilationErrorPage.cshtml"
+ Write(Resources.ErrorPageHtml_CompilationException);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n");
+#line 222 "CompilationErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 222 "CompilationErrorPage.cshtml"
+ foreach (var errorDetail in Model.ErrorDetails)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n");
+#line 225 "CompilationErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 225 "CompilationErrorPage.cshtml"
+
+ var stackFrameCount = 0;
+ var frameId = "";
+
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 229 "CompilationErrorPage.cshtml"
+
+ var fileName = errorDetail.StackFrames.FirstOrDefault()?.File;
+ if (!string.IsNullOrEmpty(fileName))
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral("
");
+#line 233 "CompilationErrorPage.cshtml"
+ Write(fileName);
+
+#line default
+#line hidden
+ WriteLiteral("
\r\n");
+#line 234 "CompilationErrorPage.cshtml"
+ }
+
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 236 "CompilationErrorPage.cshtml"
+ if (!string.IsNullOrEmpty(errorDetail.ErrorMessage))
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral("
");
+#line 238 "CompilationErrorPage.cshtml"
+ Write(errorDetail.ErrorMessage);
+
+#line default
+#line hidden
+ WriteLiteral("
\r\n");
+#line 239 "CompilationErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral("
\r\n
\r\n");
+#line 242 "CompilationErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 242 "CompilationErrorPage.cshtml"
+ foreach (var frame in errorDetail.StackFrames)
+ {
+
+
+#line default
+#line hidden
+
+#line 244 "CompilationErrorPage.cshtml"
+
+ stackFrameCount++;
+ frameId = "frame" + stackFrameCount;
+
+
+#line default
+#line hidden
+
+#line 247 "CompilationErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n");
+#line 249 "CompilationErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 249 "CompilationErrorPage.cshtml"
+ if (!string.IsNullOrEmpty(frame.ErrorDetails))
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 251 "CompilationErrorPage.cshtml"
+ Write(frame.ErrorDetails);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n");
+#line 252 "CompilationErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral("\r\n");
+#line 254 "CompilationErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 254 "CompilationErrorPage.cshtml"
+ if (frame.Line != 0 && frame.ContextCode.Any())
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" + \r\n \r\n");
+#line 258 "CompilationErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 258 "CompilationErrorPage.cshtml"
+ if (frame.PreContextCode.Any())
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral("
\r\n");
+#line 261 "CompilationErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 261 "CompilationErrorPage.cshtml"
+ foreach (var line in frame.PreContextCode)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 263 "CompilationErrorPage.cshtml"
+ Write(line);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n");
+#line 264 "CompilationErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n");
+#line 266 "CompilationErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral("
\r\n");
+#line 268 "CompilationErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 268 "CompilationErrorPage.cshtml"
+ foreach (var line in frame.ContextCode)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 270 "CompilationErrorPage.cshtml"
+ Write(line);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n");
+#line 271 "CompilationErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n");
+#line 273 "CompilationErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 273 "CompilationErrorPage.cshtml"
+ if (frame.PostContextCode.Any())
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral("
\r\n");
+#line 276 "CompilationErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 276 "CompilationErrorPage.cshtml"
+ foreach (var line in frame.PostContextCode)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 278 "CompilationErrorPage.cshtml"
+ Write(line);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n");
+#line 279 "CompilationErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n");
+#line 281 "CompilationErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral("
\r\n");
+#line 283 "CompilationErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n");
+#line 285 "CompilationErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n
\r\n
\r\n");
+#line 289 "CompilationErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(@"
+
+
+");
+ }
+ #pragma warning restore 1998
+ }
+}
diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.cshtml b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.cshtml
index 932d677b9c..1b93b23194 100644
--- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.cshtml
+++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.cshtml
@@ -3,6 +3,7 @@
@using System.Linq
@using System.Net
@using Microsoft.AspNetCore.Diagnostics
+@using Microsoft.AspNetCore.Diagnostics.RazorViews
@functions
{
public CompilationErrorPageModel Model { get; set; }
diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.Designer.cs b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.Designer.cs
new file mode 100644
index 0000000000..03c05faa8d
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.Designer.cs
@@ -0,0 +1,1303 @@
+namespace Microsoft.AspNetCore.Diagnostics.RazorViews
+{
+#line 1 "ErrorPage.cshtml"
+using System
+
+#line default
+#line hidden
+ ;
+#line 2 "ErrorPage.cshtml"
+using System.Globalization
+
+#line default
+#line hidden
+ ;
+#line 3 "ErrorPage.cshtml"
+using System.Linq
+
+#line default
+#line hidden
+ ;
+#line 4 "ErrorPage.cshtml"
+using System.Net
+
+#line default
+#line hidden
+ ;
+#line 5 "ErrorPage.cshtml"
+using System.Reflection
+
+#line default
+#line hidden
+ ;
+#line 6 "ErrorPage.cshtml"
+using Microsoft.AspNetCore.Diagnostics.RazorViews
+
+#line default
+#line hidden
+ ;
+#line 7 "ErrorPage.cshtml"
+using Microsoft.AspNetCore.Diagnostics
+
+#line default
+#line hidden
+ ;
+ using System.Threading.Tasks;
+
+ internal class ErrorPage : Microsoft.Extensions.RazorViews.BaseView
+ {
+#line 9 "ErrorPage.cshtml"
+
+ public ErrorPage(ErrorPageModel model)
+ {
+ Model = model;
+ }
+
+ public ErrorPageModel Model { get; set; }
+
+#line default
+#line hidden
+ #line hidden
+ public ErrorPage()
+ {
+ }
+
+ #pragma warning disable 1998
+ public override async Task ExecuteAsync()
+ {
+#line 17 "ErrorPage.cshtml"
+
+ // TODO: Response.ReasonPhrase = "Internal Server Error";
+ Response.ContentType = "text/html; charset=utf-8";
+ string location = string.Empty;
+
+#line default
+#line hidden
+
+ WriteLiteral("\r\n\r\n \r\n \r\n ");
+#line 26 "ErrorPage.cshtml"
+ Write(Resources.ErrorPageHtml_Title);
+
+#line default
+#line hidden
+ WriteLiteral(@"
+
+
+
+ ");
+#line 227 "ErrorPage.cshtml"
+ Write(Resources.ErrorPageHtml_UnhandledException);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n");
+#line 228 "ErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 228 "ErrorPage.cshtml"
+ foreach (var errorDetail in Model.ErrorDetails)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 230 "ErrorPage.cshtml"
+ Write(errorDetail.Error.GetType().Name);
+
+#line default
+#line hidden
+ WriteLiteral(": ");
+#line 230 "ErrorPage.cshtml"
+ Output.Write(HtmlEncodeAndReplaceLineBreaks(errorDetail.Error.Message));
+
+#line default
+#line hidden
+
+ WriteLiteral("
\r\n");
+#line 231 "ErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 231 "ErrorPage.cshtml"
+
+ var firstFrame = errorDetail.StackFrames.FirstOrDefault();
+ if (firstFrame != null)
+ {
+ location = firstFrame.Function;
+ }
+
+
+#line default
+#line hidden
+
+#line 237 "ErrorPage.cshtml"
+
+ if (!string.IsNullOrEmpty(location) && firstFrame != null && !string.IsNullOrEmpty(firstFrame.File))
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 240 "ErrorPage.cshtml"
+ Write(location);
+
+#line default
+#line hidden
+ WriteLiteral(" in ");
+#line 240 "ErrorPage.cshtml"
+ Write(System.IO.Path.GetFileName(firstFrame.File));
+
+#line default
+#line hidden
+ WriteLiteral(", line ");
+#line 240 "ErrorPage.cshtml"
+ Write(firstFrame.Line);
+
+#line default
+#line hidden
+ WriteLiteral("
\r\n");
+#line 241 "ErrorPage.cshtml"
+ }
+ else if (!string.IsNullOrEmpty(location))
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 244 "ErrorPage.cshtml"
+ Write(location);
+
+#line default
+#line hidden
+ WriteLiteral("
\r\n");
+#line 245 "ErrorPage.cshtml"
+ }
+ else
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 248 "ErrorPage.cshtml"
+ Write(Resources.ErrorPageHtml_UnknownLocation);
+
+#line default
+#line hidden
+ WriteLiteral("
\r\n");
+#line 249 "ErrorPage.cshtml"
+ }
+
+ var reflectionTypeLoadException = errorDetail.Error as ReflectionTypeLoadException;
+ if (reflectionTypeLoadException != null)
+ {
+ if (reflectionTypeLoadException.LoaderExceptions.Length > 0)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" Loader Exceptions: \r\n \r\n");
+#line 258 "ErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 258 "ErrorPage.cshtml"
+ foreach (var ex in reflectionTypeLoadException.LoaderExceptions)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 260 "ErrorPage.cshtml"
+ Write(ex.Message);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n");
+#line 261 "ErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n");
+#line 263 "ErrorPage.cshtml"
+ }
+ }
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n\r\n \r\n
\r\n");
+#line 283 "ErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 283 "ErrorPage.cshtml"
+
+ var exceptionCount = 0;
+ var stackFrameCount = 0;
+ var exceptionDetailId = "";
+ var frameId = "";
+
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 289 "ErrorPage.cshtml"
+ foreach (var errorDetail in Model.ErrorDetails)
+ {
+
+
+#line default
+#line hidden
+
+#line 291 "ErrorPage.cshtml"
+
+ exceptionCount++;
+ exceptionDetailId = "exceptionDetail" + exceptionCount;
+
+
+#line default
+#line hidden
+
+#line 294 "ErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n ");
+#line 296 "ErrorPage.cshtml"
+ Write(errorDetail.Error.GetType().Name);
+
+#line default
+#line hidden
+ WriteLiteral(": ");
+#line 296 "ErrorPage.cshtml"
+ Write(errorDetail.Error.Message);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n \r\n");
+#line 298 "ErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 298 "ErrorPage.cshtml"
+ foreach (var frame in errorDetail.StackFrames)
+ {
+
+
+#line default
+#line hidden
+
+#line 300 "ErrorPage.cshtml"
+
+ stackFrameCount++;
+ frameId = "frame" + stackFrameCount;
+
+
+#line default
+#line hidden
+
+#line 303 "ErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n");
+#line 305 "ErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 305 "ErrorPage.cshtml"
+ if (string.IsNullOrEmpty(frame.File))
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 307 "ErrorPage.cshtml"
+ Write(frame.Function);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n");
+#line 308 "ErrorPage.cshtml"
+ }
+ else
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 311 "ErrorPage.cshtml"
+ Write(frame.Function);
+
+#line default
+#line hidden
+ WriteLiteral(" in ");
+#line 311 "ErrorPage.cshtml"
+ Write(System.IO.Path.GetFileName(frame.File));
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n");
+#line 312 "ErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral("\r\n");
+#line 314 "ErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 314 "ErrorPage.cshtml"
+ if (frame.Line != 0 && frame.ContextCode.Any())
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" + \r\n \r\n");
+#line 318 "ErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 318 "ErrorPage.cshtml"
+ if (frame.PreContextCode.Any())
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral("
\r\n");
+#line 321 "ErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 321 "ErrorPage.cshtml"
+ foreach (var line in frame.PreContextCode)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 323 "ErrorPage.cshtml"
+ Write(line);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n");
+#line 324 "ErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n");
+#line 326 "ErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral("\r\n
\r\n");
+#line 329 "ErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 329 "ErrorPage.cshtml"
+ foreach (var line in frame.ContextCode)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 331 "ErrorPage.cshtml"
+ Write(line);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n");
+#line 332 "ErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n\r\n");
+#line 335 "ErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 335 "ErrorPage.cshtml"
+ if (frame.PostContextCode.Any())
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral("
\r\n");
+#line 338 "ErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 338 "ErrorPage.cshtml"
+ foreach (var line in frame.PostContextCode)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" ");
+#line 340 "ErrorPage.cshtml"
+ Write(line);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n");
+#line 341 "ErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n");
+#line 343 "ErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral("
\r\n");
+#line 345 "ErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n");
+#line 347 "ErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(@"
+
+
+
+
+
+ Show raw exception details \r\n
\r\n
\r\n
");
+#line 357 "ErrorPage.cshtml"
+ Write(errorDetail.Error.ToString());
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n
\r\n
\r\n \r\n");
+#line 361 "ErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n
\r\n\r\n \r\n");
+#line 366 "ErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 366 "ErrorPage.cshtml"
+ if (Model.Query.Any())
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral("
\r\n \r\n \r\n ");
+#line 371 "ErrorPage.cshtml"
+ Write(Resources.ErrorPageHtml_VariableColumn);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n ");
+#line 372 "ErrorPage.cshtml"
+ Write(Resources.ErrorPageHtml_ValueColumn);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n \r\n \r\n \r\n");
+#line 376 "ErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 376 "ErrorPage.cshtml"
+ foreach (var kv in Model.Query.OrderBy(kv => kv.Key))
+ {
+ foreach (var v in kv.Value)
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n ");
+#line 381 "ErrorPage.cshtml"
+ Write(kv.Key);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n ");
+#line 382 "ErrorPage.cshtml"
+ Write(v);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n \r\n");
+#line 384 "ErrorPage.cshtml"
+ }
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n
\r\n");
+#line 388 "ErrorPage.cshtml"
+ }
+ else
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral("
");
+#line 391 "ErrorPage.cshtml"
+ Write(Resources.ErrorPageHtml_NoQueryStringData);
+
+#line default
+#line hidden
+ WriteLiteral("
\r\n");
+#line 392 "ErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral("
\r\n\r\n \r\n");
+#line 396 "ErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 396 "ErrorPage.cshtml"
+ if (Model.Cookies.Any())
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral("
\r\n \r\n \r\n ");
+#line 401 "ErrorPage.cshtml"
+ Write(Resources.ErrorPageHtml_VariableColumn);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n ");
+#line 402 "ErrorPage.cshtml"
+ Write(Resources.ErrorPageHtml_ValueColumn);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n \r\n \r\n \r\n");
+#line 406 "ErrorPage.cshtml"
+
+
+#line default
+#line hidden
+
+#line 406 "ErrorPage.cshtml"
+ foreach (var kv in Model.Cookies.OrderBy(kv => kv.Key))
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n ");
+#line 409 "ErrorPage.cshtml"
+ Write(kv.Key);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n ");
+#line 410 "ErrorPage.cshtml"
+ Write(kv.Value);
+
+#line default
+#line hidden
+ WriteLiteral(" \r\n \r\n");
+#line 412 "ErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral(" \r\n
\r\n");
+#line 415 "ErrorPage.cshtml"
+ }
+ else
+ {
+
+#line default
+#line hidden
+
+ WriteLiteral("
");
+#line 418 "ErrorPage.cshtml"
+ Write(Resources.ErrorPageHtml_NoCookieData);
+
+#line default
+#line hidden
+ WriteLiteral("
\r\n");
+#line 419 "ErrorPage.cshtml"
+ }
+
+#line default
+#line hidden
+
+ WriteLiteral("
\r\n
+
+
+
+");
+ }
+ #pragma warning restore 1998
+ }
+}
diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.cshtml b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.cshtml
index f4392c63e8..05466d8093 100644
--- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.cshtml
+++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.cshtml
@@ -3,7 +3,7 @@
@using System.Linq
@using System.Net
@using System.Reflection
-@using Microsoft.AspNetCore.Diagnostics.Views
+@using Microsoft.AspNetCore.Diagnostics.RazorViews
@using Microsoft.AspNetCore.Diagnostics
@functions
{
@@ -42,19 +42,18 @@
}
if (!string.IsNullOrEmpty(location) && firstFrame != null && !string.IsNullOrEmpty(firstFrame.File))
{
- @location in @System.IO.Path.GetFileName(firstFrame.File), line @firstFrame.Line
+ @location in @System.IO.Path.GetFileName(firstFrame.File), line @firstFrame.Line
}
else if (!string.IsNullOrEmpty(location))
{
- @location
+ @location
}
else
{
- @Resources.ErrorPageHtml_UnknownLocation
+ @Resources.ErrorPageHtml_UnknownLocation
}
- }
- @{
- var reflectionTypeLoadException = Model.ErrorDetails.Last()?.Error as ReflectionTypeLoadException;
+
+ var reflectionTypeLoadException = errorDetail.Error as ReflectionTypeLoadException;
if (reflectionTypeLoadException != null)
{
if (reflectionTypeLoadException.LoaderExceptions.Length > 0)
diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPageModel.cs b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPageModel.cs
index ad351b1778..cb9c213a39 100644
--- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPageModel.cs
+++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPageModel.cs
@@ -5,13 +5,14 @@ using System.Collections.Generic;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
+using Microsoft.Extensions.StackTrace.Sources;
-namespace Microsoft.AspNetCore.Diagnostics.Views
+namespace Microsoft.AspNetCore.Diagnostics.RazorViews
{
///
/// Holds data to be displayed on the error page.
///
- public class ErrorPageModel
+ internal class ErrorPageModel
{
///
/// Options for what output to display.
@@ -21,7 +22,7 @@ namespace Microsoft.AspNetCore.Diagnostics.Views
///
/// Detailed information about each exception in the stack.
///
- public IEnumerable ErrorDetails { get; set; }
+ public IEnumerable ErrorDetails { get; set; }
///
/// Parsed query data.
diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/CompilationErrorModel.cs b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/CompilationErrorModel.cs
new file mode 100644
index 0000000000..c0345d3d86
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/CompilationErrorModel.cs
@@ -0,0 +1,26 @@
+// 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;
+using System.Collections.Generic;
+using Microsoft.AspNetCore.Builder;
+
+namespace Microsoft.AspNetCore.Diagnostics.Views
+{
+ ///
+ /// Holds data to be displayed on the compilation error page.
+ ///
+ [Obsolete("This type is for internal use only and will be removed in a future version.")]
+ public class CompilationErrorPageModel
+ {
+ ///
+ /// Options for what output to display.
+ ///
+ public DeveloperExceptionPageOptions Options { get; set; }
+
+ ///
+ /// Detailed information about each parse or compilation error.
+ ///
+ public IList ErrorDetails { get; } = new List();
+ }
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.cs b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/CompilationErrorPage.cs
similarity index 99%
rename from src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.cs
rename to src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/CompilationErrorPage.cs
index 325f9181a5..d3796d54b1 100644
--- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.cs
+++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/CompilationErrorPage.cs
@@ -31,7 +31,7 @@ using Microsoft.AspNetCore.Diagnostics
#line hidden
;
using System.Threading.Tasks;
-
+ [Obsolete("This type is for internal use only and will be removed in a future version.")]
public class CompilationErrorPage : Microsoft.AspNetCore.DiagnosticsViewPage.Views.BaseView
{
#line 7 "CompilationErrorPage.cshtml"
diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/CompilationErrorPage.cshtml b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/CompilationErrorPage.cshtml
new file mode 100644
index 0000000000..932d677b9c
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/CompilationErrorPage.cshtml
@@ -0,0 +1,100 @@
+@using System
+@using System.Globalization
+@using System.Linq
+@using System.Net
+@using Microsoft.AspNetCore.Diagnostics
+@functions
+{
+ public CompilationErrorPageModel Model { get; set; }
+}
+@{
+ Response.StatusCode = 500;
+ Response.ContentType = "text/html; charset=utf-8";
+ Response.ContentLength = null; // Clear any prior Content-Length
+}
+
+
+
+
+ @Resources.ErrorPageHtml_Title
+
+
+
+ @Resources.ErrorPageHtml_CompilationException
+ @foreach (var errorDetail in Model.ErrorDetails)
+ {
+
+ @{
+ var stackFrameCount = 0;
+ var frameId = "";
+ }
+ @{
+ var fileName = errorDetail.StackFrames.FirstOrDefault()?.File;
+ if (!string.IsNullOrEmpty(fileName))
+ {
+
@fileName
+ }
+ }
+ @if (!string.IsNullOrEmpty(errorDetail.ErrorMessage))
+ {
+
@errorDetail.ErrorMessage
+ }
+
+
+ @foreach (var frame in errorDetail.StackFrames)
+ {
+ @{
+ stackFrameCount++;
+ frameId = "frame" + stackFrameCount;
+ }
+
+ @if (!string.IsNullOrEmpty(frame.ErrorDetails))
+ {
+ @frame.ErrorDetails
+ }
+
+ @if (frame.Line != 0 && frame.ContextCode.Any())
+ {
+ +
+
+ @if (frame.PreContextCode.Any())
+ {
+
+ @foreach (var line in frame.PreContextCode)
+ {
+ @line
+ }
+
+ }
+
+ @foreach (var line in frame.ContextCode)
+ {
+ @line
+ }
+
+ @if (frame.PostContextCode.Any())
+ {
+
+ @foreach (var line in frame.PostContextCode)
+ {
+ @line
+ }
+
+ }
+
+ }
+
+ }
+
+
+
+ }
+
+
+
diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorDetails.cs b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorDetails.cs
similarity index 89%
rename from src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorDetails.cs
rename to src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorDetails.cs
index 7337108cc0..323c7eabed 100644
--- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorDetails.cs
+++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorDetails.cs
@@ -9,6 +9,7 @@ namespace Microsoft.AspNetCore.Diagnostics.Views
///
/// Contains details for individual exception messages.
///
+ [Obsolete("This type is for internal use only and will be removed in a future version.")]
public class ErrorDetails
{
///
diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.cs b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorPage.cs
similarity index 99%
rename from src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.cs
rename to src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorPage.cs
index 5db8eae673..0ad27f0f85 100644
--- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.cs
+++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorPage.cs
@@ -43,7 +43,7 @@ using Microsoft.AspNetCore.Diagnostics
#line hidden
;
using System.Threading.Tasks;
-
+ [Obsolete("This type is for internal use only and will be removed in a future version.")]
public class ErrorPage : Microsoft.AspNetCore.DiagnosticsViewPage.Views.BaseView
{
#line 9 "ErrorPage.cshtml"
diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorPage.cshtml b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorPage.cshtml
new file mode 100644
index 0000000000..f4392c63e8
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorPage.cshtml
@@ -0,0 +1,262 @@
+@using System
+@using System.Globalization
+@using System.Linq
+@using System.Net
+@using System.Reflection
+@using Microsoft.AspNetCore.Diagnostics.Views
+@using Microsoft.AspNetCore.Diagnostics
+@functions
+{
+ public ErrorPage(ErrorPageModel model)
+ {
+ Model = model;
+ }
+
+ public ErrorPageModel Model { get; set; }
+}
+@{
+ // TODO: Response.ReasonPhrase = "Internal Server Error";
+ Response.ContentType = "text/html; charset=utf-8";
+ string location = string.Empty;
+}
+
+
+
+
+ @Resources.ErrorPageHtml_Title
+
+
+
+ @Resources.ErrorPageHtml_UnhandledException
+ @foreach (var errorDetail in Model.ErrorDetails)
+ {
+ @errorDetail.Error.GetType().Name: @{ Output.Write(HtmlEncodeAndReplaceLineBreaks(errorDetail.Error.Message)); }
+ @{
+ var firstFrame = errorDetail.StackFrames.FirstOrDefault();
+ if (firstFrame != null)
+ {
+ location = firstFrame.Function;
+ }
+ }
+ if (!string.IsNullOrEmpty(location) && firstFrame != null && !string.IsNullOrEmpty(firstFrame.File))
+ {
+ @location in @System.IO.Path.GetFileName(firstFrame.File), line @firstFrame.Line
+ }
+ else if (!string.IsNullOrEmpty(location))
+ {
+ @location
+ }
+ else
+ {
+ @Resources.ErrorPageHtml_UnknownLocation
+ }
+ }
+ @{
+ var reflectionTypeLoadException = Model.ErrorDetails.Last()?.Error as ReflectionTypeLoadException;
+ if (reflectionTypeLoadException != null)
+ {
+ if (reflectionTypeLoadException.LoaderExceptions.Length > 0)
+ {
+ Loader Exceptions:
+
+ @foreach (var ex in reflectionTypeLoadException.LoaderExceptions)
+ {
+ @ex.Message
+ }
+
+ }
+ }
+ }
+
+
+
+
+ @{
+ var exceptionCount = 0;
+ var stackFrameCount = 0;
+ var exceptionDetailId = "";
+ var frameId = "";
+ }
+ @foreach (var errorDetail in Model.ErrorDetails)
+ {
+ @{
+ exceptionCount++;
+ exceptionDetailId = "exceptionDetail" + exceptionCount;
+ }
+
+ @errorDetail.Error.GetType().Name: @errorDetail.Error.Message
+
+ @foreach (var frame in errorDetail.StackFrames)
+ {
+ @{
+ stackFrameCount++;
+ frameId = "frame" + stackFrameCount;
+ }
+
+ @if (string.IsNullOrEmpty(frame.File))
+ {
+ @frame.Function
+ }
+ else
+ {
+ @frame.Function in @System.IO.Path.GetFileName(frame.File)
+ }
+
+ @if (frame.Line != 0 && frame.ContextCode.Any())
+ {
+ +
+
+ @if (frame.PreContextCode.Any())
+ {
+
+ @foreach (var line in frame.PreContextCode)
+ {
+ @line
+ }
+
+ }
+
+
+ @foreach (var line in frame.ContextCode)
+ {
+ @line
+ }
+
+
+ @if (frame.PostContextCode.Any())
+ {
+
+ @foreach (var line in frame.PostContextCode)
+ {
+ @line
+ }
+
+ }
+
+ }
+
+ }
+
+
+
+
+
+
+ Show raw exception details
+
+
+
@errorDetail.Error.ToString()
+
+
+
+ }
+
+
+
+
+ @if (Model.Query.Any())
+ {
+
+
+
+ @Resources.ErrorPageHtml_VariableColumn
+ @Resources.ErrorPageHtml_ValueColumn
+
+
+
+ @foreach (var kv in Model.Query.OrderBy(kv => kv.Key))
+ {
+ foreach (var v in kv.Value)
+ {
+
+ @kv.Key
+ @v
+
+ }
+ }
+
+
+ }
+ else
+ {
+
@Resources.ErrorPageHtml_NoQueryStringData
+ }
+
+
+
+ @if (Model.Cookies.Any())
+ {
+
+
+
+ @Resources.ErrorPageHtml_VariableColumn
+ @Resources.ErrorPageHtml_ValueColumn
+
+
+
+ @foreach (var kv in Model.Cookies.OrderBy(kv => kv.Key))
+ {
+
+ @kv.Key
+ @kv.Value
+
+ }
+
+
+ }
+ else
+ {
+
@Resources.ErrorPageHtml_NoCookieData
+ }
+
+
+
+
+
diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorPage.css b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorPage.css
new file mode 100644
index 0000000000..4d3287c12d
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorPage.css
@@ -0,0 +1,195 @@
+body {
+ font-family: 'Segoe UI', Tahoma, Arial, Helvetica, sans-serif;
+ font-size: .813em;
+ color: #222;
+}
+
+h1, h2, h3, h4, h5 {
+ /*font-family: 'Segoe UI',Tahoma,Arial,Helvetica,sans-serif;*/
+ font-weight: 100;
+}
+
+h1 {
+ color: #44525e;
+ margin: 15px 0 15px 0;
+}
+
+h2 {
+ margin: 10px 5px 0 0;
+}
+
+h3 {
+ color: #363636;
+ margin: 5px 5px 0 0;
+}
+
+code {
+ font-family: Consolas, "Courier New", courier, monospace;
+}
+
+body .titleerror {
+ padding: 3px 3px 6px 3px;
+ display: block;
+ font-size: 1.5em;
+ font-weight: 100;
+}
+
+body .location {
+ margin: 3px 0 10px 30px;
+}
+
+#header {
+ font-size: 18px;
+ padding: 15px 0;
+ border-top: 1px #ddd solid;
+ border-bottom: 1px #ddd solid;
+ margin-bottom: 0;
+}
+
+ #header li {
+ display: inline;
+ margin: 5px;
+ padding: 5px;
+ color: #a0a0a0;
+ cursor: pointer;
+ }
+
+ #header .selected {
+ background: #44c5f2;
+ color: #fff;
+ }
+
+#stackpage ul {
+ list-style: none;
+ padding-left: 0;
+ margin: 0;
+ /*border-bottom: 1px #ddd solid;*/
+}
+
+#stackpage .details {
+ font-size: 1.2em;
+ padding: 3px;
+ color: #000;
+}
+
+#stackpage .stackerror {
+ padding: 5px;
+ border-bottom: 1px #ddd solid;
+}
+
+
+#stackpage .frame {
+ padding: 0;
+ margin: 0 0 0 30px;
+}
+
+ #stackpage .frame h3 {
+ padding: 2px;
+ margin: 0;
+ }
+
+#stackpage .source {
+ padding: 0 0 0 30px;
+}
+
+ #stackpage .source ol li {
+ font-family: Consolas, "Courier New", courier, monospace;
+ white-space: pre;
+ background-color: #fbfbfb;
+ }
+
+#stackpage .frame .source .highlight li span {
+ color: #FF0000;
+}
+
+#stackpage .source ol.collapsible li {
+ color: #888;
+}
+
+ #stackpage .source ol.collapsible li span {
+ color: #606060;
+ }
+
+.page table {
+ border-collapse: separate;
+ border-spacing: 0;
+ margin: 0 0 20px;
+}
+
+.page th {
+ vertical-align: bottom;
+ padding: 10px 5px 5px 5px;
+ font-weight: 400;
+ color: #a0a0a0;
+ text-align: left;
+}
+
+.page td {
+ padding: 3px 10px;
+}
+
+.page th, .page td {
+ border-right: 1px #ddd solid;
+ border-bottom: 1px #ddd solid;
+ border-left: 1px transparent solid;
+ border-top: 1px transparent solid;
+ box-sizing: border-box;
+}
+
+ .page th:last-child, .page td:last-child {
+ border-right: 1px transparent solid;
+ }
+
+.page .length {
+ text-align: right;
+}
+
+a {
+ color: #1ba1e2;
+ text-decoration: none;
+}
+
+ a:hover {
+ color: #13709e;
+ text-decoration: underline;
+ }
+
+.showRawException {
+ cursor: pointer;
+ color: #44c5f2;
+ background-color: transparent;
+ font-size: 1.2em;
+ text-align: left;
+ text-decoration: none;
+ display: inline-block;
+ border: 0;
+ padding: 0;
+}
+
+.rawExceptionStackTrace {
+ font-size: 1.2em;
+}
+
+.rawExceptionBlock {
+ border-top: 1px #ddd solid;
+ border-bottom: 1px #ddd solid;
+}
+
+.showRawExceptionContainer {
+ margin-top: 10px;
+ margin-bottom: 10px;
+}
+
+.expandCollapseButton {
+ cursor: pointer;
+ float: left;
+ height: 16px;
+ width: 16px;
+ font-size: 10px;
+ position: absolute;
+ left: 10px;
+ background-color: #eee;
+ padding: 0;
+ border: 0;
+ margin: 0;
+}
diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorPage.js b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorPage.js
new file mode 100644
index 0000000000..3925cfd2f2
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorPage.js
@@ -0,0 +1,192 @@
+(function (window, undefined) {
+ "use strict";
+
+ function ns(selector, element) {
+ return new NodeCollection(selector, element);
+ }
+
+ function NodeCollection(selector, element) {
+ this.items = [];
+ element = element || window.document;
+
+ var nodeList;
+
+ if (typeof (selector) === "string") {
+ nodeList = element.querySelectorAll(selector);
+ for (var i = 0, l = nodeList.length; i < l; i++) {
+ this.items.push(nodeList.item(i));
+ }
+ }
+ }
+
+ NodeCollection.prototype = {
+ each: function (callback) {
+ for (var i = 0, l = this.items.length; i < l; i++) {
+ callback(this.items[i], i);
+ }
+ return this;
+ },
+
+ children: function (selector) {
+ var children = [];
+
+ this.each(function (el) {
+ children = children.concat(ns(selector, el).items);
+ });
+
+ return ns(children);
+ },
+
+ hide: function () {
+ this.each(function (el) {
+ el.style.display = "none";
+ });
+
+ return this;
+ },
+
+ toggle: function () {
+ this.each(function (el) {
+ el.style.display = el.style.display === "none" ? "" : "none";
+ });
+
+ return this;
+ },
+
+ show: function () {
+ this.each(function (el) {
+ el.style.display = "";
+ });
+
+ return this;
+ },
+
+ addClass: function (className) {
+ this.each(function (el) {
+ var existingClassName = el.className,
+ classNames;
+ if (!existingClassName) {
+ el.className = className;
+ } else {
+ classNames = existingClassName.split(" ");
+ if (classNames.indexOf(className) < 0) {
+ el.className = existingClassName + " " + className;
+ }
+ }
+ });
+
+ return this;
+ },
+
+ removeClass: function (className) {
+ this.each(function (el) {
+ var existingClassName = el.className,
+ classNames, index;
+ if (existingClassName === className) {
+ el.className = "";
+ } else if (existingClassName) {
+ classNames = existingClassName.split(" ");
+ index = classNames.indexOf(className);
+ if (index > 0) {
+ classNames.splice(index, 1);
+ el.className = classNames.join(" ");
+ }
+ }
+ });
+
+ return this;
+ },
+
+ attr: function (name) {
+ if (this.items.length === 0) {
+ return null;
+ }
+
+ return this.items[0].getAttribute(name);
+ },
+
+ on: function (eventName, handler) {
+ this.each(function (el, idx) {
+ var callback = function (e) {
+ e = e || window.event;
+ if (!e.which && e.keyCode) {
+ e.which = e.keyCode; // Normalize IE8 key events
+ }
+ handler.apply(el, [e]);
+ };
+
+ if (el.addEventListener) { // DOM Events
+ el.addEventListener(eventName, callback, false);
+ } else if (el.attachEvent) { // IE8 events
+ el.attachEvent("on" + eventName, callback);
+ } else {
+ el["on" + type] = callback;
+ }
+ });
+
+ return this;
+ },
+
+ click: function (handler) {
+ return this.on("click", handler);
+ },
+
+ keypress: function (handler) {
+ return this.on("keypress", handler);
+ }
+ };
+
+ function frame(el) {
+ ns(".source .collapsible", el).toggle();
+ }
+
+ function expandCollapseButton(el) {
+ var frameId = el.getAttribute("data-frameId");
+ frame(document.getElementById(frameId));
+ if (el.innerText === "+") {
+ el.innerText = "-";
+ }
+ else {
+ el.innerText = "+";
+ }
+ }
+
+ function tab(el) {
+ var unselected = ns("#header .selected").removeClass("selected").attr("id");
+ var selected = ns("#" + el.id).addClass("selected").attr("id");
+
+ ns("#" + unselected + "page").hide();
+ ns("#" + selected + "page").show();
+ }
+
+ ns(".rawExceptionDetails").hide();
+ ns(".collapsible").hide();
+ ns(".page").hide();
+ ns("#stackpage").show();
+
+ ns(".expandCollapseButton")
+ .click(function () {
+ expandCollapseButton(this);
+ })
+ .keypress(function (e) {
+ if (e.which === 13) {
+ expandCollapseButton(this);
+ }
+ });
+
+ ns("#header li")
+ .click(function () {
+ tab(this);
+ })
+ .keypress(function (e) {
+ if (e.which === 13) {
+ tab(this);
+ }
+ });
+
+ ns(".showRawException")
+ .click(function () {
+ var exceptionDetailId = this.getAttribute("data-exceptionDetailId");
+ ns("#" + exceptionDetailId).toggle();
+ });
+})(window);
\ No newline at end of file
diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorPageModel.cs b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorPageModel.cs
new file mode 100644
index 0000000000..454c8e010e
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/ErrorPageModel.cs
@@ -0,0 +1,43 @@
+// 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;
+using System.Collections.Generic;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Primitives;
+
+namespace Microsoft.AspNetCore.Diagnostics.Views
+{
+ ///
+ /// Holds data to be displayed on the error page.
+ ///
+ [Obsolete("This type is for internal use only and will be removed in a future version.")]
+ public class ErrorPageModel
+ {
+ ///
+ /// Options for what output to display.
+ ///
+ public DeveloperExceptionPageOptions Options { get; set; }
+
+ ///
+ /// Detailed information about each exception in the stack.
+ ///
+ public IEnumerable ErrorDetails { get; set; }
+
+ ///
+ /// Parsed query data.
+ ///
+ public IQueryCollection Query { get; set; }
+
+ ///
+ /// Request cookies.
+ ///
+ public IRequestCookieCollection Cookies { get; set; }
+
+ ///
+ /// Request headers.
+ ///
+ public IDictionary Headers { get; set; }
+ }
+}
diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/StackFrame.cs b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/StackFrame.cs
similarity index 94%
rename from src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/StackFrame.cs
rename to src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/StackFrame.cs
index 1947f162b8..831202a660 100644
--- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/StackFrame.cs
+++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/StackFrame.cs
@@ -2,6 +2,7 @@
// 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 System.Linq;
@@ -10,6 +11,7 @@ namespace Microsoft.AspNetCore.Diagnostics.Views
///
/// Detailed exception stack information used to generate a view
///
+ [Obsolete("This type is for internal use only and will be removed in a future version.")]
public class StackFrame
{
///
diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/StackFrameInfo.cs b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/StackFrameInfo.cs
similarity index 94%
rename from src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/StackFrameInfo.cs
rename to src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/StackFrameInfo.cs
index 689cd43af0..b4f4819860 100644
--- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/StackFrameInfo.cs
+++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/Obsolete/StackFrameInfo.cs
@@ -1,6 +1,7 @@
// 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;
using System.Collections.Generic;
using System.Linq;
@@ -9,6 +10,7 @@ namespace Microsoft.AspNetCore.Diagnostics.Views
///
/// Detailed exception stack information used to generate a view
///
+ [Obsolete("This type is for internal use only and will be removed in a future version.")]
public class StackFrameInfo
{
///
diff --git a/src/Microsoft.AspNetCore.Diagnostics/WelcomePage/Views/WelcomePage.cs b/src/Microsoft.AspNetCore.Diagnostics/WelcomePage/Views/Obsolete/WelcomePage.cs
similarity index 99%
rename from src/Microsoft.AspNetCore.Diagnostics/WelcomePage/Views/WelcomePage.cs
rename to src/Microsoft.AspNetCore.Diagnostics/WelcomePage/Views/Obsolete/WelcomePage.cs
index 874194e0a9..991c601bb6 100644
--- a/src/Microsoft.AspNetCore.Diagnostics/WelcomePage/Views/WelcomePage.cs
+++ b/src/Microsoft.AspNetCore.Diagnostics/WelcomePage/Views/Obsolete/WelcomePage.cs
@@ -13,7 +13,8 @@ using Microsoft.AspNetCore.Diagnostics
#line hidden
;
using System.Threading.Tasks;
-
+
+ [Obsolete("This type is for internal use only and will be removed in a future version.")]
public class WelcomePage : Microsoft.AspNetCore.DiagnosticsViewPage.Views.BaseView
{
#line hidden
diff --git a/src/Microsoft.AspNetCore.Diagnostics/WelcomePage/Views/Obsolete/WelcomePage.cshtml b/src/Microsoft.AspNetCore.Diagnostics/WelcomePage/Views/Obsolete/WelcomePage.cshtml
new file mode 100644
index 0000000000..9cfb311cbd
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics/WelcomePage/Views/Obsolete/WelcomePage.cshtml
@@ -0,0 +1,196 @@
+@using System
+@using Microsoft.AspNetCore.Diagnostics
+@{
+ Response.ContentType = "text/html";
+}
+
+
+
+
+ @Resources.WelcomeTitle
+
+
+
+
+
+
+
+
+
+
:-)
+
+
+
+
+
+
+
+
+
+
+
+
@Resources.WelcomeHeader
+
@Resources.WelcomeStarted
+
@Resources.WelcomeLearnMicrosoftAspNet
+
+
+
+
+
+
diff --git a/src/Microsoft.AspNetCore.Diagnostics/WelcomePage/Views/WelcomePage.Designer.cs b/src/Microsoft.AspNetCore.Diagnostics/WelcomePage/Views/WelcomePage.Designer.cs
new file mode 100644
index 0000000000..5d322fb788
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Diagnostics/WelcomePage/Views/WelcomePage.Designer.cs
@@ -0,0 +1,372 @@
+namespace Microsoft.AspNetCore.Diagnostics.RazorViews
+{
+#line 1 "WelcomePage.cshtml"
+using System
+
+#line default
+#line hidden
+ ;
+#line 2 "WelcomePage.cshtml"
+using Microsoft.AspNetCore.Diagnostics
+
+#line default
+#line hidden
+ ;
+ using System.Threading.Tasks;
+
+ internal class WelcomePage : Microsoft.Extensions.RazorViews.BaseView
+ {
+ #line hidden
+ public WelcomePage()
+ {
+ }
+
+ #pragma warning disable 1998
+ public override async Task ExecuteAsync()
+ {
+#line 3 "WelcomePage.cshtml"
+
+ Response.ContentType = "text/html; charset=utf-8";
+
+#line default
+#line hidden
+
+ WriteLiteral("\r\n\r\n\r\n \r\n ");
+#line 10 "WelcomePage.cshtml"
+ Write(Resources.WelcomeTitle);
+
+#line default
+#line hidden
+ WriteLiteral(@"
+
+
+
+
+
+
+
+ ");
+ WriteLiteral(@"
+
+
:-)
+
+
+
+
+
+
+
\r\n
\r\n
\r\n\r\n \r\n
");
+#line 187 "WelcomePage.cshtml"
+ Write(Resources.WelcomeHeader);
+
+#line default
+#line hidden
+ WriteLiteral("
\r\n
");
+#line 188 "WelcomePage.cshtml"
+ Write(Resources.WelcomeStarted);
+
+#line default
+#line hidden
+ WriteLiteral("
\r\n
");
+#line 189 "WelcomePage.cshtml"
+ Write(Resources.WelcomeLearnMicrosoftAspNet);
+
+#line default
+#line hidden
+ WriteLiteral(@"
+
\r\n \r\n
\r\n\r\n\r\n\r\n");
+ }
+ #pragma warning restore 1998
+ }
+}
diff --git a/src/Microsoft.AspNetCore.Diagnostics/WelcomePage/Views/WelcomePage.cshtml b/src/Microsoft.AspNetCore.Diagnostics/WelcomePage/Views/WelcomePage.cshtml
index 9cfb311cbd..3e15978d72 100644
--- a/src/Microsoft.AspNetCore.Diagnostics/WelcomePage/Views/WelcomePage.cshtml
+++ b/src/Microsoft.AspNetCore.Diagnostics/WelcomePage/Views/WelcomePage.cshtml
@@ -1,7 +1,7 @@
-@using System
+@using System
@using Microsoft.AspNetCore.Diagnostics
@{
- Response.ContentType = "text/html";
+ Response.ContentType = "text/html; charset=utf-8";
}
diff --git a/src/Microsoft.AspNetCore.Diagnostics/WelcomePage/WelcomePageMiddleware.cs b/src/Microsoft.AspNetCore.Diagnostics/WelcomePage/WelcomePageMiddleware.cs
index 623d2b1302..ad201ddff1 100644
--- a/src/Microsoft.AspNetCore.Diagnostics/WelcomePage/WelcomePageMiddleware.cs
+++ b/src/Microsoft.AspNetCore.Diagnostics/WelcomePage/WelcomePageMiddleware.cs
@@ -1,11 +1,10 @@
// 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;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.Diagnostics.Views;
+using Microsoft.AspNetCore.Diagnostics.RazorViews;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
diff --git a/src/Microsoft.AspNetCore.Diagnostics/project.json b/src/Microsoft.AspNetCore.Diagnostics/project.json
index de22dab891..3694cf9af0 100644
--- a/src/Microsoft.AspNetCore.Diagnostics/project.json
+++ b/src/Microsoft.AspNetCore.Diagnostics/project.json
@@ -31,6 +31,10 @@
"Microsoft.Extensions.FileProviders.Physical": "1.1.0-*",
"Microsoft.Extensions.Logging.Abstractions": "1.1.0-*",
"Microsoft.Extensions.Options": "1.1.0-*",
+ "Microsoft.Extensions.RazorViews.Sources": {
+ "type": "build",
+ "version": "1.1.0-*"
+ },
"Microsoft.Extensions.StackTrace.Sources": {
"type": "build",
"version": "1.1.0-*"
@@ -42,6 +46,9 @@
"System.Diagnostics.DiagnosticSource": "4.0.0-*",
"System.Reflection.Metadata": "1.3.0-*"
},
+ "tools": {
+ "RazorPageGenerator": "1.1.0-*"
+ },
"frameworks": {
"net451": {},
"netstandard1.3": {
diff --git a/src/Microsoft.AspNetCore.DiagnosticsViewPage.Sources/AttributeValue.cs b/src/Microsoft.AspNetCore.DiagnosticsViewPage.Sources/AttributeValue.cs
index 9bb3119d3e..2be902b6ae 100644
--- a/src/Microsoft.AspNetCore.DiagnosticsViewPage.Sources/AttributeValue.cs
+++ b/src/Microsoft.AspNetCore.DiagnosticsViewPage.Sources/AttributeValue.cs
@@ -5,6 +5,7 @@ using System;
namespace Microsoft.AspNetCore.DiagnosticsViewPage.Views
{
+ [Obsolete("This type is for internal use only and will be removed in a future version.")]
public class AttributeValue
{
public AttributeValue(string prefix, object value, bool literal)
diff --git a/src/Microsoft.AspNetCore.DiagnosticsViewPage.Sources/BaseView.cs b/src/Microsoft.AspNetCore.DiagnosticsViewPage.Sources/BaseView.cs
index ef2bee53a9..76f324df60 100644
--- a/src/Microsoft.AspNetCore.DiagnosticsViewPage.Sources/BaseView.cs
+++ b/src/Microsoft.AspNetCore.DiagnosticsViewPage.Sources/BaseView.cs
@@ -17,6 +17,7 @@ namespace Microsoft.AspNetCore.DiagnosticsViewPage.Views
///
/// Infrastructure
///
+ [Obsolete("This type is for internal use only and will be removed in a future version.")]
public abstract class BaseView
{
///
diff --git a/src/Microsoft.AspNetCore.DiagnosticsViewPage.Sources/HelperResult.cs b/src/Microsoft.AspNetCore.DiagnosticsViewPage.Sources/HelperResult.cs
index f336daa751..10a3d1603d 100644
--- a/src/Microsoft.AspNetCore.DiagnosticsViewPage.Sources/HelperResult.cs
+++ b/src/Microsoft.AspNetCore.DiagnosticsViewPage.Sources/HelperResult.cs
@@ -9,6 +9,7 @@ namespace Microsoft.AspNetCore.DiagnosticsViewPage.Views
///
/// Represents a deferred write operation in a .
///
+ [Obsolete("This type is for internal use only and will be removed in a future version.")]
public class HelperResult
{
///
diff --git a/tools/PageGenerator/PageGenerator.xproj b/test/ClassLibraryWithPortablePdbs/ClassLibraryWithPortablePdbs.xproj
similarity index 54%
rename from tools/PageGenerator/PageGenerator.xproj
rename to test/ClassLibraryWithPortablePdbs/ClassLibraryWithPortablePdbs.xproj
index 4780f62048..5acd090053 100644
--- a/tools/PageGenerator/PageGenerator.xproj
+++ b/test/ClassLibraryWithPortablePdbs/ClassLibraryWithPortablePdbs.xproj
@@ -1,18 +1,19 @@
-
+
- 14.0
+ 14.0.25420
$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
-
+
- 4d4a785a-ecb9-4916-a88f-0fd306ee3b74
+ aa3661a1-ce8d-4597-adfd-a5a30834e5d0
+ ClassLibraryWithPortablePdbs
.\obj
.\bin\
+
2.0
- 0
-
+
\ No newline at end of file
diff --git a/test/ClassLibraryWithPortablePdbs/ExceptionType.cs b/test/ClassLibraryWithPortablePdbs/ExceptionType.cs
new file mode 100644
index 0000000000..8ca0f563af
--- /dev/null
+++ b/test/ClassLibraryWithPortablePdbs/ExceptionType.cs
@@ -0,0 +1,20 @@
+// 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;
+
+namespace ClassLibraryWithPortablePdbs
+{
+ public class ExceptionType
+ {
+ public static void StaticMethodThatThrows()
+ {
+ throw new Exception();
+ }
+
+ public void MethodThatThrows()
+ {
+ throw new Exception();
+ }
+ }
+}
diff --git a/test/ClassLibraryWithPortablePdbs/project.json b/test/ClassLibraryWithPortablePdbs/project.json
new file mode 100644
index 0000000000..86c3c2628f
--- /dev/null
+++ b/test/ClassLibraryWithPortablePdbs/project.json
@@ -0,0 +1,13 @@
+{
+ "version": "1.1.0-*",
+ "buildOptions": {
+ "debugType": "portable",
+ "keyFile": "../../tools/Key.snk"
+ },
+ "dependencies": {
+ "System.Runtime": "4.1.0-*"
+ },
+ "frameworks": {
+ "netstandard1.0": {}
+ }
+}
\ No newline at end of file
diff --git a/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests/ApiConsistencyTestBase.cs b/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests/ApiConsistencyTestBase.cs
index ac5ef876dc..a838bdf397 100644
--- a/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests/ApiConsistencyTestBase.cs
+++ b/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests/ApiConsistencyTestBase.cs
@@ -7,7 +7,7 @@ using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Views;
+using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.RazorViews;
using Microsoft.AspNetCore.Testing.xunit;
using Xunit;
diff --git a/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests/DatabaseErrorPageTest.cs b/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests/DatabaseErrorPageTest.cs
index 4a05483360..1058b980e6 100644
--- a/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests/DatabaseErrorPageTest.cs
+++ b/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests/DatabaseErrorPageTest.cs
@@ -3,7 +3,7 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests.Helpers;
-using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Views;
+using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.RazorViews;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Moq;
@@ -153,7 +153,7 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests
Assert.Contains("Something bad happened", content);
Assert.Contains("Because something more badder happened", content);
}
-
+
[Fact]
public async Task MigrationsEndPointPath_is_respected()
{
diff --git a/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests/project.json b/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests/project.json
index ca0c29fc77..d79b697759 100644
--- a/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests/project.json
+++ b/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests/project.json
@@ -1,12 +1,13 @@
{
"buildOptions": {
- "warningsAsErrors": true,
"compile": {
"include": [
"../Shared/ApiConsistencyTestBase.cs",
"../Shared/TestHelpers.cs"
]
- }
+ },
+ "keyFile": "../../tools/Key.snk",
+ "warningsAsErrors": true
},
"dependencies": {
"dotnet-test-xunit": "2.2.0-*",
diff --git a/test/Microsoft.AspNetCore.Diagnostics.Tests/DeveloperExceptionPageMiddlewareTest.cs b/test/Microsoft.AspNetCore.Diagnostics.Tests/DeveloperExceptionPageMiddlewareTest.cs
index 4b84444581..ef903e3e7f 100644
--- a/test/Microsoft.AspNetCore.Diagnostics.Tests/DeveloperExceptionPageMiddlewareTest.cs
+++ b/test/Microsoft.AspNetCore.Diagnostics.Tests/DeveloperExceptionPageMiddlewareTest.cs
@@ -2,424 +2,19 @@
// 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 System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost;
-using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.FileProviders;
-using Microsoft.Extensions.Logging;
-using Microsoft.Extensions.Options;
-using Microsoft.Extensions.Primitives;
-using Moq;
using Xunit;
namespace Microsoft.AspNetCore.Diagnostics
{
public class DeveloperExceptionPageMiddlewareTest
{
- public static TheoryData RelativePathsData
- {
- get
- {
- var data = new TheoryData
- {
- "TestFiles/SourceFile.txt"
- };
-
- if (!(RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)))
- {
- data.Add(@"TestFiles\SourceFile.txt");
- }
-
- return data;
- }
- }
-
- [Theory]
- [MemberData(nameof(RelativePathsData))]
- public void UsesDefaultFileProvider_IfNotProvidedOnOptions(string relativePath)
- {
- // Arrange & Act
- var middleware = GetErrorPageMiddleware(fileProvider: null);
- var stackFrame = middleware.GetStackFrame("func1", relativePath, lineNumber: 10);
-
- // Assert
- // Lines 4-16 (inclusive) is the code block
- Assert.Equal(4, stackFrame.PreContextLine);
- Assert.Equal(GetCodeLines(4, 9), stackFrame.PreContextCode);
- Assert.Equal(GetCodeLines(10, 10), stackFrame.ContextCode);
- Assert.Equal(GetCodeLines(11, 16), stackFrame.PostContextCode);
- }
-
- public static TheoryData AbsolutePathsData
- {
- get
- {
- var rootPath = Directory.GetCurrentDirectory();
-
- var data = new TheoryData()
- {
- Path.Combine(rootPath, "TestFiles/SourceFile.txt")
- };
-
- if (!TestPlatformHelper.IsMono)
- {
- Path.Combine(rootPath, @"TestFiles\SourceFile.txt");
- }
-
- return data;
- }
- }
-
- [Theory]
- [MemberData(nameof(AbsolutePathsData))]
- public void DisplaysSourceCodeLines_ForAbsolutePaths(string absoluteFilePath)
- {
- // Arrange
- var rootPath = Directory.GetCurrentDirectory();
- // PhysicalFileProvider handles only relative paths but we fall back to work with absolute paths too
- using (var provider = new PhysicalFileProvider(rootPath))
- {
- // Act
- var middleware = GetErrorPageMiddleware(provider);
- var stackFrame = middleware.GetStackFrame("func1", absoluteFilePath, lineNumber: 10);
-
- // Assert
- // Lines 4-16 (inclusive) is the code block
- Assert.Equal(4, stackFrame.PreContextLine);
- Assert.Equal(GetCodeLines(4, 9), stackFrame.PreContextCode);
- Assert.Equal(GetCodeLines(10, 10), stackFrame.ContextCode);
- Assert.Equal(GetCodeLines(11, 16), stackFrame.PostContextCode);
- }
- }
-
- [Theory]
- [MemberData(nameof(RelativePathsData))]
- public void DisplaysSourceCodeLines_ForRelativePaths(string relativePath)
- {
- // Arrange
- var rootPath = Directory.GetCurrentDirectory();
- using (var provider = new PhysicalFileProvider(rootPath))
- {
- // Act
- var middleware = GetErrorPageMiddleware(provider);
- var stackFrame = middleware.GetStackFrame("func1", relativePath, lineNumber: 10);
-
- // Assert
- // Lines 4-16 (inclusive) is the code block
- Assert.Equal(4, stackFrame.PreContextLine);
- Assert.Equal(GetCodeLines(4, 9), stackFrame.PreContextCode);
- Assert.Equal(GetCodeLines(10, 10), stackFrame.ContextCode);
- Assert.Equal(GetCodeLines(11, 16), stackFrame.PostContextCode);
- }
- }
-
- [Theory]
- [InlineData("TestFiles/EmbeddedSourceFile.txt")]
- //[InlineData(@"TestFiles\EmbeddedSourceFile.txt")]
- public void DisplaysSourceCodeLines_ForRelativeEmbeddedPaths(string relativePath)
- {
- // Arrange
- var provider = new EmbeddedFileProvider(
- GetType().GetTypeInfo().Assembly,
- baseNamespace: $"{typeof(DeveloperExceptionPageMiddlewareTest).GetTypeInfo().Assembly.GetName().Name}.Resources");
-
- // Act
- var middleware = GetErrorPageMiddleware(provider);
- var stackFrame = middleware.GetStackFrame("func1", relativePath, lineNumber: 10);
-
- // Assert
- // Lines 4-16 (inclusive) is the code block
- Assert.Equal(4, stackFrame.PreContextLine);
- Assert.Equal(GetCodeLines(4, 9), stackFrame.PreContextCode);
- Assert.Equal(GetCodeLines(10, 10), stackFrame.ContextCode);
- Assert.Equal(GetCodeLines(11, 16), stackFrame.PostContextCode);
- }
-
- public static TheoryData DisplaysSourceCodeLines_PreAndPostErrorLineData
- {
- get
- {
- return new TheoryData()
- {
- new ErrorData()
- {
- AllLines = GetCodeLines(1, 30),
- ErrorStartLine = 10,
- ErrorEndLine = 10,
- ExpectedPreContextLine = 4,
- ExpectedPreErrorCode = GetCodeLines(4, 9),
- ExpectedErrorCode = GetCodeLines(10, 10),
- ExpectedPostErrorCode = GetCodeLines(11, 16)
- },
- new ErrorData()
- {
- AllLines = GetCodeLines(1, 30),
- ErrorStartLine = 10,
- ErrorEndLine = 13, // multi-line error
- ExpectedPreContextLine = 4,
- ExpectedPreErrorCode = GetCodeLines(4, 9),
- ExpectedErrorCode = GetCodeLines(10, 13),
- ExpectedPostErrorCode = GetCodeLines(14, 19)
- },
-
- // PreErrorCode less than source code line count
- new ErrorData()
- {
- AllLines = GetCodeLines(1, 10),
- ErrorStartLine = 1,
- ErrorEndLine = 1,
- ExpectedPreContextLine = 1,
- ExpectedPreErrorCode = Enumerable.Empty(),
- ExpectedErrorCode = GetCodeLines(1, 1),
- ExpectedPostErrorCode = GetCodeLines(2, 7)
- },
- new ErrorData()
- {
- AllLines = GetCodeLines(1, 10),
- ErrorStartLine = 3,
- ErrorEndLine = 5,
- ExpectedPreContextLine = 1,
- ExpectedPreErrorCode = GetCodeLines(1, 2),
- ExpectedErrorCode = GetCodeLines(3, 5),
- ExpectedPostErrorCode = GetCodeLines(6, 10)
- },
-
- // PostErrorCode less than source code line count
- new ErrorData()
- {
- AllLines = GetCodeLines(1, 10),
- ErrorStartLine = 10,
- ErrorEndLine = 10,
- ExpectedPreContextLine = 4,
- ExpectedPreErrorCode = GetCodeLines(4, 9),
- ExpectedErrorCode = GetCodeLines(10, 10),
- ExpectedPostErrorCode = Enumerable.Empty()
- },
- new ErrorData()
- {
- AllLines = GetCodeLines(1, 10),
- ErrorStartLine = 7,
- ErrorEndLine = 10,
- ExpectedPreContextLine = 1,
- ExpectedPreErrorCode = GetCodeLines(1, 6),
- ExpectedErrorCode = GetCodeLines(7, 10),
- ExpectedPostErrorCode = Enumerable.Empty()
- },
- new ErrorData()
- {
- AllLines = GetCodeLines(1, 10),
- ErrorStartLine = 5,
- ErrorEndLine = 8,
- ExpectedPreContextLine = 1,
- ExpectedPreErrorCode = GetCodeLines(1, 4),
- ExpectedErrorCode = GetCodeLines(5, 8),
- ExpectedPostErrorCode = GetCodeLines(9, 10)
- },
-
- // Pre and Post error code less than source code line count
- new ErrorData()
- {
- AllLines = GetCodeLines(1, 4),
- ErrorStartLine = 2,
- ErrorEndLine = 3,
- ExpectedPreContextLine = 1,
- ExpectedPreErrorCode = GetCodeLines(1, 1),
- ExpectedErrorCode = GetCodeLines(2, 3),
- ExpectedPostErrorCode = GetCodeLines(4, 4)
- },
- new ErrorData()
- {
- AllLines = GetCodeLines(1, 4),
- ErrorStartLine = 1,
- ErrorEndLine = 4,
- ExpectedPreContextLine = 1,
- ExpectedPreErrorCode = Enumerable.Empty(),
- ExpectedErrorCode = GetCodeLines(1, 4),
- ExpectedPostErrorCode = Enumerable.Empty()
- },
-
- // change source code line count
- new ErrorData()
- {
- SourceCodeLineCount = 1,
- AllLines = GetCodeLines(1, 1),
- ErrorStartLine = 1,
- ErrorEndLine = 1,
- ExpectedPreContextLine = 1,
- ExpectedPreErrorCode = Enumerable.Empty(),
- ExpectedErrorCode = GetCodeLines(1, 1),
- ExpectedPostErrorCode = Enumerable.Empty()
- },
- };
- }
- }
-
- [Theory]
- [MemberData(nameof(DisplaysSourceCodeLines_PreAndPostErrorLineData))]
- public void DisplaysSourceCodeLines_PreAndPostErrorLine(ErrorData errorData)
- {
- // Arrange
- var middleware = GetErrorPageMiddleware();
- var stackFrame = new Views.StackFrame();
-
- // Act
- middleware.ReadFrameContent(
- stackFrame, errorData.AllLines, errorData.ErrorStartLine, errorData.ErrorEndLine);
-
- // Assert
- Assert.Equal(errorData.ExpectedPreContextLine, stackFrame.PreContextLine);
- Assert.Equal(errorData.ExpectedPreErrorCode, stackFrame.PreContextCode);
- Assert.Equal(errorData.ExpectedErrorCode, stackFrame.ContextCode);
- Assert.Equal(errorData.ExpectedPostErrorCode, stackFrame.PostContextCode);
- }
-
- private static IEnumerable GetCodeLines(int fromLine, int toLine)
- {
- var start = fromLine;
- var count = toLine - fromLine + 1;
- return Enumerable.Range(start, count).Select(i => string.Format("Line{0}", i));
- }
-
- private DeveloperExceptionPageMiddleware GetErrorPageMiddleware(
- IFileProvider fileProvider = null, int sourceCodeLineCount = 6)
- {
- var options = new DeveloperExceptionPageOptions();
- options.SourceCodeLineCount = sourceCodeLineCount;
-
- if (fileProvider != null)
- {
- options.FileProvider = fileProvider;
- }
-
- var middleware = new DeveloperExceptionPageMiddleware(
- (httpContext) => { return Task.FromResult(0); },
- Options.Create(options),
- new LoggerFactory(),
- Mock.Of(),
- new DiagnosticListener("Microsoft.Aspnet"));
-
- return middleware;
- }
-
- private class TestFileProvider : IFileProvider
- {
- private readonly IEnumerable _sourceCodeLines;
-
- public TestFileProvider(IEnumerable sourceCodeLines)
- {
- _sourceCodeLines = sourceCodeLines;
- }
-
- public IDirectoryContents GetDirectoryContents(string subpath)
- {
- throw new NotImplementedException();
- }
-
- public IFileInfo GetFileInfo(string subpath)
- {
- return new TestFileInfo(_sourceCodeLines);
- }
-
- public IChangeToken Watch(string filter)
- {
- throw new NotImplementedException();
- }
- }
-
- private class TestFileInfo : IFileInfo
- {
- private readonly MemoryStream _stream;
-
- public TestFileInfo(IEnumerable sourceCodeLines)
- {
- _stream = new MemoryStream();
- using (var writer = new StreamWriter(_stream, Encoding.UTF8, 1024, leaveOpen: true))
- {
- foreach (var line in sourceCodeLines)
- {
- writer.WriteLine(line);
- }
- }
- _stream.Seek(0, SeekOrigin.Begin);
- }
-
- public bool Exists
- {
- get
- {
- return true;
- }
- }
-
- public bool IsDirectory
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public DateTimeOffset LastModified
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public long Length
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public string Name
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public string PhysicalPath
- {
- get
- {
- return null;
- }
- }
-
- public Stream CreateReadStream()
- {
- return _stream;
- }
- }
-
- public class ErrorData
- {
- public int SourceCodeLineCount { get; set; } = 6;
- public IEnumerable AllLines { get; set; }
- public int ErrorStartLine { get; set; }
- public int ErrorEndLine { get; set; }
- public int ExpectedPreContextLine { get; set; }
- public IEnumerable ExpectedPreErrorCode { get; set; }
- public IEnumerable ExpectedErrorCode { get; set; }
- public IEnumerable ExpectedPostErrorCode { get; set; }
- }
-
[Fact]
public async Task UnhandledErrorsWriteToDiagnosticWhenUsingExceptionPage()
{
diff --git a/test/Microsoft.AspNetCore.Diagnostics.Tests/ExceptionDetailsProviderTest.cs b/test/Microsoft.AspNetCore.Diagnostics.Tests/ExceptionDetailsProviderTest.cs
new file mode 100644
index 0000000000..bda7bde74d
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Diagnostics.Tests/ExceptionDetailsProviderTest.cs
@@ -0,0 +1,392 @@
+// 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;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Text;
+using Microsoft.AspNetCore.Testing;
+using Microsoft.Extensions.FileProviders;
+using Microsoft.Extensions.Primitives;
+using Microsoft.Extensions.StackTrace.Sources;
+using Xunit;
+
+namespace Microsoft.Extensions.Internal
+{
+ public class ExceptionDetailsProviderTest
+ {
+ public static TheoryData RelativePathsData
+ {
+ get
+ {
+ var data = new TheoryData
+ {
+ "TestFiles/SourceFile.txt"
+ };
+
+ if (!(RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)))
+ {
+ data.Add(@"TestFiles\SourceFile.txt");
+ }
+
+ return data;
+ }
+ }
+
+ public static TheoryData AbsolutePathsData
+ {
+ get
+ {
+ var rootPath = Directory.GetCurrentDirectory();
+
+ var data = new TheoryData()
+ {
+ Path.Combine(rootPath, "TestFiles/SourceFile.txt")
+ };
+
+ if (!TestPlatformHelper.IsMono)
+ {
+ Path.Combine(rootPath, @"TestFiles\SourceFile.txt");
+ }
+
+ return data;
+ }
+ }
+
+ [Theory]
+ [MemberData(nameof(AbsolutePathsData))]
+ public void DisplaysSourceCodeLines_ForAbsolutePaths(string absoluteFilePath)
+ {
+ // Arrange
+ var rootPath = Directory.GetCurrentDirectory();
+ // PhysicalFileProvider handles only relative paths but we fall back to work with absolute paths too
+ using (var provider = new PhysicalFileProvider(rootPath))
+ {
+ // Act
+ var exceptionDetailProvider = new ExceptionDetailsProvider(provider, sourceCodeLineCount: 6);
+ var stackFrame = exceptionDetailProvider.GetStackFrameSourceCodeInfo(
+ "func1",
+ absoluteFilePath,
+ lineNumber: 10);
+
+ // Assert
+ // Lines 4-16 (inclusive) is the code block
+ Assert.Equal(4, stackFrame.PreContextLine);
+ Assert.Equal(GetCodeLines(4, 9), stackFrame.PreContextCode);
+ Assert.Equal(GetCodeLines(10, 10), stackFrame.ContextCode);
+ Assert.Equal(GetCodeLines(11, 16), stackFrame.PostContextCode);
+ }
+ }
+
+ [Theory]
+ [MemberData(nameof(RelativePathsData))]
+ public void DisplaysSourceCodeLines_ForRelativePaths(string relativePath)
+ {
+ // Arrange
+ var rootPath = Directory.GetCurrentDirectory();
+ using (var provider = new PhysicalFileProvider(rootPath))
+ {
+ // Act
+ var exceptionDetailProvider = new ExceptionDetailsProvider(provider, sourceCodeLineCount: 6);
+ var stackFrame = exceptionDetailProvider.GetStackFrameSourceCodeInfo(
+ "func1",
+ relativePath,
+ lineNumber: 10);
+
+ // Assert
+ // Lines 4-16 (inclusive) is the code block
+ Assert.Equal(4, stackFrame.PreContextLine);
+ Assert.Equal(GetCodeLines(4, 9), stackFrame.PreContextCode);
+ Assert.Equal(GetCodeLines(10, 10), stackFrame.ContextCode);
+ Assert.Equal(GetCodeLines(11, 16), stackFrame.PostContextCode);
+ }
+ }
+
+ [Theory]
+ [InlineData("TestFiles/EmbeddedSourceFile.txt")]
+ //[InlineData(@"TestFiles\EmbeddedSourceFile.txt")]
+ public void DisplaysSourceCodeLines_ForRelativeEmbeddedPaths(string relativePath)
+ {
+ // Arrange
+ var provider = new EmbeddedFileProvider(
+ GetType().GetTypeInfo().Assembly,
+ baseNamespace: $"{typeof(ExceptionDetailsProviderTest).GetTypeInfo().Assembly.GetName().Name}.Resources");
+
+ // Act
+ var exceptionDetailProvider = new ExceptionDetailsProvider(provider, sourceCodeLineCount: 6);
+ var stackFrame = exceptionDetailProvider.GetStackFrameSourceCodeInfo(
+ "func1",
+ relativePath,
+ lineNumber: 10);
+
+ // Assert
+ // Lines 4-16 (inclusive) is the code block
+ Assert.Equal(4, stackFrame.PreContextLine);
+ Assert.Equal(GetCodeLines(4, 9), stackFrame.PreContextCode);
+ Assert.Equal(GetCodeLines(10, 10), stackFrame.ContextCode);
+ Assert.Equal(GetCodeLines(11, 16), stackFrame.PostContextCode);
+ }
+
+ public static TheoryData DisplaysSourceCodeLines_PreAndPostErrorLineData
+ {
+ get
+ {
+ return new TheoryData()
+ {
+ new ErrorData()
+ {
+ AllLines = GetCodeLines(1, 30),
+ ErrorStartLine = 10,
+ ErrorEndLine = 10,
+ ExpectedPreContextLine = 4,
+ ExpectedPreErrorCode = GetCodeLines(4, 9),
+ ExpectedErrorCode = GetCodeLines(10, 10),
+ ExpectedPostErrorCode = GetCodeLines(11, 16)
+ },
+ new ErrorData()
+ {
+ AllLines = GetCodeLines(1, 30),
+ ErrorStartLine = 10,
+ ErrorEndLine = 13, // multi-line error
+ ExpectedPreContextLine = 4,
+ ExpectedPreErrorCode = GetCodeLines(4, 9),
+ ExpectedErrorCode = GetCodeLines(10, 13),
+ ExpectedPostErrorCode = GetCodeLines(14, 19)
+ },
+
+ // PreErrorCode less than source code line count
+ new ErrorData()
+ {
+ AllLines = GetCodeLines(1, 10),
+ ErrorStartLine = 1,
+ ErrorEndLine = 1,
+ ExpectedPreContextLine = 1,
+ ExpectedPreErrorCode = Enumerable.Empty(),
+ ExpectedErrorCode = GetCodeLines(1, 1),
+ ExpectedPostErrorCode = GetCodeLines(2, 7)
+ },
+ new ErrorData()
+ {
+ AllLines = GetCodeLines(1, 10),
+ ErrorStartLine = 3,
+ ErrorEndLine = 5,
+ ExpectedPreContextLine = 1,
+ ExpectedPreErrorCode = GetCodeLines(1, 2),
+ ExpectedErrorCode = GetCodeLines(3, 5),
+ ExpectedPostErrorCode = GetCodeLines(6, 10)
+ },
+
+ // PostErrorCode less than source code line count
+ new ErrorData()
+ {
+ AllLines = GetCodeLines(1, 10),
+ ErrorStartLine = 10,
+ ErrorEndLine = 10,
+ ExpectedPreContextLine = 4,
+ ExpectedPreErrorCode = GetCodeLines(4, 9),
+ ExpectedErrorCode = GetCodeLines(10, 10),
+ ExpectedPostErrorCode = Enumerable.Empty()
+ },
+ new ErrorData()
+ {
+ AllLines = GetCodeLines(1, 10),
+ ErrorStartLine = 7,
+ ErrorEndLine = 10,
+ ExpectedPreContextLine = 1,
+ ExpectedPreErrorCode = GetCodeLines(1, 6),
+ ExpectedErrorCode = GetCodeLines(7, 10),
+ ExpectedPostErrorCode = Enumerable.Empty()
+ },
+ new ErrorData()
+ {
+ AllLines = GetCodeLines(1, 10),
+ ErrorStartLine = 5,
+ ErrorEndLine = 8,
+ ExpectedPreContextLine = 1,
+ ExpectedPreErrorCode = GetCodeLines(1, 4),
+ ExpectedErrorCode = GetCodeLines(5, 8),
+ ExpectedPostErrorCode = GetCodeLines(9, 10)
+ },
+
+ // Pre and Post error code less than source code line count
+ new ErrorData()
+ {
+ AllLines = GetCodeLines(1, 4),
+ ErrorStartLine = 2,
+ ErrorEndLine = 3,
+ ExpectedPreContextLine = 1,
+ ExpectedPreErrorCode = GetCodeLines(1, 1),
+ ExpectedErrorCode = GetCodeLines(2, 3),
+ ExpectedPostErrorCode = GetCodeLines(4, 4)
+ },
+ new ErrorData()
+ {
+ AllLines = GetCodeLines(1, 4),
+ ErrorStartLine = 1,
+ ErrorEndLine = 4,
+ ExpectedPreContextLine = 1,
+ ExpectedPreErrorCode = Enumerable.Empty(),
+ ExpectedErrorCode = GetCodeLines(1, 4),
+ ExpectedPostErrorCode = Enumerable.Empty()
+ },
+
+ // change source code line count
+ new ErrorData()
+ {
+ SourceCodeLineCount = 1,
+ AllLines = GetCodeLines(1, 1),
+ ErrorStartLine = 1,
+ ErrorEndLine = 1,
+ ExpectedPreContextLine = 1,
+ ExpectedPreErrorCode = Enumerable.Empty(),
+ ExpectedErrorCode = GetCodeLines(1, 1),
+ ExpectedPostErrorCode = Enumerable.Empty()
+ },
+ };
+ }
+ }
+
+ [Theory]
+ [MemberData(nameof(DisplaysSourceCodeLines_PreAndPostErrorLineData))]
+ public void DisplaysSourceCodeLines_PreAndPostErrorLine(ErrorData errorData)
+ {
+ // Arrange
+ var stackFrame = new StackFrameSourceCodeInfo();
+
+ // Act
+ var exceptionDetailProvider = new ExceptionDetailsProvider(
+ new PhysicalFileProvider(Directory.GetCurrentDirectory()),
+ sourceCodeLineCount: 6);
+
+ exceptionDetailProvider.ReadFrameContent(
+ stackFrame,
+ errorData.AllLines,
+ errorData.ErrorStartLine,
+ errorData.ErrorEndLine);
+
+ // Assert
+ Assert.Equal(errorData.ExpectedPreContextLine, stackFrame.PreContextLine);
+ Assert.Equal(errorData.ExpectedPreErrorCode, stackFrame.PreContextCode);
+ Assert.Equal(errorData.ExpectedErrorCode, stackFrame.ContextCode);
+ Assert.Equal(errorData.ExpectedPostErrorCode, stackFrame.PostContextCode);
+ }
+
+ private static IEnumerable GetCodeLines(int fromLine, int toLine)
+ {
+ var start = fromLine;
+ var count = toLine - fromLine + 1;
+ return Enumerable.Range(start, count).Select(i => string.Format("Line{0}", i));
+ }
+
+ private class TestFileProvider : IFileProvider
+ {
+ private readonly IEnumerable _sourceCodeLines;
+
+ public TestFileProvider(IEnumerable sourceCodeLines)
+ {
+ _sourceCodeLines = sourceCodeLines;
+ }
+
+ public IDirectoryContents GetDirectoryContents(string subpath)
+ {
+ throw new NotImplementedException();
+ }
+
+ public IFileInfo GetFileInfo(string subpath)
+ {
+ return new TestFileInfo(_sourceCodeLines);
+ }
+
+ public IChangeToken Watch(string filter)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ private class TestFileInfo : IFileInfo
+ {
+ private readonly MemoryStream _stream;
+
+ public TestFileInfo(IEnumerable sourceCodeLines)
+ {
+ _stream = new MemoryStream();
+ using (var writer = new StreamWriter(_stream, Encoding.UTF8, 1024, leaveOpen: true))
+ {
+ foreach (var line in sourceCodeLines)
+ {
+ writer.WriteLine(line);
+ }
+ }
+ _stream.Seek(0, SeekOrigin.Begin);
+ }
+
+ public bool Exists
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ public bool IsDirectory
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public DateTimeOffset LastModified
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public long Length
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public string Name
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public string PhysicalPath
+ {
+ get
+ {
+ return null;
+ }
+ }
+
+ public Stream CreateReadStream()
+ {
+ return _stream;
+ }
+ }
+
+ public class ErrorData
+ {
+ public int SourceCodeLineCount { get; set; } = 6;
+ public IEnumerable AllLines { get; set; }
+ public int ErrorStartLine { get; set; }
+ public int ErrorEndLine { get; set; }
+ public int ExpectedPreContextLine { get; set; }
+ public IEnumerable ExpectedPreErrorCode { get; set; }
+ public IEnumerable ExpectedErrorCode { get; set; }
+ public IEnumerable ExpectedPostErrorCode { get; set; }
+ }
+ }
+}
diff --git a/test/Microsoft.AspNetCore.Diagnostics.Tests/StackTraceTest.cs b/test/Microsoft.AspNetCore.Diagnostics.Tests/StackTraceTest.cs
new file mode 100644
index 0000000000..5ab8041347
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Diagnostics.Tests/StackTraceTest.cs
@@ -0,0 +1,159 @@
+// 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;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Globalization;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
+using System.Threading.Tasks;
+using ClassLibraryWithPortablePdbs;
+using Microsoft.Extensions.StackTrace.Sources;
+using Xunit;
+
+namespace Microsoft.Extensions.Internal.Test
+{
+ public class StackTraceTest
+ {
+ public static TheoryData CanGetStackTraceData => new TheoryData
+ {
+ {
+ ThrowsException,
+ $"{typeof(StackTraceTest).GetTypeInfo().FullName}.{nameof(ThrowsException)}()"
+ },
+ {
+ new ExceptionType().MethodThatThrows,
+ $"{typeof(ExceptionType).GetTypeInfo().FullName}.{nameof(ExceptionType.MethodThatThrows)}()"
+ },
+ {
+ ExceptionType.StaticMethodThatThrows,
+ $"{typeof(ExceptionType).GetTypeInfo().FullName}.{nameof(ExceptionType.StaticMethodThatThrows)}()"
+ }
+ };
+
+ [Theory]
+ [MemberData(nameof(CanGetStackTraceData))]
+ public void GetFrames_CanGetStackTrace(Action action, string expectedDisplay)
+ {
+ try
+ {
+ action();
+ }
+ catch (Exception exception)
+ {
+ // Arrange and Act
+ var frames = StackTraceHelper.GetFrames(exception);
+
+ // Assert
+ Assert.Equal(expectedDisplay, frames.First().MethodDisplayInfo.ToString());
+ Assert.Equal(
+ $"{typeof(StackTraceTest).GetTypeInfo().FullName}.{nameof(GetFrames_CanGetStackTrace)}" +
+ "(Action action, string expectedDisplay)",
+ frames.Last().MethodDisplayInfo.ToString());
+ }
+ }
+
+ [Fact]
+ public void GetFrames_DoesNotFailForDynamicallyGeneratedAssemblies()
+ {
+ // Arrange
+ var action = (Action)Expression.Lambda(
+ Expression.Throw(
+ Expression.New(typeof(Exception)))).Compile();
+
+ // Act
+ try
+ {
+ action();
+ }
+ catch (Exception exception)
+ {
+ var frames = StackTraceHelper.GetFrames(exception);
+
+ // Assert
+ Assert.Null(frames.First().FilePath);
+ Assert.Equal(
+ $"{typeof(StackTraceTest).GetTypeInfo().FullName}.{nameof(GetFrames_DoesNotFailForDynamicallyGeneratedAssemblies)}()",
+ frames.Last().MethodDisplayInfo.ToString());
+ }
+ }
+
+ public static TheoryData GetMethodDisplayString_ReturnsTypeNameQualifiedMethodsData
+ {
+ get
+ {
+ var thisType = typeof(StackTraceTest);
+ var intParse = ((Func)int.Parse).GetMethodInfo();
+ var dateTimeOffsetTryParse = typeof(DateTimeOffset).GetMethods()
+ .First(m => m.Name == nameof(DateTimeOffset.TryParse) && m.GetParameters().Length == 2);
+ var genericTypeMethod = typeof(List).GetMethod(nameof(List.Remove));
+ var genericMethod = thisType.GetMethod(nameof(GenericMethod));
+ var multiGenericMethod = thisType.GetMethod(nameof(MultiParameterGenericMethod));
+ var byRefMethod = thisType.GetMethod(nameof(ByRefMethod));
+ var asyncMethod = thisType.GetMethod(nameof(AsyncMethod));
+ var nullableParam = thisType.GetMethod(nameof(MethodWithNullableParams));
+ var nestedMethod = thisType.GetNestedType(nameof(NestedType), BindingFlags.Public)
+ .GetMethod(nameof(NestedType.NestedMethod));
+ var nestedGenericMethod = thisType.GetNestedType(nameof(NestedType), BindingFlags.Public)
+ .GetMethod(nameof(NestedType.NestedGenericMethod));
+
+ return new TheoryData
+ {
+ { intParse, "int.Parse(string s)" },
+ { dateTimeOffsetTryParse, "System.DateTimeOffset.TryParse(string input, out DateTimeOffset result)" },
+ { genericTypeMethod, "System.Collections.Generic.List.Remove(Process item)" },
+ { genericMethod, $"{thisType}.{nameof(GenericMethod)}(TVal value)" },
+ { multiGenericMethod, $"{thisType}.{nameof(MultiParameterGenericMethod)}(KeyValuePair keyValuePair)" },
+ { byRefMethod, $"{thisType}.{nameof(ByRefMethod)}(int a, CultureInfo b, ref long c)" },
+ { asyncMethod, $"{thisType}.{nameof(AsyncMethod)}(string name)" },
+ { nullableParam, $"{thisType}.{nameof(MethodWithNullableParams)}(Nullable name, string value)" },
+ { nestedMethod, $"{typeof(NestedType)}.{nameof(NestedType.NestedMethod)}(string value)" },
+ { nestedGenericMethod, $"{typeof(NestedType)}.{nameof(NestedType.NestedGenericMethod)}(NestedParameterType a, TKey key)" }
+ };
+ }
+ }
+
+ [Theory]
+ [MemberData(nameof(GetMethodDisplayString_ReturnsTypeNameQualifiedMethodsData))]
+ public void GetMethodDisplayString_ReturnsTypeNameQualifiedMethods(MethodBase method, string expected)
+ {
+ // Act
+ var actual = StackTraceHelper.GetMethodDisplayString(method);
+
+ // Assert
+ Assert.Equal(expected, actual.ToString());
+ }
+
+ public static void ThrowsException()
+ {
+ throw new Exception();
+ }
+
+ public string GenericMethod(TVal value) => value.ToString();
+
+ public void MultiParameterGenericMethod(KeyValuePair keyValuePair)
+ {
+ }
+
+ public decimal ByRefMethod(int a, CultureInfo b, ref long c) => a + c;
+
+ public async Task AsyncMethod(string name) => await Task.FromResult(0);
+
+ public void MethodWithNullableParams(int? name, string value)
+ {
+ }
+
+ public class NestedType
+ {
+ public void NestedMethod(string value) => Console.WriteLine("Hello world");
+
+ public TKey NestedGenericMethod(NestedParameterType a, TKey key) => key;
+ }
+
+ public class NestedParameterType
+ {
+ }
+ }
+}
diff --git a/test/Microsoft.AspNetCore.Diagnostics.Tests/project.json b/test/Microsoft.AspNetCore.Diagnostics.Tests/project.json
index 93643beb31..fafeb2cdfb 100644
--- a/test/Microsoft.AspNetCore.Diagnostics.Tests/project.json
+++ b/test/Microsoft.AspNetCore.Diagnostics.Tests/project.json
@@ -14,7 +14,7 @@
}
},
"dependencies": {
- "System.Runtime.InteropServices.RuntimeInformation": "4.0.0-*",
+ "ClassLibraryWithPortablePdbs": "1.1.0-*",
"dotnet-test-xunit": "2.2.0-*",
"Microsoft.AspNetCore.Diagnostics": "1.1.0-*",
"Microsoft.AspNetCore.Diagnostics.Elm": "0.2.0-*",
@@ -24,6 +24,7 @@
"Microsoft.Extensions.DiagnosticAdapter": "1.1.0-*",
"Microsoft.Extensions.FileProviders.Embedded": "1.1.0-*",
"Moq": "4.6.36-*",
+ "System.Runtime.InteropServices.RuntimeInformation": "4.0.0-*",
"xunit": "2.2.0-*"
},
"frameworks": {
diff --git a/tools/PageGenerator/Program.cs b/tools/PageGenerator/Program.cs
deleted file mode 100644
index b98d1d24fa..0000000000
--- a/tools/PageGenerator/Program.cs
+++ /dev/null
@@ -1,130 +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 System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using Microsoft.AspNetCore.Razor;
-using Microsoft.AspNetCore.Razor.CodeGenerators;
-
-namespace PageGenerator
-{
- public class Program
- {
- private const int NumArgs = 1;
-
- public static void Main(string[] args)
- {
- if (args.Length != NumArgs)
- {
- throw new ArgumentException(string.Format("Requires {0} argument (Project Directory), {1} given", NumArgs, args.Length));
- }
- var diagnosticsDir = args[0];
-
- var viewDirectories = Directory.EnumerateDirectories(diagnosticsDir, "Views", SearchOption.AllDirectories);
-
- var fileCount = 0;
- foreach (var viewDir in viewDirectories)
- {
- Console.WriteLine();
- Console.WriteLine(" Generating code files for views in {0}", viewDir);
-
- var cshtmlFiles = Directory.EnumerateFiles(viewDir, "*.cshtml");
-
- if (!cshtmlFiles.Any())
- {
- Console.WriteLine(" No .cshtml files were found.");
- continue;
- }
-
- foreach (var fileName in cshtmlFiles)
- {
- Console.WriteLine(" Generating code file for view {0}...", Path.GetFileName(fileName));
- var rootNamespace = Path.GetDirectoryName(diagnosticsDir);
- GenerateCodeFile(fileName, $"{rootNamespace}.Views");
- Console.WriteLine(" Done!");
- fileCount++;
- }
- }
-
- Console.WriteLine();
- Console.WriteLine("{0} files successfully generated.", fileCount);
- Console.WriteLine();
- }
-
- private static void GenerateCodeFile(string cshtmlFilePath, string rootNamespace)
- {
- var basePath = Path.GetDirectoryName(cshtmlFilePath);
- var fileName = Path.GetFileName(cshtmlFilePath);
- var fileNameNoExtension = Path.GetFileNameWithoutExtension(fileName);
- var codeLang = new CSharpRazorCodeLanguage();
- var host = new RazorEngineHost(codeLang);
- host.DefaultBaseClass = "Microsoft.AspNetCore.DiagnosticsViewPage.Views.BaseView";
- host.GeneratedClassContext = new GeneratedClassContext(
- executeMethodName: GeneratedClassContext.DefaultExecuteMethodName,
- writeMethodName: GeneratedClassContext.DefaultWriteMethodName,
- writeLiteralMethodName: GeneratedClassContext.DefaultWriteLiteralMethodName,
- writeToMethodName: "WriteTo",
- writeLiteralToMethodName: "WriteLiteralTo",
- templateTypeName: "HelperResult",
- defineSectionMethodName: "DefineSection",
- generatedTagHelperContext: new GeneratedTagHelperContext());
- var engine = new RazorTemplateEngine(host);
-
- using (var fileStream = File.OpenText(cshtmlFilePath))
- {
- var code = engine.GenerateCode(
- input: fileStream,
- className: fileNameNoExtension,
- rootNamespace: Path.GetFileName(rootNamespace),
- sourceFileName: fileName);
-
- var source = code.GeneratedCode;
- var startIndex = 0;
- while (startIndex < source.Length)
- {
- var startMatch = @"<%$ include: ";
- var endMatch = @" %>";
- startIndex = source.IndexOf(startMatch, startIndex);
- if (startIndex == -1)
- {
- break;
- }
- var endIndex = source.IndexOf(endMatch, startIndex);
- if (endIndex == -1)
- {
- break;
- }
- var includeFileName = source.Substring(startIndex + startMatch.Length, endIndex - (startIndex + startMatch.Length));
- includeFileName = SanitizeFileName(includeFileName);
- Console.WriteLine(" Inlining file {0}", includeFileName);
- var replacement = File.ReadAllText(Path.Combine(basePath, includeFileName)).Replace("\"", "\\\"").Replace("\n", "\\n").Replace("\r", "\\r");
- source = source.Substring(0, startIndex) + replacement + source.Substring(endIndex + endMatch.Length);
- startIndex = startIndex + replacement.Length;
- }
- File.WriteAllText(Path.Combine(basePath, string.Format("{0}.cs", fileNameNoExtension)), source);
- }
- }
-
- private static string SanitizeFileName(string fileName)
- {
- // The Razor generated code sometimes splits strings across multiple lines
- // which can hit the include file name, so we need to strip out the non-filename chars.
- //ErrorPage.j" +
- //"s
-
- var invalidChars = new List(Path.GetInvalidFileNameChars());
- invalidChars.Add('+');
- invalidChars.Add(' ');
- //These are already in the list on windows, but for other platforms
- //it seems like some of them are missing, so we add them explicitly
- invalidChars.Add('"');
- invalidChars.Add('\'');
- invalidChars.Add('\r');
- invalidChars.Add('\n');
-
- return string.Join(string.Empty, fileName.Where(c => !invalidChars.Contains(c)).ToArray());
- }
- }
-}
diff --git a/tools/PageGenerator/project.json b/tools/PageGenerator/project.json
deleted file mode 100644
index 869bec7862..0000000000
--- a/tools/PageGenerator/project.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "version": "1.1.0-*",
- "description": "Builds the pages for the Diagnostics projects. Runs in build.cmd.",
- "buildOptions": {
- "warningsAsErrors": true,
- "emitEntryPoint": true
- },
- "dependencies": {
- "Microsoft.AspNetCore.Razor": "1.0.0",
- "Microsoft.NETCore.App": {
- "version": "1.0.0",
- "type": "platform"
- }
- },
- "frameworks": {
- "netcoreapp1.0": {}
- }
-}
\ No newline at end of file