From d2dfae108ab69803a0825e543aaffff0e98ddd5f Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 2 Apr 2015 12:10:52 -0700 Subject: [PATCH] * Remove ICompilation* interfaces from Diagnostics * Removing error message from CompilationErrorPage since it repeats individual errors. Fixes #111 --- .../Compilation/ICompilationException.cs | 18 -- .../Compilation/ICompilationFailure.cs | 38 ----- .../Compilation/ICompilationMessage.cs | 37 ----- .../ErrorPageMiddleware.cs | 1 + .../Views/CompilationErrorPage.cs | 156 +++++++++--------- .../Views/CompilationErrorPage.cshtml | 13 +- 6 files changed, 91 insertions(+), 172 deletions(-) delete mode 100644 src/Microsoft.AspNet.Diagnostics.Interfaces/Compilation/ICompilationException.cs delete mode 100644 src/Microsoft.AspNet.Diagnostics.Interfaces/Compilation/ICompilationFailure.cs delete mode 100644 src/Microsoft.AspNet.Diagnostics.Interfaces/Compilation/ICompilationMessage.cs diff --git a/src/Microsoft.AspNet.Diagnostics.Interfaces/Compilation/ICompilationException.cs b/src/Microsoft.AspNet.Diagnostics.Interfaces/Compilation/ICompilationException.cs deleted file mode 100644 index 31e9a01347..0000000000 --- a/src/Microsoft.AspNet.Diagnostics.Interfaces/Compilation/ICompilationException.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Collections.Generic; - -namespace Microsoft.AspNet.Diagnostics -{ - /// - /// Specifies the contract for an exception representing compilation failure. - /// - public interface ICompilationException - { - /// - /// Gets a sequence of with compilation failures. - /// - IEnumerable CompilationFailures { get; } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Diagnostics.Interfaces/Compilation/ICompilationFailure.cs b/src/Microsoft.AspNet.Diagnostics.Interfaces/Compilation/ICompilationFailure.cs deleted file mode 100644 index ede7bcd270..0000000000 --- a/src/Microsoft.AspNet.Diagnostics.Interfaces/Compilation/ICompilationFailure.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Collections.Generic; - -namespace Microsoft.AspNet.Diagnostics -{ - /// - /// Specifies the contract for a file that fails compilation. - /// - public interface ICompilationFailure - { - /// - /// Path of the file that produced the compilation exception. - /// - string SourceFilePath { get; } - - /// - /// Contents of the file. - /// - string SourceFileContent { get; } - - /// - /// Contents being compiled. - /// - /// - /// For templated files, the represents the original content and - /// represents the transformed content. This property can be null if - /// the exception is encountered during transformation. - /// - string CompiledContent { get; } - - /// - /// Gets a sequence of produced as a result of compilation. - /// - IEnumerable Messages { get; } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Diagnostics.Interfaces/Compilation/ICompilationMessage.cs b/src/Microsoft.AspNet.Diagnostics.Interfaces/Compilation/ICompilationMessage.cs deleted file mode 100644 index 237dcd2332..0000000000 --- a/src/Microsoft.AspNet.Diagnostics.Interfaces/Compilation/ICompilationMessage.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -namespace Microsoft.AspNet.Diagnostics -{ - /// - /// Specifies the contract for diagnostic messages produced as result of compiling an instance - /// of . - /// - public interface ICompilationMessage - { - /// - /// Gets the error message. - /// - string Message { get; } - - /// - /// Gets the zero-based line index for the start of the compilation error. - /// - int StartLine { get; } - - /// - /// Gets the zero-based column index for the start of the compilation error. - /// - int StartColumn { get; } - - /// - /// Gets the zero-based line index for the end of the compilation error. - /// - int EndLine { get; } - - /// - /// Gets the zero-based column index for the end of the compilation error. - /// - int EndColumn { get; } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Diagnostics/ErrorPageMiddleware.cs b/src/Microsoft.AspNet.Diagnostics/ErrorPageMiddleware.cs index aa8851bcc0..fccbf7b42c 100644 --- a/src/Microsoft.AspNet.Diagnostics/ErrorPageMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics/ErrorPageMiddleware.cs @@ -12,6 +12,7 @@ using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Diagnostics.Views; using Microsoft.AspNet.Http; +using Microsoft.Framework.Runtime; namespace Microsoft.AspNet.Diagnostics { diff --git a/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cs b/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cs index 6649e04287..4211cd3fc6 100644 --- a/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cs +++ b/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cs @@ -81,49 +81,27 @@ using Views #line hidden #line 28 "CompilationErrorPage.cshtml" - if (Model.Options.ShowExceptionDetails) - { - -#line default -#line hidden - - WriteLiteral("
"); -#line 30 "CompilationErrorPage.cshtml" - Write(errorDetail.Error.GetType().Name); - -#line default -#line hidden - WriteLiteral(": "); -#line 30 "CompilationErrorPage.cshtml" - Output.Write(HtmlEncodeAndReplaceLineBreaks(errorDetail.Error.Message)); - -#line default -#line hidden - - WriteLiteral("
\r\n"); -#line 31 "CompilationErrorPage.cshtml" - } - else + if (!Model.Options.ShowExceptionDetails) { #line default #line hidden WriteLiteral("

"); -#line 34 "CompilationErrorPage.cshtml" +#line 30 "CompilationErrorPage.cshtml" Write(Resources.ErrorPageHtml_EnableShowExceptions); #line default #line hidden WriteLiteral("

\r\n"); -#line 35 "CompilationErrorPage.cshtml" +#line 31 "CompilationErrorPage.cshtml" } #line default #line hidden WriteLiteral(" "); -#line 36 "CompilationErrorPage.cshtml" +#line 32 "CompilationErrorPage.cshtml" if (Model.Options.ShowExceptionDetails) { @@ -131,26 +109,56 @@ using Views #line hidden WriteLiteral("
\r\n"); -#line 39 "CompilationErrorPage.cshtml" +#line 35 "CompilationErrorPage.cshtml" #line default #line hidden -#line 39 "CompilationErrorPage.cshtml" +#line 35 "CompilationErrorPage.cshtml" int tabIndex = 6; #line default #line hidden - WriteLiteral("\r\n
\r\n
    \r\n"); -#line 42 "CompilationErrorPage.cshtml" + WriteLiteral("\r\n"); +#line 36 "CompilationErrorPage.cshtml" #line default #line hidden -#line 42 "CompilationErrorPage.cshtml" +#line 36 "CompilationErrorPage.cshtml" + + var fileName = errorDetail.StackFrames.FirstOrDefault()?.File; + if (!string.IsNullOrEmpty(fileName)) + { + +#line default +#line hidden + + WriteLiteral("
    "); +#line 40 "CompilationErrorPage.cshtml" + Write(fileName); + +#line default +#line hidden + WriteLiteral("
    \r\n"); +#line 41 "CompilationErrorPage.cshtml" + } + + +#line default +#line hidden + + WriteLiteral("\r\n
    \r\n
      \r\n"); +#line 45 "CompilationErrorPage.cshtml" + + +#line default +#line hidden + +#line 45 "CompilationErrorPage.cshtml" foreach (var frame in errorDetail.StackFrames) { @@ -158,29 +166,29 @@ using Views #line hidden WriteLiteral("
    • (tabIndex, 1319), false)); + WriteAttribute("tabindex", Tuple.Create(" tabindex=\"", 1409), Tuple.Create("\"", 1429), + Tuple.Create(Tuple.Create("", 1420), Tuple.Create(tabIndex, 1420), false)); WriteLiteral(">\r\n"); -#line 45 "CompilationErrorPage.cshtml" +#line 48 "CompilationErrorPage.cshtml" #line default #line hidden -#line 45 "CompilationErrorPage.cshtml" +#line 48 "CompilationErrorPage.cshtml" tabIndex++; #line default #line hidden WriteLiteral("\r\n"); -#line 46 "CompilationErrorPage.cshtml" +#line 49 "CompilationErrorPage.cshtml" #line default #line hidden -#line 46 "CompilationErrorPage.cshtml" +#line 49 "CompilationErrorPage.cshtml" if (!string.IsNullOrEmpty(frame.ErrorDetails)) { @@ -188,13 +196,13 @@ using Views #line hidden WriteLiteral("

      "); -#line 48 "CompilationErrorPage.cshtml" +#line 51 "CompilationErrorPage.cshtml" Write(frame.ErrorDetails); #line default #line hidden WriteLiteral("

      \r\n"); -#line 49 "CompilationErrorPage.cshtml" +#line 52 "CompilationErrorPage.cshtml" } else { @@ -205,13 +213,13 @@ using Views #line hidden WriteLiteral("

      "); -#line 54 "CompilationErrorPage.cshtml" +#line 57 "CompilationErrorPage.cshtml" Write(frame.Function); #line default #line hidden WriteLiteral("

      \r\n"); -#line 55 "CompilationErrorPage.cshtml" +#line 58 "CompilationErrorPage.cshtml" } else { @@ -220,22 +228,22 @@ using Views #line hidden WriteLiteral("

      "); -#line 58 "CompilationErrorPage.cshtml" +#line 61 "CompilationErrorPage.cshtml" Write(frame.Function); #line default #line hidden WriteLiteral(" in (frame.File, 1936), false)); + WriteAttribute("title", Tuple.Create(" title=\"", 2029), Tuple.Create("\"", 2048), + Tuple.Create(Tuple.Create("", 2037), Tuple.Create(frame.File, 2037), false)); WriteLiteral(">"); -#line 58 "CompilationErrorPage.cshtml" +#line 61 "CompilationErrorPage.cshtml" Write(System.IO.Path.GetFileName(frame.File)); #line default #line hidden WriteLiteral("

      \r\n"); -#line 59 "CompilationErrorPage.cshtml" +#line 62 "CompilationErrorPage.cshtml" } } @@ -243,7 +251,7 @@ using Views #line hidden WriteLiteral(" "); -#line 61 "CompilationErrorPage.cshtml" +#line 64 "CompilationErrorPage.cshtml" if (frame.Line != 0 && frame.ContextCode.Any()) { @@ -251,13 +259,13 @@ using Views #line hidden WriteLiteral("
      \r\n"); -#line 64 "CompilationErrorPage.cshtml" +#line 67 "CompilationErrorPage.cshtml" #line default #line hidden -#line 64 "CompilationErrorPage.cshtml" +#line 67 "CompilationErrorPage.cshtml" if (frame.PreContextCode != null) { @@ -265,16 +273,16 @@ using Views #line hidden WriteLiteral(" (frame.PreContextLine, 2361), false)); + WriteAttribute("start", Tuple.Create(" start=\"", 2454), Tuple.Create("\"", 2483), + Tuple.Create(Tuple.Create("", 2462), Tuple.Create(frame.PreContextLine, 2462), false)); WriteLiteral(" class=\"collapsible\">\r\n"); -#line 67 "CompilationErrorPage.cshtml" +#line 70 "CompilationErrorPage.cshtml" #line default #line hidden -#line 67 "CompilationErrorPage.cshtml" +#line 70 "CompilationErrorPage.cshtml" foreach (var line in frame.PreContextCode) { @@ -282,36 +290,36 @@ using Views #line hidden WriteLiteral("
    • "); -#line 69 "CompilationErrorPage.cshtml" +#line 72 "CompilationErrorPage.cshtml" Write(line); #line default #line hidden WriteLiteral("
    • \r\n"); -#line 70 "CompilationErrorPage.cshtml" +#line 73 "CompilationErrorPage.cshtml" } #line default #line hidden WriteLiteral(" \r\n"); -#line 72 "CompilationErrorPage.cshtml" +#line 75 "CompilationErrorPage.cshtml" } #line default #line hidden WriteLiteral(" (frame.Line, 2771), false)); + WriteAttribute("start", Tuple.Create(" start=\"", 2864), Tuple.Create("\"", 2883), + Tuple.Create(Tuple.Create("", 2872), Tuple.Create(frame.Line, 2872), false)); WriteLiteral(" class=\"highlight\">\r\n"); -#line 74 "CompilationErrorPage.cshtml" +#line 77 "CompilationErrorPage.cshtml" #line default #line hidden -#line 74 "CompilationErrorPage.cshtml" +#line 77 "CompilationErrorPage.cshtml" foreach (var line in frame.ContextCode) { @@ -319,26 +327,26 @@ using Views #line hidden WriteLiteral("
    • "); -#line 76 "CompilationErrorPage.cshtml" +#line 79 "CompilationErrorPage.cshtml" Write(line); #line default #line hidden WriteLiteral("
    • \r\n"); -#line 77 "CompilationErrorPage.cshtml" +#line 80 "CompilationErrorPage.cshtml" } #line default #line hidden WriteLiteral(" \r\n"); -#line 79 "CompilationErrorPage.cshtml" +#line 82 "CompilationErrorPage.cshtml" #line default #line hidden -#line 79 "CompilationErrorPage.cshtml" +#line 82 "CompilationErrorPage.cshtml" if (frame.PostContextCode != null) { @@ -346,16 +354,16 @@ using Views #line hidden WriteLiteral(" (frame.Line + 1, 3219), false)); + WriteAttribute("start", Tuple.Create(" start=\'", 3312), Tuple.Create("\'", 3337), + Tuple.Create(Tuple.Create("", 3320), Tuple.Create(frame.Line + 1, 3320), false)); WriteLiteral(" class=\"collapsible\">\r\n"); -#line 82 "CompilationErrorPage.cshtml" +#line 85 "CompilationErrorPage.cshtml" #line default #line hidden -#line 82 "CompilationErrorPage.cshtml" +#line 85 "CompilationErrorPage.cshtml" foreach (var line in frame.PostContextCode) { @@ -363,41 +371,41 @@ using Views #line hidden WriteLiteral("
    • "); -#line 84 "CompilationErrorPage.cshtml" +#line 87 "CompilationErrorPage.cshtml" Write(line); #line default #line hidden WriteLiteral("
    • \r\n"); -#line 85 "CompilationErrorPage.cshtml" +#line 88 "CompilationErrorPage.cshtml" } #line default #line hidden WriteLiteral(" \r\n"); -#line 87 "CompilationErrorPage.cshtml" +#line 90 "CompilationErrorPage.cshtml" } #line default #line hidden WriteLiteral("
\r\n"); -#line 89 "CompilationErrorPage.cshtml" +#line 92 "CompilationErrorPage.cshtml" } #line default #line hidden WriteLiteral(" \r\n"); -#line 91 "CompilationErrorPage.cshtml" +#line 94 "CompilationErrorPage.cshtml" } #line default #line hidden WriteLiteral(" \r\n \r\n"); -#line 94 "CompilationErrorPage.cshtml" +#line 97 "CompilationErrorPage.cshtml" } #line default diff --git a/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cshtml b/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cshtml index 619778b097..b07612f535 100644 --- a/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cshtml +++ b/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cshtml @@ -25,11 +25,7 @@

@Resources.ErrorPageHtml_CompilationException

- @if (Model.Options.ShowExceptionDetails) - { -
@errorDetail.Error.GetType().Name: @{ Output.Write(HtmlEncodeAndReplaceLineBreaks(errorDetail.Error.Message)); }
- } - else + @if (!Model.Options.ShowExceptionDetails) {

@Resources.ErrorPageHtml_EnableShowExceptions

} @@ -37,6 +33,13 @@ {
@{ int tabIndex = 6; } + @{ + var fileName = errorDetail.StackFrames.FirstOrDefault()?.File; + if (!string.IsNullOrEmpty(fileName)) + { +
@fileName
+ } + }
    @foreach (var frame in errorDetail.StackFrames)