diff --git a/src/Microsoft.AspNetCore.Diagnostics.Abstractions/CompilationFailure.cs b/src/Microsoft.AspNetCore.Diagnostics.Abstractions/CompilationFailure.cs index 978d5f8058..4a100e3dc0 100644 --- a/src/Microsoft.AspNetCore.Diagnostics.Abstractions/CompilationFailure.cs +++ b/src/Microsoft.AspNetCore.Diagnostics.Abstractions/CompilationFailure.cs @@ -10,12 +10,44 @@ namespace Microsoft.AspNetCore.Diagnostics /// public class CompilationFailure { - public CompilationFailure(string sourceFilePath, string sourceFileContent, string compiledContent, IEnumerable messages) + /// + /// Initializes a new instance of . + /// + /// Path for the file that produced the compilation failure. + /// Contents of the file being compiled. + /// For templated languages (such as Asp.Net Core Razor), the generated content. + /// + /// One or or more instances. + public CompilationFailure( + string sourceFilePath, + string sourceFileContent, + string compiledContent, + IEnumerable messages) + : this(sourceFilePath, sourceFileContent, compiledContent, messages, failureSummary: null) + { + } + + /// + /// Initializes a new instance of . + /// + /// Path for the file that produced the compilation failure. + /// Contents of the file being compiled. + /// For templated languages (such as Asp.Net Core Razor), the generated content. + /// + /// One or or more instances. + /// Summary message or instructions to fix the failure. + public CompilationFailure( + string sourceFilePath, + string sourceFileContent, + string compiledContent, + IEnumerable messages, + string failureSummary) { SourceFilePath = sourceFilePath; SourceFileContent = sourceFileContent; CompiledContent = compiledContent; Messages = messages; + FailureSummary = failureSummary; } /// @@ -42,5 +74,10 @@ namespace Microsoft.AspNetCore.Diagnostics /// Gets a sequence of produced as a result of compilation. /// public IEnumerable Messages { get; } + + /// + /// Summary message or instructions to fix the failure. + /// + public string FailureSummary { get; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs index 0bbc1ce499..d6a3f9f542 100644 --- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs +++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs @@ -131,7 +131,8 @@ namespace Microsoft.AspNetCore.Diagnostics var stackFrames = new List(); var errorDetails = new ErrorDetails { - StackFrames = stackFrames + StackFrames = stackFrames, + ErrorMessage = compilationFailure.FailureSummary, }; var fileContent = compilationFailure .SourceFileContent diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.cs b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.cs index 4b5033ea4f..3cecefb7c4 100644 --- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.cs +++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.cs @@ -63,7 +63,7 @@ using Microsoft.AspNetCore.Diagnostics #line default #line hidden - WriteLiteral("\r\n \r\n \r\n \r\n

"); + WriteLiteral("\r\n \r\n \r\n \r\n

"); #line 25 "CompilationErrorPage.cshtml" Write(Resources.ErrorPageHtml_CompilationException); @@ -120,14 +120,35 @@ using Microsoft.AspNetCore.Diagnostics #line default #line hidden - WriteLiteral("
\r\n
    \r\n"); + WriteLiteral(" "); +#line 37 "CompilationErrorPage.cshtml" + if (!string.IsNullOrEmpty(errorDetail.ErrorMessage)) + { + +#line default +#line hidden + + WriteLiteral("
    "); #line 39 "CompilationErrorPage.cshtml" + Write(errorDetail.ErrorMessage); + +#line default +#line hidden + WriteLiteral("
    \r\n"); +#line 40 "CompilationErrorPage.cshtml" + } + +#line default +#line hidden + + WriteLiteral("
    \r\n
      \r\n"); +#line 43 "CompilationErrorPage.cshtml" #line default #line hidden -#line 39 "CompilationErrorPage.cshtml" +#line 43 "CompilationErrorPage.cshtml" foreach (var frame in errorDetail.StackFrames) { @@ -135,28 +156,28 @@ using Microsoft.AspNetCore.Diagnostics #line hidden WriteLiteral("
    • "); -#line 56 "CompilationErrorPage.cshtml" +#line 60 "CompilationErrorPage.cshtml" Write(line); #line default #line hidden WriteLiteral("
    • \r\n"); -#line 57 "CompilationErrorPage.cshtml" +#line 61 "CompilationErrorPage.cshtml" } #line default #line hidden WriteLiteral(" \r\n"); -#line 59 "CompilationErrorPage.cshtml" +#line 63 "CompilationErrorPage.cshtml" } #line default #line hidden WriteLiteral("
    \r\n
    \r\n \r\n"); -#line 82 "CompilationErrorPage.cshtml" +#line 86 "CompilationErrorPage.cshtml" } #line default diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.cshtml b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.cshtml index 99eca89e66..2e23e428d3 100644 --- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.cshtml +++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.cshtml @@ -1,4 +1,4 @@ -@using System +@using System @using System.Globalization @using System.Linq @using System.Net @@ -34,6 +34,10 @@
    @fileName
    } } + @if (!string.IsNullOrEmpty(errorDetail.ErrorMessage)) + { +
    @errorDetail.ErrorMessage
    + }
      @foreach (var frame in errorDetail.StackFrames) diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorDetails.cs b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorDetails.cs index 983669c689..7337108cc0 100644 --- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorDetails.cs +++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorDetails.cs @@ -20,5 +20,10 @@ namespace Microsoft.AspNetCore.Diagnostics.Views /// The generated stack frames /// public IEnumerable StackFrames { get; set; } + + /// + /// Gets or sets the summary message. + /// + public string ErrorMessage { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.cs b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.cs index 09060ca945..6f4a0cec2a 100644 --- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.cs +++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.cs @@ -82,7 +82,7 @@ WriteAttributeValue("", 512, CultureInfo.CurrentUICulture.TwoLetterISOLanguageNa #line default #line hidden - WriteLiteral("\r\n \r\n \r\n \r\n

      "); + WriteLiteral("\r\n \r\n \r\n \r\n

      "); #line 31 "ErrorPage.cshtml" Write(Resources.ErrorPageHtml_UnhandledException); diff --git a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.css b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.css index f8b84738e4..a241df72d2 100644 --- a/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.css +++ b/src/Microsoft.AspNetCore.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.css @@ -29,7 +29,7 @@ code { } body .titleerror { - padding: 3px; + padding: 3px 3px 6px 3px; display: block; font-size: 1.5em; font-weight: 100; @@ -72,6 +72,12 @@ body .location { /*border-bottom: 1px #ddd solid;*/ } +#stackpage details { + font-size: 1.2em; + padding: 3px; + color: #000; +} + #stackpage .stackerror { padding: 5px; border-bottom: 1px #ddd solid;