Skip to content

Commit

Permalink
Added a console app to generate the Razor pages
Browse files Browse the repository at this point in the history
- Replaces the TT files previously being used (in Katana)
- Modified the include file logic to work better with the new generated Razor output as the old syntax/logic didn't work well with the additional line pragmas, etc. being emitted
- Updated the middleware to work with new generated output (ExecuteAsync instead of Execute, etc.)
- Fixed a scoping issue in Error.cshtml
- gitignore sln.ide cache directory
- #3
  • Loading branch information
DamianEdwards committed May 1, 2014
1 parent a78d5ac commit b4de33e
Show file tree
Hide file tree
Showing 17 changed files with 4,737 additions and 5,495 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ nuget.exe
*DS_Store
*.ncrunchsolution
*.*sdf
*.ipch
*.ipch
*.sln.ide
16 changes: 14 additions & 2 deletions DiagnosticsPages.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30327.0
# Visual Studio 14
VisualStudioVersion = 14.0.21628.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{509A6F36-AD80-4A18-B5B1-717D38DFF29D}"
EndProject
Expand All @@ -13,6 +13,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Diagnostic
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ErrorPageSample", "samples\ErrorPageSample\ErrorPageSample.kproj", "{589AC17F-9455-4764-8F82-FCD2AE58DA14}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "PageGenerator", "src\PageGenerator\PageGenerator.kproj", "{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -51,6 +53,15 @@ Global
{589AC17F-9455-4764-8F82-FCD2AE58DA14}.Release|Mixed Platforms.Build.0 = Release|x86
{589AC17F-9455-4764-8F82-FCD2AE58DA14}.Release|x86.ActiveCfg = Release|x86
{589AC17F-9455-4764-8F82-FCD2AE58DA14}.Release|x86.Build.0 = Release|x86
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Debug|Any CPU.ActiveCfg = Debug|x86
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Debug|x86.ActiveCfg = Debug|x86
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Debug|x86.Build.0 = Debug|x86
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Release|Any CPU.ActiveCfg = Release|x86
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Release|Mixed Platforms.ActiveCfg = Release|x86
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Release|Mixed Platforms.Build.0 = Release|x86
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Release|x86.ActiveCfg = Release|x86
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -59,5 +70,6 @@ Global
{C5F59CBA-DF2D-4983-8CBB-11B6AF21B416} = {ACAA0157-A8C4-4152-93DE-90CCDF304087}
{68A1F0E1-ECCE-46D1-B20F-C43EE5B097DE} = {509A6F36-AD80-4A18-B5B1-717D38DFF29D}
{589AC17F-9455-4764-8F82-FCD2AE58DA14} = {ACAA0157-A8C4-4152-93DE-90CCDF304087}
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74} = {509A6F36-AD80-4A18-B5B1-717D38DFF29D}
EndGlobalSection
EndGlobal
6 changes: 3 additions & 3 deletions src/Microsoft.AspNet.Diagnostics/ErrorPageMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public async Task Invoke(HttpContext context)
{
try
{
DisplayException(context, ex);
await DisplayException(context, ex);
return;
}
catch (Exception)
Expand All @@ -72,7 +72,7 @@ public async Task Invoke(HttpContext context)
}

// Assumes the response headers have not been sent. If they have, still attempt to write to the body.
private void DisplayException(HttpContext context, Exception ex)
private async Task DisplayException(HttpContext context, Exception ex)
{
var request = context.Request;

Expand Down Expand Up @@ -103,7 +103,7 @@ private void DisplayException(HttpContext context, Exception ex)
}*/

var errorPage = new ErrorPage() { Model = model };
errorPage.Execute(context);
await errorPage.ExecuteAsync(context);
}

private IEnumerable<ErrorDetails> GetErrorDetails(Exception ex, bool showSource)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@
<Content Include="Project.json" />
<Content Include="Resources.resx" />
<Content Include="Views\DiagnosticsPage.cshtml" />
<Content Include="Views\DiagnosticsPage.tt" />
<Content Include="Views\ErrorPage.cshtml" />
<Content Include="Views\ErrorPage.css" />
<Content Include="Views\ErrorPage.js" />
<Content Include="Views\ErrorPage.tt" />
<Content Include="Views\WelcomePage.cshtml" />
<Content Include="Views\WelcomePage.tt" />
</ItemGroup>
<ItemGroup>
<Compile Include="Constants.cs" />
Expand Down
7 changes: 4 additions & 3 deletions src/Microsoft.AspNet.Diagnostics/Views/BaseView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Globalization;
using System.IO;
using System.Net;
using System.Threading.Tasks;

namespace Microsoft.AspNet.Diagnostics.Views
{
Expand Down Expand Up @@ -37,20 +38,20 @@ public abstract class BaseView
/// Execute an individual request
/// </summary>
/// <param name="context"></param>
public void Execute(HttpContext context)
public async Task ExecuteAsync(HttpContext context)
{
Context = context;
Request = Context.Request;
Response = Context.Response;
Output = new StreamWriter(Response.Body);
Execute();
await ExecuteAsync();
Output.Dispose();
}

/// <summary>
/// Execute an individual request
/// </summary>
public abstract void Execute();
public abstract Task ExecuteAsync();

/// <summary>
/// Write the given value directly to the output
Expand Down
184 changes: 76 additions & 108 deletions src/Microsoft.AspNet.Diagnostics/Views/DiagnosticsPage.cs
Original file line number Diff line number Diff line change
@@ -1,38 +1,29 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18213
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Microsoft.AspNet.Diagnostics.Views {

#line 1 "DiagnosticsPage.cshtml"
using System;

#line default
#line hidden

#line 2 "DiagnosticsPage.cshtml"
using System.Globalization;

#line default
#line hidden


public class DiagnosticsPage : Microsoft.AspNet.Diagnostics.Views.BaseView {

namespace Microsoft.AspNet.Diagnostics.Views
{
#line 1 "DiagnosticsPage.cshtml"
using System

#line default
#line hidden
;
#line 2 "DiagnosticsPage.cshtml"
using System.Globalization

#line default
#line hidden

public DiagnosticsPage() {
;
using System.Threading.Tasks;

public class DiagnosticsPage : Microsoft.AspNet.Diagnostics.Views.BaseView
{
#line hidden
public DiagnosticsPage()
{
}
public override void Execute() {
#line 3 "DiagnosticsPage.cshtml"

public override async Task ExecuteAsync()
{
#line 3 "DiagnosticsPage.cshtml"

Response.ContentType = "text/html";
string error = Request.Query.Get("error");
Expand All @@ -41,93 +32,70 @@ public override void Execute() {
throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "User requested error '{0}'", error));
}


#line default
#line hidden
WriteLiteral("\r\n<!DOCTYPE html>\r\n\r\n<html");

WriteLiteral(" lang=\"en\"");

WriteLiteral(" xmlns=\"http://www.w3.org/1999/xhtml\"");

WriteLiteral(">\r\n<head>\r\n <meta");

WriteLiteral(" charset=\"utf-8\"");

WriteLiteral(" />\r\n <title>");


#line 16 "DiagnosticsPage.cshtml"
Write(Resources.DiagnosticsPageHtml_Title);


#line default
#line hidden
WriteLiteral("</title>\r\n</head>\r\n<body>\r\n <div");

WriteLiteral(" class=\"main\"");
#line default
#line hidden

WriteLiteral(">\r\n <h1>");
WriteLiteral("\r\n<!DOCTYPE html>\r\n\r\n<html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head" +
">\r\n <meta charset=\"utf-8\" />\r\n <title>");
Write(
#line 16 "DiagnosticsPage.cshtml"
Resources.DiagnosticsPageHtml_Title

#line 20 "DiagnosticsPage.cshtml"
Write(Resources.DiagnosticsPageHtml_Title);
#line default
#line hidden
);


#line default
#line hidden
WriteLiteral("</h1>\r\n <p>");
WriteLiteral("</title>\r\n</head>\r\n<body>\r\n <div class=\"main\">\r\n <h1>");
Write(
#line 20 "DiagnosticsPage.cshtml"
Resources.DiagnosticsPageHtml_Title

#line 21 "DiagnosticsPage.cshtml"
Write(Resources.DiagnosticsPageHtml_Information);
#line default
#line hidden
);


#line default
#line hidden
WriteLiteral("</p>\r\n </div>\r\n <div");
WriteLiteral("</h1>\r\n <p>");
Write(
#line 21 "DiagnosticsPage.cshtml"
Resources.DiagnosticsPageHtml_Information

WriteLiteral(" class=\"errors\"");
#line default
#line hidden
);

WriteLiteral(">\r\n <h2>");
WriteLiteral("</p>\r\n </div>\r\n <div class=\"errors\">\r\n <h2>");
Write(
#line 24 "DiagnosticsPage.cshtml"
Resources.DiagnosticsPageHtml_TestErrorSection

#line 24 "DiagnosticsPage.cshtml"
Write(Resources.DiagnosticsPageHtml_TestErrorSection);
#line default
#line hidden
);


#line default
#line hidden
WriteLiteral("</h2>\r\n <p><a");
WriteLiteral("</h2>\r\n <p><a");
WriteAttribute("href", Tuple.Create(" href=\"", 767), Tuple.Create("\"", 858),
Tuple.Create(Tuple.Create("", 774), Tuple.Create<System.Object, System.Int32>(
#line 25 "DiagnosticsPage.cshtml"
Request.PathBase

WriteAttribute("href", Tuple.Create(" href=\"", 767), Tuple.Create("\"", 858)

#line 25 "DiagnosticsPage.cshtml"
, Tuple.Create(Tuple.Create("", 774), Tuple.Create<System.Object, System.Int32>(Request.PathBase

#line default
#line hidden
, 774), false)

#line 25 "DiagnosticsPage.cshtml"
, Tuple.Create(Tuple.Create("", 791), Tuple.Create<System.Object, System.Int32>(Request.Path

#line default
#line hidden
, 791), false)
, Tuple.Create(Tuple.Create("", 804), Tuple.Create("?error=", 804), true)

#line 25 "DiagnosticsPage.cshtml"
, Tuple.Create(Tuple.Create("", 811), Tuple.Create<System.Object, System.Int32>(Resources.DiagnosticsPageHtml_TestErrorMessage

#line default
#line hidden
, 811), false)
);
#line default
#line hidden
, 774), false),
Tuple.Create(Tuple.Create("", 791), Tuple.Create<System.Object, System.Int32>(
#line 25 "DiagnosticsPage.cshtml"
Request.Path

WriteLiteral(">throw InvalidOperationException</a></p>\r\n </div>\r\n</body>\r\n</html>\r\n");
#line default
#line hidden
, 791), false), Tuple.Create(Tuple.Create("", 804), Tuple.Create("?error=", 804), true),
Tuple.Create(Tuple.Create("", 811), Tuple.Create<System.Object, System.Int32>(
#line 25 "DiagnosticsPage.cshtml"
Resources.DiagnosticsPageHtml_TestErrorMessage

#line default
#line hidden
, 811), false));
WriteLiteral(">throw InvalidOperationException</a></p>\r\n </div>\r\n</body>\r\n</html>\r\n");
}
}
}

26 changes: 0 additions & 26 deletions src/Microsoft.AspNet.Diagnostics/Views/DiagnosticsPage.tt

This file was deleted.

Loading

0 comments on commit b4de33e

Please sign in to comment.