Refactor attribute parsing (dotnet/aspnetcore-tooling#3)

\n\nCommit migrated from b7441d433f
This commit is contained in:
Ajay Bhargav Baaskaran 2018-12-03 12:24:12 -08:00 committed by GitHub
parent f2bc93d0f6
commit 19f5798c2a
52 changed files with 905 additions and 518 deletions

View File

@ -53,7 +53,8 @@ Document -
IntermediateToken - (153:7,30 [3] Basic.cshtml) - CSharp - cls
IntermediateToken - (156:7,33 [2] Basic.cshtml) - CSharp - }
HtmlContent - (159:7,36 [5] Basic.cshtml)
IntermediateToken - (159:7,36 [3] Basic.cshtml) - Html - />
IntermediateToken - (159:7,36 [1] Basic.cshtml) - Html -
IntermediateToken - (160:7,37 [2] Basic.cshtml) - Html - />
IntermediateToken - (162:7,39 [2] Basic.cshtml) - Html - \n
Inject -
Inject -

View File

@ -41,14 +41,16 @@ Document -
IntermediateToken - (68:4,2 [46] Sections.cshtml) - CSharp - \n Layout = "_SectionTestLayout.cshtml";\n
HtmlContent - (117:7,0 [26] Sections.cshtml)
IntermediateToken - (117:7,0 [2] Sections.cshtml) - Html - \n
IntermediateToken - (119:8,0 [5] Sections.cshtml) - Html - <div>
IntermediateToken - (119:8,0 [4] Sections.cshtml) - Html - <div
IntermediateToken - (123:8,4 [1] Sections.cshtml) - Html - >
IntermediateToken - (124:8,5 [9] Sections.cshtml) - Html - Some body
IntermediateToken - (133:8,14 [6] Sections.cshtml) - Html - </div>
IntermediateToken - (139:8,20 [4] Sections.cshtml) - Html - \n\n
Section - - Section1
HtmlContent - (162:10,19 [43] Sections.cshtml)
IntermediateToken - (162:10,19 [6] Sections.cshtml) - Html - \n
IntermediateToken - (168:11,4 [5] Sections.cshtml) - Html - <div>
IntermediateToken - (168:11,4 [4] Sections.cshtml) - Html - <div
IntermediateToken - (172:11,8 [1] Sections.cshtml) - Html - >
IntermediateToken - (173:11,9 [20] Sections.cshtml) - Html - This is in Section 1
IntermediateToken - (193:11,29 [6] Sections.cshtml) - Html - </div>
IntermediateToken - (199:11,35 [6] Sections.cshtml) - Html - \n

View File

@ -55,7 +55,8 @@ Document -
IntermediateToken - (153:7,30 [3] Basic.cshtml) - CSharp - cls
IntermediateToken - (156:7,33 [2] Basic.cshtml) - CSharp - }
HtmlContent - (159:7,36 [5] Basic.cshtml)
IntermediateToken - (159:7,36 [3] Basic.cshtml) - Html - />
IntermediateToken - (159:7,36 [1] Basic.cshtml) - Html -
IntermediateToken - (160:7,37 [2] Basic.cshtml) - Html - />
IntermediateToken - (162:7,39 [2] Basic.cshtml) - Html - \n
Inject -
Inject -

View File

@ -65,7 +65,8 @@ Document -
CSharpCode -
IntermediateToken - - CSharp - BeginContext(159, 5, true);
HtmlContent - (159:7,36 [5] Basic.cshtml)
IntermediateToken - (159:7,36 [3] Basic.cshtml) - Html - />
IntermediateToken - (159:7,36 [1] Basic.cshtml) - Html -
IntermediateToken - (160:7,37 [2] Basic.cshtml) - Html - />
IntermediateToken - (162:7,39 [2] Basic.cshtml) - Html - \n
CSharpCode -
IntermediateToken - - CSharp - EndContext();

View File

@ -33,11 +33,13 @@ Document -
MalformedDirective - (0:0,0 [6] MalformedPageDirective.cshtml) - page
HtmlContent - (6:0,6 [49] MalformedPageDirective.cshtml)
IntermediateToken - (6:0,6 [8] MalformedPageDirective.cshtml) - Html - "foo\n\n
IntermediateToken - (14:2,0 [4] MalformedPageDirective.cshtml) - Html - <h1>
IntermediateToken - (14:2,0 [3] MalformedPageDirective.cshtml) - Html - <h1
IntermediateToken - (17:2,3 [1] MalformedPageDirective.cshtml) - Html - >
IntermediateToken - (18:2,4 [8] MalformedPageDirective.cshtml) - Html - About Us
IntermediateToken - (26:2,12 [5] MalformedPageDirective.cshtml) - Html - </h1>
IntermediateToken - (31:2,17 [2] MalformedPageDirective.cshtml) - Html - \n
IntermediateToken - (33:3,0 [3] MalformedPageDirective.cshtml) - Html - <p>
IntermediateToken - (33:3,0 [2] MalformedPageDirective.cshtml) - Html - <p
IntermediateToken - (35:3,2 [1] MalformedPageDirective.cshtml) - Html - >
IntermediateToken - (36:3,3 [15] MalformedPageDirective.cshtml) - Html - We are awesome.
IntermediateToken - (51:3,18 [4] MalformedPageDirective.cshtml) - Html - </p>
Inject -

View File

@ -18,11 +18,13 @@ Document -
IntermediateToken - - CSharp - BeginContext(6, 49, true);
HtmlContent - (6:0,6 [49] MalformedPageDirective.cshtml)
IntermediateToken - (6:0,6 [8] MalformedPageDirective.cshtml) - Html - "foo\n\n
IntermediateToken - (14:2,0 [4] MalformedPageDirective.cshtml) - Html - <h1>
IntermediateToken - (14:2,0 [3] MalformedPageDirective.cshtml) - Html - <h1
IntermediateToken - (17:2,3 [1] MalformedPageDirective.cshtml) - Html - >
IntermediateToken - (18:2,4 [8] MalformedPageDirective.cshtml) - Html - About Us
IntermediateToken - (26:2,12 [5] MalformedPageDirective.cshtml) - Html - </h1>
IntermediateToken - (31:2,17 [2] MalformedPageDirective.cshtml) - Html - \n
IntermediateToken - (33:3,0 [3] MalformedPageDirective.cshtml) - Html - <p>
IntermediateToken - (33:3,0 [2] MalformedPageDirective.cshtml) - Html - <p
IntermediateToken - (35:3,2 [1] MalformedPageDirective.cshtml) - Html - >
IntermediateToken - (36:3,3 [15] MalformedPageDirective.cshtml) - Html - We are awesome.
IntermediateToken - (51:3,18 [4] MalformedPageDirective.cshtml) - Html - </p>
CSharpCode -

View File

@ -32,7 +32,8 @@ Document -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
HtmlContent - (34:2,0 [20] PageWithNamespace.cshtml)
IntermediateToken - (34:2,0 [4] PageWithNamespace.cshtml) - Html - <h1>
IntermediateToken - (34:2,0 [3] PageWithNamespace.cshtml) - Html - <h1
IntermediateToken - (37:2,3 [1] PageWithNamespace.cshtml) - Html - >
IntermediateToken - (38:2,4 [9] PageWithNamespace.cshtml) - Html - Hi There!
IntermediateToken - (47:2,13 [5] PageWithNamespace.cshtml) - Html - </h1>
IntermediateToken - (52:2,18 [2] PageWithNamespace.cshtml) - Html - \n

View File

@ -16,7 +16,8 @@ Document -
CSharpCode -
IntermediateToken - - CSharp - BeginContext(34, 20, true);
HtmlContent - (34:2,0 [20] PageWithNamespace.cshtml)
IntermediateToken - (34:2,0 [4] PageWithNamespace.cshtml) - Html - <h1>
IntermediateToken - (34:2,0 [3] PageWithNamespace.cshtml) - Html - <h1
IntermediateToken - (37:2,3 [1] PageWithNamespace.cshtml) - Html - >
IntermediateToken - (38:2,4 [9] PageWithNamespace.cshtml) - Html - Hi There!
IntermediateToken - (47:2,13 [5] PageWithNamespace.cshtml) - Html - </h1>
IntermediateToken - (52:2,18 [2] PageWithNamespace.cshtml) - Html - \n

View File

@ -31,7 +31,8 @@ Document -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
HtmlContent - (0:0,0 [28] RazorPageWithNoLeadingPageDirective.cshtml)
IntermediateToken - (0:0,0 [5] RazorPageWithNoLeadingPageDirective.cshtml) - Html - <div>
IntermediateToken - (0:0,0 [4] RazorPageWithNoLeadingPageDirective.cshtml) - Html - <div
IntermediateToken - (4:0,4 [1] RazorPageWithNoLeadingPageDirective.cshtml) - Html - >
IntermediateToken - (5:0,5 [15] RazorPageWithNoLeadingPageDirective.cshtml) - Html - Some text here.
IntermediateToken - (20:0,20 [6] RazorPageWithNoLeadingPageDirective.cshtml) - Html - </div>
IntermediateToken - (26:0,26 [2] RazorPageWithNoLeadingPageDirective.cshtml) - Html - \n

View File

@ -16,7 +16,8 @@ Document -
CSharpCode -
IntermediateToken - - CSharp - BeginContext(0, 28, true);
HtmlContent - (0:0,0 [28] RazorPageWithNoLeadingPageDirective.cshtml)
IntermediateToken - (0:0,0 [5] RazorPageWithNoLeadingPageDirective.cshtml) - Html - <div>
IntermediateToken - (0:0,0 [4] RazorPageWithNoLeadingPageDirective.cshtml) - Html - <div
IntermediateToken - (4:0,4 [1] RazorPageWithNoLeadingPageDirective.cshtml) - Html - >
IntermediateToken - (5:0,5 [15] RazorPageWithNoLeadingPageDirective.cshtml) - Html - Some text here.
IntermediateToken - (20:0,20 [6] RazorPageWithNoLeadingPageDirective.cshtml) - Html - </div>
IntermediateToken - (26:0,26 [2] RazorPageWithNoLeadingPageDirective.cshtml) - Html - \n

View File

@ -40,7 +40,8 @@ Document -
IntermediateToken - (77:3,42 [4] RazorPagesWithRouteTemplate.cshtml) - Html - \n\n
HtmlContent - (191:10,1 [21] RazorPagesWithRouteTemplate.cshtml)
IntermediateToken - (191:10,1 [4] RazorPagesWithRouteTemplate.cshtml) - Html - \n\n
IntermediateToken - (195:12,0 [4] RazorPagesWithRouteTemplate.cshtml) - Html - <h1>
IntermediateToken - (195:12,0 [3] RazorPagesWithRouteTemplate.cshtml) - Html - <h1
IntermediateToken - (198:12,3 [1] RazorPagesWithRouteTemplate.cshtml) - Html - >
IntermediateToken - (199:12,4 [13] RazorPagesWithRouteTemplate.cshtml) - Html - New Customer
CSharpExpression - (213:12,18 [10] RazorPagesWithRouteTemplate.cshtml)
IntermediateToken - (213:12,18 [10] RazorPagesWithRouteTemplate.cshtml) - CSharp - Model.Name

View File

@ -31,7 +31,8 @@ Document -
IntermediateToken - - CSharp - BeginContext(193, 19, true);
HtmlContent - (193:11,0 [19] RazorPagesWithRouteTemplate.cshtml)
IntermediateToken - (193:11,0 [2] RazorPagesWithRouteTemplate.cshtml) - Html - \n
IntermediateToken - (195:12,0 [4] RazorPagesWithRouteTemplate.cshtml) - Html - <h1>
IntermediateToken - (195:12,0 [3] RazorPagesWithRouteTemplate.cshtml) - Html - <h1
IntermediateToken - (198:12,3 [1] RazorPagesWithRouteTemplate.cshtml) - Html - >
IntermediateToken - (199:12,4 [13] RazorPagesWithRouteTemplate.cshtml) - Html - New Customer
CSharpCode -
IntermediateToken - - CSharp - EndContext();

View File

@ -42,7 +42,8 @@ Document -
IntermediateToken - (79:3,42 [4] RazorPagesWithoutModel.cshtml) - Html - \n\n
HtmlContent - (379:18,1 [77] RazorPagesWithoutModel.cshtml)
IntermediateToken - (379:18,1 [4] RazorPagesWithoutModel.cshtml) - Html - \n\n
IntermediateToken - (383:20,0 [4] RazorPagesWithoutModel.cshtml) - Html - <h1>
IntermediateToken - (383:20,0 [3] RazorPagesWithoutModel.cshtml) - Html - <h1
IntermediateToken - (386:20,3 [1] RazorPagesWithoutModel.cshtml) - Html - >
IntermediateToken - (387:20,4 [12] RazorPagesWithoutModel.cshtml) - Html - New Customer
IntermediateToken - (399:20,16 [5] RazorPagesWithoutModel.cshtml) - Html - </h1>
IntermediateToken - (404:20,21 [2] RazorPagesWithoutModel.cshtml) - Html - \n
@ -78,7 +79,8 @@ Document -
IntermediateToken - (611:25,31 [14] RazorPagesWithoutModel.cshtml) - Html - \n
IntermediateToken - (625:26,12 [6] RazorPagesWithoutModel.cshtml) - Html - <input
IntermediateToken - (631:26,18 [21] RazorPagesWithoutModel.cshtml) - Html - class="form-control"
IntermediateToken - (652:26,39 [3] RazorPagesWithoutModel.cshtml) - Html - />
IntermediateToken - (652:26,39 [1] RazorPagesWithoutModel.cshtml) - Html -
IntermediateToken - (653:26,40 [2] RazorPagesWithoutModel.cshtml) - Html - />
IntermediateToken - (655:26,42 [14] RazorPagesWithoutModel.cshtml) - Html - \n
IntermediateToken - (669:27,12 [5] RazorPagesWithoutModel.cshtml) - Html - <span
IntermediateToken - (674:27,17 [20] RazorPagesWithoutModel.cshtml) - Html - class="text-danger"

View File

@ -36,7 +36,8 @@ Document -
IntermediateToken - - CSharp - BeginContext(381, 75, true);
HtmlContent - (381:19,0 [75] RazorPagesWithoutModel.cshtml)
IntermediateToken - (381:19,0 [2] RazorPagesWithoutModel.cshtml) - Html - \n
IntermediateToken - (383:20,0 [4] RazorPagesWithoutModel.cshtml) - Html - <h1>
IntermediateToken - (383:20,0 [3] RazorPagesWithoutModel.cshtml) - Html - <h1
IntermediateToken - (386:20,3 [1] RazorPagesWithoutModel.cshtml) - Html - >
IntermediateToken - (387:20,4 [12] RazorPagesWithoutModel.cshtml) - Html - New Customer
IntermediateToken - (399:20,16 [5] RazorPagesWithoutModel.cshtml) - Html - </h1>
IntermediateToken - (404:20,21 [2] RazorPagesWithoutModel.cshtml) - Html - \n
@ -98,7 +99,8 @@ Document -
IntermediateToken - (611:25,31 [14] RazorPagesWithoutModel.cshtml) - Html - \n
IntermediateToken - (625:26,12 [6] RazorPagesWithoutModel.cshtml) - Html - <input
IntermediateToken - (631:26,18 [21] RazorPagesWithoutModel.cshtml) - Html - class="form-control"
IntermediateToken - (652:26,39 [3] RazorPagesWithoutModel.cshtml) - Html - />
IntermediateToken - (652:26,39 [1] RazorPagesWithoutModel.cshtml) - Html -
IntermediateToken - (653:26,40 [2] RazorPagesWithoutModel.cshtml) - Html - />
IntermediateToken - (655:26,42 [14] RazorPagesWithoutModel.cshtml) - Html - \n
IntermediateToken - (669:27,12 [5] RazorPagesWithoutModel.cshtml) - Html - <span
IntermediateToken - (674:27,17 [20] RazorPagesWithoutModel.cshtml) - Html - class="text-danger"

View File

@ -43,14 +43,16 @@ Document -
IntermediateToken - (96:4,42 [4] RazorPages.cshtml) - Html - \n\n
HtmlContent - (473:22,1 [78] RazorPages.cshtml)
IntermediateToken - (473:22,1 [4] RazorPages.cshtml) - Html - \n\n
IntermediateToken - (477:24,0 [4] RazorPages.cshtml) - Html - <h1>
IntermediateToken - (477:24,0 [3] RazorPages.cshtml) - Html - <h1
IntermediateToken - (480:24,3 [1] RazorPages.cshtml) - Html - >
IntermediateToken - (481:24,4 [12] RazorPages.cshtml) - Html - New Customer
IntermediateToken - (493:24,16 [5] RazorPages.cshtml) - Html - </h1>
IntermediateToken - (498:24,21 [2] RazorPages.cshtml) - Html - \n
IntermediateToken - (500:25,0 [5] RazorPages.cshtml) - Html - <form
IntermediateToken - (505:25,5 [14] RazorPages.cshtml) - Html - method="post"
IntermediateToken - (519:25,19 [24] RazorPages.cshtml) - Html - class="form-horizontal"
IntermediateToken - (543:25,43 [2] RazorPages.cshtml) - Html - >
IntermediateToken - (543:25,43 [1] RazorPages.cshtml) - Html -
IntermediateToken - (544:25,44 [1] RazorPages.cshtml) - Html - >
IntermediateToken - (545:25,45 [6] RazorPages.cshtml) - Html - \n
TagHelper - (551:26,4 [31] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag
DefaultTagHelperBody -
@ -79,7 +81,8 @@ Document -
IntermediateToken - (712:29,31 [14] RazorPages.cshtml) - Html - \n
IntermediateToken - (726:30,12 [6] RazorPages.cshtml) - Html - <input
IntermediateToken - (732:30,18 [21] RazorPages.cshtml) - Html - class="form-control"
IntermediateToken - (753:30,39 [3] RazorPages.cshtml) - Html - />
IntermediateToken - (753:30,39 [1] RazorPages.cshtml) - Html -
IntermediateToken - (754:30,40 [2] RazorPages.cshtml) - Html - />
IntermediateToken - (756:30,42 [14] RazorPages.cshtml) - Html - \n
IntermediateToken - (770:31,12 [5] RazorPages.cshtml) - Html - <span
IntermediateToken - (775:31,17 [20] RazorPages.cshtml) - Html - class="text-danger"

View File

@ -36,14 +36,16 @@ Document -
IntermediateToken - - CSharp - BeginContext(475, 76, true);
HtmlContent - (475:23,0 [76] RazorPages.cshtml)
IntermediateToken - (475:23,0 [2] RazorPages.cshtml) - Html - \n
IntermediateToken - (477:24,0 [4] RazorPages.cshtml) - Html - <h1>
IntermediateToken - (477:24,0 [3] RazorPages.cshtml) - Html - <h1
IntermediateToken - (480:24,3 [1] RazorPages.cshtml) - Html - >
IntermediateToken - (481:24,4 [12] RazorPages.cshtml) - Html - New Customer
IntermediateToken - (493:24,16 [5] RazorPages.cshtml) - Html - </h1>
IntermediateToken - (498:24,21 [2] RazorPages.cshtml) - Html - \n
IntermediateToken - (500:25,0 [5] RazorPages.cshtml) - Html - <form
IntermediateToken - (505:25,5 [14] RazorPages.cshtml) - Html - method="post"
IntermediateToken - (519:25,19 [24] RazorPages.cshtml) - Html - class="form-horizontal"
IntermediateToken - (543:25,43 [2] RazorPages.cshtml) - Html - >
IntermediateToken - (543:25,43 [1] RazorPages.cshtml) - Html -
IntermediateToken - (544:25,44 [1] RazorPages.cshtml) - Html - >
IntermediateToken - (545:25,45 [6] RazorPages.cshtml) - Html - \n
CSharpCode -
IntermediateToken - - CSharp - EndContext();
@ -98,7 +100,8 @@ Document -
IntermediateToken - (712:29,31 [14] RazorPages.cshtml) - Html - \n
IntermediateToken - (726:30,12 [6] RazorPages.cshtml) - Html - <input
IntermediateToken - (732:30,18 [21] RazorPages.cshtml) - Html - class="form-control"
IntermediateToken - (753:30,39 [3] RazorPages.cshtml) - Html - />
IntermediateToken - (753:30,39 [1] RazorPages.cshtml) - Html -
IntermediateToken - (754:30,40 [2] RazorPages.cshtml) - Html - />
IntermediateToken - (756:30,42 [14] RazorPages.cshtml) - Html - \n
IntermediateToken - (770:31,12 [5] RazorPages.cshtml) - Html - <span
IntermediateToken - (775:31,17 [20] RazorPages.cshtml) - Html - class="text-danger"

View File

@ -43,14 +43,16 @@ Document -
IntermediateToken - (68:4,2 [46] Sections.cshtml) - CSharp - \n Layout = "_SectionTestLayout.cshtml";\n
HtmlContent - (117:7,0 [26] Sections.cshtml)
IntermediateToken - (117:7,0 [2] Sections.cshtml) - Html - \n
IntermediateToken - (119:8,0 [5] Sections.cshtml) - Html - <div>
IntermediateToken - (119:8,0 [4] Sections.cshtml) - Html - <div
IntermediateToken - (123:8,4 [1] Sections.cshtml) - Html - >
IntermediateToken - (124:8,5 [9] Sections.cshtml) - Html - Some body
IntermediateToken - (133:8,14 [6] Sections.cshtml) - Html - </div>
IntermediateToken - (139:8,20 [4] Sections.cshtml) - Html - \n\n
Section - - Section1
HtmlContent - (162:10,19 [43] Sections.cshtml)
IntermediateToken - (162:10,19 [6] Sections.cshtml) - Html - \n
IntermediateToken - (168:11,4 [5] Sections.cshtml) - Html - <div>
IntermediateToken - (168:11,4 [4] Sections.cshtml) - Html - <div
IntermediateToken - (172:11,8 [1] Sections.cshtml) - Html - >
IntermediateToken - (173:11,9 [20] Sections.cshtml) - Html - This is in Section 1
IntermediateToken - (193:11,29 [6] Sections.cshtml) - Html - </div>
IntermediateToken - (199:11,35 [6] Sections.cshtml) - Html - \n

View File

@ -33,7 +33,8 @@ Document -
IntermediateToken - - CSharp - BeginContext(117, 26, true);
HtmlContent - (117:7,0 [26] Sections.cshtml)
IntermediateToken - (117:7,0 [2] Sections.cshtml) - Html - \n
IntermediateToken - (119:8,0 [5] Sections.cshtml) - Html - <div>
IntermediateToken - (119:8,0 [4] Sections.cshtml) - Html - <div
IntermediateToken - (123:8,4 [1] Sections.cshtml) - Html - >
IntermediateToken - (124:8,5 [9] Sections.cshtml) - Html - Some body
IntermediateToken - (133:8,14 [6] Sections.cshtml) - Html - </div>
IntermediateToken - (139:8,20 [4] Sections.cshtml) - Html - \n\n
@ -44,7 +45,8 @@ Document -
IntermediateToken - - CSharp - BeginContext(162, 43, true);
HtmlContent - (162:10,19 [43] Sections.cshtml)
IntermediateToken - (162:10,19 [6] Sections.cshtml) - Html - \n
IntermediateToken - (168:11,4 [5] Sections.cshtml) - Html - <div>
IntermediateToken - (168:11,4 [4] Sections.cshtml) - Html - <div
IntermediateToken - (172:11,8 [1] Sections.cshtml) - Html - >
IntermediateToken - (173:11,9 [20] Sections.cshtml) - Html - This is in Section 1
IntermediateToken - (193:11,29 [6] Sections.cshtml) - Html - </div>
IntermediateToken - (199:11,35 [6] Sections.cshtml) - Html - \n

View File

@ -32,7 +32,8 @@ Document -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
HtmlContent - (27:1,0 [20] ViewWithNamespace.cshtml)
IntermediateToken - (27:1,0 [4] ViewWithNamespace.cshtml) - Html - <h1>
IntermediateToken - (27:1,0 [3] ViewWithNamespace.cshtml) - Html - <h1
IntermediateToken - (30:1,3 [1] ViewWithNamespace.cshtml) - Html - >
IntermediateToken - (31:1,4 [9] ViewWithNamespace.cshtml) - Html - Hi There!
IntermediateToken - (40:1,13 [5] ViewWithNamespace.cshtml) - Html - </h1>
IntermediateToken - (45:1,18 [2] ViewWithNamespace.cshtml) - Html - \n

View File

@ -16,7 +16,8 @@ Document -
CSharpCode -
IntermediateToken - - CSharp - BeginContext(27, 20, true);
HtmlContent - (27:1,0 [20] ViewWithNamespace.cshtml)
IntermediateToken - (27:1,0 [4] ViewWithNamespace.cshtml) - Html - <h1>
IntermediateToken - (27:1,0 [3] ViewWithNamespace.cshtml) - Html - <h1
IntermediateToken - (30:1,3 [1] ViewWithNamespace.cshtml) - Html - >
IntermediateToken - (31:1,4 [9] ViewWithNamespace.cshtml) - Html - Hi There!
IntermediateToken - (40:1,13 [5] ViewWithNamespace.cshtml) - Html - </h1>
IntermediateToken - (45:1,18 [2] ViewWithNamespace.cshtml) - Html - \n

View File

@ -71,7 +71,8 @@ Document -
IntermediateToken - - CSharp - BeginContext(158, 31, true);
HtmlContent - (158:5,7 [31] BasicTest.cshtml)
IntermediateToken - (158:5,7 [4] BasicTest.cshtml) - Html - \n\n
IntermediateToken - (162:7,0 [6] BasicTest.cshtml) - Html - <span>
IntermediateToken - (162:7,0 [5] BasicTest.cshtml) - Html - <span
IntermediateToken - (167:7,5 [1] BasicTest.cshtml) - Html - >
IntermediateToken - (168:7,6 [21] BasicTest.cshtml) - Html - Here is some content
CSharpCode -
IntermediateToken - - CSharp - EndContext();
@ -90,7 +91,8 @@ Document -
CSharpCode -
IntermediateToken - - CSharp - BeginContext(222, 24, true);
HtmlContent - (222:8,6 [24] BasicTest.cshtml)
IntermediateToken - (222:8,6 [6] BasicTest.cshtml) - Html - <span>
IntermediateToken - (222:8,6 [5] BasicTest.cshtml) - Html - <span
IntermediateToken - (227:8,11 [1] BasicTest.cshtml) - Html - >
IntermediateToken - (228:8,12 [11] BasicTest.cshtml) - Html - Hello world
IntermediateToken - (239:8,23 [7] BasicTest.cshtml) - Html - </span>
CSharpCode -

View File

@ -55,7 +55,8 @@ Document -
IntermediateToken - (153:7,30 [3] Basic.cshtml) - CSharp - cls
IntermediateToken - (156:7,33 [2] Basic.cshtml) - CSharp - }
HtmlContent - (159:7,36 [5] Basic.cshtml)
IntermediateToken - (159:7,36 [3] Basic.cshtml) - Html - />
IntermediateToken - (159:7,36 [1] Basic.cshtml) - Html -
IntermediateToken - (160:7,37 [2] Basic.cshtml) - Html - />
IntermediateToken - (162:7,39 [2] Basic.cshtml) - Html - \n
Inject -
Inject -

View File

@ -39,7 +39,8 @@ Document -
IntermediateToken - (153:7,30 [3] Basic.cshtml) - CSharp - cls
IntermediateToken - (156:7,33 [2] Basic.cshtml) - CSharp - }
HtmlContent - (159:7,36 [5] Basic.cshtml)
IntermediateToken - (159:7,36 [3] Basic.cshtml) - Html - />
IntermediateToken - (159:7,36 [1] Basic.cshtml) - Html -
IntermediateToken - (160:7,37 [2] Basic.cshtml) - Html - />
IntermediateToken - (162:7,39 [2] Basic.cshtml) - Html - \n
Inject -
Inject -

View File

@ -33,11 +33,13 @@ Document -
MalformedDirective - (0:0,0 [6] MalformedPageDirective.cshtml) - page
HtmlContent - (6:0,6 [49] MalformedPageDirective.cshtml)
IntermediateToken - (6:0,6 [8] MalformedPageDirective.cshtml) - Html - "foo\n\n
IntermediateToken - (14:2,0 [4] MalformedPageDirective.cshtml) - Html - <h1>
IntermediateToken - (14:2,0 [3] MalformedPageDirective.cshtml) - Html - <h1
IntermediateToken - (17:2,3 [1] MalformedPageDirective.cshtml) - Html - >
IntermediateToken - (18:2,4 [8] MalformedPageDirective.cshtml) - Html - About Us
IntermediateToken - (26:2,12 [5] MalformedPageDirective.cshtml) - Html - </h1>
IntermediateToken - (31:2,17 [2] MalformedPageDirective.cshtml) - Html - \n
IntermediateToken - (33:3,0 [3] MalformedPageDirective.cshtml) - Html - <p>
IntermediateToken - (33:3,0 [2] MalformedPageDirective.cshtml) - Html - <p
IntermediateToken - (35:3,2 [1] MalformedPageDirective.cshtml) - Html - >
IntermediateToken - (36:3,3 [15] MalformedPageDirective.cshtml) - Html - We are awesome.
IntermediateToken - (51:3,18 [4] MalformedPageDirective.cshtml) - Html - </p>
Inject -

View File

@ -16,11 +16,13 @@ Document -
MalformedDirective - (0:0,0 [6] MalformedPageDirective.cshtml) - page
HtmlContent - (6:0,6 [49] MalformedPageDirective.cshtml)
IntermediateToken - (6:0,6 [8] MalformedPageDirective.cshtml) - Html - "foo\n\n
IntermediateToken - (14:2,0 [4] MalformedPageDirective.cshtml) - Html - <h1>
IntermediateToken - (14:2,0 [3] MalformedPageDirective.cshtml) - Html - <h1
IntermediateToken - (17:2,3 [1] MalformedPageDirective.cshtml) - Html - >
IntermediateToken - (18:2,4 [8] MalformedPageDirective.cshtml) - Html - About Us
IntermediateToken - (26:2,12 [5] MalformedPageDirective.cshtml) - Html - </h1>
IntermediateToken - (31:2,17 [2] MalformedPageDirective.cshtml) - Html - \n
IntermediateToken - (33:3,0 [3] MalformedPageDirective.cshtml) - Html - <p>
IntermediateToken - (33:3,0 [2] MalformedPageDirective.cshtml) - Html - <p
IntermediateToken - (35:3,2 [1] MalformedPageDirective.cshtml) - Html - >
IntermediateToken - (36:3,3 [15] MalformedPageDirective.cshtml) - Html - We are awesome.
IntermediateToken - (51:3,18 [4] MalformedPageDirective.cshtml) - Html - </p>
Inject -

View File

@ -32,7 +32,8 @@ Document -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
HtmlContent - (34:2,0 [20] PageWithNamespace.cshtml)
IntermediateToken - (34:2,0 [4] PageWithNamespace.cshtml) - Html - <h1>
IntermediateToken - (34:2,0 [3] PageWithNamespace.cshtml) - Html - <h1
IntermediateToken - (37:2,3 [1] PageWithNamespace.cshtml) - Html - >
IntermediateToken - (38:2,4 [9] PageWithNamespace.cshtml) - Html - Hi There!
IntermediateToken - (47:2,13 [5] PageWithNamespace.cshtml) - Html - </h1>
IntermediateToken - (52:2,18 [2] PageWithNamespace.cshtml) - Html - \n

View File

@ -14,7 +14,8 @@ Document -
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PageWithNamespace - global::Microsoft.AspNetCore.Mvc.RazorPages.Page -
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
HtmlContent - (34:2,0 [20] PageWithNamespace.cshtml)
IntermediateToken - (34:2,0 [4] PageWithNamespace.cshtml) - Html - <h1>
IntermediateToken - (34:2,0 [3] PageWithNamespace.cshtml) - Html - <h1
IntermediateToken - (37:2,3 [1] PageWithNamespace.cshtml) - Html - >
IntermediateToken - (38:2,4 [9] PageWithNamespace.cshtml) - Html - Hi There!
IntermediateToken - (47:2,13 [5] PageWithNamespace.cshtml) - Html - </h1>
IntermediateToken - (52:2,18 [2] PageWithNamespace.cshtml) - Html - \n

View File

@ -31,7 +31,8 @@ Document -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
HtmlContent - (0:0,0 [28] RazorPageWithNoLeadingPageDirective.cshtml)
IntermediateToken - (0:0,0 [5] RazorPageWithNoLeadingPageDirective.cshtml) - Html - <div>
IntermediateToken - (0:0,0 [4] RazorPageWithNoLeadingPageDirective.cshtml) - Html - <div
IntermediateToken - (4:0,4 [1] RazorPageWithNoLeadingPageDirective.cshtml) - Html - >
IntermediateToken - (5:0,5 [15] RazorPageWithNoLeadingPageDirective.cshtml) - Html - Some text here.
IntermediateToken - (20:0,20 [6] RazorPageWithNoLeadingPageDirective.cshtml) - Html - </div>
IntermediateToken - (26:0,26 [2] RazorPageWithNoLeadingPageDirective.cshtml) - Html - \n

View File

@ -14,7 +14,8 @@ Document -
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPageWithNoLeadingPageDirective - global::Microsoft.AspNetCore.Mvc.RazorPages.Page -
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
HtmlContent - (0:0,0 [28] RazorPageWithNoLeadingPageDirective.cshtml)
IntermediateToken - (0:0,0 [5] RazorPageWithNoLeadingPageDirective.cshtml) - Html - <div>
IntermediateToken - (0:0,0 [4] RazorPageWithNoLeadingPageDirective.cshtml) - Html - <div
IntermediateToken - (4:0,4 [1] RazorPageWithNoLeadingPageDirective.cshtml) - Html - >
IntermediateToken - (5:0,5 [15] RazorPageWithNoLeadingPageDirective.cshtml) - Html - Some text here.
IntermediateToken - (20:0,20 [6] RazorPageWithNoLeadingPageDirective.cshtml) - Html - </div>
IntermediateToken - (26:0,26 [2] RazorPageWithNoLeadingPageDirective.cshtml) - Html - \n

View File

@ -40,7 +40,8 @@ Document -
IntermediateToken - (77:3,42 [4] RazorPagesWithRouteTemplate.cshtml) - Html - \n\n
HtmlContent - (191:10,1 [21] RazorPagesWithRouteTemplate.cshtml)
IntermediateToken - (191:10,1 [4] RazorPagesWithRouteTemplate.cshtml) - Html - \n\n
IntermediateToken - (195:12,0 [4] RazorPagesWithRouteTemplate.cshtml) - Html - <h1>
IntermediateToken - (195:12,0 [3] RazorPagesWithRouteTemplate.cshtml) - Html - <h1
IntermediateToken - (198:12,3 [1] RazorPagesWithRouteTemplate.cshtml) - Html - >
IntermediateToken - (199:12,4 [13] RazorPagesWithRouteTemplate.cshtml) - Html - New Customer
CSharpExpression - (213:12,18 [10] RazorPagesWithRouteTemplate.cshtml)
IntermediateToken - (213:12,18 [10] RazorPagesWithRouteTemplate.cshtml) - CSharp - Model.Name

View File

@ -21,7 +21,8 @@ Document -
IntermediateToken - (79:4,0 [2] RazorPagesWithRouteTemplate.cshtml) - Html - \n
HtmlContent - (193:11,0 [19] RazorPagesWithRouteTemplate.cshtml)
IntermediateToken - (193:11,0 [2] RazorPagesWithRouteTemplate.cshtml) - Html - \n
IntermediateToken - (195:12,0 [4] RazorPagesWithRouteTemplate.cshtml) - Html - <h1>
IntermediateToken - (195:12,0 [3] RazorPagesWithRouteTemplate.cshtml) - Html - <h1
IntermediateToken - (198:12,3 [1] RazorPagesWithRouteTemplate.cshtml) - Html - >
IntermediateToken - (199:12,4 [13] RazorPagesWithRouteTemplate.cshtml) - Html - New Customer
CSharpExpression - (213:12,18 [10] RazorPagesWithRouteTemplate.cshtml)
IntermediateToken - (213:12,18 [10] RazorPagesWithRouteTemplate.cshtml) - CSharp - Model.Name

View File

@ -42,7 +42,8 @@ Document -
IntermediateToken - (79:3,42 [4] RazorPagesWithoutModel.cshtml) - Html - \n\n
HtmlContent - (379:18,1 [77] RazorPagesWithoutModel.cshtml)
IntermediateToken - (379:18,1 [4] RazorPagesWithoutModel.cshtml) - Html - \n\n
IntermediateToken - (383:20,0 [4] RazorPagesWithoutModel.cshtml) - Html - <h1>
IntermediateToken - (383:20,0 [3] RazorPagesWithoutModel.cshtml) - Html - <h1
IntermediateToken - (386:20,3 [1] RazorPagesWithoutModel.cshtml) - Html - >
IntermediateToken - (387:20,4 [12] RazorPagesWithoutModel.cshtml) - Html - New Customer
IntermediateToken - (399:20,16 [5] RazorPagesWithoutModel.cshtml) - Html - </h1>
IntermediateToken - (404:20,21 [2] RazorPagesWithoutModel.cshtml) - Html - \n
@ -78,7 +79,8 @@ Document -
IntermediateToken - (611:25,31 [14] RazorPagesWithoutModel.cshtml) - Html - \n
IntermediateToken - (625:26,12 [6] RazorPagesWithoutModel.cshtml) - Html - <input
IntermediateToken - (631:26,18 [21] RazorPagesWithoutModel.cshtml) - Html - class="form-control"
IntermediateToken - (652:26,39 [3] RazorPagesWithoutModel.cshtml) - Html - />
IntermediateToken - (652:26,39 [1] RazorPagesWithoutModel.cshtml) - Html -
IntermediateToken - (653:26,40 [2] RazorPagesWithoutModel.cshtml) - Html - />
IntermediateToken - (655:26,42 [14] RazorPagesWithoutModel.cshtml) - Html - \n
IntermediateToken - (669:27,12 [5] RazorPagesWithoutModel.cshtml) - Html - <span
IntermediateToken - (674:27,17 [20] RazorPagesWithoutModel.cshtml) - Html - class="text-danger"

View File

@ -26,7 +26,8 @@ Document -
IntermediateToken - (81:4,0 [2] RazorPagesWithoutModel.cshtml) - Html - \n
HtmlContent - (381:19,0 [75] RazorPagesWithoutModel.cshtml)
IntermediateToken - (381:19,0 [2] RazorPagesWithoutModel.cshtml) - Html - \n
IntermediateToken - (383:20,0 [4] RazorPagesWithoutModel.cshtml) - Html - <h1>
IntermediateToken - (383:20,0 [3] RazorPagesWithoutModel.cshtml) - Html - <h1
IntermediateToken - (386:20,3 [1] RazorPagesWithoutModel.cshtml) - Html - >
IntermediateToken - (387:20,4 [12] RazorPagesWithoutModel.cshtml) - Html - New Customer
IntermediateToken - (399:20,16 [5] RazorPagesWithoutModel.cshtml) - Html - </h1>
IntermediateToken - (404:20,21 [2] RazorPagesWithoutModel.cshtml) - Html - \n
@ -60,7 +61,8 @@ Document -
IntermediateToken - (611:25,31 [14] RazorPagesWithoutModel.cshtml) - Html - \n
IntermediateToken - (625:26,12 [6] RazorPagesWithoutModel.cshtml) - Html - <input
IntermediateToken - (631:26,18 [21] RazorPagesWithoutModel.cshtml) - Html - class="form-control"
IntermediateToken - (652:26,39 [3] RazorPagesWithoutModel.cshtml) - Html - />
IntermediateToken - (652:26,39 [1] RazorPagesWithoutModel.cshtml) - Html -
IntermediateToken - (653:26,40 [2] RazorPagesWithoutModel.cshtml) - Html - />
IntermediateToken - (655:26,42 [14] RazorPagesWithoutModel.cshtml) - Html - \n
IntermediateToken - (669:27,12 [5] RazorPagesWithoutModel.cshtml) - Html - <span
IntermediateToken - (674:27,17 [20] RazorPagesWithoutModel.cshtml) - Html - class="text-danger"

View File

@ -43,14 +43,16 @@ Document -
IntermediateToken - (96:4,42 [4] RazorPages.cshtml) - Html - \n\n
HtmlContent - (473:22,1 [78] RazorPages.cshtml)
IntermediateToken - (473:22,1 [4] RazorPages.cshtml) - Html - \n\n
IntermediateToken - (477:24,0 [4] RazorPages.cshtml) - Html - <h1>
IntermediateToken - (477:24,0 [3] RazorPages.cshtml) - Html - <h1
IntermediateToken - (480:24,3 [1] RazorPages.cshtml) - Html - >
IntermediateToken - (481:24,4 [12] RazorPages.cshtml) - Html - New Customer
IntermediateToken - (493:24,16 [5] RazorPages.cshtml) - Html - </h1>
IntermediateToken - (498:24,21 [2] RazorPages.cshtml) - Html - \n
IntermediateToken - (500:25,0 [5] RazorPages.cshtml) - Html - <form
IntermediateToken - (505:25,5 [14] RazorPages.cshtml) - Html - method="post"
IntermediateToken - (519:25,19 [24] RazorPages.cshtml) - Html - class="form-horizontal"
IntermediateToken - (543:25,43 [2] RazorPages.cshtml) - Html - >
IntermediateToken - (543:25,43 [1] RazorPages.cshtml) - Html -
IntermediateToken - (544:25,44 [1] RazorPages.cshtml) - Html - >
IntermediateToken - (545:25,45 [6] RazorPages.cshtml) - Html - \n
TagHelper - (551:26,4 [31] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag
DefaultTagHelperBody -
@ -79,7 +81,8 @@ Document -
IntermediateToken - (712:29,31 [14] RazorPages.cshtml) - Html - \n
IntermediateToken - (726:30,12 [6] RazorPages.cshtml) - Html - <input
IntermediateToken - (732:30,18 [21] RazorPages.cshtml) - Html - class="form-control"
IntermediateToken - (753:30,39 [3] RazorPages.cshtml) - Html - />
IntermediateToken - (753:30,39 [1] RazorPages.cshtml) - Html -
IntermediateToken - (754:30,40 [2] RazorPages.cshtml) - Html - />
IntermediateToken - (756:30,42 [14] RazorPages.cshtml) - Html - \n
IntermediateToken - (770:31,12 [5] RazorPages.cshtml) - Html - <span
IntermediateToken - (775:31,17 [20] RazorPages.cshtml) - Html - class="text-danger"

View File

@ -26,14 +26,16 @@ Document -
IntermediateToken - (98:5,0 [2] RazorPages.cshtml) - Html - \n
HtmlContent - (475:23,0 [76] RazorPages.cshtml)
IntermediateToken - (475:23,0 [2] RazorPages.cshtml) - Html - \n
IntermediateToken - (477:24,0 [4] RazorPages.cshtml) - Html - <h1>
IntermediateToken - (477:24,0 [3] RazorPages.cshtml) - Html - <h1
IntermediateToken - (480:24,3 [1] RazorPages.cshtml) - Html - >
IntermediateToken - (481:24,4 [12] RazorPages.cshtml) - Html - New Customer
IntermediateToken - (493:24,16 [5] RazorPages.cshtml) - Html - </h1>
IntermediateToken - (498:24,21 [2] RazorPages.cshtml) - Html - \n
IntermediateToken - (500:25,0 [5] RazorPages.cshtml) - Html - <form
IntermediateToken - (505:25,5 [14] RazorPages.cshtml) - Html - method="post"
IntermediateToken - (519:25,19 [24] RazorPages.cshtml) - Html - class="form-horizontal"
IntermediateToken - (543:25,43 [2] RazorPages.cshtml) - Html - >
IntermediateToken - (543:25,43 [1] RazorPages.cshtml) - Html -
IntermediateToken - (544:25,44 [1] RazorPages.cshtml) - Html - >
IntermediateToken - (545:25,45 [6] RazorPages.cshtml) - Html - \n
TagHelper - (551:26,4 [31] RazorPages.cshtml) - div - TagMode.StartTagAndEndTag
DefaultTagHelperBody -
@ -60,7 +62,8 @@ Document -
IntermediateToken - (712:29,31 [14] RazorPages.cshtml) - Html - \n
IntermediateToken - (726:30,12 [6] RazorPages.cshtml) - Html - <input
IntermediateToken - (732:30,18 [21] RazorPages.cshtml) - Html - class="form-control"
IntermediateToken - (753:30,39 [3] RazorPages.cshtml) - Html - />
IntermediateToken - (753:30,39 [1] RazorPages.cshtml) - Html -
IntermediateToken - (754:30,40 [2] RazorPages.cshtml) - Html - />
IntermediateToken - (756:30,42 [14] RazorPages.cshtml) - Html - \n
IntermediateToken - (770:31,12 [5] RazorPages.cshtml) - Html - <span
IntermediateToken - (775:31,17 [20] RazorPages.cshtml) - Html - class="text-danger"

View File

@ -43,14 +43,16 @@ Document -
IntermediateToken - (68:4,2 [46] Sections.cshtml) - CSharp - \n Layout = "_SectionTestLayout.cshtml";\n
HtmlContent - (117:7,0 [26] Sections.cshtml)
IntermediateToken - (117:7,0 [2] Sections.cshtml) - Html - \n
IntermediateToken - (119:8,0 [5] Sections.cshtml) - Html - <div>
IntermediateToken - (119:8,0 [4] Sections.cshtml) - Html - <div
IntermediateToken - (123:8,4 [1] Sections.cshtml) - Html - >
IntermediateToken - (124:8,5 [9] Sections.cshtml) - Html - Some body
IntermediateToken - (133:8,14 [6] Sections.cshtml) - Html - </div>
IntermediateToken - (139:8,20 [4] Sections.cshtml) - Html - \n\n
Section - - Section1
HtmlContent - (162:10,19 [43] Sections.cshtml)
IntermediateToken - (162:10,19 [6] Sections.cshtml) - Html - \n
IntermediateToken - (168:11,4 [5] Sections.cshtml) - Html - <div>
IntermediateToken - (168:11,4 [4] Sections.cshtml) - Html - <div
IntermediateToken - (172:11,8 [1] Sections.cshtml) - Html - >
IntermediateToken - (173:11,9 [20] Sections.cshtml) - Html - This is in Section 1
IntermediateToken - (193:11,29 [6] Sections.cshtml) - Html - </div>
IntermediateToken - (199:11,35 [6] Sections.cshtml) - Html - \n

View File

@ -23,14 +23,16 @@ Document -
IntermediateToken - (68:4,2 [46] Sections.cshtml) - CSharp - \n Layout = "_SectionTestLayout.cshtml";\n
HtmlContent - (117:7,0 [26] Sections.cshtml)
IntermediateToken - (117:7,0 [2] Sections.cshtml) - Html - \n
IntermediateToken - (119:8,0 [5] Sections.cshtml) - Html - <div>
IntermediateToken - (119:8,0 [4] Sections.cshtml) - Html - <div
IntermediateToken - (123:8,4 [1] Sections.cshtml) - Html - >
IntermediateToken - (124:8,5 [9] Sections.cshtml) - Html - Some body
IntermediateToken - (133:8,14 [6] Sections.cshtml) - Html - </div>
IntermediateToken - (139:8,20 [4] Sections.cshtml) - Html - \n\n
Section - - Section1
HtmlContent - (162:10,19 [43] Sections.cshtml)
IntermediateToken - (162:10,19 [6] Sections.cshtml) - Html - \n
IntermediateToken - (168:11,4 [5] Sections.cshtml) - Html - <div>
IntermediateToken - (168:11,4 [4] Sections.cshtml) - Html - <div
IntermediateToken - (172:11,8 [1] Sections.cshtml) - Html - >
IntermediateToken - (173:11,9 [20] Sections.cshtml) - Html - This is in Section 1
IntermediateToken - (193:11,29 [6] Sections.cshtml) - Html - </div>
IntermediateToken - (199:11,35 [6] Sections.cshtml) - Html - \n

View File

@ -32,7 +32,8 @@ Document -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
HtmlContent - (27:1,0 [20] ViewWithNamespace.cshtml)
IntermediateToken - (27:1,0 [4] ViewWithNamespace.cshtml) - Html - <h1>
IntermediateToken - (27:1,0 [3] ViewWithNamespace.cshtml) - Html - <h1
IntermediateToken - (30:1,3 [1] ViewWithNamespace.cshtml) - Html - >
IntermediateToken - (31:1,4 [9] ViewWithNamespace.cshtml) - Html - Hi There!
IntermediateToken - (40:1,13 [5] ViewWithNamespace.cshtml) - Html - </h1>
IntermediateToken - (45:1,18 [2] ViewWithNamespace.cshtml) - Html - \n

View File

@ -14,7 +14,8 @@ Document -
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewWithNamespace - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic> -
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
HtmlContent - (27:1,0 [20] ViewWithNamespace.cshtml)
IntermediateToken - (27:1,0 [4] ViewWithNamespace.cshtml) - Html - <h1>
IntermediateToken - (27:1,0 [3] ViewWithNamespace.cshtml) - Html - <h1
IntermediateToken - (30:1,3 [1] ViewWithNamespace.cshtml) - Html - >
IntermediateToken - (31:1,4 [9] ViewWithNamespace.cshtml) - Html - Hi There!
IntermediateToken - (40:1,13 [5] ViewWithNamespace.cshtml) - Html - </h1>
IntermediateToken - (45:1,18 [2] ViewWithNamespace.cshtml) - Html - \n

View File

@ -0,0 +1,65 @@
// Copyright (c) .NET Foundation. 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.AspNetCore.Razor.Language.Legacy;
using Microsoft.AspNetCore.Razor.Language.Syntax;
namespace Microsoft.AspNetCore.Razor.Language
{
internal class ClassifiedSpanRewriter : SyntaxRewriter
{
public override SyntaxNode VisitMarkupTagBlock(MarkupTagBlockSyntax node)
{
SpanContext latestSpanContext = null;
var newChildren = SyntaxListBuilder<RazorSyntaxNode>.Create();
var literals = new List<MarkupTextLiteralSyntax>();
foreach (var child in node.Children)
{
if (child is MarkupTextLiteralSyntax literal)
{
literals.Add(literal);
latestSpanContext = literal.GetSpanContext() ?? latestSpanContext;
}
else if (child is MarkupMiscAttributeContentSyntax miscContent)
{
foreach (var contentChild in miscContent.Children)
{
if (contentChild is MarkupTextLiteralSyntax contentLiteral)
{
literals.Add(contentLiteral);
latestSpanContext = contentLiteral.GetSpanContext() ?? latestSpanContext;
}
else
{
// Pop stack
AddLiteralIfExists();
newChildren.Add(contentChild);
}
}
}
else
{
AddLiteralIfExists();
newChildren.Add(child);
}
}
AddLiteralIfExists();
return SyntaxFactory.MarkupTagBlock(newChildren.ToList()).Green.CreateRed(node.Parent, node.Position);
void AddLiteralIfExists()
{
if (literals.Count > 0)
{
var mergedLiteral = SyntaxUtilities.MergeTextLiterals(literals.ToArray());
mergedLiteral = mergedLiteral.WithSpanContext(latestSpanContext);
literals.Clear();
latestSpanContext = null;
newChildren.Add(mergedLiteral);
}
}
}
}
}

View File

@ -137,7 +137,7 @@ namespace Microsoft.AspNetCore.Razor.Language
WriteBlock(node, BlockKindInternal.Markup, n =>
{
var equalsSyntax = SyntaxFactory.MarkupTextLiteral(new SyntaxList<SyntaxToken>(node.EqualsToken));
var mergedAttributePrefix = MergeTextLiteralSpans(node.NamePrefix, node.Name, node.NameSuffix, equalsSyntax, node.ValuePrefix);
var mergedAttributePrefix = SyntaxUtilities.MergeTextLiterals(node.NamePrefix, node.Name, node.NameSuffix, equalsSyntax, node.ValuePrefix);
Visit(mergedAttributePrefix);
Visit(node.Value);
Visit(node.ValueSuffix);
@ -153,7 +153,7 @@ namespace Microsoft.AspNetCore.Razor.Language
{
WriteBlock(node, BlockKindInternal.Markup, n =>
{
var mergedAttributePrefix = MergeTextLiteralSpans(node.NamePrefix, node.Name);
var mergedAttributePrefix = SyntaxUtilities.MergeTextLiterals(node.NamePrefix, node.Name);
Visit(mergedAttributePrefix);
});
}
@ -270,43 +270,5 @@ namespace Microsoft.AspNetCore.Razor.Language
var span = new ClassifiedSpanInternal(spanSource, blockSource, kind, _currentBlockKind, acceptedCharacters.Value);
_spans.Add(span);
}
private MarkupTextLiteralSyntax MergeTextLiteralSpans(params MarkupTextLiteralSyntax[] literalSyntaxes)
{
if (literalSyntaxes == null || literalSyntaxes.Length == 0)
{
return null;
}
SyntaxNode parent = null;
var position = 0;
var seenFirstLiteral = false;
var builder = Syntax.InternalSyntax.SyntaxListBuilder.Create();
foreach (var syntax in literalSyntaxes)
{
if (syntax == null)
{
continue;
}
else if (!seenFirstLiteral)
{
// Set the parent and position of the merged literal to the value of the first non-null literal.
parent = syntax.Parent;
position = syntax.Position;
seenFirstLiteral = true;
}
foreach (var token in syntax.LiteralTokens)
{
builder.Add(token.Green);
}
}
var mergedLiteralSyntax = Syntax.InternalSyntax.SyntaxFactory.MarkupTextLiteral(
builder.ToList<Syntax.InternalSyntax.SyntaxToken>());
return (MarkupTextLiteralSyntax)mergedLiteralSyntax.CreateRed(parent, position);
}
}
}

View File

@ -240,7 +240,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
var scriptTag = At(SyntaxKind.Text) &&
string.Equals(CurrentToken.Content, "script", StringComparison.OrdinalIgnoreCase);
TryAccept(SyntaxKind.Text);
LegacyParseTagContent(tagBuilder); // Parse the tag, don't care about the content
// Output open angle and tag name
tagBuilder.Add(OutputAsMarkupLiteral());
ParseAttributes(tagBuilder); // Parse the tag, don't care about the content
TryAccept(SyntaxKind.ForwardSlash);
TryAccept(SyntaxKind.CloseAngle);
@ -278,372 +280,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
}
}
private void LegacyParseTagContent(in SyntaxListBuilder<RazorSyntaxNode> builder)
{
if (!At(SyntaxKind.Whitespace) && !At(SyntaxKind.NewLine))
{
// We should be right after the tag name, so if there's no whitespace or new line, something is wrong
RecoverToEndOfTag(builder);
}
else
{
// We are here ($): <tag$ foo="bar" biz="~/Baz" />
while (!EndOfFile && !IsEndOfTag())
{
BeforeAttribute(builder);
}
}
}
private bool IsEndOfTag()
{
if (At(SyntaxKind.ForwardSlash))
{
if (NextIs(SyntaxKind.CloseAngle))
{
return true;
}
else
{
AcceptAndMoveNext();
}
}
return At(SyntaxKind.CloseAngle) || At(SyntaxKind.OpenAngle);
}
private void BeforeAttribute(in SyntaxListBuilder<RazorSyntaxNode> builder)
{
// http://dev.w3.org/html5/spec/tokenization.html#before-attribute-name-state
// Capture whitespace
var whitespace = ReadWhile(token => token.Kind == SyntaxKind.Whitespace || token.Kind == SyntaxKind.NewLine);
if (At(SyntaxKind.Transition) || At(SyntaxKind.RazorCommentTransition))
{
// Transition outside of attribute value => Switch to recovery mode
Accept(whitespace);
RecoverToEndOfTag(builder);
return;
}
// http://dev.w3.org/html5/spec/tokenization.html#attribute-name-state
// Read the 'name' (i.e. read until the '=' or whitespace/newline)
var nameTokens = Enumerable.Empty<SyntaxToken>();
var whitespaceAfterAttributeName = Enumerable.Empty<SyntaxToken>();
if (IsValidAttributeNameToken(CurrentToken))
{
nameTokens = ReadWhile(token =>
token.Kind != SyntaxKind.Whitespace &&
token.Kind != SyntaxKind.NewLine &&
token.Kind != SyntaxKind.Equals &&
token.Kind != SyntaxKind.CloseAngle &&
token.Kind != SyntaxKind.OpenAngle &&
(token.Kind != SyntaxKind.ForwardSlash || !NextIs(SyntaxKind.CloseAngle)));
// capture whitespace after attribute name (if any)
whitespaceAfterAttributeName = ReadWhile(
token => token.Kind == SyntaxKind.Whitespace || token.Kind == SyntaxKind.NewLine);
}
else
{
// Unexpected character in tag, enter recovery
Accept(whitespace);
RecoverToEndOfTag(builder);
return;
}
if (!At(SyntaxKind.Equals))
{
// Minimized attribute
// We are at the prefix of the next attribute or the end of tag. Put it back so it is parsed later.
PutCurrentBack();
PutBack(whitespaceAfterAttributeName);
// Output anything prior to the attribute, in most cases this will be the tag name:
// |<input| checked />. If in-between other attributes this will noop or output malformed attribute
// content (if the previous attribute was malformed).
builder.Add(OutputAsMarkupLiteral());
Accept(whitespace);
var namePrefix = OutputAsMarkupLiteral();
Accept(nameTokens);
var name = OutputAsMarkupLiteral();
var minimizedAttributeBlock = SyntaxFactory.MarkupMinimizedAttributeBlock(namePrefix, name);
builder.Add(minimizedAttributeBlock);
return;
}
// Not a minimized attribute, parse as if it were well-formed (if attribute turns out to be malformed we
// will go into recovery).
builder.Add(OutputAsMarkupLiteral());
var attributeBlock = ParseAttributePrefix(whitespace, nameTokens, whitespaceAfterAttributeName);
builder.Add(attributeBlock);
}
private MarkupAttributeBlockSyntax ParseAttributePrefix(
IEnumerable<SyntaxToken> whitespace,
IEnumerable<SyntaxToken> nameTokens,
IEnumerable<SyntaxToken> whitespaceAfterAttributeName)
{
// First, determine if this is a 'data-' attribute (since those can't use conditional attributes)
var nameContent = string.Concat(nameTokens.Select(s => s.Content));
var attributeCanBeConditional =
Context.FeatureFlags.EXPERIMENTAL_AllowConditionalDataDashAttributes ||
!nameContent.StartsWith("data-", StringComparison.OrdinalIgnoreCase);
// Accept the whitespace and name
Accept(whitespace);
var namePrefix = OutputAsMarkupLiteral();
Accept(nameTokens);
var name = OutputAsMarkupLiteral();
// Since this is not a minimized attribute, the whitespace after attribute name belongs to this attribute.
Accept(whitespaceAfterAttributeName);
var nameSuffix = OutputAsMarkupLiteral();
Assert(SyntaxKind.Equals); // We should be at "="
var equalsToken = EatCurrentToken();
var whitespaceAfterEquals = ReadWhile(token => token.Kind == SyntaxKind.Whitespace || token.Kind == SyntaxKind.NewLine);
var quote = SyntaxKind.Marker;
if (At(SyntaxKind.SingleQuote) || At(SyntaxKind.DoubleQuote))
{
// Found a quote, the whitespace belongs to this attribute.
Accept(whitespaceAfterEquals);
quote = CurrentToken.Kind;
AcceptAndMoveNext();
}
else if (whitespaceAfterEquals.Any())
{
// No quotes found after the whitespace. Put it back so that it can be parsed later.
PutCurrentBack();
PutBack(whitespaceAfterEquals);
}
MarkupTextLiteralSyntax valuePrefix = null;
RazorBlockSyntax attributeValue = null;
MarkupTextLiteralSyntax valueSuffix = null;
if (attributeCanBeConditional)
{
SpanContext.ChunkGenerator = SpanChunkGenerator.Null; // The block chunk generator will render the prefix
// We now have the value prefix which is usually whitespace and/or a quote
valuePrefix = OutputAsMarkupLiteral();
// Read the attribute value only if the value is quoted
// or if there is no whitespace between '=' and the unquoted value.
if (quote != SyntaxKind.Marker || !whitespaceAfterEquals.Any())
{
using (var pooledResult = Pool.Allocate<RazorSyntaxNode>())
{
var attributeValueBuilder = pooledResult.Builder;
// Read the attribute value.
while (!EndOfFile && !IsEndOfAttributeValue(quote, CurrentToken))
{
ParseAttributeValue(attributeValueBuilder, quote);
}
if (attributeValueBuilder.Count > 0)
{
attributeValue = SyntaxFactory.GenericBlock(attributeValueBuilder.ToList());
}
}
}
// Capture the suffix
if (quote != SyntaxKind.Marker && At(quote))
{
AcceptAndMoveNext();
// Again, block chunk generator will render the suffix
SpanContext.ChunkGenerator = SpanChunkGenerator.Null;
valueSuffix = OutputAsMarkupLiteral();
}
}
else if (quote != SyntaxKind.Marker || !whitespaceAfterEquals.Any())
{
valuePrefix = OutputAsMarkupLiteral();
using (var pooledResult = Pool.Allocate<RazorSyntaxNode>())
{
var attributeValueBuilder = pooledResult.Builder;
// Not a "conditional" attribute, so just read the value
SkipToAndParseCode(attributeValueBuilder, token => IsEndOfAttributeValue(quote, token));
// Output already accepted tokens if any as markup literal
var literalValue = OutputAsMarkupLiteral();
attributeValueBuilder.Add(literalValue);
// Capture the attribute value (will include everything in-between the attribute's quotes).
attributeValue = SyntaxFactory.GenericBlock(attributeValueBuilder.ToList());
}
if (quote != SyntaxKind.Marker)
{
TryAccept(quote);
valueSuffix = OutputAsMarkupLiteral();
}
}
else
{
// There is no quote and there is whitespace after equals. There is no attribute value.
}
return SyntaxFactory.MarkupAttributeBlock(namePrefix, name, nameSuffix, equalsToken, valuePrefix, attributeValue, valueSuffix);
}
private void ParseAttributeValue(in SyntaxListBuilder<RazorSyntaxNode> builder, SyntaxKind quote)
{
var prefixStart = CurrentStart;
var prefixTokens = ReadWhile(token => token.Kind == SyntaxKind.Whitespace || token.Kind == SyntaxKind.NewLine);
if (At(SyntaxKind.Transition))
{
if (NextIs(SyntaxKind.Transition))
{
// Wrapping this in a block so that the ConditionalAttributeCollapser doesn't rewrite it.
using (var pooledResult = Pool.Allocate<RazorSyntaxNode>())
{
var markupBuilder = pooledResult.Builder;
Accept(prefixTokens);
// Render a single "@" in place of "@@".
SpanContext.ChunkGenerator = new LiteralAttributeChunkGenerator(
new LocationTagged<string>(string.Concat(prefixTokens.Select(s => s.Content)), prefixStart),
new LocationTagged<string>(CurrentToken.Content, CurrentStart));
AcceptAndMoveNext();
SpanContext.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None;
markupBuilder.Add(OutputAsMarkupLiteral());
SpanContext.ChunkGenerator = SpanChunkGenerator.Null;
AcceptAndMoveNext();
SpanContext.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None;
markupBuilder.Add(OutputAsMarkupEphemeralLiteral());
var markupBlock = SyntaxFactory.MarkupBlock(markupBuilder.ToList());
builder.Add(markupBlock);
}
}
else
{
Accept(prefixTokens);
var valueStart = CurrentStart;
PutCurrentBack();
var prefix = OutputAsMarkupLiteral();
// Dynamic value, start a new block and set the chunk generator
using (var pooledResult = Pool.Allocate<RazorSyntaxNode>())
{
var dynamicAttributeValueBuilder = pooledResult.Builder;
OtherParserBlock(dynamicAttributeValueBuilder);
var value = SyntaxFactory.MarkupDynamicAttributeValue(prefix, SyntaxFactory.GenericBlock(dynamicAttributeValueBuilder.ToList()));
builder.Add(value);
}
}
}
else
{
Accept(prefixTokens);
var prefix = OutputAsMarkupLiteral();
// Literal value
// 'quote' should be "Unknown" if not quoted and tokens coming from the tokenizer should never have
// "Unknown" type.
var valueTokens = ReadWhile(token =>
// These three conditions find separators which break the attribute value into portions
token.Kind != SyntaxKind.Whitespace &&
token.Kind != SyntaxKind.NewLine &&
token.Kind != SyntaxKind.Transition &&
// This condition checks for the end of the attribute value (it repeats some of the checks above
// but for now that's ok)
!IsEndOfAttributeValue(quote, token));
Accept(valueTokens);
var value = OutputAsMarkupLiteral();
var literalAttributeValue = SyntaxFactory.MarkupLiteralAttributeValue(prefix, value);
builder.Add(literalAttributeValue);
}
}
private void RecoverToEndOfTag(in SyntaxListBuilder<RazorSyntaxNode> builder)
{
// Accept until ">", "/" or "<", but parse code
while (!EndOfFile)
{
SkipToAndParseCode(builder, IsTagRecoveryStopPoint);
if (!EndOfFile)
{
EnsureCurrent();
switch (CurrentToken.Kind)
{
case SyntaxKind.SingleQuote:
case SyntaxKind.DoubleQuote:
ParseQuoted(builder);
break;
case SyntaxKind.OpenAngle:
// Another "<" means this tag is invalid.
case SyntaxKind.ForwardSlash:
// Empty tag
case SyntaxKind.CloseAngle:
// End of tag
return;
default:
AcceptAndMoveNext();
break;
}
}
}
}
private bool IsTagRecoveryStopPoint(SyntaxToken token)
{
return token.Kind == SyntaxKind.CloseAngle ||
token.Kind == SyntaxKind.ForwardSlash ||
token.Kind == SyntaxKind.OpenAngle ||
token.Kind == SyntaxKind.SingleQuote ||
token.Kind == SyntaxKind.DoubleQuote;
}
private bool IsEndOfAttributeValue(SyntaxKind quote, SyntaxToken token)
{
return EndOfFile || token == null ||
(quote != SyntaxKind.Marker
? token.Kind == quote // If quoted, just wait for the quote
: IsUnquotedEndOfAttributeValue(token));
}
private bool IsUnquotedEndOfAttributeValue(SyntaxToken token)
{
// If unquoted, we have a larger set of terminating characters:
// http://dev.w3.org/html5/spec/tokenization.html#attribute-value-unquoted-state
// Also we need to detect "/" and ">"
return token.Kind == SyntaxKind.DoubleQuote ||
token.Kind == SyntaxKind.SingleQuote ||
token.Kind == SyntaxKind.OpenAngle ||
token.Kind == SyntaxKind.Equals ||
(token.Kind == SyntaxKind.ForwardSlash && NextIs(SyntaxKind.CloseAngle)) ||
token.Kind == SyntaxKind.CloseAngle ||
token.Kind == SyntaxKind.Whitespace ||
token.Kind == SyntaxKind.NewLine;
}
private void ParseQuoted(in SyntaxListBuilder<RazorSyntaxNode> builder)
{
var type = CurrentToken.Kind;
AcceptAndMoveNext();
SkipToAndParseCode(builder, type);
if (!EndOfFile)
{
Assert(type);
AcceptAndMoveNext();
}
}
private bool ParseBangTag(in SyntaxListBuilder<RazorSyntaxNode> builder)
{
// Accept "!"
@ -1240,6 +876,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
Accept(_bufferedOpenAngle);
TryParseBangEscape(builder);
TryAccept(SyntaxKind.Text);
if (At(SyntaxKind.CloseAngle))
{
// Completed tags have no accepted characters inside of blocks.
SpanContext.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None;
}
// Output open angle and tag name
builder.Add(OutputAsMarkupLiteral());
return ParseRestOfTag(builder, parentBuilder, tag, tags);
}
@ -1250,7 +894,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
Stack<Tuple<SyntaxToken, SourceLocation>> tags)
{
var blockAlreadyBuilt = false;
LegacyParseTagContent(builder);
ParseAttributes(builder);
// We are now at a possible end of the tag
// Found '<', so we just abort this tag.
@ -1718,28 +1362,5 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
return last.Green;
}
internal static bool IsValidAttributeNameToken(SyntaxToken token)
{
if (token == null)
{
return false;
}
// These restrictions cover most of the spec defined: http://www.w3.org/TR/html5/syntax.html#attributes-0
// However, it's not all of it. For instance we don't special case control characters or allow OpenAngle.
// It also doesn't try to exclude Razor specific features such as the @ transition. This is based on the
// expectation that the parser handles such scenarios prior to falling through to name resolution.
var tokenType = token.Kind;
return tokenType != SyntaxKind.Whitespace &&
tokenType != SyntaxKind.NewLine &&
tokenType != SyntaxKind.CloseAngle &&
tokenType != SyntaxKind.OpenAngle &&
tokenType != SyntaxKind.ForwardSlash &&
tokenType != SyntaxKind.DoubleQuote &&
tokenType != SyntaxKind.SingleQuote &&
tokenType != SyntaxKind.Equals &&
tokenType != SyntaxKind.Marker;
}
}
}

View File

@ -174,8 +174,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
}
TryAccept(SyntaxKind.Text);
// Output open angle and tag name
tagBuilder.Add(OutputAsMarkupLiteral());
// Parse the contents of a tag like attributes.
ParseTagContent(tagBuilder);
ParseAttributes(tagBuilder);
if (TryAccept(SyntaxKind.ForwardSlash))
{
@ -233,10 +236,366 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
return null;
}
private void ParseTagContent(in SyntaxListBuilder<RazorSyntaxNode> builder)
private void ParseAttributes(in SyntaxListBuilder<RazorSyntaxNode> builder)
{
// Calling to legacy code for now.
LegacyParseTagContent(builder);
if (!At(SyntaxKind.Whitespace) && !At(SyntaxKind.NewLine))
{
// We should be right after the tag name, so if there's no whitespace or new line, something is wrong
ParseMiscAttribute(builder);
return;
}
// We are here ($): <tag$ foo="bar" biz="~/Baz" />
while (!EndOfFile && !IsEndOfTag())
{
if (At(SyntaxKind.ForwardSlash))
{
// This means we're at a '/' but it's not considered end of tag. E.g. <p / class=foo>
// We are at the '/' but the tag isn't closed. Accept and continue parsing the next attribute.
AcceptAndMoveNext();
}
ParseAttribute(builder);
}
}
private bool IsEndOfTag()
{
if (At(SyntaxKind.ForwardSlash))
{
if (NextIs(SyntaxKind.CloseAngle) || NextIs(SyntaxKind.OpenAngle))
{
return true;
}
}
return At(SyntaxKind.CloseAngle) || At(SyntaxKind.OpenAngle);
}
private void ParseMiscAttribute(in SyntaxListBuilder<RazorSyntaxNode> builder)
{
using (var pooledResult = Pool.Allocate<RazorSyntaxNode>())
{
var miscAttributeContentBuilder = pooledResult.Builder;
while (!EndOfFile)
{
ParseMarkupNodes(miscAttributeContentBuilder, ParseMode.Text, IsTagRecoveryStopPoint);
if (!EndOfFile)
{
EnsureCurrent();
switch (CurrentToken.Kind)
{
case SyntaxKind.SingleQuote:
case SyntaxKind.DoubleQuote:
// We should parse until we reach a matching quote.
var openQuoteKind = CurrentToken.Kind;
AcceptAndMoveNext();
ParseMarkupNodes(miscAttributeContentBuilder, ParseMode.Text, token => token.Kind == openQuoteKind);
if (!EndOfFile)
{
Assert(openQuoteKind);
AcceptAndMoveNext();
}
break;
case SyntaxKind.OpenAngle: // Another "<" means this tag is invalid.
case SyntaxKind.ForwardSlash: // Empty tag
case SyntaxKind.CloseAngle: // End of tag
miscAttributeContentBuilder.Add(OutputAsMarkupLiteral());
if (miscAttributeContentBuilder.Count > 0)
{
var miscAttributeContent = SyntaxFactory.MarkupMiscAttributeContent(miscAttributeContentBuilder.ToList());
builder.Add(miscAttributeContent);
}
return;
default:
AcceptAndMoveNext();
break;
}
}
}
miscAttributeContentBuilder.Add(OutputAsMarkupLiteral());
if (miscAttributeContentBuilder.Count > 0)
{
var miscAttributeContent = SyntaxFactory.MarkupMiscAttributeContent(miscAttributeContentBuilder.ToList());
builder.Add(miscAttributeContent);
}
}
}
private void ParseAttribute(in SyntaxListBuilder<RazorSyntaxNode> builder)
{
// Output anything prior to the attribute, in most cases this will be any invalid content after the tag name or a previous attribute:
// <input| /| checked />. If there is nothing in-between other attributes this will noop.
using (var pooledResult = Pool.Allocate<RazorSyntaxNode>())
{
var miscAttributeContentBuilder = pooledResult.Builder;
miscAttributeContentBuilder.Add(OutputAsMarkupLiteral());
if (miscAttributeContentBuilder.Count > 0)
{
var invalidAttributeBlock = SyntaxFactory.MarkupMiscAttributeContent(miscAttributeContentBuilder.ToList());
builder.Add(invalidAttributeBlock);
}
}
// http://dev.w3.org/html5/spec/tokenization.html#before-attribute-name-state
// Capture whitespace
var attributePrefixWhitespace = ReadWhile(token => token.Kind == SyntaxKind.Whitespace || token.Kind == SyntaxKind.NewLine);
// http://dev.w3.org/html5/spec/tokenization.html#attribute-name-state
// Read the 'name' (i.e. read until the '=' or whitespace/newline)
if (!TryParseAttributeName(out var nameTokens))
{
// Unexpected character in tag, enter recovery
Accept(attributePrefixWhitespace);
ParseMiscAttribute(builder);
return;
}
Accept(attributePrefixWhitespace); // Whitespace before attribute name
var namePrefix = OutputAsMarkupLiteral();
Accept(nameTokens); // Attribute name
var name = OutputAsMarkupLiteral();
var atMinimizedAttribute = !TokenExistsAfterWhitespace(SyntaxKind.Equals);
if (atMinimizedAttribute)
{
// Minimized attribute
var minimizedAttributeBlock = SyntaxFactory.MarkupMinimizedAttributeBlock(namePrefix, name);
builder.Add(minimizedAttributeBlock);
}
else
{
// Not a minimized attribute
var attributeBlock = ParseRemainingAttribute(namePrefix, name);
builder.Add(attributeBlock);
}
}
private bool TryParseAttributeName(out IEnumerable<SyntaxToken> nameTokens)
{
nameTokens = Enumerable.Empty<SyntaxToken>();
if (At(SyntaxKind.Transition) || At(SyntaxKind.RazorCommentTransition))
{
return false;
}
if (IsValidAttributeNameToken(CurrentToken))
{
nameTokens = ReadWhile(token =>
token.Kind != SyntaxKind.Whitespace &&
token.Kind != SyntaxKind.NewLine &&
token.Kind != SyntaxKind.Equals &&
token.Kind != SyntaxKind.CloseAngle &&
token.Kind != SyntaxKind.OpenAngle &&
(token.Kind != SyntaxKind.ForwardSlash || !NextIs(SyntaxKind.CloseAngle)));
return true;
}
return false;
}
private MarkupAttributeBlockSyntax ParseRemainingAttribute(MarkupTextLiteralSyntax namePrefix, MarkupTextLiteralSyntax name)
{
// Since this is not a minimized attribute, the whitespace after attribute name belongs to this attribute.
AcceptWhile(token => token.Kind == SyntaxKind.Whitespace || token.Kind == SyntaxKind.NewLine);
var nameSuffix = OutputAsMarkupLiteral();
Assert(SyntaxKind.Equals); // We should be at "="
var equalsToken = EatCurrentToken();
var whitespaceAfterEquals = ReadWhile(token => token.Kind == SyntaxKind.Whitespace || token.Kind == SyntaxKind.NewLine);
var quote = SyntaxKind.Marker;
if (At(SyntaxKind.SingleQuote) || At(SyntaxKind.DoubleQuote))
{
// Found a quote, the whitespace belongs to this attribute.
Accept(whitespaceAfterEquals);
quote = CurrentToken.Kind;
AcceptAndMoveNext();
}
else if (whitespaceAfterEquals.Any())
{
// No quotes found after the whitespace. Put it back so that it can be parsed later.
PutCurrentBack();
PutBack(whitespaceAfterEquals);
}
MarkupTextLiteralSyntax valuePrefix = null;
RazorBlockSyntax attributeValue = null;
MarkupTextLiteralSyntax valueSuffix = null;
// First, determine if this is a 'data-' attribute (since those can't use conditional attributes)
var nameContent = string.Concat(name.LiteralTokens.Nodes.Select(s => s.Content));
if (IsConditionalAttributeName(nameContent))
{
SpanContext.ChunkGenerator = SpanChunkGenerator.Null; // The block chunk generator will render the prefix
// We now have the value prefix which is usually whitespace and/or a quote
valuePrefix = OutputAsMarkupLiteral();
// Read the attribute value only if the value is quoted
// or if there is no whitespace between '=' and the unquoted value.
if (quote != SyntaxKind.Marker || !whitespaceAfterEquals.Any())
{
using (var pooledResult = Pool.Allocate<RazorSyntaxNode>())
{
var attributeValueBuilder = pooledResult.Builder;
// Read the attribute value.
while (!EndOfFile && !IsEndOfAttributeValue(quote, CurrentToken))
{
ParseConditionalAttributeValue(attributeValueBuilder, quote);
}
if (attributeValueBuilder.Count > 0)
{
attributeValue = SyntaxFactory.GenericBlock(attributeValueBuilder.ToList());
}
}
}
// Capture the suffix
if (quote != SyntaxKind.Marker && At(quote))
{
AcceptAndMoveNext();
// Again, block chunk generator will render the suffix
SpanContext.ChunkGenerator = SpanChunkGenerator.Null;
valueSuffix = OutputAsMarkupLiteral();
}
}
else if (quote != SyntaxKind.Marker || !whitespaceAfterEquals.Any())
{
valuePrefix = OutputAsMarkupLiteral();
attributeValue = ParseNonConditionalAttributeValue(quote);
if (quote != SyntaxKind.Marker)
{
TryAccept(quote);
valueSuffix = OutputAsMarkupLiteral();
}
}
else
{
// There is no quote and there is whitespace after equals. There is no attribute value.
}
return SyntaxFactory.MarkupAttributeBlock(namePrefix, name, nameSuffix, equalsToken, valuePrefix, attributeValue, valueSuffix);
}
private RazorBlockSyntax ParseNonConditionalAttributeValue(SyntaxKind quote)
{
using (var pooledResult = Pool.Allocate<RazorSyntaxNode>())
{
var attributeValueBuilder = pooledResult.Builder;
// Not a "conditional" attribute, so just read the value
ParseMarkupNodes(attributeValueBuilder, ParseMode.Text, token => IsEndOfAttributeValue(quote, token));
// Output already accepted tokens if any as markup literal
var literalValue = OutputAsMarkupLiteral();
attributeValueBuilder.Add(literalValue);
// Capture the attribute value (will include everything in-between the attribute's quotes).
return SyntaxFactory.GenericBlock(attributeValueBuilder.ToList());
}
}
private void ParseConditionalAttributeValue(in SyntaxListBuilder<RazorSyntaxNode> builder, SyntaxKind quote)
{
var prefixStart = CurrentStart;
var prefixTokens = ReadWhile(token => token.Kind == SyntaxKind.Whitespace || token.Kind == SyntaxKind.NewLine);
if (At(SyntaxKind.Transition))
{
if (NextIs(SyntaxKind.Transition))
{
using (var pooledResult = Pool.Allocate<RazorSyntaxNode>())
{
var markupBuilder = pooledResult.Builder;
Accept(prefixTokens);
// Render a single "@" in place of "@@".
SpanContext.ChunkGenerator = new LiteralAttributeChunkGenerator(
new LocationTagged<string>(string.Concat(prefixTokens.Select(s => s.Content)), prefixStart),
new LocationTagged<string>(CurrentToken.Content, CurrentStart));
AcceptAndMoveNext();
SpanContext.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None;
markupBuilder.Add(OutputAsMarkupLiteral());
SpanContext.ChunkGenerator = SpanChunkGenerator.Null;
AcceptAndMoveNext();
SpanContext.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.None;
markupBuilder.Add(OutputAsMarkupEphemeralLiteral());
var markupBlock = SyntaxFactory.MarkupBlock(markupBuilder.ToList());
builder.Add(markupBlock);
}
}
else
{
Accept(prefixTokens);
var valueStart = CurrentStart;
PutCurrentBack();
var prefix = OutputAsMarkupLiteral();
// Dynamic value, start a new block and set the chunk generator
using (var pooledResult = Pool.Allocate<RazorSyntaxNode>())
{
var dynamicAttributeValueBuilder = pooledResult.Builder;
OtherParserBlock(dynamicAttributeValueBuilder);
var value = SyntaxFactory.MarkupDynamicAttributeValue(prefix, SyntaxFactory.GenericBlock(dynamicAttributeValueBuilder.ToList()));
builder.Add(value);
}
}
}
else
{
Accept(prefixTokens);
var prefix = OutputAsMarkupLiteral();
// Literal value
// 'quote' should be "Unknown" if not quoted and tokens coming from the tokenizer should never have
// "Unknown" type.
var valueTokens = ReadWhile(token =>
// These three conditions find separators which break the attribute value into portions
token.Kind != SyntaxKind.Whitespace &&
token.Kind != SyntaxKind.NewLine &&
token.Kind != SyntaxKind.Transition &&
// This condition checks for the end of the attribute value (it repeats some of the checks above
// but for now that's ok)
!IsEndOfAttributeValue(quote, token));
Accept(valueTokens);
var value = OutputAsMarkupLiteral();
var literalAttributeValue = SyntaxFactory.MarkupLiteralAttributeValue(prefix, value);
builder.Add(literalAttributeValue);
}
}
private bool IsEndOfAttributeValue(SyntaxKind quote, SyntaxToken token)
{
return EndOfFile || token == null ||
(quote != SyntaxKind.Marker
? token.Kind == quote // If quoted, just wait for the quote
: IsUnquotedEndOfAttributeValue(token));
}
private bool IsUnquotedEndOfAttributeValue(SyntaxToken token)
{
// If unquoted, we have a larger set of terminating characters:
// http://dev.w3.org/html5/spec/tokenization.html#attribute-value-unquoted-state
// Also we need to detect "/" and ">"
return token.Kind == SyntaxKind.DoubleQuote ||
token.Kind == SyntaxKind.SingleQuote ||
token.Kind == SyntaxKind.OpenAngle ||
token.Kind == SyntaxKind.Equals ||
(token.Kind == SyntaxKind.ForwardSlash && NextIs(SyntaxKind.CloseAngle)) ||
token.Kind == SyntaxKind.CloseAngle ||
token.Kind == SyntaxKind.Whitespace ||
token.Kind == SyntaxKind.NewLine;
}
private void ParseJavascriptAndEndScriptTag(in SyntaxListBuilder<RazorSyntaxNode> builder, AcceptedCharactersInternal endTagAcceptedCharacters = AcceptedCharactersInternal.Any)
@ -811,6 +1170,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
}
}
private bool IsConditionalAttributeName(string name)
{
var attributeCanBeConditional =
Context.FeatureFlags.EXPERIMENTAL_AllowConditionalDataDashAttributes ||
!name.StartsWith("data-", StringComparison.OrdinalIgnoreCase);
return attributeCanBeConditional;
}
private void OtherParserBlock(in SyntaxListBuilder<RazorSyntaxNode> builder)
{
AcceptMarkerTokenIfNecessary();
@ -860,6 +1227,38 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
return token.Kind == SyntaxKind.Text && token.Content == "-";
}
internal static bool IsValidAttributeNameToken(SyntaxToken token)
{
if (token == null)
{
return false;
}
// These restrictions cover most of the spec defined: http://www.w3.org/TR/html5/syntax.html#attributes-0
// However, it's not all of it. For instance we don't special case control characters or allow OpenAngle.
// It also doesn't try to exclude Razor specific features such as the @ transition. This is based on the
// expectation that the parser handles such scenarios prior to falling through to name resolution.
var tokenType = token.Kind;
return tokenType != SyntaxKind.Whitespace &&
tokenType != SyntaxKind.NewLine &&
tokenType != SyntaxKind.CloseAngle &&
tokenType != SyntaxKind.OpenAngle &&
tokenType != SyntaxKind.ForwardSlash &&
tokenType != SyntaxKind.DoubleQuote &&
tokenType != SyntaxKind.SingleQuote &&
tokenType != SyntaxKind.Equals &&
tokenType != SyntaxKind.Marker;
}
private static bool IsTagRecoveryStopPoint(SyntaxToken token)
{
return token.Kind == SyntaxKind.CloseAngle ||
token.Kind == SyntaxKind.ForwardSlash ||
token.Kind == SyntaxKind.OpenAngle ||
token.Kind == SyntaxKind.SingleQuote ||
token.Kind == SyntaxKind.DoubleQuote;
}
private void DefaultMarkupSpanContext(SpanContextBuilder spanContext)
{
spanContext.ChunkGenerator = new MarkupChunkGenerator();

View File

@ -16,8 +16,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
throw new ArgumentNullException(nameof(syntaxTree));
}
var rewriter = new ClassifiedSpanRewriter();
var rewritten = rewriter.Visit(syntaxTree.Root);
var visitor = new ClassifiedSpanVisitor(syntaxTree.Source);
visitor.Visit(syntaxTree.Root);
visitor.Visit(rewritten);
return visitor.ClassifiedSpans;
}

View File

@ -107,29 +107,36 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
processedBoundAttributeNames);
tagHelperBuilder.Add(result.RewrittenAttribute);
}
else if (child is CSharpCodeBlockSyntax)
else if (child is MarkupMiscAttributeContentSyntax miscContent)
{
// TODO: Accept more than just Markup attributes: https://github.com/aspnet/Razor/issues/96.
// Something like:
// <input @checked />
var location = new SourceSpan(child.GetSourceLocation(source), child.FullWidth);
var diagnostic = RazorDiagnosticFactory.CreateParsing_TagHelpersCannotHaveCSharpInTagDeclaration(location, tagName);
errorSink.OnError(diagnostic);
result = null;
}
else if (child is MarkupTextLiteralSyntax)
{
// If the original span content was whitespace it ultimately means the tag
// that owns this "attribute" is malformed and is expecting a user to type a new attribute.
// ex: <myTH class="btn"| |
var literalContent = child.GetContent();
if (!string.IsNullOrWhiteSpace(literalContent))
foreach (var contentChild in miscContent.Children)
{
var location = child.GetSourceSpan(source);
var diagnostic = RazorDiagnosticFactory.CreateParsing_TagHelperAttributeListMustBeWellFormed(location);
errorSink.OnError(diagnostic);
if (contentChild is CSharpCodeBlockSyntax codeBlock)
{
// TODO: Accept more than just Markup attributes: https://github.com/aspnet/Razor/issues/96.
// Something like:
// <input @checked />
var location = new SourceSpan(codeBlock.GetSourceLocation(source), codeBlock.FullWidth);
var diagnostic = RazorDiagnosticFactory.CreateParsing_TagHelpersCannotHaveCSharpInTagDeclaration(location, tagName);
errorSink.OnError(diagnostic);
break;
}
else
{
// If the original span content was whitespace it ultimately means the tag
// that owns this "attribute" is malformed and is expecting a user to type a new attribute.
// ex: <myTH class="btn"| |
var literalContent = contentChild.GetContent();
if (!string.IsNullOrWhiteSpace(literalContent))
{
var location = contentChild.GetSourceSpan(source);
var diagnostic = RazorDiagnosticFactory.CreateParsing_TagHelperAttributeListMustBeWellFormed(location);
errorSink.OnError(diagnostic);
break;
}
}
}
result = null;
}
else

View File

@ -233,6 +233,21 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
return !EndOfFile && CurrentToken != null && CurrentToken.Kind == type;
}
protected bool TokenExistsAfterWhitespace(SyntaxKind kind, bool includeNewLines = true)
{
var tokenFound = false;
var whitespace = ReadWhile(token =>
token.Kind == SyntaxKind.Whitespace ||
(includeNewLines && token.Kind == SyntaxKind.NewLine));
tokenFound = At(kind);
PutCurrentBack();
PutBack(whitespace);
EnsureCurrent();
return tokenFound;
}
protected bool EnsureCurrent()
{
if (CurrentToken == null)

View File

@ -1176,6 +1176,87 @@ namespace Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax
}
}
internal sealed partial class MarkupMiscAttributeContentSyntax : MarkupSyntaxNode
{
private readonly GreenNode _children;
internal MarkupMiscAttributeContentSyntax(SyntaxKind kind, GreenNode children, RazorDiagnostic[] diagnostics, SyntaxAnnotation[] annotations)
: base(kind, diagnostics, annotations)
{
SlotCount = 1;
if (children != null)
{
AdjustFlagsAndWidth(children);
_children = children;
}
}
internal MarkupMiscAttributeContentSyntax(SyntaxKind kind, GreenNode children)
: base(kind)
{
SlotCount = 1;
if (children != null)
{
AdjustFlagsAndWidth(children);
_children = children;
}
}
public SyntaxList<RazorSyntaxNode> Children { get { return new SyntaxList<RazorSyntaxNode>(_children); } }
internal override GreenNode GetSlot(int index)
{
switch (index)
{
case 0: return _children;
default: return null;
}
}
internal override SyntaxNode CreateRed(SyntaxNode parent, int position)
{
return new Syntax.MarkupMiscAttributeContentSyntax(this, parent, position);
}
public override TResult Accept<TResult>(SyntaxVisitor<TResult> visitor)
{
return visitor.VisitMarkupMiscAttributeContent(this);
}
public override void Accept(SyntaxVisitor visitor)
{
visitor.VisitMarkupMiscAttributeContent(this);
}
public MarkupMiscAttributeContentSyntax Update(Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax.SyntaxList<RazorSyntaxNode> children)
{
if (children != Children)
{
var newNode = SyntaxFactory.MarkupMiscAttributeContent(children);
var diags = GetDiagnostics();
if (diags != null && diags.Length > 0)
newNode = newNode.WithDiagnosticsGreen(diags);
var annotations = GetAnnotations();
if (annotations != null && annotations.Length > 0)
newNode = newNode.WithAnnotationsGreen(annotations);
return newNode;
}
return this;
}
internal override GreenNode SetDiagnostics(RazorDiagnostic[] diagnostics)
{
return new MarkupMiscAttributeContentSyntax(Kind, _children, diagnostics, GetAnnotations());
}
internal override GreenNode SetAnnotations(SyntaxAnnotation[] annotations)
{
return new MarkupMiscAttributeContentSyntax(Kind, _children, GetDiagnostics(), annotations);
}
}
internal sealed partial class MarkupLiteralAttributeValueSyntax : MarkupSyntaxNode
{
private readonly MarkupTextLiteralSyntax _prefix;
@ -3282,6 +3363,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax
return DefaultVisit(node);
}
public virtual TResult VisitMarkupMiscAttributeContent(MarkupMiscAttributeContentSyntax node)
{
return DefaultVisit(node);
}
public virtual TResult VisitMarkupLiteralAttributeValue(MarkupLiteralAttributeValueSyntax node)
{
return DefaultVisit(node);
@ -3466,6 +3552,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax
DefaultVisit(node);
}
public virtual void VisitMarkupMiscAttributeContent(MarkupMiscAttributeContentSyntax node)
{
DefaultVisit(node);
}
public virtual void VisitMarkupLiteralAttributeValue(MarkupLiteralAttributeValueSyntax node)
{
DefaultVisit(node);
@ -3673,6 +3764,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax
return node.Update(namePrefix, name, nameSuffix, equalsToken, valuePrefix, value, valueSuffix);
}
public override GreenNode VisitMarkupMiscAttributeContent(MarkupMiscAttributeContentSyntax node)
{
var children = VisitList(node.Children);
return node.Update(children);
}
public override GreenNode VisitMarkupLiteralAttributeValue(MarkupLiteralAttributeValueSyntax node)
{
var prefix = (MarkupTextLiteralSyntax)Visit(node.Prefix);
@ -3987,6 +4084,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax
return new MarkupAttributeBlockSyntax(SyntaxKind.MarkupAttributeBlock, namePrefix, name, nameSuffix, equalsToken, valuePrefix, value, valueSuffix);
}
public static MarkupMiscAttributeContentSyntax MarkupMiscAttributeContent(Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax.SyntaxList<RazorSyntaxNode> children)
{
var result = new MarkupMiscAttributeContentSyntax(SyntaxKind.MarkupMiscAttributeContent, children.Node);
return result;
}
public static MarkupLiteralAttributeValueSyntax MarkupLiteralAttributeValue(MarkupTextLiteralSyntax prefix, MarkupTextLiteralSyntax value)
{
var result = new MarkupLiteralAttributeValueSyntax(SyntaxKind.MarkupLiteralAttributeValue, prefix, value);
@ -4235,6 +4339,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Syntax.InternalSyntax
typeof(MarkupTagBlockSyntax),
typeof(MarkupMinimizedAttributeBlockSyntax),
typeof(MarkupAttributeBlockSyntax),
typeof(MarkupMiscAttributeContentSyntax),
typeof(MarkupLiteralAttributeValueSyntax),
typeof(MarkupDynamicAttributeValueSyntax),
typeof(MarkupElementSyntax),

View File

@ -89,6 +89,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Syntax
return DefaultVisit(node);
}
/// <summary>Called when the visitor visits a MarkupMiscAttributeContentSyntax node.</summary>
public virtual TResult VisitMarkupMiscAttributeContent(MarkupMiscAttributeContentSyntax node)
{
return DefaultVisit(node);
}
/// <summary>Called when the visitor visits a MarkupLiteralAttributeValueSyntax node.</summary>
public virtual TResult VisitMarkupLiteralAttributeValue(MarkupLiteralAttributeValueSyntax node)
{
@ -308,6 +314,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Syntax
DefaultVisit(node);
}
/// <summary>Called when the visitor visits a MarkupMiscAttributeContentSyntax node.</summary>
public virtual void VisitMarkupMiscAttributeContent(MarkupMiscAttributeContentSyntax node)
{
DefaultVisit(node);
}
/// <summary>Called when the visitor visits a MarkupLiteralAttributeValueSyntax node.</summary>
public virtual void VisitMarkupLiteralAttributeValue(MarkupLiteralAttributeValueSyntax node)
{
@ -538,6 +550,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Syntax
return node.Update(namePrefix, name, nameSuffix, equalsToken, valuePrefix, value, valueSuffix);
}
public override SyntaxNode VisitMarkupMiscAttributeContent(MarkupMiscAttributeContentSyntax node)
{
var children = VisitList(node.Children);
return node.Update(children);
}
public override SyntaxNode VisitMarkupLiteralAttributeValue(MarkupLiteralAttributeValueSyntax node)
{
var prefix = (MarkupTextLiteralSyntax)Visit(node.Prefix);
@ -905,6 +923,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Syntax
return SyntaxFactory.MarkupAttributeBlock(default(MarkupTextLiteralSyntax), SyntaxFactory.MarkupTextLiteral(), default(MarkupTextLiteralSyntax), SyntaxFactory.Token(SyntaxKind.Equals), default(MarkupTextLiteralSyntax), default(RazorBlockSyntax), default(MarkupTextLiteralSyntax));
}
/// <summary>Creates a new MarkupMiscAttributeContentSyntax instance.</summary>
public static MarkupMiscAttributeContentSyntax MarkupMiscAttributeContent(SyntaxList<RazorSyntaxNode> children)
{
return (MarkupMiscAttributeContentSyntax)InternalSyntax.SyntaxFactory.MarkupMiscAttributeContent(children.Node.ToGreenList<InternalSyntax.RazorSyntaxNode>()).CreateRed();
}
/// <summary>Creates a new MarkupMiscAttributeContentSyntax instance.</summary>
public static MarkupMiscAttributeContentSyntax MarkupMiscAttributeContent()
{
return SyntaxFactory.MarkupMiscAttributeContent(default(SyntaxList<RazorSyntaxNode>));
}
/// <summary>Creates a new MarkupLiteralAttributeValueSyntax instance.</summary>
public static MarkupLiteralAttributeValueSyntax MarkupLiteralAttributeValue(MarkupTextLiteralSyntax prefix, MarkupTextLiteralSyntax value)
{

View File

@ -1133,6 +1133,75 @@ namespace Microsoft.AspNetCore.Razor.Language.Syntax
}
}
internal sealed partial class MarkupMiscAttributeContentSyntax : MarkupSyntaxNode
{
private SyntaxNode _children;
internal MarkupMiscAttributeContentSyntax(GreenNode green, SyntaxNode parent, int position)
: base(green, parent, position)
{
}
public SyntaxList<RazorSyntaxNode> Children
{
get
{
return new SyntaxList<RazorSyntaxNode>(GetRed(ref _children, 0));
}
}
internal override SyntaxNode GetNodeSlot(int index)
{
switch (index)
{
case 0: return GetRedAtZero(ref _children);
default: return null;
}
}
internal override SyntaxNode GetCachedSlot(int index)
{
switch (index)
{
case 0: return _children;
default: return null;
}
}
public override TResult Accept<TResult>(SyntaxVisitor<TResult> visitor)
{
return visitor.VisitMarkupMiscAttributeContent(this);
}
public override void Accept(SyntaxVisitor visitor)
{
visitor.VisitMarkupMiscAttributeContent(this);
}
public MarkupMiscAttributeContentSyntax Update(SyntaxList<RazorSyntaxNode> children)
{
if (children != Children)
{
var newNode = SyntaxFactory.MarkupMiscAttributeContent(children);
var annotations = GetAnnotations();
if (annotations != null && annotations.Length > 0)
return newNode.WithAnnotations(annotations);
return newNode;
}
return this;
}
public MarkupMiscAttributeContentSyntax WithChildren(SyntaxList<RazorSyntaxNode> children)
{
return Update(children);
}
public MarkupMiscAttributeContentSyntax AddChildren(params RazorSyntaxNode[] items)
{
return WithChildren(this.Children.AddRange(items));
}
}
internal sealed partial class MarkupLiteralAttributeValueSyntax : MarkupSyntaxNode
{
private MarkupTextLiteralSyntax _prefix;

View File

@ -86,6 +86,10 @@
<Field Name="Value" Type="RazorBlockSyntax" Optional="true" />
<Field Name="ValueSuffix" Type="MarkupTextLiteralSyntax" Optional="true" />
</Node>
<Node Name="MarkupMiscAttributeContentSyntax" Base="MarkupSyntaxNode">
<Kind Name="MarkupMiscAttributeContent" />
<Field Name="Children" Type="SyntaxList&lt;RazorSyntaxNode&gt;" />
</Node>
<Node Name="MarkupLiteralAttributeValueSyntax" Base="MarkupSyntaxNode">
<Kind Name="MarkupLiteralAttributeValue" />
<Field Name="Prefix" Type="MarkupTextLiteralSyntax" Optional="true" />
@ -99,7 +103,7 @@
<Node Name="MarkupElementSyntax" Base="MarkupSyntaxNode">
<Kind Name="MarkupElement" />
<Field Name="StartTag" Type="MarkupTagBlockSyntax" Optional="true" />
<Field Name="Body" Type="SyntaxList&lt;RazorSyntaxNode&gt;" Optional="true" />
<Field Name="Body" Type="SyntaxList&lt;RazorSyntaxNode&gt;" />
<Field Name="EndTag" Type="MarkupTagBlockSyntax" Optional="true" />
</Node>
<Node Name="MarkupTagHelperElementSyntax" Base="MarkupSyntaxNode">

View File

@ -25,6 +25,7 @@ namespace Microsoft.AspNetCore.Razor.Language
MarkupCommentBlock,
MarkupAttributeBlock,
MarkupMinimizedAttributeBlock,
MarkupMiscAttributeContent,
MarkupLiteralAttributeValue,
MarkupDynamicAttributeValue,
MarkupTagHelperElement,

View File

@ -0,0 +1,46 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNetCore.Razor.Language.Syntax
{
internal static class SyntaxUtilities
{
public static MarkupTextLiteralSyntax MergeTextLiterals(params MarkupTextLiteralSyntax[] literalSyntaxes)
{
if (literalSyntaxes == null || literalSyntaxes.Length == 0)
{
return null;
}
SyntaxNode parent = null;
var position = 0;
var seenFirstLiteral = false;
var builder = Syntax.InternalSyntax.SyntaxListBuilder.Create();
foreach (var syntax in literalSyntaxes)
{
if (syntax == null)
{
continue;
}
else if (!seenFirstLiteral)
{
// Set the parent and position of the merged literal to the value of the first non-null literal.
parent = syntax.Parent;
position = syntax.Position;
seenFirstLiteral = true;
}
foreach (var token in syntax.LiteralTokens)
{
builder.Add(token.Green);
}
}
var mergedLiteralSyntax = Syntax.InternalSyntax.SyntaxFactory.MarkupTextLiteral(
builder.ToList<Syntax.InternalSyntax.SyntaxToken>());
return (MarkupTextLiteralSyntax)mergedLiteralSyntax.CreateRed(parent, position);
}
}
}