From cb6639c818046e089cae4ef6834bcc0afd371e1c Mon Sep 17 00:00:00 2001 From: Suhas Joshi Date: Mon, 8 Dec 2014 15:24:28 -0800 Subject: [PATCH 01/18] Updating to dev NuGet.config --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index 2d3b0cb857..f41e9c631d 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@  - + From 71a4c1859829af6be652536ad26a21eadea67dd2 Mon Sep 17 00:00:00 2001 From: SonjaKhan Date: Mon, 1 Dec 2014 14:09:06 -0800 Subject: [PATCH 02/18] Collapsed Logs --- .../ErrorHandlerSample.kproj | 5 +- .../RuntimeInfoPageSample.kproj | 5 +- .../ElmPageMiddleware.cs | 1 - .../Views/LogPage.cs | 321 +++++++++++++----- .../Views/LogPage.cshtml | 66 +++- .../Views/LogPage.css | 18 +- 6 files changed, 309 insertions(+), 107 deletions(-) diff --git a/samples/ErrorHandlerSample/ErrorHandlerSample.kproj b/samples/ErrorHandlerSample/ErrorHandlerSample.kproj index 883977b1ee..cfdbec9b85 100644 --- a/samples/ErrorHandlerSample/ErrorHandlerSample.kproj +++ b/samples/ErrorHandlerSample/ErrorHandlerSample.kproj @@ -1,4 +1,4 @@ - + 14.0 @@ -12,6 +12,7 @@ 2.0 + 62671 - + \ No newline at end of file diff --git a/samples/RuntimeInfoPageSample/RuntimeInfoPageSample.kproj b/samples/RuntimeInfoPageSample/RuntimeInfoPageSample.kproj index 922df5d4c2..8c1b79c499 100644 --- a/samples/RuntimeInfoPageSample/RuntimeInfoPageSample.kproj +++ b/samples/RuntimeInfoPageSample/RuntimeInfoPageSample.kproj @@ -1,4 +1,4 @@ - + 14.0 @@ -12,6 +12,7 @@ 2.0 + 62670 - + \ No newline at end of file diff --git a/src/Microsoft.AspNet.Diagnostics.Elm/ElmPageMiddleware.cs b/src/Microsoft.AspNet.Diagnostics.Elm/ElmPageMiddleware.cs index 020f7193e7..9cf5614540 100644 --- a/src/Microsoft.AspNet.Diagnostics.Elm/ElmPageMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics.Elm/ElmPageMiddleware.cs @@ -57,7 +57,6 @@ namespace Microsoft.AspNet.Diagnostics.Elm { var model = new LogPageModel() { - // sort so most recent logs are first Activities = _store.GetActivities(), Options = options, Path = _options.Path diff --git a/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cs b/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cs index 3433f135dd..b38a5f79e3 100644 --- a/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cs +++ b/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cs @@ -7,36 +7,42 @@ using System #line hidden ; #line 2 "LogPage.cshtml" -using System.Globalization +using System.Collections.Generic #line default #line hidden ; #line 3 "LogPage.cshtml" -using System.Linq +using System.Globalization #line default #line hidden ; #line 4 "LogPage.cshtml" -using Microsoft.AspNet.Diagnostics.Elm.Views +using System.Linq #line default #line hidden ; #line 5 "LogPage.cshtml" -using Microsoft.AspNet.Diagnostics.Elm +using Microsoft.AspNet.Diagnostics.Elm.Views #line default #line hidden ; #line 6 "LogPage.cshtml" -using Microsoft.AspNet.Diagnostics.Views +using Microsoft.AspNet.Diagnostics.Elm #line default #line hidden ; #line 7 "LogPage.cshtml" +using Microsoft.AspNet.Diagnostics.Views + +#line default +#line hidden + ; +#line 8 "LogPage.cshtml" using Microsoft.Framework.Logging #line default @@ -47,13 +53,13 @@ using Microsoft.Framework.Logging public class LogPage : Microsoft.AspNet.Diagnostics.Views.BaseView { public HelperResult -#line 20 "LogPage.cshtml" +#line 21 "LogPage.cshtml" LogRow(LogInfo log, int level) { #line default #line hidden return new HelperResult((__razor_helper_writer) => { -#line 20 "LogPage.cshtml" +#line 21 "LogPage.cshtml" if (log.Severity >= Model.Options.MinLevel && (string.IsNullOrEmpty(Model.Options.NamePrefix) || log.Name.StartsWith(Model.Options.NamePrefix, StringComparison.Ordinal))) @@ -63,46 +69,46 @@ LogRow(LogInfo log, int level) { #line hidden WriteLiteralTo(__razor_helper_writer, " \r\n "); -#line 25 "LogPage.cshtml" +#line 26 "LogPage.cshtml" WriteTo(__razor_helper_writer, string.Format("{0:MM/dd/yy}", log.Time)); #line default #line hidden WriteLiteralTo(__razor_helper_writer, "\r\n "); -#line 26 "LogPage.cshtml" +#line 27 "LogPage.cshtml" WriteTo(__razor_helper_writer, string.Format("{0:H:mm:ss}", log.Time)); #line default #line hidden WriteLiteralTo(__razor_helper_writer, "\r\n (log.Name, 844), false)); + WriteAttributeTo(__razor_helper_writer, "title", Tuple.Create(" title=\"", 871), Tuple.Create("\"", 888), + Tuple.Create(Tuple.Create("", 879), Tuple.Create(log.Name, 879), false)); WriteLiteralTo(__razor_helper_writer, ">"); -#line 27 "LogPage.cshtml" +#line 28 "LogPage.cshtml" WriteTo(__razor_helper_writer, log.Name); #line default #line hidden WriteLiteralTo(__razor_helper_writer, "\r\n (log.Severity.ToString().ToLowerInvariant(), 894), false)); + WriteAttributeTo(__razor_helper_writer, "class", Tuple.Create(" class=\"", 921), Tuple.Create("\"", 972), + Tuple.Create(Tuple.Create("", 929), Tuple.Create(log.Severity.ToString().ToLowerInvariant(), 929), false)); WriteLiteralTo(__razor_helper_writer, ">"); -#line 28 "LogPage.cshtml" +#line 29 "LogPage.cshtml" WriteTo(__razor_helper_writer, log.Severity); #line default #line hidden WriteLiteralTo(__razor_helper_writer, "\r\n (log.Message, 982), false)); + WriteAttributeTo(__razor_helper_writer, "title", Tuple.Create(" title=\"", 1009), Tuple.Create("\"", 1029), + Tuple.Create(Tuple.Create("", 1017), Tuple.Create(log.Message, 1017), false)); WriteLiteralTo(__razor_helper_writer, ">\r\n"); -#line 30 "LogPage.cshtml" +#line 31 "LogPage.cshtml" #line default #line hidden -#line 30 "LogPage.cshtml" +#line 31 "LogPage.cshtml" for (var i = 0; i < level; i++) { @@ -110,29 +116,29 @@ WriteTo(__razor_helper_writer, string.Format("{0:H:mm:ss}", log.Time)); #line hidden WriteLiteralTo(__razor_helper_writer, " \r\n"); -#line 33 "LogPage.cshtml" +#line 34 "LogPage.cshtml" } #line default #line hidden WriteLiteralTo(__razor_helper_writer, " "); -#line 34 "LogPage.cshtml" +#line 35 "LogPage.cshtml" WriteTo(__razor_helper_writer, log.Message); #line default #line hidden WriteLiteralTo(__razor_helper_writer, "\r\n \r\n (log.Exception, 1205), false)); + WriteAttributeTo(__razor_helper_writer, "title", Tuple.Create(" title=\"", 1232), Tuple.Create("\"", 1254), + Tuple.Create(Tuple.Create("", 1240), Tuple.Create(log.Exception, 1240), false)); WriteLiteralTo(__razor_helper_writer, ">"); -#line 36 "LogPage.cshtml" +#line 37 "LogPage.cshtml" WriteTo(__razor_helper_writer, log.Exception); #line default #line hidden WriteLiteralTo(__razor_helper_writer, "\r\n \r\n"); -#line 38 "LogPage.cshtml" +#line 39 "LogPage.cshtml" } #line default @@ -140,21 +146,21 @@ WriteTo(__razor_helper_writer, log.Message); } ); -#line 39 "LogPage.cshtml" +#line 40 "LogPage.cshtml" } #line default #line hidden public HelperResult -#line 41 "LogPage.cshtml" -Traverse(ScopeNode node, int level) +#line 42 "LogPage.cshtml" +Traverse(ScopeNode node, int level, Dictionary counts) { #line default #line hidden return new HelperResult((__razor_helper_writer) => { -#line 42 "LogPage.cshtml" +#line 43 "LogPage.cshtml" // print start of scope @@ -162,7 +168,7 @@ Traverse(ScopeNode node, int level) #line default #line hidden -#line 44 "LogPage.cshtml" +#line 45 "LogPage.cshtml" WriteTo(__razor_helper_writer, LogRow(new LogInfo() { Name = node.Name, @@ -173,7 +179,7 @@ WriteTo(__razor_helper_writer, LogRow(new LogInfo() #line default #line hidden -#line 50 "LogPage.cshtml" +#line 51 "LogPage.cshtml" ; var messageIndex = 0; var childIndex = 0; @@ -186,13 +192,14 @@ WriteTo(__razor_helper_writer, LogRow(new LogInfo() #line default #line hidden -#line 57 "LogPage.cshtml" +#line 58 "LogPage.cshtml" WriteTo(__razor_helper_writer, LogRow(node.Messages[messageIndex], level)); #line default #line hidden -#line 57 "LogPage.cshtml" +#line 58 "LogPage.cshtml" + counts[node.Messages[messageIndex].Severity.ToString()]++; messageIndex++; } else @@ -202,13 +209,13 @@ WriteTo(__razor_helper_writer, LogRow(node.Messages[messageIndex], level)); #line default #line hidden -#line 62 "LogPage.cshtml" -WriteTo(__razor_helper_writer, Traverse(node.Children[childIndex], level + 1)); +#line 64 "LogPage.cshtml" +WriteTo(__razor_helper_writer, Traverse(node.Children[childIndex], level + 1, counts)); #line default #line hidden -#line 62 "LogPage.cshtml" - +#line 64 "LogPage.cshtml" + childIndex++; } } @@ -221,13 +228,14 @@ WriteTo(__razor_helper_writer, Traverse(node.Children[childIndex], level + 1)); #line default #line hidden -#line 70 "LogPage.cshtml" +#line 72 "LogPage.cshtml" WriteTo(__razor_helper_writer, LogRow(node.Messages[i], level)); #line default #line hidden -#line 70 "LogPage.cshtml" +#line 72 "LogPage.cshtml" + counts[node.Messages[i].Severity.ToString()]++; } } else @@ -239,13 +247,13 @@ WriteTo(__razor_helper_writer, LogRow(node.Messages[i], level)); #line default #line hidden -#line 77 "LogPage.cshtml" -WriteTo(__razor_helper_writer, Traverse(node.Children[i], level + 1)); +#line 80 "LogPage.cshtml" +WriteTo(__razor_helper_writer, Traverse(node.Children[i], level + 1, counts)); #line default #line hidden -#line 77 "LogPage.cshtml" - +#line 80 "LogPage.cshtml" + } } // print end of scope @@ -254,7 +262,7 @@ WriteTo(__razor_helper_writer, Traverse(node.Children[i], level + 1)); #line default #line hidden -#line 81 "LogPage.cshtml" +#line 84 "LogPage.cshtml" WriteTo(__razor_helper_writer, LogRow(new LogInfo() { Name = node.Name, @@ -265,7 +273,7 @@ WriteTo(__razor_helper_writer, LogRow(new LogInfo() #line default #line hidden -#line 87 "LogPage.cshtml" +#line 90 "LogPage.cshtml" ; #line default @@ -273,13 +281,13 @@ WriteTo(__razor_helper_writer, LogRow(new LogInfo() } ); -#line 88 "LogPage.cshtml" +#line 91 "LogPage.cshtml" } #line default #line hidden -#line 10 "LogPage.cshtml" +#line 11 "LogPage.cshtml" public LogPage(LogPageModel model) { @@ -307,6 +315,7 @@ WriteTo(__razor_helper_writer, LogRow(new LogInfo() ASP.NET Logs + diff --git a/src/Microsoft.AspNet.Diagnostics.Elm/Views/RequestPage.css b/src/Microsoft.AspNet.Diagnostics.Elm/Views/DetailsPage.css similarity index 100% rename from src/Microsoft.AspNet.Diagnostics.Elm/Views/RequestPage.css rename to src/Microsoft.AspNet.Diagnostics.Elm/Views/DetailsPage.css diff --git a/src/Microsoft.AspNet.Diagnostics.Elm/Views/RequestPageModel.cs b/src/Microsoft.AspNet.Diagnostics.Elm/Views/DetailsPageModel.cs similarity index 61% rename from src/Microsoft.AspNet.Diagnostics.Elm/Views/RequestPageModel.cs rename to src/Microsoft.AspNet.Diagnostics.Elm/Views/DetailsPageModel.cs index b42fa3cc0a..c824625cf4 100644 --- a/src/Microsoft.AspNet.Diagnostics.Elm/Views/RequestPageModel.cs +++ b/src/Microsoft.AspNet.Diagnostics.Elm/Views/DetailsPageModel.cs @@ -1,12 +1,9 @@ using System; -using System.Collections.Generic; namespace Microsoft.AspNet.Diagnostics.Elm.Views { - public class RequestPageModel + public class DetailsPageModel { - public Guid RequestID { get; set; } - public ActivityContext Activity { get; set; } public ViewOptions Options { get; set; } diff --git a/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cs b/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cs index b38a5f79e3..be1ab6f12f 100644 --- a/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cs +++ b/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cs @@ -574,21 +574,21 @@ tr:nth-child(2n) { #line 149 "LogPage.cshtml" + var activityPath = Model.Path.Value + "/" + activity.Id; if (activity.HttpInfo != null) { - var requestPath = Model.Path.Value + "/" + activity.HttpInfo.RequestID; #line default #line hidden - WriteLiteral(" (requestPath, 4908), false)); - WriteAttribute("title", Tuple.Create(" title=\"", 4921), Tuple.Create("\"", 4952), - Tuple.Create(Tuple.Create("", 4929), Tuple.Create(activity.HttpInfo.Path, 4929), false)); + WriteLiteral(" \t(activityPath, 4886), false)); + WriteAttribute("title", Tuple.Create(" title=\"", 4900), Tuple.Create("\"", 4931), + Tuple.Create(Tuple.Create("", 4908), Tuple.Create(activity.HttpInfo.Path, 4908), false)); WriteLiteral(">"); #line 153 "LogPage.cshtml" - Write(activity.HttpInfo.Path); + Write(activity.HttpInfo.Path); #line default #line hidden @@ -612,6 +612,26 @@ tr:nth-child(2n) { #line hidden WriteLiteral("\r\n"); #line 157 "LogPage.cshtml" + } + else if (activity.RepresentsScope) + { + +#line default +#line hidden + + WriteLiteral(" (activityPath, 5328), false)); + WriteAttribute("title", Tuple.Create(" title=\"", 5342), Tuple.Create("\"", 5370), + Tuple.Create(Tuple.Create("", 5350), Tuple.Create(activity.Root.State, 5350), false)); + WriteLiteral(">"); +#line 160 "LogPage.cshtml" + Write(activity.Root.State); + +#line default +#line hidden + WriteLiteral("\r\n"); +#line 161 "LogPage.cshtml" } else { @@ -619,14 +639,11 @@ tr:nth-child(2n) { #line default #line hidden - WriteLiteral(" "); -#line 160 "LogPage.cshtml" - Write(activity.Root.State); - -#line default -#line hidden - WriteLiteral("\r\n"); -#line 161 "LogPage.cshtml" + WriteLiteral(" (activityPath, 5540), false)); + WriteLiteral(">Non-scope Log\r\n"); +#line 165 "LogPage.cshtml" } @@ -647,13 +664,13 @@ tr:nth-child(2n) { "); -#line 175 "LogPage.cshtml" +#line 179 "LogPage.cshtml" #line default #line hidden -#line 175 "LogPage.cshtml" +#line 179 "LogPage.cshtml" var counts = new Dictionary(); counts["Critical"] = 0; @@ -667,14 +684,14 @@ tr:nth-child(2n) { #line hidden WriteLiteral("\r\n \r\n"); -#line 184 "LogPage.cshtml" +#line 188 "LogPage.cshtml" #line default #line hidden -#line 184 "LogPage.cshtml" - if (activity.Id.Equals(Guid.Empty)) +#line 188 "LogPage.cshtml" + if (!activity.RepresentsScope) { // message not within a scope var logInfo = activity.Root.Messages.FirstOrDefault(); @@ -683,12 +700,12 @@ tr:nth-child(2n) { #line default #line hidden -#line 188 "LogPage.cshtml" +#line 192 "LogPage.cshtml" Write(LogRow(logInfo, 0)); #line default #line hidden -#line 188 "LogPage.cshtml" +#line 192 "LogPage.cshtml" counts[logInfo.Severity.ToString()] = 1; } @@ -699,12 +716,12 @@ tr:nth-child(2n) { #line default #line hidden -#line 193 "LogPage.cshtml" +#line 197 "LogPage.cshtml" Write(Traverse(activity.Root, 0, counts)); #line default #line hidden -#line 193 "LogPage.cshtml" +#line 197 "LogPage.cshtml" } @@ -714,19 +731,19 @@ tr:nth-child(2n) { WriteLiteral(" \r\n \r\n \r\n " + " "); -#line 198 "LogPage.cshtml" +#line 202 "LogPage.cshtml" Write(activity.Time.ToString("MM-dd-yyyy HH:mm:ss")); #line default #line hidden WriteLiteral("\r\n"); -#line 199 "LogPage.cshtml" +#line 203 "LogPage.cshtml" #line default #line hidden -#line 199 "LogPage.cshtml" +#line 203 "LogPage.cshtml" foreach (var kvp in counts) { if (string.Equals("Verbose", kvp.Key)) { @@ -735,19 +752,19 @@ tr:nth-child(2n) { #line hidden WriteLiteral(" "); -#line 202 "LogPage.cshtml" +#line 206 "LogPage.cshtml" Write(kvp.Value); #line default #line hidden WriteLiteral(" "); -#line 202 "LogPage.cshtml" +#line 206 "LogPage.cshtml" Write(kvp.Key); #line default #line hidden WriteLiteral("v\r\n"); -#line 203 "LogPage.cshtml" +#line 207 "LogPage.cshtml" } else { @@ -756,19 +773,19 @@ tr:nth-child(2n) { #line hidden WriteLiteral(" "); -#line 206 "LogPage.cshtml" +#line 210 "LogPage.cshtml" Write(kvp.Value); #line default #line hidden WriteLiteral(" "); -#line 206 "LogPage.cshtml" +#line 210 "LogPage.cshtml" Write(kvp.Key); #line default #line hidden WriteLiteral("\r\n"); -#line 207 "LogPage.cshtml" +#line 211 "LogPage.cshtml" } } @@ -778,7 +795,7 @@ tr:nth-child(2n) { WriteLiteral(" \r\n \r\n " + " \r\n \r\n \r\n" + " \r\n"); -#line 215 "LogPage.cshtml" +#line 219 "LogPage.cshtml" } #line default diff --git a/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cshtml b/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cshtml index c802ea66f5..2490be69dd 100644 --- a/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cshtml +++ b/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cshtml @@ -147,17 +147,21 @@ @{ + var activityPath = Model.Path.Value + "/" + activity.Id; if (activity.HttpInfo != null) { - var requestPath = Model.Path.Value + "/" + activity.HttpInfo.RequestID; - @activity.HttpInfo.Path + @activity.HttpInfo.Path @activity.HttpInfo.Method @activity.HttpInfo.Host @activity.HttpInfo.StatusCode } + else if (activity.RepresentsScope) + { + @activity.Root.State + } else { - @activity.Root.State + Non-scope Log } } @@ -181,7 +185,7 @@ counts["Verbose"] = 0; } - @if (activity.Id.Equals(Guid.Empty)) + @if (!activity.RepresentsScope) { // message not within a scope var logInfo = activity.Root.Messages.FirstOrDefault(); diff --git a/test/Microsoft.AspNet.Diagnostics.Tests/ElmMiddlewareTest.cs b/test/Microsoft.AspNet.Diagnostics.Tests/ElmMiddlewareTest.cs index 4e8a298fa7..518da0450e 100644 --- a/test/Microsoft.AspNet.Diagnostics.Tests/ElmMiddlewareTest.cs +++ b/test/Microsoft.AspNet.Diagnostics.Tests/ElmMiddlewareTest.cs @@ -155,7 +155,7 @@ namespace Microsoft.AspNet.Diagnostics.Tests // Assert contextMock.VerifyGet(c => c.Request.Query, Times.AtLeastOnce()); - Assert.True(response.Contains("Invalid Request Id")); + Assert.True(response.Contains("Invalid Id")); } } From effdc65d9ff4c733c1199d89d06c27235366c597 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 15 Dec 2014 14:32:31 -0800 Subject: [PATCH 04/18] Reacting to System.Threading.ExecutionContext being removed --- src/Microsoft.AspNet.Diagnostics.Elm/project.json | 2 +- src/Microsoft.AspNet.Diagnostics.Entity/project.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNet.Diagnostics.Elm/project.json b/src/Microsoft.AspNet.Diagnostics.Elm/project.json index ecbc925e74..4d832c4969 100644 --- a/src/Microsoft.AspNet.Diagnostics.Elm/project.json +++ b/src/Microsoft.AspNet.Diagnostics.Elm/project.json @@ -10,7 +10,7 @@ "aspnet50": { }, "aspnetcore50": { "dependencies": { - "System.Threading.ExecutionContext": "4.0.0-beta-*" + "System.Threading": "4.0.10-beta-*" } } } diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/project.json b/src/Microsoft.AspNet.Diagnostics.Entity/project.json index 9d4cb8e028..4ffb158faa 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/project.json +++ b/src/Microsoft.AspNet.Diagnostics.Entity/project.json @@ -17,7 +17,7 @@ }, "aspnetcore50": { "dependencies": { - "System.Threading.ExecutionContext": "4.0.0-beta-*" + "System.Threading": "4.0.10-beta-*" } } } From b014a9ef418a4ae114b8eb0bdc4a8bdce59bb329 Mon Sep 17 00:00:00 2001 From: Brennan Date: Mon, 15 Dec 2014 13:56:41 -0800 Subject: [PATCH 05/18] Update tests to use the official xunit --- .../project.json | 4 ++-- test/Microsoft.AspNet.Diagnostics.Entity.Tests/project.json | 4 ++-- test/Microsoft.AspNet.Diagnostics.Tests/project.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/project.json b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/project.json index a064bdbca8..7b55cb635e 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/project.json +++ b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/project.json @@ -4,10 +4,10 @@ "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*", "Microsoft.AspNet.Diagnostics.Entity.Tests": "1.0.0", "Microsoft.AspNet.TestHost": "1.0.0-*", - "Xunit.KRunner": "1.0.0-*" + "xunit.runner.kre": "1.0.0-*" }, "commands": { - "test": "Xunit.KRunner" + "test": "xunit.runner.kre" }, "frameworks": { "aspnet50": { } diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.Tests/project.json b/test/Microsoft.AspNet.Diagnostics.Entity.Tests/project.json index 69fa4bca68..bca9f67fd0 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.Tests/project.json +++ b/test/Microsoft.AspNet.Diagnostics.Entity.Tests/project.json @@ -3,11 +3,11 @@ "EntityFramework.InMemory": "7.0.0-*", "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*", "Moq": "4.2.1312.1622", - "Xunit.KRunner": "1.0.0-*" + "xunit.runner.kre": "1.0.0-*" }, "code": [ "**\\*.cs", "..\\Shared\\ApiConsistencyTestBase.cs", "..\\Shared\\TestHelpers.cs" ], "commands": { - "test": "Xunit.KRunner" + "test": "xunit.runner.kre" }, "frameworks": { "aspnet50": { } diff --git a/test/Microsoft.AspNet.Diagnostics.Tests/project.json b/test/Microsoft.AspNet.Diagnostics.Tests/project.json index 31e676c054..8d43ffb74b 100644 --- a/test/Microsoft.AspNet.Diagnostics.Tests/project.json +++ b/test/Microsoft.AspNet.Diagnostics.Tests/project.json @@ -4,7 +4,7 @@ }, "dependencies": { "Microsoft.AspNet.Diagnostics.Elm": "1.0.0-*", - "Xunit.KRunner": "1.0.0-*" + "xunit.runner.kre": "1.0.0-*" }, "frameworks": { @@ -17,6 +17,6 @@ } }, "commands": { - "test": "Xunit.KRunner" + "test": "xunit.runner.kre" } } From 5e00937d591db8cc36cdfcf28f7696c2b7a3c7a9 Mon Sep 17 00:00:00 2001 From: rowanmiller Date: Tue, 16 Dec 2014 11:15:16 -0800 Subject: [PATCH 06/18] Handle wrapped exceptions in Database Error Page If a database exception is wrapped later in the request (after EF has logged it) then we were not displaying the database error page. This was occurring in ASP.NET Identity where the exception was getting wrapped in an AggregateException. We now walk the tree of inner exceptions looking for a match. Also adding some extra logging as this was hard to debug without resorting to source code. --- .../DatabaseErrorPageMiddleware.cs | 35 +++++++- .../Properties/Strings.Designer.cs | 80 +++++++++++++++++++ .../Strings.resx | 15 ++++ .../DatabaseErrorPageMiddlewareTest.cs | 35 ++++++++ 4 files changed, 162 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs index bc32702c55..b4fb72d6d2 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs @@ -66,8 +66,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity { try { - if (_loggerProvider.Logger.LastError.IsErrorLogged - && _loggerProvider.Logger.LastError.Exception == ex) + if (ShouldDisplayErrorPage(_loggerProvider.Logger.LastError, ex, _logger)) { using (RequestServicesContainer.EnsureRequestServices(context, _serviceProvider)) { @@ -79,7 +78,11 @@ namespace Microsoft.AspNet.Diagnostics.Entity } else { - if (dbContext.Database is RelationalDatabase) + if (!(dbContext.Database is RelationalDatabase)) + { + _logger.WriteVerbose(Strings.DatabaseErrorPage_NotRelationalDatabase); + } + else { var databaseExists = dbContext.Database.AsRelational().Exists(); @@ -115,5 +118,31 @@ namespace Microsoft.AspNet.Diagnostics.Entity throw; } } + + private static bool ShouldDisplayErrorPage(DataStoreErrorLogger.DataStoreErrorLog lastError, Exception exception, ILogger logger) + { + logger.WriteVerbose(Strings.FormatDatabaseErrorPage_AttemptingToMatchException(exception.GetType())); + + if (!lastError.IsErrorLogged) + { + logger.WriteVerbose(Strings.DatabaseErrorPage_NoRecordedException); + return false; + } + + bool match = false; + for (var e = exception; e != null && !match; e = e.InnerException) + { + match = lastError.Exception == e; + } + + if (!match) + { + logger.WriteVerbose(Strings.DatabaseErrorPage_NoMatch); + return false; + } + + logger.WriteVerbose(Strings.DatabaseErrorPage_Matched); + return true; + } } } diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/Properties/Strings.Designer.cs b/src/Microsoft.AspNet.Diagnostics.Entity/Properties/Strings.Designer.cs index 01ed143a61..713fe5e89f 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/Properties/Strings.Designer.cs +++ b/src/Microsoft.AspNet.Diagnostics.Entity/Properties/Strings.Designer.cs @@ -458,6 +458,86 @@ namespace Microsoft.AspNet.Diagnostics.Entity return GetString("DatabaseErrorPage_EnableMigrationsCommandsInfo"); } + /// + /// {0} occurred, checking if Entity Framework recorded this exception as resulting from a failed database operation. + /// + internal static string DatabaseErrorPage_AttemptingToMatchException + { + get { return GetString("DatabaseErrorPage_AttemptingToMatchException"); } + } + + /// + /// {0} occurred, checking if Entity Framework recorded this exception as resulting from a failed database operation. + /// + internal static string FormatDatabaseErrorPage_AttemptingToMatchException(object p0) + { + return string.Format(CultureInfo.CurrentCulture, GetString("DatabaseErrorPage_AttemptingToMatchException"), p0); + } + + /// + /// Entity Framework recorded that the current exception was due to a failed database operation. Attempting to show database error page. + /// + internal static string DatabaseErrorPage_Matched + { + get { return GetString("DatabaseErrorPage_Matched"); } + } + + /// + /// Entity Framework recorded that the current exception was due to a failed database operation. Attempting to show database error page. + /// + internal static string FormatDatabaseErrorPage_Matched() + { + return GetString("DatabaseErrorPage_Matched"); + } + + /// + /// Entity Framework did not record any exceptions due to failed database operations. This means the current exception is not a failed Entity Framework database operation, or the current exception occurred from a DbContext that was not obtained from request services. + /// + internal static string DatabaseErrorPage_NoRecordedException + { + get { return GetString("DatabaseErrorPage_NoRecordedException"); } + } + + /// + /// Entity Framework did not record any exceptions due to failed database operations. This means the current exception is not a failed Entity Framework database operation, or the current exception occurred from a DbContext that was not obtained from request services. + /// + internal static string FormatDatabaseErrorPage_NoRecordedException() + { + return GetString("DatabaseErrorPage_NoRecordedException"); + } + + /// + /// The target data store is not a relational database. Skipping the database error page. + /// + internal static string DatabaseErrorPage_NotRelationalDatabase + { + get { return GetString("DatabaseErrorPage_NotRelationalDatabase"); } + } + + /// + /// The target data store is not a relational database. Skipping the database error page. + /// + internal static string FormatDatabaseErrorPage_NotRelationalDatabase() + { + return GetString("DatabaseErrorPage_NotRelationalDatabase"); + } + + /// + /// The current exception (and its inner exceptions) do not match the last exception Entity Framework recorded due to a failed database operation. This means the database operation exception was handled and another exception occurred later in the request. + /// + internal static string DatabaseErrorPage_NoMatch + { + get { return GetString("DatabaseErrorPage_NoMatch"); } + } + + /// + /// The current exception (and its inner exceptions) do not match the last exception Entity Framework recorded due to a failed database operation. This means the database operation exception was handled and another exception occurred later in the request. + /// + internal static string FormatDatabaseErrorPage_NoMatch() + { + return GetString("DatabaseErrorPage_NoMatch"); + } + private static string GetString(string name, params string[] formatterNames) { var value = _resourceManager.GetString(name); diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/Strings.resx b/src/Microsoft.AspNet.Diagnostics.Entity/Strings.resx index 12b4868cf5..7e57f9d7b1 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/Strings.resx +++ b/src/Microsoft.AspNet.Diagnostics.Entity/Strings.resx @@ -201,4 +201,19 @@ To use migrations from a command prompt you will need to <a href='http://go.microsoft.com/fwlink/?LinkId=518242'>install K Version Manager (KVM)</a>. Once installed, you can run migration commands from a standard command prompt in the project directory. + + {0} occurred, checking if Entity Framework recorded this exception as resulting from a failed database operation. + + + Entity Framework recorded that the current exception was due to a failed database operation. Attempting to show database error page. + + + Entity Framework did not record any exceptions due to failed database operations. This means the current exception is not a failed Entity Framework database operation, or the current exception occurred from a DbContext that was not obtained from request services. + + + The target data store is not a relational database. Skipping the database error page. + + + The current exception (and its inner exceptions) do not match the last exception Entity Framework recorded due to a failed database operation. This means the database operation exception was handled and another exception occurred later in the request. + \ No newline at end of file diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs index 61516a7a97..e62828c312 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs +++ b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs @@ -338,6 +338,41 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests } } + [Fact] + public async Task Error_page_displayed_when_exception_wrapped() + { + TestServer server = SetupTestServer(); + HttpResponseMessage response = await server.CreateClient().GetAsync("http://localhost/"); + + Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode); + var content = await response.Content.ReadAsStringAsync(); + Assert.Contains("I wrapped your exception", content); + Assert.Contains(StringsHelpers.GetResourceString("FormatDatabaseErrorPage_NoDbOrMigrationsTitle", typeof(BloggingContext).Name), content); + } + + class WrappedExceptionMiddleware + { + public WrappedExceptionMiddleware(RequestDelegate next) + { } + + public virtual Task Invoke(HttpContext context) + { + using (var db = context.ApplicationServices.GetService()) + { + db.Blogs.Add(new Blog()); + try + { + db.SaveChanges(); + throw new Exception("SaveChanges should have thrown"); + } + catch (Exception ex) + { + throw new Exception("I wrapped your exception", ex); + } + } + } + } + private static TestServer SetupTestServer(ILoggerProvider logProvider = null) where TContext : DbContext { From f76583b18b0024f7c3be0ea9a93bce2631bfe22d Mon Sep 17 00:00:00 2001 From: mikary Date: Fri, 19 Dec 2014 10:47:45 -0800 Subject: [PATCH 07/18] Reacting to API changes in EntityFramework --- .../DatabaseErrorPageMiddlewareTest.cs | 20 ++++++++++++------- .../MigrationsEndPointMiddlewareTest.cs | 6 ++++-- .../SqlServerTestStore.cs | 5 ++++- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs index e62828c312..336eb39834 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs +++ b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs @@ -235,7 +235,10 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests { services.AddEntityFramework().AddSqlServer(); services.AddScoped(); - services.AddInstance(new DbContextOptions().UseSqlServer(database.ConnectionString)); + + var contextOptions = new DbContextOptions(); + contextOptions.UseSqlServer(database.ConnectionString); + services.AddInstance(contextOptions); }); var options = DatabaseErrorPageOptions.ShowAll; @@ -268,9 +271,10 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests services.AddEntityFramework() .AddSqlServer(); - services.AddInstance( - new DbContextOptions() - .UseSqlServer(database.ConnectionString)); + var options = new DbContextOptions(); + options.UseSqlServer(database.ConnectionString); + + services.AddInstance(options); }); app.UseDatabaseErrorPage(); @@ -386,9 +390,11 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests .AddSqlServer(); services.AddScoped(); - services.AddInstance( - new DbContextOptions() - .UseSqlServer(database.ConnectionString)); + + var options = new DbContextOptions(); + options.UseSqlServer(database.ConnectionString); + + services.AddInstance(options); }); app.UseDatabaseErrorPage(); diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/MigrationsEndPointMiddlewareTest.cs b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/MigrationsEndPointMiddlewareTest.cs index 66fa99abc7..711cd2955d 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/MigrationsEndPointMiddlewareTest.cs +++ b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/MigrationsEndPointMiddlewareTest.cs @@ -65,7 +65,8 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests { using (var database = SqlServerTestStore.CreateScratch()) { - var options = new DbContextOptions().UseSqlServer(database.ConnectionString); + var options = new DbContextOptions(); + options.UseSqlServer(database.ConnectionString); var path = useCustomPath ? new PathString("/EndPoints/ApplyMyMigrations") : MigrationsEndPointOptions.DefaultPath; TestServer server = TestServer.Create(app => @@ -183,7 +184,8 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests { using (var database = SqlServerTestStore.CreateScratch()) { - var options = new DbContextOptions().UseSqlServer(database.ConnectionString); + var options = new DbContextOptions(); + options.UseSqlServer(database.ConnectionString); TestServer server = TestServer.Create(app => { diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/SqlServerTestStore.cs b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/SqlServerTestStore.cs index d4752ab46f..9082d4b2bb 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/SqlServerTestStore.cs +++ b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/SqlServerTestStore.cs @@ -40,7 +40,10 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests private void EnsureDeleted() { - using (var db = new DbContext(new DbContextOptions().UseSqlServer(_connectionString))) + var options = new DbContextOptions(); + options.UseSqlServer(_connectionString); + + using (var db = new DbContext(options)) { db.Database.EnsureDeleted(); } From 32e28a8fc862d13233a8681b1cc71989317a7fad Mon Sep 17 00:00:00 2001 From: mikary Date: Wed, 7 Jan 2015 14:51:05 -0800 Subject: [PATCH 08/18] Reacting to API changes in EntityFramework Migrations --- .../DatabaseErrorPageMiddleware.cs | 6 +++--- .../MigrationsEndPointMiddleware.cs | 2 +- src/Microsoft.AspNet.Diagnostics.Entity/project.json | 2 +- .../DatabaseErrorPageMiddlewareTest.cs | 4 ++-- .../MigrationsEndPointMiddlewareTest.cs | 6 +++--- .../TestModels/BloggingContext.cs | 2 +- .../TestModels/BloggingContextWithMigrations.cs | 6 +++--- .../TestModels/BloggingContextWithPendingModelChanges.cs | 6 +++--- .../TestModels/BloggingContextWithSnapshotThatThrows.cs | 6 +++--- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs index b4fb72d6d2..2919f6b5c0 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs @@ -9,10 +9,10 @@ using Microsoft.AspNet.Http; using Microsoft.AspNet.RequestContainer; using Microsoft.Data.Entity; using Microsoft.Data.Entity.Infrastructure; -using Microsoft.Data.Entity.Migrations; -using Microsoft.Data.Entity.Migrations.Infrastructure; -using Microsoft.Data.Entity.Migrations.Utilities; using Microsoft.Data.Entity.Relational; +using Microsoft.Data.Entity.Relational.Migrations; +using Microsoft.Data.Entity.Relational.Migrations.Infrastructure; +using Microsoft.Data.Entity.Relational.Migrations.Utilities; using Microsoft.Data.Entity.Utilities; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs index e381179d29..42a0cbb87f 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs @@ -8,7 +8,7 @@ using Microsoft.AspNet.Builder; using Microsoft.AspNet.Diagnostics.Entity.Utilities; using Microsoft.AspNet.Http; using Microsoft.Data.Entity; -using Microsoft.Data.Entity.Migrations.Infrastructure; +using Microsoft.Data.Entity.Relational.Migrations.Infrastructure; using Microsoft.Framework.DependencyInjection; using System.Net; using Microsoft.Framework.Logging; diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/project.json b/src/Microsoft.AspNet.Diagnostics.Entity/project.json index 4ffb158faa..6e0ee188dd 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/project.json +++ b/src/Microsoft.AspNet.Diagnostics.Entity/project.json @@ -6,7 +6,7 @@ }, "dependencies": { "Microsoft.AspNet.Diagnostics": "1.0.0-*", - "EntityFramework.Migrations": "7.0.0-*" + "EntityFramework.Relational": "7.0.0-*" }, "code": [ "**\\*.cs", "..\\Shared\\*.cs" ], "frameworks": { diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs index 336eb39834..4ff4d60d3d 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs +++ b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs @@ -14,8 +14,8 @@ using Microsoft.AspNet.Http; using Microsoft.AspNet.TestHost; using Microsoft.Data.Entity; using Microsoft.Data.Entity.Infrastructure; -using Microsoft.Data.Entity.Migrations; -using Microsoft.Data.Entity.Migrations.Infrastructure; +using Microsoft.Data.Entity.Relational.Migrations; +using Microsoft.Data.Entity.Relational.Migrations.Infrastructure; using Microsoft.Data.Entity.Utilities; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/MigrationsEndPointMiddlewareTest.cs b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/MigrationsEndPointMiddlewareTest.cs index 711cd2955d..73db458229 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/MigrationsEndPointMiddlewareTest.cs +++ b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/MigrationsEndPointMiddlewareTest.cs @@ -12,9 +12,9 @@ using Microsoft.AspNet.Http; using Microsoft.AspNet.TestHost; using Microsoft.Data.Entity; using Microsoft.Data.Entity.Infrastructure; -using Microsoft.Data.Entity.Migrations; -using Microsoft.Data.Entity.Migrations.Infrastructure; -using Microsoft.Data.Entity.Migrations.Utilities; +using Microsoft.Data.Entity.Relational.Migrations; +using Microsoft.Data.Entity.Relational.Migrations.Infrastructure; +using Microsoft.Data.Entity.Relational.Migrations.Utilities; using Microsoft.Data.Entity.Utilities; using Microsoft.Framework.DependencyInjection; using Xunit; diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/TestModels/BloggingContext.cs b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/TestModels/BloggingContext.cs index a8ecc378aa..5a322a7a5e 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/TestModels/BloggingContext.cs +++ b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/TestModels/BloggingContext.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.Data.Entity; -using Microsoft.Data.Entity.Migrations.Infrastructure; +using Microsoft.Data.Entity.Relational.Migrations.Infrastructure; using System; using System.Linq; using System.Reflection; diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/TestModels/BloggingContextWithMigrations.cs b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/TestModels/BloggingContextWithMigrations.cs index 5d59d57820..d2047fd0f4 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/TestModels/BloggingContextWithMigrations.cs +++ b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/TestModels/BloggingContextWithMigrations.cs @@ -3,9 +3,9 @@ using Microsoft.Data.Entity; using Microsoft.Data.Entity.Metadata; -using Microsoft.Data.Entity.Migrations; -using Microsoft.Data.Entity.Migrations.Builders; -using Microsoft.Data.Entity.Migrations.Infrastructure; +using Microsoft.Data.Entity.Relational.Migrations; +using Microsoft.Data.Entity.Relational.Migrations.Builders; +using Microsoft.Data.Entity.Relational.Migrations.Infrastructure; using System; using System.Linq; using System.Reflection; diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/TestModels/BloggingContextWithPendingModelChanges.cs b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/TestModels/BloggingContextWithPendingModelChanges.cs index cb98b4bcbf..e571d930ef 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/TestModels/BloggingContextWithPendingModelChanges.cs +++ b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/TestModels/BloggingContextWithPendingModelChanges.cs @@ -3,9 +3,9 @@ using Microsoft.Data.Entity; using Microsoft.Data.Entity.Metadata; -using Microsoft.Data.Entity.Migrations; -using Microsoft.Data.Entity.Migrations.Builders; -using Microsoft.Data.Entity.Migrations.Infrastructure; +using Microsoft.Data.Entity.Relational.Migrations; +using Microsoft.Data.Entity.Relational.Migrations.Builders; +using Microsoft.Data.Entity.Relational.Migrations.Infrastructure; using System; namespace Microsoft.AspNet.Diagnostics.Entity.Tests diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/TestModels/BloggingContextWithSnapshotThatThrows.cs b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/TestModels/BloggingContextWithSnapshotThatThrows.cs index f1c1fd1973..ff2b09354b 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/TestModels/BloggingContextWithSnapshotThatThrows.cs +++ b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/TestModels/BloggingContextWithSnapshotThatThrows.cs @@ -3,9 +3,9 @@ using Microsoft.Data.Entity; using Microsoft.Data.Entity.Metadata; -using Microsoft.Data.Entity.Migrations; -using Microsoft.Data.Entity.Migrations.Builders; -using Microsoft.Data.Entity.Migrations.Infrastructure; +using Microsoft.Data.Entity.Relational.Migrations; +using Microsoft.Data.Entity.Relational.Migrations.Builders; +using Microsoft.Data.Entity.Relational.Migrations.Infrastructure; using System; using System.Linq; using System.Reflection; From 97b151f2c29d41db2a7b4a4653e7f6d95fdef6cb Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Wed, 7 Jan 2015 16:25:42 -0800 Subject: [PATCH 09/18] Handle ReadFormAsync breaking change. --- src/Microsoft.AspNet.Diagnostics.Elm/ElmPageMiddleware.cs | 2 +- .../MigrationsEndPointMiddleware.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNet.Diagnostics.Elm/ElmPageMiddleware.cs b/src/Microsoft.AspNet.Diagnostics.Elm/ElmPageMiddleware.cs index 0c4dab97b4..cf02d4abd3 100644 --- a/src/Microsoft.AspNet.Diagnostics.Elm/ElmPageMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics.Elm/ElmPageMiddleware.cs @@ -93,7 +93,7 @@ namespace Microsoft.AspNet.Diagnostics.Elm NamePrefix = string.Empty }; var isRedirect = false; - var form = await context.Request.GetFormAsync(); + var form = await context.Request.ReadFormAsync(); if (form.ContainsKey("clear")) { _store.Clear(); diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs index 42a0cbb87f..f6c8f568da 100644 --- a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs @@ -78,7 +78,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity private static async Task GetDbContext(HttpContext context, ILogger logger) { - var form = await context.Request.GetFormAsync().WithCurrentCulture(); + var form = await context.Request.ReadFormAsync().WithCurrentCulture(); var contextTypeName = form["context"]; if (string.IsNullOrWhiteSpace(contextTypeName)) { From 44dadb1d0f1801f8add5151f4162465d02d4e384 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Wed, 7 Jan 2015 18:30:36 -0800 Subject: [PATCH 10/18] Handle ReadForAsync changes. --- test/Microsoft.AspNet.Diagnostics.Tests/ElmMiddlewareTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNet.Diagnostics.Tests/ElmMiddlewareTest.cs b/test/Microsoft.AspNet.Diagnostics.Tests/ElmMiddlewareTest.cs index 518da0450e..8343b54910 100644 --- a/test/Microsoft.AspNet.Diagnostics.Tests/ElmMiddlewareTest.cs +++ b/test/Microsoft.AspNet.Diagnostics.Tests/ElmMiddlewareTest.cs @@ -205,8 +205,8 @@ namespace Microsoft.AspNet.Diagnostics.Tests .SetupGet(c => c.Request.Cookies) .Returns(new Mock().Object); contextMock - .Setup(c => c.Request.GetFormAsync(It.IsAny())) - .Returns(Task.FromResult(new Mock().Object)); + .Setup(c => c.Request.ReadFormAsync(It.IsAny())) + .Returns(Task.FromResult(new Mock().Object)); return contextMock; } From 576731e86e322dd0f3d63efc66cda1b929315ad4 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 19 Dec 2014 15:48:37 -0800 Subject: [PATCH 11/18] Adding contract interfaces for specifying runtime compilation exceptions. Fixes #12 --- .../Compilation/ICompilationException.cs | 20 + .../Compilation/ICompilationFailure.cs | 40 ++ .../Compilation/ICompilationMessage.cs | 40 ++ .../ErrorPageMiddleware.cs | 83 +++- .../Properties/Resources.Designer.cs | 20 +- .../Resources.resx | 3 + .../Views/CompilationErrorModel.cs | 23 + .../Views/CompilationErrorPage.cs | 417 ++++++++++++++++++ .../Views/CompilationErrorPage.cshtml | 101 +++++ .../Views/ErrorPage.cs | 121 ++--- .../Views/ErrorPage.cshtml | 8 +- .../Views/StackFrame.cs | 7 +- 12 files changed, 822 insertions(+), 61 deletions(-) create mode 100644 src/Microsoft.AspNet.Diagnostics/Compilation/ICompilationException.cs create mode 100644 src/Microsoft.AspNet.Diagnostics/Compilation/ICompilationFailure.cs create mode 100644 src/Microsoft.AspNet.Diagnostics/Compilation/ICompilationMessage.cs create mode 100644 src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorModel.cs create mode 100644 src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cs create mode 100644 src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cshtml diff --git a/src/Microsoft.AspNet.Diagnostics/Compilation/ICompilationException.cs b/src/Microsoft.AspNet.Diagnostics/Compilation/ICompilationException.cs new file mode 100644 index 0000000000..ba9102a35b --- /dev/null +++ b/src/Microsoft.AspNet.Diagnostics/Compilation/ICompilationException.cs @@ -0,0 +1,20 @@ +// 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; +using Microsoft.Framework.Runtime; + +namespace Microsoft.AspNet.Diagnostics +{ + /// + /// Specifies the contract for an exception representing compilation failure. + /// + [AssemblyNeutral] + 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/Compilation/ICompilationFailure.cs b/src/Microsoft.AspNet.Diagnostics/Compilation/ICompilationFailure.cs new file mode 100644 index 0000000000..bf16458fc6 --- /dev/null +++ b/src/Microsoft.AspNet.Diagnostics/Compilation/ICompilationFailure.cs @@ -0,0 +1,40 @@ +// 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; +using Microsoft.Framework.Runtime; + +namespace Microsoft.AspNet.Diagnostics +{ + /// + /// Specifies the contract for a file that fails compilation. + /// + [AssemblyNeutral] + 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/Compilation/ICompilationMessage.cs b/src/Microsoft.AspNet.Diagnostics/Compilation/ICompilationMessage.cs new file mode 100644 index 0000000000..ed3ca5fed8 --- /dev/null +++ b/src/Microsoft.AspNet.Diagnostics/Compilation/ICompilationMessage.cs @@ -0,0 +1,40 @@ +// 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 Microsoft.Framework.Runtime; + +namespace Microsoft.AspNet.Diagnostics +{ + /// + /// Specifies the contract for diagnostic messages produced as result of compiling an instance + /// of . + /// + [AssemblyNeutral] + 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 d872d65f04..aa8851bcc0 100644 --- a/src/Microsoft.AspNet.Diagnostics/ErrorPageMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics/ErrorPageMiddleware.cs @@ -76,7 +76,70 @@ namespace Microsoft.AspNet.Diagnostics } // Assumes the response headers have not been sent. If they have, still attempt to write to the body. - private async Task DisplayException(HttpContext context, Exception ex) + private Task DisplayException(HttpContext context, Exception ex) + { + var compilationException = ex as ICompilationException; + if (compilationException != null) + { + return DisplayCompilationException(context, ex, compilationException); + } + + return DisplayRuntimeException(context, ex); + } + + private Task DisplayCompilationException(HttpContext context, + Exception ex, + ICompilationException compilationException) + { + var stackFrames = new List(); + var model = new CompilationErrorPageModel() + { + Options = _options, + ErrorDetails = new ErrorDetails + { + Error = ex, + StackFrames = stackFrames + } + }; + + // For view compilation, the most common case is to stop at the first failing file compiled as part of + // rendering a view. Consequently we'll limit ourselves to displaying errors from the first failure. + var failedCompilationFile = compilationException.CompilationFailures.FirstOrDefault(); + if (failedCompilationFile != null) + { + var fileContent = failedCompilationFile.SourceFileContent + .Split(new[] { Environment.NewLine }, StringSplitOptions.None); + + foreach (var item in failedCompilationFile.Messages) + { + // Convert 0-based line indexes to 1-based index that the StackFrame expects + var lineIndex = item.StartLine + 1; + var frame = new StackFrame + { + File = failedCompilationFile.SourceFilePath, + Line = lineIndex, + Function = string.Empty + }; + + if (_options.ShowSourceCode) + { + ReadFrameContent(frame, fileContent, lineIndex, item.EndLine + 1); + frame.ErrorDetails = item.Message; + } + + stackFrames.Add(frame); + } + } + + var errorPage = new CompilationErrorPage + { + Model = model + }; + + return errorPage.ExecuteAsync(context); + } + + private Task DisplayRuntimeException(HttpContext context, Exception ex) { var request = context.Request; @@ -107,7 +170,7 @@ namespace Microsoft.AspNet.Diagnostics }*/ var errorPage = new ErrorPage(model); - await errorPage.ExecuteAsync(context); + return errorPage.ExecuteAsync(context); } private IEnumerable GetErrorDetails(Exception ex, bool showSource) @@ -160,14 +223,22 @@ namespace Microsoft.AspNet.Diagnostics if (showSource && File.Exists(file)) { IEnumerable code = File.ReadLines(file); - frame.PreContextLine = Math.Max(lineNumber - _options.SourceCodeLineCount, 1); - frame.PreContextCode = code.Skip(frame.PreContextLine - 1).Take(lineNumber - frame.PreContextLine).ToArray(); - frame.ContextCode = code.Skip(lineNumber - 1).FirstOrDefault(); - frame.PostContextCode = code.Skip(lineNumber).Take(_options.SourceCodeLineCount).ToArray(); + ReadFrameContent(frame, code, lineNumber, lineNumber); } return frame; } + private void ReadFrameContent(StackFrame frame, + IEnumerable code, + int startLineNumber, + int endLineNumber) + { + frame.PreContextLine = Math.Max(startLineNumber - _options.SourceCodeLineCount, 1); + frame.PreContextCode = code.Skip(frame.PreContextLine - 1).Take(startLineNumber - frame.PreContextLine).ToArray(); + frame.ContextCode = code.Skip(startLineNumber - 1).Take(1 + Math.Max(0, endLineNumber - startLineNumber)); + frame.PostContextCode = code.Skip(startLineNumber).Take(_options.SourceCodeLineCount).ToArray(); + } + internal class Chunk { public string Text { get; set; } diff --git a/src/Microsoft.AspNet.Diagnostics/Properties/Resources.Designer.cs b/src/Microsoft.AspNet.Diagnostics/Properties/Resources.Designer.cs index 151b1aa94f..9ac48701ad 100644 --- a/src/Microsoft.AspNet.Diagnostics/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNet.Diagnostics/Properties/Resources.Designer.cs @@ -379,7 +379,7 @@ namespace Microsoft.AspNet.Diagnostics } /// - /// Name + /// Version /// internal static string RuntimeInfoPage_PackageVersionColumnName { @@ -387,7 +387,7 @@ namespace Microsoft.AspNet.Diagnostics } /// - /// Name + /// Version /// internal static string FormatRuntimeInfoPage_PackageVersionColumnName() { @@ -570,6 +570,22 @@ namespace Microsoft.AspNet.Diagnostics return GetString("WelcomeTitle"); } + /// + /// An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately. + /// + internal static string ErrorPageHtml_CompilationException + { + get { return GetString("ErrorPageHtml_CompilationException"); } + } + + /// + /// An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately. + /// + internal static string FormatErrorPageHtml_CompilationException() + { + return GetString("ErrorPageHtml_CompilationException"); + } + private static string GetString(string name, params string[] formatterNames) { var value = _resourceManager.GetString(name); diff --git a/src/Microsoft.AspNet.Diagnostics/Resources.resx b/src/Microsoft.AspNet.Diagnostics/Resources.resx index a56b82ed1d..98190423f4 100644 --- a/src/Microsoft.AspNet.Diagnostics/Resources.resx +++ b/src/Microsoft.AspNet.Diagnostics/Resources.resx @@ -230,4 +230,7 @@ Your ASP.NET vNext application has been successfully started. + + An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately. + \ No newline at end of file diff --git a/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorModel.cs b/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorModel.cs new file mode 100644 index 0000000000..fed8231c1b --- /dev/null +++ b/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorModel.cs @@ -0,0 +1,23 @@ +// 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.Views +{ + /// + /// Holds data to be displayed on the compilation error page. + /// + public class CompilationErrorPageModel + { + /// + /// Options for what output to display. + /// + public ErrorPageOptions Options { get; set; } + + /// + /// Detailed information about each parse or compilation error. + /// + public ErrorDetails ErrorDetails { get; set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cs b/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cs new file mode 100644 index 0000000000..c2647b0698 --- /dev/null +++ b/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cs @@ -0,0 +1,417 @@ +namespace Microsoft.AspNet.Diagnostics.Views +{ +#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 Views + +#line default +#line hidden + ; + using System.Threading.Tasks; + + public class CompilationErrorPage : Microsoft.AspNet.Diagnostics.Views.BaseView + { +#line 7 "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 10 "CompilationErrorPage.cshtml" + + var errorDetail = Model.ErrorDetails; + + Response.StatusCode = 500; + Response.ContentType = "text/html"; + Response.ContentLength = null; // Clear any prior Content-Length + +#line default +#line hidden + + WriteLiteral("\r\n\r\n\r\n \r\n \r\n " + +""); +#line 21 "CompilationErrorPage.cshtml" + Write(Resources.ErrorPageHtml_Title); + +#line default +#line hidden + WriteLiteral("\r\n + + +

@Resources.ErrorPageHtml_CompilationException

+ @if (Model.Options.ShowExceptionDetails) + { +
@errorDetail.Error.GetType().Name: @{ Output.Write(WebUtility.HtmlEncode(errorDetail.Error.Message).Replace("\r\n", "
").Replace("\r", "
").Replace("\n", "
")); }
+ } + else + { +

@Resources.ErrorPageHtml_EnableShowExceptions

+ } + @if (Model.Options.ShowExceptionDetails) + { +
+ @{ int tabIndex = 6; } +
+
    + @foreach (var frame in errorDetail.StackFrames) + { +
  • + @{ tabIndex++; } + @if (!string.IsNullOrEmpty(frame.ErrorDetails)) + { +

    @frame.ErrorDetails

    + } + else + { + 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 != null) + { +
      + @foreach (var line in frame.PreContextCode) + { +
    1. @line
    2. + } +
    + } +
      + @foreach (var line in frame.ContextCode) + { +
    1. @line
    2. + } +
    + @if (frame.PostContextCode != null) + { +
      + @foreach (var line in frame.PostContextCode) + { +
    1. @line
    2. + } +
    + } +
    + } +
  • + } +
+
+ } + + + diff --git a/src/Microsoft.AspNet.Diagnostics/Views/ErrorPage.cs b/src/Microsoft.AspNet.Diagnostics/Views/ErrorPage.cs index a2826d6d32..ecb486deae 100644 --- a/src/Microsoft.AspNet.Diagnostics/Views/ErrorPage.cs +++ b/src/Microsoft.AspNet.Diagnostics/Views/ErrorPage.cs @@ -472,7 +472,7 @@ using Views #line hidden #line 123 "ErrorPage.cshtml" - if (frame.Line != 0 && frame.ContextCode != null) + if (frame.Line != 0 && frame.ContextCode.Any()) { #line default @@ -493,8 +493,8 @@ using Views #line hidden WriteLiteral(" (frame.PreContextLine, 5285), false)); + WriteAttribute("start", Tuple.Create(" start=\"", 5275), Tuple.Create("\"", 5304), + Tuple.Create(Tuple.Create("", 5283), Tuple.Create(frame.PreContextLine, 5283), false)); WriteLiteral(" class=\"collapsible\">\r\n"); #line 129 "ErrorPage.cshtml" @@ -530,22 +530,43 @@ using Views #line hidden WriteLiteral("\r\n (frame.Line, 5782), false)); - WriteLiteral(" class=\"highlight\">\r\n
  • "); + WriteAttribute("start", Tuple.Create(" start=\"", 5772), Tuple.Create("\"", 5791), + Tuple.Create(Tuple.Create("", 5780), Tuple.Create(frame.Line, 5780), false)); + WriteLiteral(" class=\"highlight\">\r\n"); #line 137 "ErrorPage.cshtml" - Write(frame.ContextCode); + #line default #line hidden - WriteLiteral("
  • \r\n\r\n"); + +#line 137 "ErrorPage.cshtml" + foreach (var line in frame.ContextCode) + { + +#line default +#line hidden + + WriteLiteral("
  • "); #line 139 "ErrorPage.cshtml" + Write(line); + +#line default +#line hidden + WriteLiteral("
  • \r\n"); +#line 140 "ErrorPage.cshtml" + } + +#line default +#line hidden + + WriteLiteral(" \r\n\r\n"); +#line 143 "ErrorPage.cshtml" #line default #line hidden -#line 139 "ErrorPage.cshtml" +#line 143 "ErrorPage.cshtml" if (frame.PostContextCode != null) { @@ -553,16 +574,16 @@ using Views #line hidden WriteLiteral(" (frame.Line + 1, 6099), false)); + WriteAttribute("start", Tuple.Create(" start=\'", 6318), Tuple.Create("\'", 6343), + Tuple.Create(Tuple.Create("", 6326), Tuple.Create(frame.Line + 1, 6326), false)); WriteLiteral(" class=\"collapsible\">\r\n"); -#line 142 "ErrorPage.cshtml" +#line 146 "ErrorPage.cshtml" #line default #line hidden -#line 142 "ErrorPage.cshtml" +#line 146 "ErrorPage.cshtml" foreach (var line in frame.PostContextCode) { @@ -570,55 +591,55 @@ using Views #line hidden WriteLiteral("
  • "); -#line 144 "ErrorPage.cshtml" +#line 148 "ErrorPage.cshtml" Write(line); #line default #line hidden WriteLiteral("
  • \r\n"); -#line 145 "ErrorPage.cshtml" +#line 149 "ErrorPage.cshtml" } #line default #line hidden WriteLiteral(" \r\n"); -#line 147 "ErrorPage.cshtml" +#line 151 "ErrorPage.cshtml" } #line default #line hidden WriteLiteral(" \r\n"); -#line 149 "ErrorPage.cshtml" +#line 153 "ErrorPage.cshtml" } #line default #line hidden WriteLiteral(" \r\n"); -#line 151 "ErrorPage.cshtml" +#line 155 "ErrorPage.cshtml" } #line default #line hidden WriteLiteral(" \r\n \r\n"); -#line 154 "ErrorPage.cshtml" +#line 158 "ErrorPage.cshtml" } #line default #line hidden WriteLiteral(" \r\n \r\n"); -#line 157 "ErrorPage.cshtml" +#line 161 "ErrorPage.cshtml" } #line default #line hidden WriteLiteral(" "); -#line 158 "ErrorPage.cshtml" +#line 162 "ErrorPage.cshtml" if (Model.Options.ShowQuery) { @@ -626,13 +647,13 @@ using Views #line hidden WriteLiteral("
    \r\n"); -#line 161 "ErrorPage.cshtml" +#line 165 "ErrorPage.cshtml" #line default #line hidden -#line 161 "ErrorPage.cshtml" +#line 165 "ErrorPage.cshtml" if (Model.Query.Any()) { @@ -641,26 +662,26 @@ using Views WriteLiteral(" \r\n \r\n " + " \r\n \r\n \r\n \r\n \r\n " + " \r\n"); -#line 171 "ErrorPage.cshtml" +#line 175 "ErrorPage.cshtml" #line default #line hidden -#line 171 "ErrorPage.cshtml" +#line 175 "ErrorPage.cshtml" foreach (var kv in Model.Query.OrderBy(kv => kv.Key)) { foreach (var v in kv.Value) @@ -671,19 +692,19 @@ using Views WriteLiteral(" \r\n " + " \r\n \r\n \r\n"); -#line 179 "ErrorPage.cshtml" +#line 183 "ErrorPage.cshtml" } } @@ -691,7 +712,7 @@ using Views #line hidden WriteLiteral(" \r\n
    "); -#line 166 "ErrorPage.cshtml" +#line 170 "ErrorPage.cshtml" Write(Resources.ErrorPageHtml_VariableColumn); #line default #line hidden WriteLiteral(""); -#line 167 "ErrorPage.cshtml" +#line 171 "ErrorPage.cshtml" Write(Resources.ErrorPageHtml_ValueColumn); #line default #line hidden WriteLiteral("
    "); -#line 176 "ErrorPage.cshtml" +#line 180 "ErrorPage.cshtml" Write(kv.Key); #line default #line hidden WriteLiteral(""); -#line 177 "ErrorPage.cshtml" +#line 181 "ErrorPage.cshtml" Write(v); #line default #line hidden WriteLiteral("
    \r\n"); -#line 183 "ErrorPage.cshtml" +#line 187 "ErrorPage.cshtml" } else { @@ -700,27 +721,27 @@ using Views #line hidden WriteLiteral("

    "); -#line 186 "ErrorPage.cshtml" +#line 190 "ErrorPage.cshtml" Write(Resources.ErrorPageHtml_NoQueryStringData); #line default #line hidden WriteLiteral("

    \r\n"); -#line 187 "ErrorPage.cshtml" +#line 191 "ErrorPage.cshtml" } #line default #line hidden WriteLiteral("
    \r\n"); -#line 189 "ErrorPage.cshtml" +#line 193 "ErrorPage.cshtml" } #line default #line hidden WriteLiteral(" "); -#line 190 "ErrorPage.cshtml" +#line 194 "ErrorPage.cshtml" if (Model.Options.ShowCookies) { /* TODO: @@ -757,7 +778,7 @@ using Views #line hidden WriteLiteral(" "); -#line 221 "ErrorPage.cshtml" +#line 225 "ErrorPage.cshtml" if (Model.Options.ShowHeaders) { @@ -765,13 +786,13 @@ using Views #line hidden WriteLiteral("
    \r\n"); -#line 224 "ErrorPage.cshtml" +#line 228 "ErrorPage.cshtml" #line default #line hidden -#line 224 "ErrorPage.cshtml" +#line 228 "ErrorPage.cshtml" if (Model.Headers.Any()) { @@ -780,26 +801,26 @@ using Views WriteLiteral(" \r\n \r\n " + " \r\n \r\n \r\n \r\n \r\n " + " \r\n"); -#line 234 "ErrorPage.cshtml" +#line 238 "ErrorPage.cshtml" #line default #line hidden -#line 234 "ErrorPage.cshtml" +#line 238 "ErrorPage.cshtml" foreach (var kv in Model.Headers.OrderBy(kv => kv.Key)) { foreach (var v in kv.Value) @@ -810,19 +831,19 @@ using Views WriteLiteral(" \r\n " + " \r\n \r\n \r\n"); -#line 242 "ErrorPage.cshtml" +#line 246 "ErrorPage.cshtml" } } @@ -830,7 +851,7 @@ using Views #line hidden WriteLiteral(" \r\n
    "); -#line 229 "ErrorPage.cshtml" +#line 233 "ErrorPage.cshtml" Write(Resources.ErrorPageHtml_VariableColumn); #line default #line hidden WriteLiteral(""); -#line 230 "ErrorPage.cshtml" +#line 234 "ErrorPage.cshtml" Write(Resources.ErrorPageHtml_ValueColumn); #line default #line hidden WriteLiteral("
    "); -#line 239 "ErrorPage.cshtml" +#line 243 "ErrorPage.cshtml" Write(kv.Key); #line default #line hidden WriteLiteral(""); -#line 240 "ErrorPage.cshtml" +#line 244 "ErrorPage.cshtml" Write(v); #line default #line hidden WriteLiteral("
    \r\n"); -#line 246 "ErrorPage.cshtml" +#line 250 "ErrorPage.cshtml" } else { @@ -839,27 +860,27 @@ using Views #line hidden WriteLiteral("

    "); -#line 249 "ErrorPage.cshtml" +#line 253 "ErrorPage.cshtml" Write(Resources.ErrorPageHtml_NoHeaderData); #line default #line hidden WriteLiteral("

    \r\n"); -#line 250 "ErrorPage.cshtml" +#line 254 "ErrorPage.cshtml" } #line default #line hidden WriteLiteral("
    \r\n"); -#line 252 "ErrorPage.cshtml" +#line 256 "ErrorPage.cshtml" } #line default #line hidden WriteLiteral(" "); -#line 253 "ErrorPage.cshtml" +#line 257 "ErrorPage.cshtml" if (Model.Options.ShowEnvironment) { /* TODO: diff --git a/src/Microsoft.AspNet.Diagnostics/Views/ErrorPage.cshtml b/src/Microsoft.AspNet.Diagnostics/Views/ErrorPage.cshtml index de7abfad3c..7a0075ac42 100644 --- a/src/Microsoft.AspNet.Diagnostics/Views/ErrorPage.cshtml +++ b/src/Microsoft.AspNet.Diagnostics/Views/ErrorPage.cshtml @@ -120,7 +120,7 @@

    @frame.Function in @System.IO.Path.GetFileName(frame.File)

    } - @if (frame.Line != 0 && frame.ContextCode != null) + @if (frame.Line != 0 && frame.ContextCode.Any()) {
    @if (frame.PreContextCode != null) @@ -134,7 +134,11 @@ }
      -
    1. @frame.ContextCode
    + @foreach (var line in frame.ContextCode) + { +
  • @line
  • + } + @if (frame.PostContextCode != null) { diff --git a/src/Microsoft.AspNet.Diagnostics/Views/StackFrame.cs b/src/Microsoft.AspNet.Diagnostics/Views/StackFrame.cs index 2b17068868..4a1ec2f513 100644 --- a/src/Microsoft.AspNet.Diagnostics/Views/StackFrame.cs +++ b/src/Microsoft.AspNet.Diagnostics/Views/StackFrame.cs @@ -39,11 +39,16 @@ namespace Microsoft.AspNet.Diagnostics.Views /// /// /// - public string ContextCode { get; set; } + public IEnumerable ContextCode { get; set; } /// /// /// public IEnumerable PostContextCode { get; set; } + + /// + /// Specific error details for this stack frame. + /// + public string ErrorDetails { get; set; } } } From 05cacda513a6d9e0a84a52fbffca98351ed18dff Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Thu, 15 Jan 2015 21:49:43 -0800 Subject: [PATCH 12/18] Remove unused PipelineCore reference. --- src/Microsoft.AspNet.Diagnostics/project.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Microsoft.AspNet.Diagnostics/project.json b/src/Microsoft.AspNet.Diagnostics/project.json index c45eb89a56..d180b2787a 100644 --- a/src/Microsoft.AspNet.Diagnostics/project.json +++ b/src/Microsoft.AspNet.Diagnostics/project.json @@ -2,7 +2,6 @@ "version": "1.0.0-*", "description": "ASP.NET 5 Middleware for error handling, error pages, and diagnostics information.", "dependencies": { - "Microsoft.AspNet.PipelineCore": "1.0.0-*", "Microsoft.AspNet.RequestContainer": "1.0.0-*", "Microsoft.Framework.Runtime.Interfaces": { "version": "1.0.0-*", "type": "build" } }, From d1fcdc529f0453ce1938e9b207dfe39fab04e996 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 20 Jan 2015 01:30:54 -0800 Subject: [PATCH 13/18] Updating build.cmd and build.sh to use dotnetsdk --- build.cmd | 6 +++--- build.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.cmd b/build.cmd index 86ca5bbbf1..c8041fdd9d 100644 --- a/build.cmd +++ b/build.cmd @@ -20,9 +20,9 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion IF "%SKIP_KRE_INSTALL%"=="1" goto run -CALL packages\KoreBuild\build\kvm upgrade -runtime CLR -x86 -CALL packages\KoreBuild\build\kvm install default -runtime CoreCLR -x86 +CALL packages\KoreBuild\build\dotnetsdk upgrade -runtime CLR -x86 +CALL packages\KoreBuild\build\dotnetsdk install default -runtime CoreCLR -x86 :run -CALL packages\KoreBuild\build\kvm use default -runtime CLR -x86 +CALL packages\KoreBuild\build\dotnetsdk use default -runtime CLR -x86 packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* diff --git a/build.sh b/build.sh index c7873ef58e..3f3c731c04 100644 --- a/build.sh +++ b/build.sh @@ -28,11 +28,11 @@ if test ! -d packages/KoreBuild; then fi if ! type k > /dev/null 2>&1; then - source packages/KoreBuild/build/kvm.sh + source setup/dotnetsdk.sh fi if ! type k > /dev/null 2>&1; then - kvm upgrade + dotnetsdk upgrade fi mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" From 32cf5e9ee41ff31648c614bae0895a61034102b0 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 20 Jan 2015 01:35:44 -0800 Subject: [PATCH 14/18] Updating build.cmd and build.sh to use dotnetsdk --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 3f3c731c04..350d7e389a 100644 --- a/build.sh +++ b/build.sh @@ -28,7 +28,7 @@ if test ! -d packages/KoreBuild; then fi if ! type k > /dev/null 2>&1; then - source setup/dotnetsdk.sh + source packages/KoreBuild/build/dotnetsdk.sh fi if ! type k > /dev/null 2>&1; then From 8c3edc158f25a53112d7872b70c39f7fe2abdb7d Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 20 Jan 2015 01:49:44 -0800 Subject: [PATCH 15/18] Reacting to KRuntime renames --- src/Microsoft.AspNet.Diagnostics/RuntimeInfoMiddleware.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.Diagnostics/RuntimeInfoMiddleware.cs b/src/Microsoft.AspNet.Diagnostics/RuntimeInfoMiddleware.cs index b3988d8cfb..57286763a4 100644 --- a/src/Microsoft.AspNet.Diagnostics/RuntimeInfoMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics/RuntimeInfoMiddleware.cs @@ -65,7 +65,7 @@ namespace Microsoft.AspNet.Diagnostics private static string GetRuntimeVersion() { - var klr = Assembly.Load(new AssemblyName("klr.host")); + var klr = Assembly.Load(new AssemblyName("dotnet.host")); var version = klr.GetCustomAttribute(); return version?.InformationalVersion; } From f8db022888b0543dfc2ef1fbe273f69be607e76f Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Tue, 20 Jan 2015 18:14:30 -0800 Subject: [PATCH 16/18] Rename SKIP_KRE_INSTALL to SKIP_DOTNET_INSTALL --- build.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cmd b/build.cmd index c8041fdd9d..220a1ff561 100644 --- a/build.cmd +++ b/build.cmd @@ -19,7 +19,7 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion -IF "%SKIP_KRE_INSTALL%"=="1" goto run +IF "%SKIP_DOTNET_INSTALL%"=="1" goto run CALL packages\KoreBuild\build\dotnetsdk upgrade -runtime CLR -x86 CALL packages\KoreBuild\build\dotnetsdk install default -runtime CoreCLR -x86 From ea4a2437e7b3ebdec292b5a6aafeb024d0e2bfbb Mon Sep 17 00:00:00 2001 From: Aligned Date: Wed, 21 Jan 2015 13:20:01 -0600 Subject: [PATCH 17/18] Change ASP.NET vNext to ASP.Net 5 in the Readme.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5a8d48556d..7d8c5d8a51 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,4 @@ ASP.NET DiagnosticsPages Diagnostics middleware. -This project is part of ASP.NET vNext. You can find samples, documentation and getting started instructions for ASP.NET vNext at the [Home](https://github.com/aspnet/home) repo. +This project is part of ASP.NET 5. You can find samples, documentation and getting started instructions for ASP.NET 5 at the [Home](https://github.com/aspnet/home) repo. From bd9954fd1a80fa850efea8f1ba2947ec8f15b741 Mon Sep 17 00:00:00 2001 From: Suhas Joshi Date: Wed, 21 Jan 2015 15:47:01 -0800 Subject: [PATCH 18/18] Updating to release NuGet.config --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index f41e9c631d..2d3b0cb857 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@  - +