From 398222d6e6b5cfcfa9935dc292ff9fc440182649 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 25 Oct 2016 18:27:54 -0700 Subject: [PATCH] Show full generated output option for Razor compilation errors Fixes #303 --- .../DeveloperExceptionPageMiddleware.cs | 1 + .../Views/CompilationErrorModel.cs | 5 + .../Views/CompilationErrorPage.Designer.cs | 182 ++++++++++++------ .../Views/CompilationErrorPage.cshtml | 20 +- 4 files changed, 143 insertions(+), 65 deletions(-) diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs index 8296174a7b..d05f0cc182 100644 --- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs +++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs @@ -154,6 +154,7 @@ namespace Microsoft.AspNetCore.Diagnostics } model.ErrorDetails.Add(exceptionDetails); + model.CompiledContent.Add(compilationFailure.CompiledContent); } var errorPage = new CompilationErrorPage diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorModel.cs b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorModel.cs index 195b303d11..f84bb4f19d 100644 --- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorModel.cs +++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorModel.cs @@ -21,5 +21,10 @@ namespace Microsoft.AspNetCore.Diagnostics.RazorViews /// Detailed information about each parse or compilation error. /// public IList ErrorDetails { get; } = new List(); + + /// + /// Gets the generated content that produced the corresponding . + /// + public IList CompiledContent { 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 index da6c949507..01bf824655 100644 --- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.Designer.cs +++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.Designer.cs @@ -288,20 +288,32 @@ a { #line hidden #line 223 "CompilationErrorPage.cshtml" - foreach (var errorDetail in Model.ErrorDetails) + + var exceptionDetailId = ""; + + +#line default +#line hidden + + WriteLiteral(" "); +#line 226 "CompilationErrorPage.cshtml" + for (var i = 0; i < Model.ErrorDetails.Count; i++) { + var errorDetail = Model.ErrorDetails[i]; + exceptionDetailId = "exceptionDetail" + i; + #line default #line hidden WriteLiteral("
\r\n"); -#line 226 "CompilationErrorPage.cshtml" +#line 232 "CompilationErrorPage.cshtml" #line default #line hidden -#line 226 "CompilationErrorPage.cshtml" +#line 232 "CompilationErrorPage.cshtml" var stackFrameCount = 0; var frameId = ""; @@ -311,7 +323,7 @@ a { #line hidden WriteLiteral(" "); -#line 230 "CompilationErrorPage.cshtml" +#line 236 "CompilationErrorPage.cshtml" var fileName = errorDetail.StackFrames.FirstOrDefault()?.File; if (!string.IsNullOrEmpty(fileName)) @@ -321,13 +333,13 @@ a { #line hidden WriteLiteral("
"); -#line 234 "CompilationErrorPage.cshtml" +#line 240 "CompilationErrorPage.cshtml" Write(fileName); #line default #line hidden WriteLiteral("
\r\n"); -#line 235 "CompilationErrorPage.cshtml" +#line 241 "CompilationErrorPage.cshtml" } @@ -335,7 +347,7 @@ a { #line hidden WriteLiteral(" "); -#line 237 "CompilationErrorPage.cshtml" +#line 243 "CompilationErrorPage.cshtml" if (!string.IsNullOrEmpty(errorDetail.ErrorMessage)) { @@ -343,26 +355,26 @@ a { #line hidden WriteLiteral("
"); -#line 239 "CompilationErrorPage.cshtml" +#line 245 "CompilationErrorPage.cshtml" Write(errorDetail.ErrorMessage); #line default #line hidden WriteLiteral("
\r\n"); -#line 240 "CompilationErrorPage.cshtml" +#line 246 "CompilationErrorPage.cshtml" } #line default #line hidden WriteLiteral("
\r\n
    \r\n"); -#line 243 "CompilationErrorPage.cshtml" +#line 249 "CompilationErrorPage.cshtml" #line default #line hidden -#line 243 "CompilationErrorPage.cshtml" +#line 249 "CompilationErrorPage.cshtml" foreach (var frame in errorDetail.StackFrames) { @@ -370,7 +382,7 @@ a { #line default #line hidden -#line 245 "CompilationErrorPage.cshtml" +#line 251 "CompilationErrorPage.cshtml" stackFrameCount++; frameId = "frame" + stackFrameCount; @@ -379,28 +391,28 @@ a { #line default #line hidden -#line 248 "CompilationErrorPage.cshtml" +#line 254 "CompilationErrorPage.cshtml" #line default #line hidden WriteLiteral("
  • "); -#line 264 "CompilationErrorPage.cshtml" +#line 270 "CompilationErrorPage.cshtml" Write(line); #line default #line hidden WriteLiteral("
  • \r\n"); -#line 265 "CompilationErrorPage.cshtml" +#line 271 "CompilationErrorPage.cshtml" } #line default #line hidden WriteLiteral(" \r\n"); -#line 267 "CompilationErrorPage.cshtml" +#line 273 "CompilationErrorPage.cshtml" } #line default #line hidden WriteLiteral("
\r\n"); -#line 284 "CompilationErrorPage.cshtml" +#line 290 "CompilationErrorPage.cshtml" } #line default #line hidden WriteLiteral(" \r\n"); -#line 286 "CompilationErrorPage.cshtml" +#line 292 "CompilationErrorPage.cshtml" } #line default #line hidden WriteLiteral(" \r\n
\r\n \r\n"); -#line 290 "CompilationErrorPage.cshtml" +#line 296 "CompilationErrorPage.cshtml" + + +#line default +#line hidden + +#line 296 "CompilationErrorPage.cshtml" + if (!string.IsNullOrEmpty(Model.CompiledContent[i])) + { + +#line default +#line hidden + + WriteLiteral("
\r\n
\r\n \r\n
\r\n
\r\n \r\n"); +#line 306 "CompilationErrorPage.cshtml" + } + +#line default +#line hidden + +#line 306 "CompilationErrorPage.cshtml" + } #line default #line hidden - WriteLiteral(@"