Skip to content

Commit b4de33e

Browse files
committed
Added a console app to generate the Razor pages
- 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
1 parent a78d5ac commit b4de33e

17 files changed

+4737
-5495
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ nuget.exe
2121
*DS_Store
2222
*.ncrunchsolution
2323
*.*sdf
24-
*.ipch
24+
*.ipch
25+
*.sln.ide

DiagnosticsPages.sln

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 2013
4-
VisualStudioVersion = 12.0.30327.0
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.21628.1
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{509A6F36-AD80-4A18-B5B1-717D38DFF29D}"
77
EndProject
@@ -13,6 +13,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Diagnostic
1313
EndProject
1414
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ErrorPageSample", "samples\ErrorPageSample\ErrorPageSample.kproj", "{589AC17F-9455-4764-8F82-FCD2AE58DA14}"
1515
EndProject
16+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "PageGenerator", "src\PageGenerator\PageGenerator.kproj", "{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}"
17+
EndProject
1618
Global
1719
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1820
Debug|Any CPU = Debug|Any CPU
@@ -51,6 +53,15 @@ Global
5153
{589AC17F-9455-4764-8F82-FCD2AE58DA14}.Release|Mixed Platforms.Build.0 = Release|x86
5254
{589AC17F-9455-4764-8F82-FCD2AE58DA14}.Release|x86.ActiveCfg = Release|x86
5355
{589AC17F-9455-4764-8F82-FCD2AE58DA14}.Release|x86.Build.0 = Release|x86
56+
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Debug|Any CPU.ActiveCfg = Debug|x86
57+
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
58+
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Debug|x86.ActiveCfg = Debug|x86
59+
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Debug|x86.Build.0 = Debug|x86
60+
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Release|Any CPU.ActiveCfg = Release|x86
61+
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Release|Mixed Platforms.ActiveCfg = Release|x86
62+
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Release|Mixed Platforms.Build.0 = Release|x86
63+
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Release|x86.ActiveCfg = Release|x86
64+
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74}.Release|x86.Build.0 = Release|x86
5465
EndGlobalSection
5566
GlobalSection(SolutionProperties) = preSolution
5667
HideSolutionNode = FALSE
@@ -59,5 +70,6 @@ Global
5970
{C5F59CBA-DF2D-4983-8CBB-11B6AF21B416} = {ACAA0157-A8C4-4152-93DE-90CCDF304087}
6071
{68A1F0E1-ECCE-46D1-B20F-C43EE5B097DE} = {509A6F36-AD80-4A18-B5B1-717D38DFF29D}
6172
{589AC17F-9455-4764-8F82-FCD2AE58DA14} = {ACAA0157-A8C4-4152-93DE-90CCDF304087}
73+
{4D4A785A-ECB9-4916-A88F-0FD306EE3B74} = {509A6F36-AD80-4A18-B5B1-717D38DFF29D}
6274
EndGlobalSection
6375
EndGlobal

src/Microsoft.AspNet.Diagnostics/ErrorPageMiddleware.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public async Task Invoke(HttpContext context)
6060
{
6161
try
6262
{
63-
DisplayException(context, ex);
63+
await DisplayException(context, ex);
6464
return;
6565
}
6666
catch (Exception)
@@ -72,7 +72,7 @@ public async Task Invoke(HttpContext context)
7272
}
7373

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

@@ -103,7 +103,7 @@ private void DisplayException(HttpContext context, Exception ex)
103103
}*/
104104

105105
var errorPage = new ErrorPage() { Model = model };
106-
errorPage.Execute(context);
106+
await errorPage.ExecuteAsync(context);
107107
}
108108

109109
private IEnumerable<ErrorDetails> GetErrorDetails(Exception ex, bool showSource)

src/Microsoft.AspNet.Diagnostics/Microsoft.AspNet.Diagnostics.kproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@
2020
<Content Include="Project.json" />
2121
<Content Include="Resources.resx" />
2222
<Content Include="Views\DiagnosticsPage.cshtml" />
23-
<Content Include="Views\DiagnosticsPage.tt" />
2423
<Content Include="Views\ErrorPage.cshtml" />
2524
<Content Include="Views\ErrorPage.css" />
2625
<Content Include="Views\ErrorPage.js" />
27-
<Content Include="Views\ErrorPage.tt" />
2826
<Content Include="Views\WelcomePage.cshtml" />
29-
<Content Include="Views\WelcomePage.tt" />
3027
</ItemGroup>
3128
<ItemGroup>
3229
<Compile Include="Constants.cs" />

src/Microsoft.AspNet.Diagnostics/Views/BaseView.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Globalization;
66
using System.IO;
77
using System.Net;
8+
using System.Threading.Tasks;
89

910
namespace Microsoft.AspNet.Diagnostics.Views
1011
{
@@ -37,20 +38,20 @@ public abstract class BaseView
3738
/// Execute an individual request
3839
/// </summary>
3940
/// <param name="context"></param>
40-
public void Execute(HttpContext context)
41+
public async Task ExecuteAsync(HttpContext context)
4142
{
4243
Context = context;
4344
Request = Context.Request;
4445
Response = Context.Response;
4546
Output = new StreamWriter(Response.Body);
46-
Execute();
47+
await ExecuteAsync();
4748
Output.Dispose();
4849
}
4950

5051
/// <summary>
5152
/// Execute an individual request
5253
/// </summary>
53-
public abstract void Execute();
54+
public abstract Task ExecuteAsync();
5455

5556
/// <summary>
5657
/// Write the given value directly to the output
Lines changed: 76 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,29 @@
1-
//------------------------------------------------------------------------------
2-
// <auto-generated>
3-
// This code was generated by a tool.
4-
// Runtime Version:4.0.30319.18213
5-
//
6-
// Changes to this file may cause incorrect behavior and will be lost if
7-
// the code is regenerated.
8-
// </auto-generated>
9-
//------------------------------------------------------------------------------
10-
11-
namespace Microsoft.AspNet.Diagnostics.Views {
12-
13-
#line 1 "DiagnosticsPage.cshtml"
14-
using System;
15-
16-
#line default
17-
#line hidden
18-
19-
#line 2 "DiagnosticsPage.cshtml"
20-
using System.Globalization;
21-
22-
#line default
23-
#line hidden
24-
25-
26-
public class DiagnosticsPage : Microsoft.AspNet.Diagnostics.Views.BaseView {
27-
1+
namespace Microsoft.AspNet.Diagnostics.Views
2+
{
3+
#line 1 "DiagnosticsPage.cshtml"
4+
using System
5+
6+
#line default
7+
#line hidden
8+
;
9+
#line 2 "DiagnosticsPage.cshtml"
10+
using System.Globalization
11+
12+
#line default
2813
#line hidden
29-
30-
public DiagnosticsPage() {
14+
;
15+
using System.Threading.Tasks;
16+
17+
public class DiagnosticsPage : Microsoft.AspNet.Diagnostics.Views.BaseView
18+
{
19+
#line hidden
20+
public DiagnosticsPage()
21+
{
3122
}
32-
33-
public override void Execute() {
34-
35-
#line 3 "DiagnosticsPage.cshtml"
23+
24+
public override async Task ExecuteAsync()
25+
{
26+
#line 3 "DiagnosticsPage.cshtml"
3627

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

44-
45-
#line default
46-
#line hidden
47-
WriteLiteral("\r\n<!DOCTYPE html>\r\n\r\n<html");
48-
49-
WriteLiteral(" lang=\"en\"");
50-
51-
WriteLiteral(" xmlns=\"http://www.w3.org/1999/xhtml\"");
52-
53-
WriteLiteral(">\r\n<head>\r\n <meta");
54-
55-
WriteLiteral(" charset=\"utf-8\"");
56-
57-
WriteLiteral(" />\r\n <title>");
58-
59-
60-
#line 16 "DiagnosticsPage.cshtml"
61-
Write(Resources.DiagnosticsPageHtml_Title);
62-
63-
64-
#line default
65-
#line hidden
66-
WriteLiteral("</title>\r\n</head>\r\n<body>\r\n <div");
67-
68-
WriteLiteral(" class=\"main\"");
35+
#line default
36+
#line hidden
6937

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

72-
73-
#line 20 "DiagnosticsPage.cshtml"
74-
Write(Resources.DiagnosticsPageHtml_Title);
44+
#line default
45+
#line hidden
46+
);
7547

76-
77-
#line default
78-
#line hidden
79-
WriteLiteral("</h1>\r\n <p>");
48+
WriteLiteral("</title>\r\n</head>\r\n<body>\r\n <div class=\"main\">\r\n <h1>");
49+
Write(
50+
#line 20 "DiagnosticsPage.cshtml"
51+
Resources.DiagnosticsPageHtml_Title
8052

81-
82-
#line 21 "DiagnosticsPage.cshtml"
83-
Write(Resources.DiagnosticsPageHtml_Information);
53+
#line default
54+
#line hidden
55+
);
8456

85-
86-
#line default
87-
#line hidden
88-
WriteLiteral("</p>\r\n </div>\r\n <div");
57+
WriteLiteral("</h1>\r\n <p>");
58+
Write(
59+
#line 21 "DiagnosticsPage.cshtml"
60+
Resources.DiagnosticsPageHtml_Information
8961

90-
WriteLiteral(" class=\"errors\"");
62+
#line default
63+
#line hidden
64+
);
9165

92-
WriteLiteral(">\r\n <h2>");
66+
WriteLiteral("</p>\r\n </div>\r\n <div class=\"errors\">\r\n <h2>");
67+
Write(
68+
#line 24 "DiagnosticsPage.cshtml"
69+
Resources.DiagnosticsPageHtml_TestErrorSection
9370

94-
95-
#line 24 "DiagnosticsPage.cshtml"
96-
Write(Resources.DiagnosticsPageHtml_TestErrorSection);
71+
#line default
72+
#line hidden
73+
);
9774

98-
99-
#line default
100-
#line hidden
101-
WriteLiteral("</h2>\r\n <p><a");
75+
WriteLiteral("</h2>\r\n <p><a");
76+
WriteAttribute("href", Tuple.Create(" href=\"", 767), Tuple.Create("\"", 858),
77+
Tuple.Create(Tuple.Create("", 774), Tuple.Create<System.Object, System.Int32>(
78+
#line 25 "DiagnosticsPage.cshtml"
79+
Request.PathBase
10280

103-
WriteAttribute("href", Tuple.Create(" href=\"", 767), Tuple.Create("\"", 858)
104-
105-
#line 25 "DiagnosticsPage.cshtml"
106-
, Tuple.Create(Tuple.Create("", 774), Tuple.Create<System.Object, System.Int32>(Request.PathBase
107-
108-
#line default
109-
#line hidden
110-
, 774), false)
111-
112-
#line 25 "DiagnosticsPage.cshtml"
113-
, Tuple.Create(Tuple.Create("", 791), Tuple.Create<System.Object, System.Int32>(Request.Path
114-
115-
#line default
116-
#line hidden
117-
, 791), false)
118-
, Tuple.Create(Tuple.Create("", 804), Tuple.Create("?error=", 804), true)
119-
120-
#line 25 "DiagnosticsPage.cshtml"
121-
, Tuple.Create(Tuple.Create("", 811), Tuple.Create<System.Object, System.Int32>(Resources.DiagnosticsPageHtml_TestErrorMessage
122-
123-
#line default
124-
#line hidden
125-
, 811), false)
126-
);
81+
#line default
82+
#line hidden
83+
, 774), false),
84+
Tuple.Create(Tuple.Create("", 791), Tuple.Create<System.Object, System.Int32>(
85+
#line 25 "DiagnosticsPage.cshtml"
86+
Request.Path
12787

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

95+
#line default
96+
#line hidden
97+
, 811), false));
98+
WriteLiteral(">throw InvalidOperationException</a></p>\r\n </div>\r\n</body>\r\n</html>\r\n");
13099
}
131100
}
132101
}
133-

src/Microsoft.AspNet.Diagnostics/Views/DiagnosticsPage.tt

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)