",
- new MarkupBlock(
- new MarkupTagHelperBlock("p",
- new List
- {
- new TagHelperAttributeNode(
- "bar",
- new MarkupBlock(
- factory.Markup("false'"),
- factory.Markup(" >
",
- new MarkupBlock(
- blockFactory.MarkupTagBlock(""))),
- new []
- {
- RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper(
- new SourceSpan(new SourceLocation(14, 0, 14), contentLength: 1), "p")
- }
- }
- };
- }
- }
-
- [Theory]
- [MemberData(nameof(MalformedTagHelperBlockData))]
- public void Rewrite_CreatesErrorForMalformedTagHelper(
- string documentContent,
- object expectedOutput,
- object expectedErrors)
- {
- RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, (RazorDiagnostic[])expectedErrors, "strong", "p");
- }
-
- public static TheoryData CodeTagHelperAttributesData
- {
- get
- {
- var factory = new SpanFactory();
- var dateTimeNow = new MarkupBlock(
- factory.Markup(" "),
- new ExpressionBlock(
- factory.CodeTransition(),
- factory.Code("DateTime.Now")
- .AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
- .Accepts(AcceptedCharactersInternal.NonWhiteSpace)));
-
- return new TheoryData
- {
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock("person",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode("age", factory.CodeMarkup("12").With(new ExpressionChunkGenerator()))
- }))
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock("person",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode(
- "birthday",
- factory.CodeMarkup("DateTime.Now").With(new ExpressionChunkGenerator()))
- }))
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock("person",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode(
- "age",
- new MarkupBlock(
- new MarkupBlock(
- new ExpressionBlock(
- factory.CodeTransition(),
- factory
- .CSharpCodeMarkup("DateTime.Now.Year")
- .With(new ExpressionChunkGenerator())))))
- }))
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock("person",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode(
- "age",
- new MarkupBlock(
- new MarkupBlock(
- factory.CodeMarkup(" ").With(new ExpressionChunkGenerator()),
- new ExpressionBlock(
- factory.CSharpCodeMarkup("@").With(new ExpressionChunkGenerator()),
- factory
- .CSharpCodeMarkup("DateTime.Now.Year")
- .With(new ExpressionChunkGenerator())))))
- }))
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock("person",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode("name", factory.Markup("John"))
- }))
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock("person",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode(
- "name",
- new MarkupBlock(factory.Markup("Time:"), dateTimeNow))
- }))
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock("person",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode(
- "age",
- new MarkupBlock(
- factory.CodeMarkup("1").With(new ExpressionChunkGenerator()),
- factory.CodeMarkup(" +").With(new ExpressionChunkGenerator()),
- new MarkupBlock(
- factory.CodeMarkup(" ").With(new ExpressionChunkGenerator()),
- new ExpressionBlock(
- factory.CSharpCodeMarkup("@").With(new ExpressionChunkGenerator()),
- factory.CSharpCodeMarkup("value")
- .With(new ExpressionChunkGenerator()))),
- factory.CodeMarkup(" +").With(new ExpressionChunkGenerator()),
- factory.CodeMarkup(" 2").With(new ExpressionChunkGenerator()))),
- new TagHelperAttributeNode(
- "birthday",
- new MarkupBlock(
- factory.CodeMarkup("(bool)").With(new ExpressionChunkGenerator()),
- new MarkupBlock(
- new ExpressionBlock(
- factory.CSharpCodeMarkup("@").With(new ExpressionChunkGenerator()),
- factory
- .CSharpCodeMarkup("Bag[\"val\"]")
- .With(new ExpressionChunkGenerator()))),
- factory.CodeMarkup(" ?").With(new ExpressionChunkGenerator()),
- new MarkupBlock(
- factory.CodeMarkup(" @").With(new ExpressionChunkGenerator())
- .As(SpanKindInternal.Code),
- factory.CodeMarkup("@").With(SpanChunkGenerator.Null)
- .As(SpanKindInternal.Code)),
- factory.CodeMarkup("DateTime").With(new ExpressionChunkGenerator()),
- factory.CodeMarkup(" :").With(new ExpressionChunkGenerator()),
- new MarkupBlock(
- factory.CodeMarkup(" ").With(new ExpressionChunkGenerator()),
- new ExpressionBlock(
- factory.CSharpCodeMarkup("@").With(new ExpressionChunkGenerator()),
- factory
- .CSharpCodeMarkup("DateTime.Now")
- .With(new ExpressionChunkGenerator())))),
- AttributeStructure.SingleQuotes)
- }))
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock("person",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode("age", factory.CodeMarkup("12").With(new ExpressionChunkGenerator())),
- new TagHelperAttributeNode(
- "birthday",
- factory.CodeMarkup("DateTime.Now").With(new ExpressionChunkGenerator())),
- new TagHelperAttributeNode(
- "name",
- new MarkupBlock(factory.Markup("Time:"), dateTimeNow))
- }))
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock("person",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode("age", factory.CodeMarkup("12").With(new ExpressionChunkGenerator())),
- new TagHelperAttributeNode(
- "birthday",
- factory.CodeMarkup("DateTime.Now").With(new ExpressionChunkGenerator())),
- new TagHelperAttributeNode(
- "name",
- new MarkupBlock(
- factory.Markup("Time:"),
- new MarkupBlock(
- factory.Markup(" @").Accepts(AcceptedCharactersInternal.None),
- factory.Markup("@")
- .With(SpanChunkGenerator.Null)
- .Accepts(AcceptedCharactersInternal.None)),
- dateTimeNow))
- }))
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock("person",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode("age", factory.CodeMarkup("12").With(new ExpressionChunkGenerator())),
- new TagHelperAttributeNode(
- "birthday",
- factory.CodeMarkup("DateTime.Now").With(new ExpressionChunkGenerator())),
- new TagHelperAttributeNode(
- "name",
- new MarkupBlock(
- new MarkupBlock(
- factory.Markup("@").Accepts(AcceptedCharactersInternal.None),
- factory.Markup("@")
- .With(SpanChunkGenerator.Null)
- .Accepts(AcceptedCharactersInternal.None)),
- factory.Markup("BoundStringAttribute")))
- }))
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock("person",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode(
- "age",
- new MarkupBlock(
- new MarkupBlock(
- factory.CodeMarkup("@").With(new ExpressionChunkGenerator()),
- factory.CodeMarkup("@").With(SpanChunkGenerator.Null)),
- new MarkupBlock(
- factory.EmptyHtml()
- .AsCodeMarkup().With(new ExpressionChunkGenerator())
- .As(SpanKindInternal.Code),
- new ExpressionBlock(
- factory.CSharpCodeMarkup("@").With(new ExpressionChunkGenerator()),
- factory.CSharpCodeMarkup("(").With(new ExpressionChunkGenerator()),
- factory.CSharpCodeMarkup("11+1")
- .With(new ExpressionChunkGenerator()),
- factory.CSharpCodeMarkup(")").With(new ExpressionChunkGenerator()))))),
- new TagHelperAttributeNode(
- "birthday",
- factory.CodeMarkup("DateTime.Now").With(new ExpressionChunkGenerator())),
- new TagHelperAttributeNode(
- "name",
- new MarkupBlock(factory.Markup("Time:"), dateTimeNow))
- }))
- },
- };
- }
- }
-
- [Theory]
- [MemberData(nameof(CodeTagHelperAttributesData))]
- public void Rewrite_CreatesMarkupCodeSpansForNonStringTagHelperAttributes(
- string documentContent,
- object expectedOutput)
+ [Fact]
+ public void Rewrite_AllowsCompatibleTagStructures1()
{
// Arrange
- var descriptors = new TagHelperDescriptor[]
- {
- TagHelperDescriptorBuilder.Create("PersonTagHelper", "personAssembly")
- .TagMatchingRuleDescriptor(rule => rule.RequireTagName("person"))
- .BoundAttributeDescriptor(attribute =>
- attribute
- .Name("age")
- .PropertyName("Age")
- .TypeName(typeof(int).FullName))
- .BoundAttributeDescriptor(attribute =>
- attribute
- .Name("birthday")
- .PropertyName("BirthDay")
- .TypeName(typeof(DateTime).FullName))
- .BoundAttributeDescriptor(attribute =>
- attribute
- .Name("name")
- .PropertyName("Name")
- .TypeName(typeof(string).FullName))
- .Build()
- };
+ var descriptors = GetTagStructureCompatibilityDescriptors(TagStructure.Unspecified, TagStructure.Unspecified);
// Act & Assert
- EvaluateData(
- descriptors,
- documentContent,
- (MarkupBlock)expectedOutput,
- expectedErrors: Enumerable.Empty());
+ EvaluateData(descriptors, "");
}
- public static IEnumerable
",
- new MarkupBlock(
- new MarkupTagHelperBlock("script",
- factory.Markup("Hel
lo
")),
- factory.Markup(" "),
- new MarkupTagHelperBlock("p",
- new MarkupTagHelperBlock("div",
- factory.Markup("World"))))
- };
- yield return new object[]
- {
- " ",
- new MarkupBlock(
- new MarkupTagHelperBlock("script",
- factory.Markup("Hello")),
- factory.Markup(" "),
- new MarkupTagHelperBlock("script",
- factory.Markup("World")))
- };
- yield return new object[]
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock("script",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode("class", factory.Markup("foo")),
- new TagHelperAttributeNode("style", factory.Markup("color:red;"))
- }))
- };
- yield return new object[]
- {
- "
Hello World
",
- new MarkupBlock(
- new MarkupTagHelperBlock("p",
- factory.Markup("Hello "),
- new MarkupTagHelperBlock("script",
- new List
- {
- new TagHelperAttributeNode("class", factory.Markup("foo")),
- new TagHelperAttributeNode("style", factory.Markup("color:red;"))
- }),
- factory.Markup(" World")))
- };
- yield return new object[]
- {
- "
Hello World
",
- new MarkupBlock(
- new MarkupTagHelperBlock("p",
- factory.Markup("Hello "),
- new MarkupTagHelperBlock("script",
- new List
- {
- new TagHelperAttributeNode(
- "class",
- new MarkupBlock(
- new MarkupBlock(
- factory.Markup("@").Accepts(AcceptedCharactersInternal.None),
- factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)),
- factory.Markup("foo@bar.com"))),
- new TagHelperAttributeNode("style", factory.Markup("color:red;"))
- }),
- factory.Markup(" World")))
- };
- }
- }
-
- [Theory]
- [MemberData(nameof(ScriptBlockData))]
- public void TagHelperParseTreeRewriter_RewritesScriptTagHelpers(
- string documentContent,
- object expectedOutput)
- {
- RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, "p", "div", "script");
- }
-
- public static IEnumerable SelfClosingBlockData
- {
- get
- {
- var factory = new SpanFactory();
-
- yield return new object[]
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock("p",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode("class", factory.Markup("foo")),
- new TagHelperAttributeNode("style", factory.Markup("color:red;"))
- }))
- };
- yield return new object[]
- {
- "
Hello
World
",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "p",
- TagMode.StartTagAndEndTag,
- children: new SyntaxTreeNode[]
- {
- factory.Markup("Hello "),
- new MarkupTagHelperBlock(
- "p",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode("class", factory.Markup("foo")),
- new TagHelperAttributeNode(
- "style",
- factory.Markup("color:red;"))
- }),
- factory.Markup(" World")
- }))
- };
- yield return new object[]
- {
- "Hello World",
- new MarkupBlock(
- factory.Markup("Hello"),
- new MarkupTagHelperBlock("p",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode("class", factory.Markup("foo"))
- }),
- factory.Markup(" "),
- new MarkupTagHelperBlock("p",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode("style", factory.Markup("color:red;"))
- }),
- factory.Markup("World"))
- };
- }
- }
-
- [Theory]
- [MemberData(nameof(SelfClosingBlockData))]
- public void TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers(
- string documentContent,
- object expectedOutput)
- {
- RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, "p");
- }
-
- public static IEnumerable QuotelessAttributeBlockData
- {
- get
- {
- var factory = new SpanFactory();
- var blockFactory = new BlockFactory(factory);
- var dateTimeNow = new Func(index =>
- new MarkupBlock(
- new MarkupBlock(
- new DynamicAttributeBlockChunkGenerator(
- new LocationTagged(
- string.Empty,
- new SourceLocation(index, 0, index)),
- new SourceLocation(index, 0, index)),
- new ExpressionBlock(
- factory.CodeTransition(),
- factory.Code("DateTime.Now")
- .AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
- .Accepts(AcceptedCharactersInternal.NonWhiteSpace)))));
-
- yield return new object[]
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock("p",
- new List
- {
- new TagHelperAttributeNode("class", factory.Markup("foo"), AttributeStructure.NoQuotes),
- new TagHelperAttributeNode("dynamic", dateTimeNow(21)),
- new TagHelperAttributeNode("style", factory.Markup("color:red;"), AttributeStructure.NoQuotes)
- }))
- };
- yield return new object[]
- {
- "
Hello World
",
- new MarkupBlock(
- new MarkupTagHelperBlock("p",
- new List
- {
- new TagHelperAttributeNode("class", factory.Markup("foo"), AttributeStructure.NoQuotes),
- new TagHelperAttributeNode("dynamic", dateTimeNow(21)),
- new TagHelperAttributeNode("style", factory.Markup("color:red;"), AttributeStructure.NoQuotes)
- },
- factory.Markup("Hello World")))
- };
- yield return new object[]
- {
- "
Hello World
",
- new MarkupBlock(
- new MarkupTagHelperBlock("p",
- new List
- {
- new TagHelperAttributeNode("class", factory.Markup("foo"), AttributeStructure.NoQuotes),
- new TagHelperAttributeNode("dynamic", dateTimeNow(21)),
- new TagHelperAttributeNode(
- "style",
- new MarkupBlock(
- factory.Markup("color"),
- new MarkupBlock(
- factory.Markup("@").Accepts(AcceptedCharactersInternal.None),
- factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)),
- factory.Markup(":red;")),
- AttributeStructure.DoubleQuotes)
- },
- factory.Markup("Hello World")))
- };
- yield return new object[]
- {
- "
Hello
World
",
- new MarkupBlock(
- new MarkupTagHelperBlock("p",
- new List
- {
- new TagHelperAttributeNode("class", factory.Markup("foo"), AttributeStructure.NoQuotes),
- new TagHelperAttributeNode("dynamic", dateTimeNow(21))
- },
- factory.Markup("Hello")),
- factory.Markup(" "),
- new MarkupTagHelperBlock("p",
- new List
- {
- new TagHelperAttributeNode("style", factory.Markup("color:red;"), AttributeStructure.NoQuotes),
- new TagHelperAttributeNode("dynamic", dateTimeNow(73))
- },
- factory.Markup("World")))
- };
- yield return new object[]
- {
- "
Hello World inside of strong tag
",
- new MarkupBlock(
- new MarkupTagHelperBlock("p",
- new List
- {
- new TagHelperAttributeNode("class", factory.Markup("foo"), AttributeStructure.NoQuotes),
- new TagHelperAttributeNode("dynamic", dateTimeNow(21)),
- new TagHelperAttributeNode("style", factory.Markup("color:red;"), AttributeStructure.NoQuotes)
- },
- factory.Markup("Hello World "),
- new MarkupTagBlock(
- factory.Markup("(" class=\"", 71, 0, 71),
- suffix: new LocationTagged("\"", 82, 0, 82)),
- factory.Markup(" class=\"").With(SpanChunkGenerator.Null),
- factory.Markup("foo").With(new LiteralAttributeChunkGenerator(prefix: new LocationTagged(string.Empty, 79, 0, 79),
- value: new LocationTagged("foo", 79, 0, 79))),
- factory.Markup("\"").With(SpanChunkGenerator.Null)),
- factory.Markup(">")),
- factory.Markup("inside of strong tag"),
- blockFactory.MarkupTagBlock("")))
- };
- }
- }
-
- [Theory]
- [MemberData(nameof(QuotelessAttributeBlockData))]
- public void TagHelperParseTreeRewriter_RewritesTagHelpersWithQuotelessAttributes(
- string documentContent,
- object expectedOutput)
- {
- RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, "p");
- }
-
- public static IEnumerable PlainAttributeBlockData
- {
- get
- {
- var factory = new SpanFactory();
- var blockFactory = new BlockFactory(factory);
-
- yield return new object[]
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock("p",
- new List
- {
- new TagHelperAttributeNode("class", factory.Markup("foo")),
- new TagHelperAttributeNode("style", factory.Markup("color:red;"))
- }))
- };
- yield return new object[]
- {
- "
Hello World
",
- new MarkupBlock(
- new MarkupTagHelperBlock("p",
- new List
- {
- new TagHelperAttributeNode("class", factory.Markup("foo")),
- new TagHelperAttributeNode("style", factory.Markup("color:red;"))
- },
- factory.Markup("Hello World")))
- };
- yield return new object[]
- {
- "
Hello
World
",
- new MarkupBlock(
- new MarkupTagHelperBlock("p",
- new List
- {
- new TagHelperAttributeNode("class", factory.Markup("foo"))
- },
- factory.Markup("Hello")),
- factory.Markup(" "),
- new MarkupTagHelperBlock("p",
- new List
- {
- new TagHelperAttributeNode("style", factory.Markup("color:red;"))
- },
- factory.Markup("World")))
- };
- yield return new object[]
- {
- "
Hello World inside of strong tag
",
- new MarkupBlock(
- new MarkupTagHelperBlock("p",
- new List
- {
- new TagHelperAttributeNode("class", factory.Markup("foo")),
- new TagHelperAttributeNode("style", factory.Markup("color:red;"))
- },
- factory.Markup("Hello World "),
- new MarkupTagBlock(
- factory.Markup("(" class=\"", 53, 0, 53),
- suffix: new LocationTagged("\"", 64, 0, 64)),
- factory.Markup(" class=\"").With(SpanChunkGenerator.Null),
- factory.Markup("foo").With(new LiteralAttributeChunkGenerator(prefix: new LocationTagged(string.Empty, 61, 0, 61),
- value: new LocationTagged("foo", 61, 0, 61))),
- factory.Markup("\"").With(SpanChunkGenerator.Null)),
- factory.Markup(">")),
- factory.Markup("inside of strong tag"),
- blockFactory.MarkupTagBlock("")))
- };
- }
- }
-
- [Theory]
- [MemberData(nameof(PlainAttributeBlockData))]
- public void TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes(
- string documentContent,
- object expectedOutput)
- {
- RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, "p");
- }
-
- public static IEnumerable PlainBlockData
- {
- get
- {
- var factory = new SpanFactory();
- var blockFactory = new BlockFactory(factory);
-
- yield return new object[]
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock("p"))
- };
- yield return new object[]
- {
- "
Hello World
",
- new MarkupBlock(
- new MarkupTagHelperBlock("p",
- factory.Markup("Hello World")))
- };
- yield return new object[]
- {
- "
Hello
World
",
- new MarkupBlock(
- new MarkupTagHelperBlock("p",
- factory.Markup("Hello")),
- factory.Markup(" "),
- new MarkupTagHelperBlock("p",
- factory.Markup("World")))
- };
- yield return new object[]
- {
- "
Hello World inside of strong tag
",
- new MarkupBlock(
- new MarkupTagHelperBlock("p",
- factory.Markup("Hello World "),
- blockFactory.MarkupTagBlock(""),
- factory.Markup("inside of strong tag"),
- blockFactory.MarkupTagBlock("")))
- };
- }
- }
-
- [Theory]
- [MemberData(nameof(PlainBlockData))]
- public void TagHelperParseTreeRewriter_RewritesPlainTagHelperTagBlocks(
- string documentContent,
- object expectedOutput)
- {
- RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, "p");
- }
-
- public static TheoryData DataDashAttributeData_Document
- {
- get
- {
- var factory = new SpanFactory();
- var dateTimeNowString = "@DateTime.Now";
- var dateTimeNow = new ExpressionBlock(
- factory.CodeTransition(),
- factory.Code("DateTime.Now")
- .AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
- .Accepts(AcceptedCharactersInternal.NonWhiteSpace));
-
- // documentContent, expectedOutput
- return new TheoryData
- {
- {
- $"",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode(
- "data-required",
- new MarkupBlock(dateTimeNow),
- AttributeStructure.SingleQuotes),
- }))
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode("data-required", factory.Markup("value"), AttributeStructure.SingleQuotes),
- }))
- },
- {
- $"",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode(
- "data-required",
- new MarkupBlock(factory.Markup("prefix "), dateTimeNow),
- AttributeStructure.SingleQuotes),
- }))
- },
- {
- $"",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode(
- "data-required",
- new MarkupBlock(dateTimeNow, factory.Markup(" suffix")),
- AttributeStructure.SingleQuotes),
- }))
- },
- {
- $"",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode(
- "data-required",
- new MarkupBlock(
- factory.Markup("prefix "),
- dateTimeNow,
- factory.Markup(" suffix")),
- AttributeStructure.SingleQuotes),
- }))
- },
- {
- $"",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode("pre-attribute", value: null, attributeStructure: AttributeStructure.Minimized),
- new TagHelperAttributeNode(
- "data-required",
- new MarkupBlock(
- factory.Markup("prefix "),
- dateTimeNow,
- factory.Markup(" suffix")),
- AttributeStructure.SingleQuotes),
- new TagHelperAttributeNode("post-attribute", value: null, attributeStructure: AttributeStructure.Minimized),
- }))
- },
- {
- $"",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode(
- "data-required",
- new MarkupBlock(
- dateTimeNow,
- factory.Markup(" middle "),
- dateTimeNow),
- AttributeStructure.SingleQuotes),
- }))
- },
- };
- }
- }
-
- public static TheoryData DataDashAttributeData_CSharpBlock
- {
- get
- {
- var factory = new SpanFactory();
- var documentData = DataDashAttributeData_Document;
- Func, MarkupBlock> buildStatementBlock = (insideBuilder) =>
- {
- return new MarkupBlock(
- factory.EmptyHtml(),
- new StatementBlock(
- factory.CodeTransition(),
- factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None),
- insideBuilder(),
- factory.EmptyCSharp().AsStatement(),
- factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)),
- factory.EmptyHtml());
- };
-
- foreach (var data in documentData)
- {
- data[0] = $"@{{{data[0]}}}";
- data[1] = buildStatementBlock(() => data[1] as MarkupBlock);
- }
-
- return documentData;
- }
- }
-
- [Theory]
- [MemberData(nameof(DataDashAttributeData_Document))]
- [MemberData(nameof(DataDashAttributeData_CSharpBlock))]
- public void Rewrite_GeneratesExpectedOutputForUnboundDataDashAttributes(
- string documentContent,
- object expectedOutput)
- {
- // Act & Assert
- RunParseTreeRewriterTest(documentContent, (MarkupBlock)expectedOutput, Enumerable.Empty(), "input");
- }
-
- public static TheoryData MinimizedAttributeData_Document
- {
- get
- {
- var factory = new SpanFactory();
- var noErrors = new RazorDiagnostic[0];
- var stringType = typeof(string).FullName;
- var intType = typeof(int).FullName;
- var expressionString = "@DateTime.Now + 1";
- var expression = new Func(index =>
- new MarkupBlock(
- new MarkupBlock(
- new DynamicAttributeBlockChunkGenerator(
- new LocationTagged(
- string.Empty,
- new SourceLocation(index, 0, index)),
- new SourceLocation(index, 0, index)),
- new ExpressionBlock(
- factory.CodeTransition(),
- factory.Code("DateTime.Now")
- .AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
- .Accepts(AcceptedCharactersInternal.NonWhiteSpace))),
- factory.Markup(" +")
- .With(new LiteralAttributeChunkGenerator(
- prefix: new LocationTagged(" ", index + 13, 0, index + 13),
- value: new LocationTagged("+", index + 14, 0, index + 14))),
- factory.Markup(" 1")
- .With(new LiteralAttributeChunkGenerator(
- prefix: new LocationTagged(" ", index + 15, 0, index + 15),
- value: new LocationTagged("1", index + 16, 0, index + 16)))));
-
- // documentContent, expectedOutput, expectedErrors
- return new TheoryData
- {
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode("unbound-required", null, AttributeStructure.Minimized),
- })),
- noErrors
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "p",
- TagMode.StartTagAndEndTag,
- attributes: new List()
- {
- new TagHelperAttributeNode("bound-string", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(3, 0, 3, 12),
- "bound-string",
- "p",
- stringType),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode("bound-required-string", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(7, 0, 7, 21),
- "bound-required-string",
- "input",
- stringType),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode("bound-required-int", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(7, 0, 7, 18),
- "bound-required-int",
- "input",
- intType),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "p",
- TagMode.StartTagAndEndTag,
- attributes: new List()
- {
- new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(3, 0, 3, 9),
- "bound-int",
- "p",
- intType),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode("int-dictionary", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(7, 0, 7, 14),
- "int-dictionary",
- "input",
- typeof(IDictionary).Namespace + ".IDictionary"),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode("string-dictionary", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(7, 0, 7, 17),
- "string-dictionary",
- "input",
- typeof(IDictionary).Namespace + ".IDictionary"),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode("int-prefix-", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(7, 0, 7, 11),
- "int-prefix-",
- "input",
- intType),
- RazorDiagnosticFactory.CreateParsing_TagHelperIndexerAttributeNameMustIncludeKey(
- new SourceSpan(7, 0, 7, 11),
- "int-prefix-",
- "input"),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode("string-prefix-", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(7, 0, 7, 14),
- "string-prefix-",
- "input",
- stringType),
- RazorDiagnosticFactory.CreateParsing_TagHelperIndexerAttributeNameMustIncludeKey(
- new SourceSpan(7, 0, 7, 14),
- "string-prefix-",
- "input"),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode("int-prefix-value", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(7, 0, 7, 16),
- "int-prefix-value",
- "input",
- intType),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode("string-prefix-value", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(7, 0, 7, 19),
- "string-prefix-value",
- "input",
- stringType),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode("int-prefix-value", new MarkupBlock(), AttributeStructure.SingleQuotes),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(7, 0, 7, 16),
- "int-prefix-value",
- "input",
- intType),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode("string-prefix-value", new MarkupBlock(), AttributeStructure.SingleQuotes),
- })),
- new RazorDiagnostic[0]
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode(
- "int-prefix-value",
- factory.CodeMarkup("3").With(new ExpressionChunkGenerator()),
- AttributeStructure.SingleQuotes),
- })),
- new RazorDiagnostic[0]
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List
- {
- new TagHelperAttributeNode(
- "string-prefix-value",
- new MarkupBlock(
- factory.Markup("some"),
- factory.Markup(" string")),
- AttributeStructure.SingleQuotes),
- })),
- new RazorDiagnostic[0]
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode("unbound-required", null, AttributeStructure.Minimized),
- new TagHelperAttributeNode("bound-required-string", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(24, 0, 24, 21),
- "bound-required-string",
- "input",
- stringType),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "p",
- TagMode.StartTagAndEndTag,
- attributes: new List()
- {
- new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized),
- new TagHelperAttributeNode("bound-string", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(3, 0, 3, 9),
- "bound-int",
- "p",
- intType),
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(13, 0, 13, 12),
- "bound-string",
- "p",
- stringType),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode("bound-required-int", null, AttributeStructure.Minimized),
- new TagHelperAttributeNode("unbound-required", null, AttributeStructure.Minimized),
- new TagHelperAttributeNode("bound-required-string", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(7, 0, 7, 18),
- "bound-required-int",
- "input",
- intType),
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(43, 0, 43, 21),
- "bound-required-string",
- "input",
- stringType),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "p",
- TagMode.StartTagAndEndTag,
- attributes: new List()
- {
- new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized),
- new TagHelperAttributeNode("bound-string", null, AttributeStructure.Minimized),
- new TagHelperAttributeNode("bound-string", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(3, 0, 3, 9),
- "bound-int",
- "p",
- intType),
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(13, 0, 13, 12),
- "bound-string",
- "p",
- stringType),
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(26, 0, 26, 12),
- "bound-string",
- "p",
- stringType),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode("unbound-required", null, AttributeStructure.Minimized),
- new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes),
- })),
- noErrors
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "p",
- TagMode.StartTagAndEndTag,
- attributes: new List()
- {
- new TagHelperAttributeNode("bound-string", null, AttributeStructure.Minimized),
- new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(3, 0, 3, 12),
- "bound-string",
- "p",
- stringType),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes),
- new TagHelperAttributeNode("unbound-required", null, AttributeStructure.Minimized),
- })),
- noErrors
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "p",
- TagMode.StartTagAndEndTag,
- attributes: new List()
- {
- new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes),
- new TagHelperAttributeNode("bound-string", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(15, 0, 15, 12),
- "bound-string",
- "p",
- stringType),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode("bound-required-string", null, AttributeStructure.Minimized),
- new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(7, 0, 7, 21),
- "bound-required-string",
- "input",
- stringType),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes),
- new TagHelperAttributeNode("bound-required-string", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(19, 0, 19, 21),
- "bound-required-string",
- "input",
- stringType),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode("bound-required-int", null, AttributeStructure.Minimized),
- new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(7, 0, 7, 18),
- "bound-required-int",
- "input",
- intType),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "p",
- TagMode.StartTagAndEndTag,
- attributes: new List()
- {
- new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized),
- new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(3, 0, 3, 9),
- "bound-int",
- "p",
- intType),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes),
- new TagHelperAttributeNode("bound-required-int", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(19, 0, 19, 18),
- "bound-required-int",
- "input",
- intType),
- }
- },
- {
- "",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "p",
- TagMode.StartTagAndEndTag,
- attributes: new List()
- {
- new TagHelperAttributeNode("class", factory.Markup("btn"), AttributeStructure.SingleQuotes),
- new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(15, 0, 15, 9),
- "bound-int",
- "p",
- intType),
- }
- },
- {
- $"",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode("class", expression(14), AttributeStructure.SingleQuotes),
- new TagHelperAttributeNode("bound-required-int", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(33, 0, 33, 18),
- "bound-required-int",
- "input",
- intType),
- }
- },
- {
- $"",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "p",
- TagMode.StartTagAndEndTag,
- attributes: new List()
- {
- new TagHelperAttributeNode("class", expression(10), AttributeStructure.SingleQuotes),
- new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(29, 0, 29, 9),
- "bound-int",
- "p",
- intType),
- }
- },
- {
- $"",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "input",
- TagMode.SelfClosing,
- attributes: new List()
- {
- new TagHelperAttributeNode("bound-required-int", null, AttributeStructure.Minimized),
- new TagHelperAttributeNode("class", expression(36), AttributeStructure.SingleQuotes),
- new TagHelperAttributeNode("bound-required-string", null, AttributeStructure.Minimized),
- new TagHelperAttributeNode("class", expression(86), AttributeStructure.SingleQuotes),
- new TagHelperAttributeNode("unbound-required", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(10, 0, 10, 18),
- "bound-required-int",
- "input",
- intType),
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(57, 0, 57, 21),
- "bound-required-string",
- "input",
- stringType),
- }
- },
- {
- $"",
- new MarkupBlock(
- new MarkupTagHelperBlock(
- "p",
- TagMode.StartTagAndEndTag,
- attributes: new List()
- {
- new TagHelperAttributeNode("bound-int", null, AttributeStructure.Minimized),
- new TagHelperAttributeNode("class", expression(23), AttributeStructure.SingleQuotes),
- new TagHelperAttributeNode("bound-string", null, AttributeStructure.Minimized),
- new TagHelperAttributeNode("class", expression(64), AttributeStructure.SingleQuotes),
- new TagHelperAttributeNode("bound-string", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(6, 0, 6, 9),
- "bound-int",
- "p",
- intType),
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(44, 0, 44, 12),
- "bound-string",
- "p",
- stringType),
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(84, 0, 84, 12),
- "bound-string",
- "p",
- stringType),
- }
- },
- };
- }
- }
-
- public static TheoryData MinimizedAttributeData_CSharpBlock
- {
- get
- {
- var factory = new SpanFactory();
- var documentData = MinimizedAttributeData_Document;
- Func, MarkupBlock> buildStatementBlock = (insideBuilder) =>
- {
- return new MarkupBlock(
- factory.EmptyHtml(),
- new StatementBlock(
- factory.CodeTransition(),
- factory.MetaCode("{").Accepts(AcceptedCharactersInternal.None),
- insideBuilder(),
- factory.EmptyCSharp().AsStatement(),
- factory.MetaCode("}").Accepts(AcceptedCharactersInternal.None)),
- factory.EmptyHtml());
- };
- Action updateDynamicChunkGenerators = (block) =>
- {
- var tagHelperBlock = block.Children.First() as MarkupTagHelperBlock;
-
- for (var i = 0; i < tagHelperBlock.Attributes.Count; i++)
- {
- var attribute = tagHelperBlock.Attributes[i];
- var holderBlock = attribute.Value as Block;
-
- if (holderBlock == null)
- {
- continue;
- }
-
- var valueBlock = holderBlock.Children.FirstOrDefault() as Block;
- if (valueBlock != null)
- {
- var chunkGenerator = valueBlock.ChunkGenerator as DynamicAttributeBlockChunkGenerator;
-
- if (chunkGenerator != null)
- {
- var blockBuilder = new BlockBuilder(holderBlock);
- var expressionBlockBuilder = new BlockBuilder(valueBlock);
- var newChunkGenerator = new DynamicAttributeBlockChunkGenerator(
- new LocationTagged(
- chunkGenerator.Prefix.Value,
- new SourceLocation(
- chunkGenerator.Prefix.Location.AbsoluteIndex + 2,
- chunkGenerator.Prefix.Location.LineIndex,
- chunkGenerator.Prefix.Location.CharacterIndex + 2)),
- new SourceLocation(
- chunkGenerator.ValueStart.AbsoluteIndex + 2,
- chunkGenerator.ValueStart.LineIndex,
- chunkGenerator.ValueStart.CharacterIndex + 2));
-
- expressionBlockBuilder.ChunkGenerator = newChunkGenerator;
- blockBuilder.Children[0] = expressionBlockBuilder.Build();
-
- for (var j = 1; j < blockBuilder.Children.Count; j++)
- {
- var span = blockBuilder.Children[j] as Span;
- if (span != null)
- {
- var literalChunkGenerator =
- span.ChunkGenerator as LiteralAttributeChunkGenerator;
-
- var spanBuilder = new SpanBuilder(span);
- spanBuilder.ChunkGenerator = new LiteralAttributeChunkGenerator(
- prefix: new LocationTagged(
- literalChunkGenerator.Prefix.Value,
- new SourceLocation(
- literalChunkGenerator.Prefix.Location.AbsoluteIndex + 2,
- literalChunkGenerator.Prefix.Location.LineIndex,
- literalChunkGenerator.Prefix.Location.CharacterIndex + 2)),
- value: new LocationTagged(
- literalChunkGenerator.Value.Value,
- new SourceLocation(
- literalChunkGenerator.Value.Location.AbsoluteIndex + 2,
- literalChunkGenerator.Value.Location.LineIndex,
- literalChunkGenerator.Value.Location.CharacterIndex + 2)));
-
- blockBuilder.Children[j] = spanBuilder.Build();
- }
- }
-
- tagHelperBlock.Attributes[i] = new TagHelperAttributeNode(
- attribute.Name,
- blockBuilder.Build(),
- attribute.AttributeStructure);
- }
- }
- }
- };
-
- foreach (var data in documentData)
- {
- data[0] = $"@{{{data[0]}}}";
-
- updateDynamicChunkGenerators(data[1] as MarkupBlock);
-
- data[1] = buildStatementBlock(() => data[1] as MarkupBlock);
-
- var errors = data[2] as RazorDiagnostic[];
-
- for (var i = 0; i < errors.Length; i++)
- {
- var error = errors[i] as DefaultRazorDiagnostic;
- var currentErrorLocation = new SourceLocation(error.Span.AbsoluteIndex, error.Span.LineIndex, error.Span.CharacterIndex);
- var newErrorLocation = SourceLocationTracker.Advance(currentErrorLocation, "@{");
- var copiedDiagnostic = new DefaultRazorDiagnostic(error.Descriptor, new SourceSpan(newErrorLocation, error.Span.Length), error.Args);
- errors[i] = copiedDiagnostic;
- }
- }
-
- return documentData;
- }
- }
-
- public static TheoryData MinimizedAttributeData_PartialTags
- {
- get
- {
- var factory = new SpanFactory();
- var noErrors = new RazorDiagnostic[0];
- var stringType = typeof(string).FullName;
- var intType = typeof(int).FullName;
-
- // documentContent, expectedOutput, expectedErrors
- return new TheoryData
- {
- {
- "()
- {
- new TagHelperAttributeNode("unbound-required", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle(
- new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 5), "input"),
- RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper(
- new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 5), "input"),
- }
- },
- {
- "()
- {
- new TagHelperAttributeNode("bound-required-string", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle(
- new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 5), "input"),
- RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper(
- new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 5), "input"),
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(7, 0, 7, 21),
- "bound-required-string",
- "input",
- stringType),
- }
- },
- {
- "()
- {
- new TagHelperAttributeNode("bound-required-int", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle(
- new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 5), "input"),
- RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper(
- new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 5), "input"),
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(7, 0, 7, 18),
- "bound-required-int",
- "input",
- intType),
- }
- },
- {
- "()
- {
- new TagHelperAttributeNode("bound-required-int", null, AttributeStructure.Minimized),
- new TagHelperAttributeNode("unbound-required", null, AttributeStructure.Minimized),
- new TagHelperAttributeNode("bound-required-string", null, AttributeStructure.Minimized),
- })),
- new[]
- {
- RazorDiagnosticFactory.CreateParsing_TagHelperMissingCloseAngle(
- new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 5), "input"),
- RazorDiagnosticFactory.CreateParsing_TagHelperFoundMalformedTagHelper(
- new SourceSpan(new SourceLocation(1, 0, 1), contentLength: 5), "input"),
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(7, 0, 7, 18),
- "bound-required-int",
- "input",
- intType),
- RazorDiagnosticFactory.CreateTagHelper_EmptyBoundAttribute(
- new SourceSpan(43, 0, 43, 21),
- "bound-required-string",
- "input",
- stringType),
- }
- },
- {
- "
+ bound - Minimized
+ #localminimized - Minimized
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CanHandleSymbolBoundAttributes7.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CanHandleSymbolBoundAttributes7.syntaxtree.txt
new file mode 100644
index 0000000000..5113b8d2c1
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CanHandleSymbolBoundAttributes7.syntaxtree.txt
@@ -0,0 +1,7 @@
+Markup block - Gen - 32 - (0:0,0)
+ Tag block - Gen - 32 - (0:0,0) - div - CatchAllTagHelper
+ StartTagAndEndTag -
...
+ bound - Minimized
+ #local - SingleQuotes
+ Markup span - Gen - [value] - SpanEditHandler;Accepts:Any - (19:0,19) - Symbols:1
+ HtmlSymbolType.Text;[value];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CanHandleWithoutEndTagTagStructure1.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CanHandleWithoutEndTagTagStructure1.syntaxtree.txt
new file mode 100644
index 0000000000..64f951bb83
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CanHandleWithoutEndTagTagStructure1.syntaxtree.txt
@@ -0,0 +1,3 @@
+Markup block - Gen - 7 - (0:0,0)
+ Tag block - Gen - 7 - (0:0,0) - input - InputTagHelper
+ StartTagOnly -
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CanHandleWithoutEndTagTagStructure2.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CanHandleWithoutEndTagTagStructure2.syntaxtree.txt
new file mode 100644
index 0000000000..bb47a46930
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CanHandleWithoutEndTagTagStructure2.syntaxtree.txt
@@ -0,0 +1,6 @@
+Markup block - Gen - 19 - (0:0,0)
+ Tag block - Gen - 19 - (0:0,0) - input - InputTagHelper
+ StartTagOnly -
+ type - SingleQuotes
+ Markup span - Gen - [text] - SpanEditHandler;Accepts:Any - (13:0,13) - Symbols:1
+ HtmlSymbolType.Text;[text];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CanHandleWithoutEndTagTagStructure3.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CanHandleWithoutEndTagTagStructure3.syntaxtree.txt
new file mode 100644
index 0000000000..5940efaad7
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CanHandleWithoutEndTagTagStructure3.syntaxtree.txt
@@ -0,0 +1,5 @@
+Markup block - Gen - 14 - (0:0,0)
+ Tag block - Gen - 7 - (0:0,0) - input - InputTagHelper
+ StartTagOnly -
+ Tag block - Gen - 7 - (7:0,7) - input - InputTagHelper
+ StartTagOnly -
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CanHandleWithoutEndTagTagStructure4.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CanHandleWithoutEndTagTagStructure4.syntaxtree.txt
new file mode 100644
index 0000000000..c0c7e5a5df
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CanHandleWithoutEndTagTagStructure4.syntaxtree.txt
@@ -0,0 +1,8 @@
+Markup block - Gen - 26 - (0:0,0)
+ Tag block - Gen - 19 - (0:0,0) - input - InputTagHelper
+ StartTagOnly -
+ type - SingleQuotes
+ Markup span - Gen - [text] - SpanEditHandler;Accepts:Any - (13:0,13) - Symbols:1
+ HtmlSymbolType.Text;[text];
+ Tag block - Gen - 7 - (19:0,19) - input - InputTagHelper
+ StartTagOnly -
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CanHandleWithoutEndTagTagStructure5.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CanHandleWithoutEndTagTagStructure5.syntaxtree.txt
new file mode 100644
index 0000000000..0ab4f0e967
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CanHandleWithoutEndTagTagStructure5.syntaxtree.txt
@@ -0,0 +1,16 @@
+Markup block - Gen - 25 - (0:0,0)
+ Tag block - Gen - 5 - (0:0,0)
+ Markup span - Gen - [
] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:3
+ HtmlSymbolType.OpenAngle;[<];
+ HtmlSymbolType.Text;[div];
+ HtmlSymbolType.CloseAngle;[>];
+ Tag block - Gen - 7 - (5:0,5) - input - InputTagHelper
+ StartTagOnly -
+ Tag block - Gen - 7 - (12:0,12) - input - InputTagHelper
+ StartTagOnly -
+ Tag block - Gen - 6 - (19:0,19)
+ Markup span - Gen - [
] - SpanEditHandler;Accepts:Any - (19:0,19) - Symbols:4
+ HtmlSymbolType.OpenAngle;[<];
+ HtmlSymbolType.ForwardSlash;[/];
+ HtmlSymbolType.Text;[div];
+ HtmlSymbolType.CloseAngle;[>];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes1.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes1.diagnostics.txt
new file mode 100644
index 0000000000..c11ff99be0
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes1.diagnostics.txt
@@ -0,0 +1 @@
+(1,7): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes1.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes1.syntaxtree.txt
new file mode 100644
index 0000000000..94077ed99f
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes1.syntaxtree.txt
@@ -0,0 +1,5 @@
+Markup block - Gen - 17 - (0:0,0)
+ Tag block - Gen - 17 - (0:0,0) - myth - mythTagHelper
+ SelfClosing -
+ bound - SingleQuotes
+ Markup block - Gen - 0 - (0:0,0)
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes10.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes10.diagnostics.txt
new file mode 100644
index 0000000000..d57ce479b5
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes10.diagnostics.txt
@@ -0,0 +1 @@
+(1,7): Error RZ2008: Attribute 'BouND' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes10.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes10.syntaxtree.txt
new file mode 100644
index 0000000000..1e5707cb20
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes10.syntaxtree.txt
@@ -0,0 +1,5 @@
+Markup block - Gen - 17 - (0:0,0)
+ Tag block - Gen - 17 - (0:0,0) - myth - mythTagHelper
+ SelfClosing -
+ BouND - SingleQuotes
+ Markup block - Gen - 0 - (0:0,0)
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes11.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes11.diagnostics.txt
new file mode 100644
index 0000000000..9739cf1558
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes11.diagnostics.txt
@@ -0,0 +1,2 @@
+(1,7): Error RZ2008: Attribute 'BOUND' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace.
+(1,19): Error RZ2008: Attribute 'bOUnd' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes11.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes11.syntaxtree.txt
new file mode 100644
index 0000000000..895d34342c
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes11.syntaxtree.txt
@@ -0,0 +1,7 @@
+Markup block - Gen - 29 - (0:0,0)
+ Tag block - Gen - 29 - (0:0,0) - myth - mythTagHelper
+ SelfClosing -
+ BOUND - SingleQuotes
+ Markup block - Gen - 0 - (0:0,0)
+ bOUnd - DoubleQuotes
+ Markup block - Gen - 0 - (0:0,0)
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes12.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes12.diagnostics.txt
new file mode 100644
index 0000000000..52810ad2c0
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes12.diagnostics.txt
@@ -0,0 +1 @@
+(1,7): Error RZ2008: Attribute 'BOUND' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes12.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes12.syntaxtree.txt
new file mode 100644
index 0000000000..74bb0ae96b
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes12.syntaxtree.txt
@@ -0,0 +1,8 @@
+Markup block - Gen - 32 - (0:0,0)
+ Tag block - Gen - 32 - (0:0,0) - myth - mythTagHelper
+ StartTagAndEndTag - ...
+ BOUND - DoubleQuotes
+ Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (12:0,12) - Symbols:0
+ nAMe - SingleQuotes
+ Markup span - Gen - [john] - SpanEditHandler;Accepts:Any - (19:0,19) - Symbols:1
+ HtmlSymbolType.Text;[john];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes13.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes13.syntaxtree.txt
new file mode 100644
index 0000000000..d72cfac82c
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes13.syntaxtree.txt
@@ -0,0 +1,15 @@
+Markup block - Gen - 28 - (0:0,0)
+ Tag block - Gen - 28 - (0:0,0) - myth - mythTagHelper
+ SelfClosing -
+ bound - SingleQuotes
+ Markup block - Gen - 11 - (13:0,13)
+ Markup block - Gen - 9 - (13:0,13)
+ Code span - Gen - [ ] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (13:0,13) - Symbols:1
+ HtmlSymbolType.WhiteSpace;[ ];
+ Expression block - Gen - 5 - (17:0,17)
+ Code span - Gen - [@] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (17:0,17) - Symbols:1
+ CSharpSymbolType.Transition;[@];
+ Code span - Gen - [true] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (18:0,18) - Symbols:1
+ CSharpSymbolType.Keyword;[true];
+ Code span - Gen - [ ] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (22:0,22) - Symbols:1
+ HtmlSymbolType.WhiteSpace;[ ];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes14.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes14.syntaxtree.txt
new file mode 100644
index 0000000000..6c9a2989e2
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes14.syntaxtree.txt
@@ -0,0 +1,19 @@
+Markup block - Gen - 30 - (0:0,0)
+ Tag block - Gen - 30 - (0:0,0) - myth - mythTagHelper
+ SelfClosing -
+ bound - SingleQuotes
+ Markup block - Gen - 13 - (13:0,13)
+ Markup block - Gen - 11 - (13:0,13)
+ Code span - Gen - [ ] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (13:0,13) - Symbols:1
+ HtmlSymbolType.WhiteSpace;[ ];
+ Expression block - Gen - 7 - (17:0,17)
+ Code span - Gen - [@] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (17:0,17) - Symbols:1
+ CSharpSymbolType.Transition;[@];
+ Code span - Gen - [(] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (18:0,18) - Symbols:1
+ CSharpSymbolType.LeftParenthesis;[(];
+ Code span - Gen - [true] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (19:0,19) - Symbols:1
+ CSharpSymbolType.Keyword;[true];
+ Code span - Gen - [)] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (23:0,23) - Symbols:1
+ CSharpSymbolType.RightParenthesis;[)];
+ Code span - Gen - [ ] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (24:0,24) - Symbols:1
+ HtmlSymbolType.WhiteSpace;[ ];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes2.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes2.syntaxtree.txt
new file mode 100644
index 0000000000..c6fb322644
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes2.syntaxtree.txt
@@ -0,0 +1,7 @@
+Markup block - Gen - 25 - (0:0,0)
+ Tag block - Gen - 25 - (0:0,0) - myth - mythTagHelper
+ SelfClosing -
+ bound - SingleQuotes
+ Code span - Gen - [ true] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (13:0,13) - Symbols:2
+ HtmlSymbolType.WhiteSpace;[ ];
+ HtmlSymbolType.Text;[true];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes3.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes3.diagnostics.txt
new file mode 100644
index 0000000000..c11ff99be0
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes3.diagnostics.txt
@@ -0,0 +1 @@
+(1,7): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes3.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes3.syntaxtree.txt
new file mode 100644
index 0000000000..5f9f600862
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes3.syntaxtree.txt
@@ -0,0 +1,6 @@
+Markup block - Gen - 21 - (0:0,0)
+ Tag block - Gen - 21 - (0:0,0) - myth - mythTagHelper
+ SelfClosing -
+ bound - SingleQuotes
+ Code span - Gen - [ ] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (13:0,13) - Symbols:1
+ HtmlSymbolType.WhiteSpace;[ ];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes4.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes4.diagnostics.txt
new file mode 100644
index 0000000000..9a927a8ecb
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes4.diagnostics.txt
@@ -0,0 +1,2 @@
+(1,7): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace.
+(1,17): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes4.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes4.syntaxtree.txt
new file mode 100644
index 0000000000..969f962e57
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes4.syntaxtree.txt
@@ -0,0 +1,7 @@
+Markup block - Gen - 27 - (0:0,0)
+ Tag block - Gen - 27 - (0:0,0) - myth - mythTagHelper
+ SelfClosing -
+ bound - SingleQuotes
+ Markup block - Gen - 0 - (0:0,0)
+ bound - DoubleQuotes
+ Markup block - Gen - 0 - (0:0,0)
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes5.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes5.diagnostics.txt
new file mode 100644
index 0000000000..f16283e328
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes5.diagnostics.txt
@@ -0,0 +1,2 @@
+(1,7): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace.
+(1,18): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes5.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes5.syntaxtree.txt
new file mode 100644
index 0000000000..15e108c221
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes5.syntaxtree.txt
@@ -0,0 +1,9 @@
+Markup block - Gen - 30 - (0:0,0)
+ Tag block - Gen - 30 - (0:0,0) - myth - mythTagHelper
+ SelfClosing -
+ bound - SingleQuotes
+ Code span - Gen - [ ] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (13:0,13) - Symbols:1
+ HtmlSymbolType.WhiteSpace;[ ];
+ bound - DoubleQuotes
+ Code span - Gen - [ ] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (24:0,24) - Symbols:1
+ HtmlSymbolType.WhiteSpace;[ ];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes6.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes6.diagnostics.txt
new file mode 100644
index 0000000000..7993f8fe1b
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes6.diagnostics.txt
@@ -0,0 +1 @@
+(1,20): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes6.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes6.syntaxtree.txt
new file mode 100644
index 0000000000..dfe00f7eb2
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes6.syntaxtree.txt
@@ -0,0 +1,8 @@
+Markup block - Gen - 29 - (0:0,0)
+ Tag block - Gen - 29 - (0:0,0) - myth - mythTagHelper
+ SelfClosing -
+ bound - SingleQuotes
+ Code span - Gen - [true] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (13:0,13) - Symbols:1
+ HtmlSymbolType.Text;[true];
+ bound - DoubleQuotes
+ Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (25:0,25) - Symbols:0
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes7.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes7.diagnostics.txt
new file mode 100644
index 0000000000..c11ff99be0
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes7.diagnostics.txt
@@ -0,0 +1 @@
+(1,7): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes7.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes7.syntaxtree.txt
new file mode 100644
index 0000000000..887ea6880f
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes7.syntaxtree.txt
@@ -0,0 +1,7 @@
+Markup block - Gen - 23 - (0:0,0)
+ Tag block - Gen - 23 - (0:0,0) - myth - mythTagHelper
+ SelfClosing -
+ bound - DoubleQuotes
+ Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (12:0,12) - Symbols:0
+ name - SingleQuotes
+ Markup block - Gen - 0 - (0:0,0)
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes8.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes8.diagnostics.txt
new file mode 100644
index 0000000000..c11ff99be0
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes8.diagnostics.txt
@@ -0,0 +1 @@
+(1,7): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes8.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes8.syntaxtree.txt
new file mode 100644
index 0000000000..d734c93130
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes8.syntaxtree.txt
@@ -0,0 +1,8 @@
+Markup block - Gen - 25 - (0:0,0)
+ Tag block - Gen - 25 - (0:0,0) - myth - mythTagHelper
+ SelfClosing -
+ bound - DoubleQuotes
+ Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (12:0,12) - Symbols:0
+ name - SingleQuotes
+ Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (19:0,19) - Symbols:1
+ HtmlSymbolType.WhiteSpace;[ ];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes9.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes9.diagnostics.txt
new file mode 100644
index 0000000000..356a13e234
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes9.diagnostics.txt
@@ -0,0 +1 @@
+(1,32): Error RZ2008: Attribute 'bound' on tag helper element 'myth' requires a value. Tag helper bound attributes of type 'System.Boolean' cannot be empty or contain only whitespace.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes9.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes9.syntaxtree.txt
new file mode 100644
index 0000000000..e411abea8a
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForEmptyTagHelperBoundAttributes9.syntaxtree.txt
@@ -0,0 +1,13 @@
+Markup block - Gen - 46 - (0:0,0)
+ Tag block - Gen - 46 - (0:0,0) - myth - mythTagHelper
+ SelfClosing -
+ bound - SingleQuotes
+ Code span - Gen - [true] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (13:0,13) - Symbols:1
+ HtmlSymbolType.Text;[true];
+ name - SingleQuotes
+ Markup span - Gen - [john] - SpanEditHandler;Accepts:Any - (25:0,25) - Symbols:1
+ HtmlSymbolType.Text;[john];
+ bound - DoubleQuotes
+ Code span - Gen - [] - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K14 - (37:0,37) - Symbols:0
+ name - DoubleQuotes
+ Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (43:0,43) - Symbols:0
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper1.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper1.diagnostics.txt
new file mode 100644
index 0000000000..b0e5b255ec
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper1.diagnostics.txt
@@ -0,0 +1,2 @@
+(1,2): Error RZ1035: Missing close angle for tag helper 'p'.
+(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper1.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper1.syntaxtree.txt
new file mode 100644
index 0000000000..a6461887d3
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper1.syntaxtree.txt
@@ -0,0 +1,3 @@
+Markup block - Gen - 2 - (0:0,0)
+ Tag block - Gen - 2 - (0:0,0) - p - ptaghelper
+ StartTagAndEndTag -
- 6 - (0:0,0)
+ Tag block - Gen - 6 - (0:0,0) - p - ptaghelper
+ StartTagAndEndTag -
...
- 10 - (0:0,0)
+ Tag block - Gen - 10 - (0:0,0) - p - ptaghelper
+ StartTagAndEndTag -
+ Tag block - Gen - 7 - (3:0,3) - strong - strongtaghelper
+ StartTagAndEndTag - - 11 - (0:0,0)
+ Tag block - Gen - 11 - (0:0,0) - strong - strongtaghelper
+ StartTagAndEndTag - - 3 - (8:0,8) - p - ptaghelper
+ StartTagAndEndTag -
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper5.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper5.diagnostics.txt
new file mode 100644
index 0000000000..83865622a4
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper5.diagnostics.txt
@@ -0,0 +1,2 @@
+(1,2): Error RZ1035: Missing close angle for tag helper 'strong'.
+(1,11): Error RZ1035: Missing close angle for tag helper 'strong'.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper5.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper5.syntaxtree.txt
new file mode 100644
index 0000000000..605e599c38
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper5.syntaxtree.txt
@@ -0,0 +1,3 @@
+Markup block - Gen - 16 - (0:0,0)
+ Tag block - Gen - 16 - (0:0,0) - strong - strongtaghelper
+ StartTagAndEndTag - - 16 - (0:0,0)
+ Tag block - Gen - 1 - (0:0,0)
+ Markup span - Gen - [<] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:1
+ HtmlSymbolType.OpenAngle;[<];
+ Tag block - Gen - 1 - (1:0,1)
+ Markup span - Gen - [<] - SpanEditHandler;Accepts:Any - (1:0,1) - Symbols:1
+ HtmlSymbolType.OpenAngle;[<];
+ Tag block - Gen - 9 - (2:0,2)
+ Markup span - Gen - [] - SpanEditHandler;Accepts:Any - (2:0,2) - Symbols:4
+ HtmlSymbolType.OpenAngle;[<];
+ HtmlSymbolType.ForwardSlash;[/];
+ HtmlSymbolType.Text;[strong];
+ HtmlSymbolType.CloseAngle;[>];
+ Markup span - Gen - [ ] - SpanEditHandler;Accepts:Any - (11:0,11) - Symbols:1
+ HtmlSymbolType.WhiteSpace;[ ];
+ Tag block - Gen - 1 - (12:0,12)
+ Markup span - Gen - [<] - SpanEditHandler;Accepts:Any - (12:0,12) - Symbols:1
+ HtmlSymbolType.OpenAngle;[<];
+ Tag block - Gen - 3 - (13:0,13) - p - ptaghelper
+ StartTagAndEndTag -
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper7.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper7.diagnostics.txt
new file mode 100644
index 0000000000..299623f22a
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper7.diagnostics.txt
@@ -0,0 +1 @@
+(1,4): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper7.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper7.syntaxtree.txt
new file mode 100644
index 0000000000..963b9575db
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper7.syntaxtree.txt
@@ -0,0 +1,21 @@
+Markup block - Gen - 16 - (0:0,0)
+ Tag block - Gen - 1 - (0:0,0)
+ Markup span - Gen - [<] - SpanEditHandler;Accepts:Any - (0:0,0) - Symbols:1
+ HtmlSymbolType.OpenAngle;[<];
+ Tag block - Gen - 1 - (1:0,1)
+ Markup span - Gen - [<] - SpanEditHandler;Accepts:Any - (1:0,1) - Symbols:1
+ HtmlSymbolType.OpenAngle;[<];
+ Tag block - Gen - 14 - (2:0,2) - strong - strongtaghelper
+ StartTagAndEndTag -
+ Markup span - Gen - [> ] - SpanEditHandler;Accepts:Any - (10:0,10) - Symbols:2
+ HtmlSymbolType.CloseAngle;[>];
+ HtmlSymbolType.WhiteSpace;[ ];
+ Tag block - Gen - 1 - (12:0,12)
+ Markup span - Gen - [<] - SpanEditHandler;Accepts:Any - (12:0,12) - Symbols:1
+ HtmlSymbolType.OpenAngle;[<];
+ Tag block - Gen - 2 - (13:0,13)
+ Markup span - Gen - [<>] - SpanEditHandler;Accepts:Any - (13:0,13) - Symbols:2
+ HtmlSymbolType.OpenAngle;[<];
+ HtmlSymbolType.CloseAngle;[>];
+ Markup span - Gen - [>] - SpanEditHandler;Accepts:Any - (15:0,15) - Symbols:1
+ HtmlSymbolType.CloseAngle;[>];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper8.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper8.diagnostics.txt
new file mode 100644
index 0000000000..fbfae8923a
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper8.diagnostics.txt
@@ -0,0 +1 @@
+(1,15): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper8.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper8.syntaxtree.txt
new file mode 100644
index 0000000000..c019cccf0f
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelper8.syntaxtree.txt
@@ -0,0 +1,13 @@
+Markup block - Gen - 25 - (0:0,0)
+ Tag block - Gen - 4 - (0:0,0)
+ Markup span - Gen - [ - 21 - (4:0,4) - strong - strongtaghelper
+ StartTagAndEndTag - ...
+ Tag block - Gen - 4 - (12:0,12)
+ Markup span - Gen - [
] - SpanEditHandler;Accepts:Any - (12:0,12) - Symbols:4
+ HtmlSymbolType.OpenAngle;[<];
+ HtmlSymbolType.ForwardSlash;[/];
+ HtmlSymbolType.Text;[p];
+ HtmlSymbolType.CloseAngle;[>];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes1.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes1.diagnostics.txt
new file mode 100644
index 0000000000..b0e5b255ec
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes1.diagnostics.txt
@@ -0,0 +1,2 @@
+(1,2): Error RZ1035: Missing close angle for tag helper 'p'.
+(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes1.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes1.syntaxtree.txt
new file mode 100644
index 0000000000..41e6c9cb10
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes1.syntaxtree.txt
@@ -0,0 +1,5 @@
+Markup block - Gen - 10 - (0:0,0)
+ Tag block - Gen - 10 - (0:0,0) - p - ptaghelper
+ StartTagAndEndTag -
- 31 - (0:0,0)
+ Tag block - Gen - 31 - (0:0,0) - p - ptaghelper
+ StartTagAndEndTag -
+ class - NoQuotes
+ Markup span - Gen - [btn] - SpanEditHandler;Accepts:Any - (9:0,9) - Symbols:1
+ HtmlSymbolType.Text;[btn];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes11.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes11.diagnostics.txt
new file mode 100644
index 0000000000..c263af5dea
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes11.diagnostics.txt
@@ -0,0 +1,3 @@
+(1,2): Error RZ1035: Missing close angle for tag helper 'p'.
+(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing.
+(1,25): Error RZ1034: Found a malformed 'strong' tag helper. Tag helpers must have a start and end tag or be self closing.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes11.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes11.syntaxtree.txt
new file mode 100644
index 0000000000..1fd6ddea9a
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes11.syntaxtree.txt
@@ -0,0 +1,14 @@
+Markup block - Gen - 31 - (0:0,0)
+ Tag block - Gen - 31 - (0:0,0) - p - ptaghelper
+ StartTagAndEndTag -
+ class - DoubleQuotes
+ Markup block - Gen - 8 - (10:0,10)
+ Markup span - Gen - [btn] - SpanEditHandler;Accepts:Any - (10:0,10) - Symbols:1
+ HtmlSymbolType.Text;[btn];
+ Markup span - Gen - [ bar=] - SpanEditHandler;Accepts:Any - (13:0,13) - Symbols:3
+ HtmlSymbolType.WhiteSpace;[ ];
+ HtmlSymbolType.Text;[bar];
+ HtmlSymbolType.Equals;[=];
+ foo - Minimized
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes13.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes13.diagnostics.txt
new file mode 100644
index 0000000000..3191132e51
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes13.diagnostics.txt
@@ -0,0 +1 @@
+(1,4): Error RZ1031: The tag helper 'p' must not have C# in the element's attribute declaration area.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes13.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes13.syntaxtree.txt
new file mode 100644
index 0000000000..d1b413266d
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes13.syntaxtree.txt
@@ -0,0 +1,3 @@
+Markup block - Gen - 33 - (0:0,0)
+ Tag block - Gen - 33 - (0:0,0) - p - ptaghelper
+ StartTagAndEndTag -
...
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes14.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes14.diagnostics.txt
new file mode 100644
index 0000000000..3191132e51
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes14.diagnostics.txt
@@ -0,0 +1 @@
+(1,4): Error RZ1031: The tag helper 'p' must not have C# in the element's attribute declaration area.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes14.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes14.syntaxtree.txt
new file mode 100644
index 0000000000..1f20b3328e
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes14.syntaxtree.txt
@@ -0,0 +1,3 @@
+Markup block - Gen - 27 - (0:0,0)
+ Tag block - Gen - 27 - (0:0,0) - p - ptaghelper
+ StartTagAndEndTag -
...
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes15.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes15.diagnostics.txt
new file mode 100644
index 0000000000..d177eb6df7
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes15.diagnostics.txt
@@ -0,0 +1 @@
+(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes15.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes15.syntaxtree.txt
new file mode 100644
index 0000000000..bbda6e6faa
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes15.syntaxtree.txt
@@ -0,0 +1,13 @@
+Markup block - Gen - 28 - (0:0,0)
+ Tag block - Gen - 28 - (0:0,0) - p - ptaghelper
+ StartTagAndEndTag -
+ class - DoubleQuotes
+ Markup block - Gen - 13 - (9:0,9)
+ Markup block - Gen - 13 - (9:0,9)
+ Expression block - Gen - 13 - (9:0,9)
+ Transition span - Gen - [@] - SpanEditHandler;Accepts:None - (9:0,9) - Symbols:1
+ CSharpSymbolType.Transition;[@];
+ Code span - Gen - [DateTime.Now] - ImplicitExpressionEditHandler;Accepts:NonWhiteSpace;ImplicitExpression[RTD];K14 - (10:0,10) - Symbols:3
+ CSharpSymbolType.Identifier;[DateTime];
+ CSharpSymbolType.Dot;[.];
+ CSharpSymbolType.Identifier;[Now];
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes16.diagnostics.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes16.diagnostics.txt
new file mode 100644
index 0000000000..719d1c8841
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes16.diagnostics.txt
@@ -0,0 +1,3 @@
+(1,2): Error RZ1035: Missing close angle for tag helper 'p'.
+(1,2): Error RZ1034: Found a malformed 'p' tag helper. Tag helpers must have a start and end tag or be self closing.
+(1,12): Error RZ1006: The do block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes16.syntaxtree.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes16.syntaxtree.txt
new file mode 100644
index 0000000000..411be6ca51
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/ParserTests/TagHelperBlockRewriterTest/Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes16.syntaxtree.txt
@@ -0,0 +1,13 @@
+Markup block - Gen - 15 - (0:0,0)
+ Tag block - Gen - 15 - (0:0,0) - p - ptaghelper
+ StartTagAndEndTag -
- 21 - (0:0,0)
+ Tag block - Gen - 21 - (0:0,0) - p - ptaghelper
+ StartTagAndEndTag -