Don't ignore whitespace at the start of '<text>' tag
This commit is contained in:
parent
758be9ae13
commit
8bba757703
|
|
@ -1272,6 +1272,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
{
|
||||
PutBack(lastWhitespace);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If it precedes a '<text>' tag, it should be accepted as code.
|
||||
Accept(lastWhitespace);
|
||||
}
|
||||
}
|
||||
|
||||
if (isMarkup)
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
length: 1));
|
||||
}
|
||||
|
||||
[Fact(Skip = "Fails due to https://github.com/aspnet/Razor/issues/897")]
|
||||
[Fact]
|
||||
public void RazorCommentInVerbatimBlock()
|
||||
{
|
||||
ParseDocumentTest("@{" + Environment.NewLine
|
||||
|
|
@ -126,7 +126,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
new StatementBlock(
|
||||
Factory.CodeTransition(),
|
||||
Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None),
|
||||
Factory.Code(Environment.NewLine)
|
||||
Factory.Code($"{Environment.NewLine} ")
|
||||
.AsStatement()
|
||||
.AutoCompleteWith("}"),
|
||||
new MarkupBlock(
|
||||
|
|
|
|||
|
|
@ -605,12 +605,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)));
|
||||
}
|
||||
|
||||
[Fact(Skip = "Fails due to https://github.com/aspnet/Razor/issues/897")]
|
||||
[Fact]
|
||||
public void ParseBlockCorrectlyReturnsFromMarkupBlockWithPseudoTag()
|
||||
{
|
||||
ParseBlockTest("if (i > 0) { <text>;</text> }",
|
||||
new StatementBlock(
|
||||
Factory.Code("if (i > 0) {").AsStatement(),
|
||||
Factory.Code("if (i > 0) { ").AsStatement(),
|
||||
new MarkupBlock(
|
||||
new MarkupTagBlock(
|
||||
Factory.MarkupTransition("<text>").Accepts(AcceptedCharactersInternal.None)),
|
||||
|
|
@ -620,13 +620,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
Factory.Code(" }").AsStatement()));
|
||||
}
|
||||
|
||||
[Fact(Skip = "Fails due to https://github.com/aspnet/Razor/issues/897")]
|
||||
[Fact]
|
||||
public void ParseBlockCorrectlyReturnsFromMarkupBlockWithPseudoTagInCodeBlock()
|
||||
{
|
||||
ParseBlockTest("{ if (i > 0) { <text>;</text> } }",
|
||||
new StatementBlock(
|
||||
Factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None),
|
||||
Factory.Code(" if (i > 0) {")
|
||||
Factory.Code(" if (i > 0) { ")
|
||||
.AsStatement()
|
||||
.AutoCompleteWith(autoCompleteString: null),
|
||||
new MarkupBlock(
|
||||
|
|
@ -639,7 +639,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
Factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)));
|
||||
}
|
||||
|
||||
[Fact(Skip = "Fails due to https://github.com/aspnet/Razor/issues/897")]
|
||||
[Fact]
|
||||
public void ParseBlockSupportsAllKindsOfImplicitMarkupInCodeBlock()
|
||||
{
|
||||
ParseBlockTest("{" + Environment.NewLine
|
||||
|
|
@ -665,7 +665,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
Factory.Markup("Single Line Markup" + Environment.NewLine)
|
||||
.With(new SpanEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString, AcceptedCharactersInternal.None))
|
||||
),
|
||||
Factory.Code($" }}{Environment.NewLine} foreach (var p in Enumerable.Range(1, 10)) {{{Environment.NewLine}").AsStatement(),
|
||||
Factory.Code($" }}{Environment.NewLine} foreach (var p in Enumerable.Range(1, 10)) {{{Environment.NewLine} ").AsStatement(),
|
||||
new MarkupBlock(
|
||||
new MarkupTagBlock(
|
||||
Factory.MarkupTransition("<text>").Accepts(AcceptedCharactersInternal.None)),
|
||||
|
|
|
|||
|
|
@ -1451,7 +1451,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
new SourceLocation(index, 0, index)),
|
||||
new StatementBlock(
|
||||
factory.CodeTransition(),
|
||||
factory.Code("do { var foo = bar;").AsStatement(),
|
||||
factory.Code("do { var foo = bar; ").AsStatement(),
|
||||
new MarkupBlock(
|
||||
new MarkupTagBlock(
|
||||
factory.MarkupTransition("<text>")),
|
||||
|
|
|
|||
|
|
@ -141,7 +141,6 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
[InlineData(12, 2)]
|
||||
[InlineData(12, 14)]
|
||||
[InlineData(13, 13)]
|
||||
[InlineData(13, 13)]
|
||||
[InlineData(20, 1)]
|
||||
[InlineData(21, 0)]
|
||||
public void GetOffSet_SpanIsNotOwnerOfChange_ThrowsException(int absoluteIndex, int length)
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles
|
|||
{
|
||||
#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml"
|
||||
|
||||
var a = 1;
|
||||
var a = 1;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("foo");
|
||||
#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement.cshtml"
|
||||
|
||||
var b = 1;
|
||||
var b = 1;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ Document -
|
|||
NamespaceDeclaration - - Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles
|
||||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockWithTextElement_Runtime - -
|
||||
MethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync
|
||||
CSharpCode - (2:0,2 [16] CodeBlockWithTextElement.cshtml)
|
||||
RazorIRToken - (2:0,2 [16] CodeBlockWithTextElement.cshtml) - CSharp - \n var a = 1;
|
||||
CSharpCode - (2:0,2 [17] CodeBlockWithTextElement.cshtml)
|
||||
RazorIRToken - (2:0,2 [17] CodeBlockWithTextElement.cshtml) - CSharp - \n var a = 1;
|
||||
HtmlContent - (25:1,21 [3] CodeBlockWithTextElement.cshtml)
|
||||
RazorIRToken - (25:1,21 [3] CodeBlockWithTextElement.cshtml) - Html - foo
|
||||
CSharpCode - (35:1,31 [19] CodeBlockWithTextElement.cshtml)
|
||||
RazorIRToken - (35:1,31 [19] CodeBlockWithTextElement.cshtml) - CSharp - \n var b = 1;
|
||||
CSharpCode - (35:1,31 [22] CodeBlockWithTextElement.cshtml)
|
||||
RazorIRToken - (35:1,31 [22] CodeBlockWithTextElement.cshtml) - CSharp - \n var b = 1;
|
||||
HtmlContent - (63:2,23 [4] CodeBlockWithTextElement.cshtml)
|
||||
RazorIRToken - (63:2,23 [4] CodeBlockWithTextElement.cshtml) - Html - bar
|
||||
CSharpExpression - (69:2,29 [3] CodeBlockWithTextElement.cshtml)
|
||||
|
|
|
|||
|
|
@ -199,13 +199,13 @@ __TestNamespace_InputTagHelper2.Checked = true;
|
|||
__tagHelperExecutionContext.Add(__TestNamespace_InputTagHelper2);
|
||||
BeginWriteTagHelperAttribute();
|
||||
#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml"
|
||||
if(true) {
|
||||
if(true) {
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("checkbox");
|
||||
#line 19 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers.cshtml"
|
||||
} else {
|
||||
} else {
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ Document -
|
|||
RazorIRToken - (166:7,35 [6] ComplexTagHelpers.cshtml) - Html - string
|
||||
HtmlContent - (178:7,47 [10] ComplexTagHelpers.cshtml)
|
||||
RazorIRToken - (178:7,47 [10] ComplexTagHelpers.cshtml) - Html - \n
|
||||
TagHelper - (188:8,8 [529] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag
|
||||
TagHelper - (188:8,8 [531] ComplexTagHelpers.cshtml) - p - TagMode.StartTagAndEndTag
|
||||
TagHelperBody -
|
||||
HtmlContent - (226:8,46 [34] ComplexTagHelpers.cshtml)
|
||||
RazorIRToken - (226:8,46 [14] ComplexTagHelpers.cshtml) - Html - \n
|
||||
|
|
@ -106,28 +106,28 @@ Document -
|
|||
HtmlContent - (591:17,66 [18] ComplexTagHelpers.cshtml)
|
||||
RazorIRToken - (591:17,66 [2] ComplexTagHelpers.cshtml) - Html - \n
|
||||
RazorIRToken - (593:18,0 [16] ComplexTagHelpers.cshtml) - Html -
|
||||
TagHelper - (609:18,16 [79] ComplexTagHelpers.cshtml) - input - TagMode.StartTagOnly
|
||||
TagHelper - (609:18,16 [81] ComplexTagHelpers.cshtml) - input - TagMode.StartTagOnly
|
||||
TagHelperBody -
|
||||
CreateTagHelper - - TestNamespace.InputTagHelper
|
||||
CreateTagHelper - - TestNamespace.InputTagHelper2
|
||||
SetTagHelperProperty - (622:18,29 [64] ComplexTagHelpers.cshtml) - type - Type - HtmlAttributeValueStyle.SingleQuotes
|
||||
CSharpCode - (623:18,30 [10] ComplexTagHelpers.cshtml)
|
||||
RazorIRToken - (623:18,30 [10] ComplexTagHelpers.cshtml) - CSharp - if(true) {
|
||||
SetTagHelperProperty - (622:18,29 [66] ComplexTagHelpers.cshtml) - type - Type - HtmlAttributeValueStyle.SingleQuotes
|
||||
CSharpCode - (623:18,30 [11] ComplexTagHelpers.cshtml)
|
||||
RazorIRToken - (623:18,30 [11] ComplexTagHelpers.cshtml) - CSharp - if(true) {
|
||||
HtmlContent - (640:18,47 [8] ComplexTagHelpers.cshtml)
|
||||
RazorIRToken - (640:18,47 [8] ComplexTagHelpers.cshtml) - Html - checkbox
|
||||
CSharpCode - (655:18,62 [9] ComplexTagHelpers.cshtml)
|
||||
RazorIRToken - (655:18,62 [9] ComplexTagHelpers.cshtml) - CSharp - } else {
|
||||
CSharpCode - (655:18,62 [10] ComplexTagHelpers.cshtml)
|
||||
RazorIRToken - (655:18,62 [10] ComplexTagHelpers.cshtml) - CSharp - } else {
|
||||
HtmlContent - (671:18,78 [8] ComplexTagHelpers.cshtml)
|
||||
RazorIRToken - (671:18,78 [8] ComplexTagHelpers.cshtml) - Html - anything
|
||||
CSharpCode - (686:18,93 [2] ComplexTagHelpers.cshtml)
|
||||
RazorIRToken - (686:18,93 [2] ComplexTagHelpers.cshtml) - CSharp - }
|
||||
SetTagHelperProperty - (622:18,29 [64] ComplexTagHelpers.cshtml) - type - Type - HtmlAttributeValueStyle.SingleQuotes
|
||||
CSharpCode - (623:18,30 [10] ComplexTagHelpers.cshtml)
|
||||
RazorIRToken - (623:18,30 [10] ComplexTagHelpers.cshtml) - CSharp - if(true) {
|
||||
SetTagHelperProperty - (622:18,29 [66] ComplexTagHelpers.cshtml) - type - Type - HtmlAttributeValueStyle.SingleQuotes
|
||||
CSharpCode - (623:18,30 [11] ComplexTagHelpers.cshtml)
|
||||
RazorIRToken - (623:18,30 [11] ComplexTagHelpers.cshtml) - CSharp - if(true) {
|
||||
HtmlContent - (640:18,47 [8] ComplexTagHelpers.cshtml)
|
||||
RazorIRToken - (640:18,47 [8] ComplexTagHelpers.cshtml) - Html - checkbox
|
||||
CSharpCode - (655:18,62 [9] ComplexTagHelpers.cshtml)
|
||||
RazorIRToken - (655:18,62 [9] ComplexTagHelpers.cshtml) - CSharp - } else {
|
||||
CSharpCode - (655:18,62 [10] ComplexTagHelpers.cshtml)
|
||||
RazorIRToken - (655:18,62 [10] ComplexTagHelpers.cshtml) - CSharp - } else {
|
||||
HtmlContent - (671:18,78 [8] ComplexTagHelpers.cshtml)
|
||||
RazorIRToken - (671:18,78 [8] ComplexTagHelpers.cshtml) - Html - anything
|
||||
CSharpCode - (686:18,93 [2] ComplexTagHelpers.cshtml)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles
|
|||
DefineSection("Link", async () => {
|
||||
});
|
||||
WriteLiteral("(string link) {\r\n <a");
|
||||
BeginWriteAttribute("href", " href=\"", 36, "\"", 93, 1);
|
||||
BeginWriteAttribute("href", " href=\"", 36, "\"", 94, 1);
|
||||
WriteAttributeValue("", 43, new Microsoft.AspNetCore.Mvc.Razor.HelperResult(async(__razor_attribute_value_writer) => {
|
||||
PushWriter(__razor_attribute_value_writer);
|
||||
#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml"
|
||||
|
|
@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles
|
|||
#line default
|
||||
#line hidden
|
||||
#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks.cshtml"
|
||||
} else {
|
||||
} else {
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
|
@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles
|
|||
#line hidden
|
||||
PopWriter();
|
||||
}
|
||||
), 43, 50, false);
|
||||
), 43, 51, false);
|
||||
EndWriteAttribute();
|
||||
WriteLiteral(" />\r\n}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ Document -
|
|||
HtmlContent - (13:0,13 [23] InlineBlocks.cshtml)
|
||||
RazorIRToken - (13:0,13 [21] InlineBlocks.cshtml) - Html - (string link) {\n
|
||||
RazorIRToken - (34:1,4 [2] InlineBlocks.cshtml) - Html - <a
|
||||
HtmlAttribute - (36:1,6 [58] InlineBlocks.cshtml) - href=" - "
|
||||
CSharpCodeAttributeValue - (43:1,13 [50] InlineBlocks.cshtml) -
|
||||
HtmlAttribute - (36:1,6 [59] InlineBlocks.cshtml) - href=" - "
|
||||
CSharpCodeAttributeValue - (43:1,13 [51] InlineBlocks.cshtml) -
|
||||
RazorIRToken - (44:1,14 [19] InlineBlocks.cshtml) - CSharp - if(link != null) {
|
||||
CSharpExpression - (64:1,34 [4] InlineBlocks.cshtml)
|
||||
RazorIRToken - (64:1,34 [4] InlineBlocks.cshtml) - CSharp - link
|
||||
RazorIRToken - (68:1,38 [9] InlineBlocks.cshtml) - CSharp - } else {
|
||||
RazorIRToken - (68:1,38 [10] InlineBlocks.cshtml) - CSharp - } else {
|
||||
HtmlContent - (84:1,54 [1] InlineBlocks.cshtml)
|
||||
RazorIRToken - (84:1,54 [1] InlineBlocks.cshtml) - Html - #
|
||||
RazorIRToken - (92:1,62 [2] InlineBlocks.cshtml) - CSharp - }
|
||||
|
|
|
|||
Loading…
Reference in New Issue