Add tests to validate @addtaghelper directive.

- Fixed existing tests to work with new RazorParser.
- Validated directive syntax tree creation, errors and code generation.

#111
This commit is contained in:
N. Taylor Mullen 2014-09-16 23:00:26 -07:00
parent b67b8dae3d
commit 7db4ed7f7e
23 changed files with 390 additions and 176 deletions

View File

@ -300,6 +300,11 @@ namespace Microsoft.AspNet.Razor.Test.Framework
return _self.With(new RazorDirectiveAttributeCodeGenerator(key, value)); return _self.With(new RazorDirectiveAttributeCodeGenerator(key, value));
} }
public SpanConstructor AsAddTagHelper(string lookupText)
{
return _self.With(new AddTagHelperCodeGenerator(lookupText));
}
public SpanConstructor As(ISpanCodeGenerator codeGenerator) public SpanConstructor As(ISpanCodeGenerator codeGenerator)
{ {
return _self.With(codeGenerator); return _self.With(codeGenerator);

View File

@ -492,16 +492,41 @@ namespace Microsoft.AspNet.Razor.Test.Generator
}); });
} }
private static LineMapping BuildLineMapping(int documentAbsoluteIndex, int documentLineIndex, int generatedAbsoluteIndex, int generatedLineIndex, int characterOffsetIndex, int contentLength) protected static LineMapping BuildLineMapping(int documentAbsoluteIndex,
int documentLineIndex,
int generatedAbsoluteIndex,
int generatedLineIndex,
int characterOffsetIndex,
int contentLength)
{ {
return BuildLineMapping(documentAbsoluteIndex, documentLineIndex, characterOffsetIndex, generatedAbsoluteIndex, generatedLineIndex, characterOffsetIndex, contentLength); return BuildLineMapping(documentAbsoluteIndex,
documentLineIndex,
characterOffsetIndex,
generatedAbsoluteIndex,
generatedLineIndex,
characterOffsetIndex,
contentLength);
} }
private static LineMapping BuildLineMapping(int documentAbsoluteIndex, int documentLineIndex, int documentCharacterOffsetIndex, int generatedAbsoluteIndex, int generatedLineIndex, int generatedCharacterOffsetIndex, int contentLength) protected static LineMapping BuildLineMapping(int documentAbsoluteIndex,
int documentLineIndex,
int documentCharacterOffsetIndex,
int generatedAbsoluteIndex,
int generatedLineIndex,
int generatedCharacterOffsetIndex,
int contentLength)
{ {
return new LineMapping( return new LineMapping(
documentLocation: new MappingLocation(new SourceLocation(documentAbsoluteIndex, documentLineIndex, documentCharacterOffsetIndex), contentLength), documentLocation: new MappingLocation(
generatedLocation: new MappingLocation(new SourceLocation(generatedAbsoluteIndex, generatedLineIndex, generatedCharacterOffsetIndex), contentLength) new SourceLocation(documentAbsoluteIndex,
documentLineIndex,
documentCharacterOffsetIndex),
contentLength),
generatedLocation: new MappingLocation(
new SourceLocation(generatedAbsoluteIndex,
generatedLineIndex,
generatedCharacterOffsetIndex),
contentLength)
); );
} }
} }

View File

@ -1,7 +1,9 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using Microsoft.AspNet.Razor.Generator.Compiler;
using Microsoft.AspNet.Razor.TagHelpers; using Microsoft.AspNet.Razor.TagHelpers;
using Moq; using Moq;
using Xunit; using Xunit;
@ -10,6 +12,34 @@ namespace Microsoft.AspNet.Razor.Test.Generator
{ {
public class CSharpTagHelperRenderingTest : TagHelperTestBase public class CSharpTagHelperRenderingTest : TagHelperTestBase
{ {
[Fact]
public void CSharpCodeGenerator_CorrectlyGeneratesMappings_ForAddTagHelperDirective()
{
// Act & Assert
RunTagHelperTest("AddTagHelperDirective",
designTimeMode: true,
expectedDesignTimePragmas: new List<LineMapping>()
{
BuildLineMapping(documentAbsoluteIndex: 14,
documentLineIndex: 0,
generatedAbsoluteIndex: 433,
generatedLineIndex: 14,
characterOffsetIndex: 14,
contentLength: 11)
});
}
[Fact]
public void TagHelpers_Directive_GenerateDesignTimeMappings()
{
// Act & Assert
RunTagHelperTest("AddTagHelperDirective",
designTimeMode: true,
tagHelperDescriptors: new[] {
new TagHelperDescriptor("p", "pTagHelper", ContentBehavior.None)
});
}
[Theory] [Theory]
[InlineData("TagHelpersInSection")] [InlineData("TagHelpersInSection")]
[InlineData("TagHelpersInHelper")] [InlineData("TagHelpersInHelper")]
@ -19,21 +49,20 @@ namespace Microsoft.AspNet.Razor.Test.Generator
var propertyInfoMock = new Mock<PropertyInfo>(); var propertyInfoMock = new Mock<PropertyInfo>();
propertyInfoMock.Setup(propertyInfo => propertyInfo.PropertyType).Returns(typeof(string)); propertyInfoMock.Setup(propertyInfo => propertyInfo.PropertyType).Returns(typeof(string));
propertyInfoMock.Setup(propertyInfo => propertyInfo.Name).Returns("BoundProperty"); propertyInfoMock.Setup(propertyInfo => propertyInfo.Name).Returns("BoundProperty");
var tagHelperDescriptorProvider = new TagHelperDescriptorProvider( var tagHelperDescriptors = new TagHelperDescriptor[]
new TagHelperDescriptor[] {
{ new TagHelperDescriptor("MyTagHelper",
new TagHelperDescriptor("MyTagHelper", "MyTagHelper",
"MyTagHelper", ContentBehavior.None,
ContentBehavior.None, new [] {
new [] { new TagHelperAttributeDescriptor("BoundProperty",
new TagHelperAttributeDescriptor("BoundProperty", propertyInfoMock.Object)
propertyInfoMock.Object) }),
}), new TagHelperDescriptor("NestedTagHelper", "NestedTagHelper", ContentBehavior.Modify)
new TagHelperDescriptor("NestedTagHelper", "NestedTagHelper", ContentBehavior.Modify) };
});
// Act & Assert // Act & Assert
RunTagHelperTest(testType, tagHelperDescriptorProvider: tagHelperDescriptorProvider); RunTagHelperTest(testType, tagHelperDescriptors: tagHelperDescriptors);
} }
[Theory] [Theory]
@ -52,50 +81,48 @@ namespace Microsoft.AspNet.Razor.Test.Generator
var checkedPropertyInfo = new Mock<PropertyInfo>(); var checkedPropertyInfo = new Mock<PropertyInfo>();
checkedPropertyInfo.Setup(propertyInfo => propertyInfo.PropertyType).Returns(typeof(bool)); checkedPropertyInfo.Setup(propertyInfo => propertyInfo.PropertyType).Returns(typeof(bool));
checkedPropertyInfo.Setup(propertyInfo => propertyInfo.Name).Returns("Checked"); checkedPropertyInfo.Setup(propertyInfo => propertyInfo.Name).Returns("Checked");
var tagHelperDescriptorProvider = new TagHelperDescriptorProvider( var tagHelperDescriptors = new TagHelperDescriptor[]
new TagHelperDescriptor[] {
{ new TagHelperDescriptor("p",
new TagHelperDescriptor("p", "PTagHelper",
"PTagHelper", ContentBehavior.None,
ContentBehavior.None, new [] {
new [] { new TagHelperAttributeDescriptor("foo", pFooPropertyInfo.Object)
new TagHelperAttributeDescriptor("foo", pFooPropertyInfo.Object) }),
}), new TagHelperDescriptor("input",
new TagHelperDescriptor("input", "InputTagHelper",
"InputTagHelper", ContentBehavior.None,
ContentBehavior.None, new TagHelperAttributeDescriptor[] {
new TagHelperAttributeDescriptor[] { new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object)
new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object) }),
}), new TagHelperDescriptor("input",
new TagHelperDescriptor("input", "InputTagHelper2",
"InputTagHelper2", ContentBehavior.None,
ContentBehavior.None, new TagHelperAttributeDescriptor[] {
new TagHelperAttributeDescriptor[] { new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object),
new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object), new TagHelperAttributeDescriptor("checked", checkedPropertyInfo.Object)
new TagHelperAttributeDescriptor("checked", checkedPropertyInfo.Object) })
}), };
});
// Act & Assert // Act & Assert
RunTagHelperTest(testType, tagHelperDescriptorProvider: tagHelperDescriptorProvider); RunTagHelperTest(testType, tagHelperDescriptors: tagHelperDescriptors);
} }
[Fact] [Fact]
public void TagHelpers_WithContentBehaviors_GenerateExpectedOutput() public void TagHelpers_WithContentBehaviors_GenerateExpectedOutput()
{ {
// Arrange // Arrange
var tagHelperDescriptorProvider = new TagHelperDescriptorProvider( var tagHelperDescriptors = new TagHelperDescriptor[]
new TagHelperDescriptor[] {
{
new TagHelperDescriptor("modify", "ModifyTagHelper", ContentBehavior.Modify), new TagHelperDescriptor("modify", "ModifyTagHelper", ContentBehavior.Modify),
new TagHelperDescriptor("none", "NoneTagHelper", ContentBehavior.None), new TagHelperDescriptor("none", "NoneTagHelper", ContentBehavior.None),
new TagHelperDescriptor("append", "AppendTagHelper", ContentBehavior.Append), new TagHelperDescriptor("append", "AppendTagHelper", ContentBehavior.Append),
new TagHelperDescriptor("prepend", "PrependTagHelper", ContentBehavior.Prepend), new TagHelperDescriptor("prepend", "PrependTagHelper", ContentBehavior.Prepend),
new TagHelperDescriptor("replace", "ReplaceTagHelper", ContentBehavior.Replace), new TagHelperDescriptor("replace", "ReplaceTagHelper", ContentBehavior.Replace),
}); };
// Act & Assert // Act & Assert
RunTagHelperTest("ContentBehaviorTagHelpers", tagHelperDescriptorProvider: tagHelperDescriptorProvider); RunTagHelperTest("ContentBehaviorTagHelpers", tagHelperDescriptors: tagHelperDescriptors);
} }
} }
} }

View File

@ -8,6 +8,7 @@ using System.Linq;
using Microsoft.AspNet.Razor.Generator.Compiler.CSharp; using Microsoft.AspNet.Razor.Generator.Compiler.CSharp;
using Microsoft.AspNet.Razor.Parser; using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.TagHelpers;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Razor.Test.Generator namespace Microsoft.AspNet.Razor.Test.Generator
@ -221,7 +222,9 @@ namespace Microsoft.AspNet.Razor.Test.Generator
{ {
Assert.True(spanIndex > 0); Assert.True(spanIndex > 0);
var parser = new RazorParser(new CSharpCodeParser(), new HtmlMarkupParser()); var parser = new RazorParser(new CSharpCodeParser(),
new HtmlMarkupParser(),
tagHelperDescriptorResolver: null);
Span[] spans; Span[] spans;

View File

@ -24,29 +24,28 @@ namespace Microsoft.AspNet.Razor.Test.Generator
var checkedPropertyInfo = new Mock<PropertyInfo>(); var checkedPropertyInfo = new Mock<PropertyInfo>();
checkedPropertyInfo.Setup(propertyInfo => propertyInfo.PropertyType).Returns(typeof(bool)); checkedPropertyInfo.Setup(propertyInfo => propertyInfo.PropertyType).Returns(typeof(bool));
checkedPropertyInfo.Setup(propertyInfo => propertyInfo.Name).Returns("Checked"); checkedPropertyInfo.Setup(propertyInfo => propertyInfo.Name).Returns("Checked");
var tagHelperDescriptorProvider = new TagHelperDescriptorProvider( var tagHelperDescriptors = new TagHelperDescriptor[]
new TagHelperDescriptor[] {
{ new TagHelperDescriptor("p", "PTagHelper", ContentBehavior.None),
new TagHelperDescriptor("p", "PTagHelper", ContentBehavior.None), new TagHelperDescriptor("input",
new TagHelperDescriptor("input", "InputTagHelper",
"InputTagHelper", ContentBehavior.None,
ContentBehavior.None, new TagHelperAttributeDescriptor[] {
new TagHelperAttributeDescriptor[] { new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object)
new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object) }),
}), new TagHelperDescriptor("input",
new TagHelperDescriptor("input", "InputTagHelper2",
"InputTagHelper2", ContentBehavior.None,
ContentBehavior.None, new TagHelperAttributeDescriptor[] {
new TagHelperAttributeDescriptor[] { new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object),
new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object), new TagHelperAttributeDescriptor("checked", checkedPropertyInfo.Object)
new TagHelperAttributeDescriptor("checked", checkedPropertyInfo.Object) })
}), };
});
// Act & Assert // Act & Assert
RunTagHelperTest(testName: "BasicTagHelpers", RunTagHelperTest(testName: "BasicTagHelpers",
baseLineName: "BasicTagHelpers.CustomAttributeCodeGenerator", baseLineName: "BasicTagHelpers.CustomAttributeCodeGenerator",
tagHelperDescriptorProvider: tagHelperDescriptorProvider, tagHelperDescriptors: tagHelperDescriptors,
hostConfig: (host) => hostConfig: (host) =>
{ {
return new CodeBuilderReplacingHost(host); return new CodeBuilderReplacingHost(host);

View File

@ -2,9 +2,10 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using Microsoft.AspNet.Razor.Generator.Compiler;
using Microsoft.AspNet.Razor.Parser; using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.TagHelpers.Internal;
using Microsoft.AspNet.Razor.TagHelpers; using Microsoft.AspNet.Razor.TagHelpers;
namespace Microsoft.AspNet.Razor.Test.Generator namespace Microsoft.AspNet.Razor.Test.Generator
@ -13,43 +14,56 @@ namespace Microsoft.AspNet.Razor.Test.Generator
{ {
protected void RunTagHelperTest(string testName, protected void RunTagHelperTest(string testName,
string baseLineName = null, string baseLineName = null,
TagHelperDescriptorProvider tagHelperDescriptorProvider = null, bool designTimeMode = false,
Func<RazorEngineHost, RazorEngineHost> hostConfig = null) IEnumerable<TagHelperDescriptor> tagHelperDescriptors = null,
Func<RazorEngineHost, RazorEngineHost> hostConfig = null,
IList<LineMapping> expectedDesignTimePragmas = null)
{ {
RunTest(name: testName, RunTest(name: testName,
baselineName: baseLineName, baselineName: baseLineName,
designTimeMode: designTimeMode,
tabTest: TabTest.NoTabs,
templateEngineConfig: (engine) => templateEngineConfig: (engine) =>
{ {
return new TagHelperTemplateEngine(engine, tagHelperDescriptorProvider); return new TagHelperTemplateEngine(engine, tagHelperDescriptors);
}, },
hostConfig: hostConfig); hostConfig: hostConfig,
expectedDesignTimePragmas: expectedDesignTimePragmas);
}
private class CustomTagHelperDescriptorResolver : ITagHelperDescriptorResolver
{
private IEnumerable<TagHelperDescriptor> _tagHelperDescriptors;
public CustomTagHelperDescriptorResolver(IEnumerable<TagHelperDescriptor> tagHelperDescriptors)
{
_tagHelperDescriptors = tagHelperDescriptors ?? Enumerable.Empty<TagHelperDescriptor>();
}
public IEnumerable<TagHelperDescriptor> Resolve(string lookupText)
{
return _tagHelperDescriptors;
}
} }
private class TagHelperTemplateEngine : RazorTemplateEngine private class TagHelperTemplateEngine : RazorTemplateEngine
{ {
private TagHelperDescriptorProvider _tagHelperDescriptorProvider; private IEnumerable<TagHelperDescriptor> _tagHelperDescriptors;
public TagHelperTemplateEngine(RazorTemplateEngine engine, TagHelperDescriptorProvider tagHelperDescriptorProvider) public TagHelperTemplateEngine(RazorTemplateEngine engine,
IEnumerable<TagHelperDescriptor> tagHelperDescriptors)
: base(engine.Host) : base(engine.Host)
{ {
_tagHelperDescriptorProvider = tagHelperDescriptorProvider; _tagHelperDescriptors = tagHelperDescriptors;
} }
protected internal override RazorParser CreateParser() protected internal override RazorParser CreateParser()
{ {
var parser = base.CreateParser(); var parser = base.CreateParser();
var tagHelperParseTreeRewriter = new TagHelperParseTreeRewriter(_tagHelperDescriptorProvider);
for (var i = 0; i < parser.Optimizers.Count; i++) return new RazorParser(parser.CodeParser,
{ parser.MarkupParser,
if (parser.Optimizers[i] is TagHelperParseTreeRewriter) new CustomTagHelperDescriptorResolver(_tagHelperDescriptors));
{
parser.Optimizers[i] = tagHelperParseTreeRewriter;
break;
}
}
return parser;
} }
} }
} }

View File

@ -12,6 +12,93 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{ {
public class CSharpDirectivesTest : CsHtmlCodeParserTestBase public class CSharpDirectivesTest : CsHtmlCodeParserTestBase
{ {
[Fact]
public void AddTagHelperDirective_Succeeds()
{
ParseBlockTest("@addtaghelper \"Foo\"",
new DirectiveBlock(
Factory.CodeTransition(),
Factory.MetaCode(SyntaxConstants.CSharp.AddTagHelperKeyword + " ")
.Accepts(AcceptedCharacters.None),
Factory.Code("\"Foo\"").AsAddTagHelper("Foo")));
}
[Fact]
public void AddTagHelperDirectiveSupportsSpaces()
{
ParseBlockTest("@addtaghelper \" Foo, Bar \" ",
new DirectiveBlock(
Factory.CodeTransition(),
Factory.MetaCode(SyntaxConstants.CSharp.AddTagHelperKeyword + " ")
.Accepts(AcceptedCharacters.None),
Factory.Code("\" Foo, Bar \" ").AsAddTagHelper(" Foo, Bar ")));
}
[Fact]
public void AddTagHelperDirectiveRequiresValue()
{
ParseBlockTest("@addtaghelper ",
new DirectiveBlock(
Factory.CodeTransition(),
Factory.MetaCode(SyntaxConstants.CSharp.AddTagHelperKeyword + " ")
.Accepts(AcceptedCharacters.None),
Factory.EmptyCSharp().AsAddTagHelper(string.Empty)),
new RazorError(
RazorResources.FormatParseError_DirectiveMustHaveValue(SyntaxConstants.CSharp.AddTagHelperKeyword),
absoluteIndex: 14, lineIndex: 0, columnIndex: 14));
}
[Fact]
public void AddTagHelperDirectiveWithStartQuoteRequiresDoubleQuotesAroundValue()
{
ParseBlockTest("@addtaghelper \"Foo",
new DirectiveBlock(
Factory.CodeTransition(),
Factory.MetaCode(SyntaxConstants.CSharp.AddTagHelperKeyword + " ")
.Accepts(AcceptedCharacters.None),
Factory.Code("\"Foo").AsAddTagHelper("Foo")),
new RazorError(
RazorResources.ParseError_Unterminated_String_Literal,
absoluteIndex: 14, lineIndex: 0, columnIndex: 14),
new RazorError(
RazorResources.FormatParseError_DirectiveMustBeSurroundedByQuotes(
SyntaxConstants.CSharp.AddTagHelperKeyword),
absoluteIndex: 14, lineIndex: 0, columnIndex: 14));
}
[Fact]
public void AddTagHelperDirectiveWithEndQuoteRequiresDoubleQuotesAroundValue()
{
ParseBlockTest("@addtaghelper Foo\"",
new DirectiveBlock(
Factory.CodeTransition(),
Factory.MetaCode(SyntaxConstants.CSharp.AddTagHelperKeyword + " ")
.Accepts(AcceptedCharacters.None),
Factory.Code("Foo\"").AsAddTagHelper("Foo")),
new RazorError(
RazorResources.ParseError_Unterminated_String_Literal,
absoluteIndex: 17, lineIndex: 0, columnIndex: 17),
new RazorError(
RazorResources.FormatParseError_DirectiveMustBeSurroundedByQuotes(
SyntaxConstants.CSharp.AddTagHelperKeyword),
absoluteIndex: 14, lineIndex: 0, columnIndex: 14));
}
[Fact]
public void AddTagHelperDirectiveRequiresDoubleQuotesAroundValue()
{
ParseBlockTest("@addtaghelper Foo",
new DirectiveBlock(
Factory.CodeTransition(),
Factory.MetaCode(SyntaxConstants.CSharp.AddTagHelperKeyword + " ")
.Accepts(AcceptedCharacters.None),
Factory.Code("Foo").AsAddTagHelper("Foo")),
new RazorError(
RazorResources.FormatParseError_DirectiveMustBeSurroundedByQuotes(
SyntaxConstants.CSharp.AddTagHelperKeyword),
absoluteIndex: 14, lineIndex: 0, columnIndex: 14));
}
[Fact] [Fact]
public void InheritsDirective() public void InheritsDirective()
{ {

View File

@ -5,6 +5,7 @@ using System;
using System.IO; using System.IO;
using Microsoft.AspNet.Razor.Parser; using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.TagHelpers;
using Microsoft.AspNet.Razor.Test.Framework; using Microsoft.AspNet.Razor.Test.Framework;
using Xunit; using Xunit;
@ -12,25 +13,15 @@ namespace Microsoft.AspNet.Razor.Test.Parser
{ {
public class RazorParserTest public class RazorParserTest
{ {
[Fact]
public void ConstructorRequiresNonNullCodeParser()
{
Assert.Throws<ArgumentNullException>("codeParser", () => new RazorParser(null, new HtmlMarkupParser()));
}
[Fact]
public void ConstructorRequiresNonNullMarkupParser()
{
Assert.Throws<ArgumentNullException>("markupParser", () => new RazorParser(new CSharpCodeParser(), null));
}
[Fact] [Fact]
public void ParseMethodCallsParseDocumentOnMarkupParserAndReturnsResults() public void ParseMethodCallsParseDocumentOnMarkupParserAndReturnsResults()
{ {
var factory = SpanFactory.CreateCsHtml(); var factory = SpanFactory.CreateCsHtml();
// Arrange // Arrange
RazorParser parser = new RazorParser(new CSharpCodeParser(), new HtmlMarkupParser()); RazorParser parser = new RazorParser(new CSharpCodeParser(),
new HtmlMarkupParser(),
tagHelperDescriptorResolver: null);
// Act/Assert // Act/Assert
ParserTestBase.EvaluateResults(parser.Parse(new StringReader("foo @bar baz")), ParserTestBase.EvaluateResults(parser.Parse(new StringReader("foo @bar baz")),
@ -50,7 +41,9 @@ namespace Microsoft.AspNet.Razor.Test.Parser
var factory = SpanFactory.CreateCsHtml(); var factory = SpanFactory.CreateCsHtml();
// Arrange // Arrange
RazorParser parser = new RazorParser(new CSharpCodeParser(), new HtmlMarkupParser()); RazorParser parser = new RazorParser(new CSharpCodeParser(),
new HtmlMarkupParser(),
tagHelperDescriptorResolver: null);
// Act // Act
ParserResults results = parser.Parse(new StringReader("foo @bar baz")); ParserResults results = parser.Parse(new StringReader("foo @bar baz"));
@ -78,7 +71,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser
// Arrange // Arrange
ParserBase markupParser = new MockMarkupParser(); ParserBase markupParser = new MockMarkupParser();
ParserBase codeParser = new CSharpCodeParser(); ParserBase codeParser = new CSharpCodeParser();
RazorParser parser = new RazorParser(codeParser, markupParser); RazorParser parser = new RazorParser(codeParser, markupParser, tagHelperDescriptorResolver: null);
TextReader expectedReader = new StringReader("foo"); TextReader expectedReader = new StringReader("foo");
// Act // Act

View File

@ -0,0 +1,33 @@
namespace TestOutput
{
using System;
using System.Threading.Tasks;
public class AddTagHelperDirective
{
private static object @__o;
private void @__RazorDesignTimeHelpers__()
{
#pragma warning disable 219
string __tagHelperDirectiveSyntaxHelper = null;
__tagHelperDirectiveSyntaxHelper =
#line 1 "AddTagHelperDirective.cshtml"
"something"
#line default
#line hidden
;
#pragma warning restore 219
}
#line hidden
public AddTagHelperDirective()
{
}
#pragma warning disable 1998
public override async Task ExecuteAsync()
{
}
#pragma warning restore 1998
}
}

View File

@ -1,4 +1,4 @@
#pragma checksum "BasicTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8d60e58d54168749dc71a0d6d3a95887b2adb5e7" #pragma checksum "BasicTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "897cb2042003c7f319b5265ba8e1878fb3043e8e"
namespace TestOutput namespace TestOutput
{ {
using Microsoft.AspNet.Razor.Runtime.TagHelpers; using Microsoft.AspNet.Razor.Runtime.TagHelpers;
@ -22,8 +22,8 @@ namespace TestOutput
#pragma warning disable 1998 #pragma warning disable 1998
public override async Task ExecuteAsync() public override async Task ExecuteAsync()
{ {
Instrumentation.BeginContext(0, 47, true); Instrumentation.BeginContext(27, 49, true);
WriteLiteral("<div class=\"randomNonTagHelperAttribute\">\r\n "); WriteLiteral("\r\n<div class=\"randomNonTagHelperAttribute\">\r\n ");
Instrumentation.EndContext(); Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
__PTagHelper = CreateTagHelper<PTagHelper>(); __PTagHelper = CreateTagHelper<PTagHelper>();
@ -31,7 +31,7 @@ namespace TestOutput
__tagHelperExecutionContext.AddHtmlAttribute("class", "Hello World"); __tagHelperExecutionContext.AddHtmlAttribute("class", "Hello World");
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
Instrumentation.BeginContext(70, 10, true); Instrumentation.BeginContext(99, 10, true);
WriteLiteral("\r\n "); WriteLiteral("\r\n ");
Instrumentation.EndContext(); Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
@ -41,7 +41,7 @@ namespace TestOutput
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(87, 10, true); Instrumentation.BeginContext(116, 10, true);
WriteLiteral("\r\n "); WriteLiteral("\r\n ");
Instrumentation.EndContext(); Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
@ -56,7 +56,7 @@ namespace TestOutput
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(118, 10, true); Instrumentation.BeginContext(147, 10, true);
WriteLiteral("\r\n "); WriteLiteral("\r\n ");
Instrumentation.EndContext(); Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
@ -73,12 +73,12 @@ namespace TestOutput
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(167, 6, true); Instrumentation.BeginContext(196, 6, true);
WriteLiteral("\r\n "); WriteLiteral("\r\n ");
Instrumentation.EndContext(); Instrumentation.EndContext();
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(177, 8, true); Instrumentation.BeginContext(206, 8, true);
WriteLiteral("\r\n</div>"); WriteLiteral("\r\n</div>");
Instrumentation.EndContext(); Instrumentation.EndContext();
} }

View File

@ -1,4 +1,4 @@
#pragma checksum "BasicTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8d60e58d54168749dc71a0d6d3a95887b2adb5e7" #pragma checksum "BasicTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "897cb2042003c7f319b5265ba8e1878fb3043e8e"
namespace TestOutput namespace TestOutput
{ {
using Microsoft.AspNet.Razor.Runtime.TagHelpers; using Microsoft.AspNet.Razor.Runtime.TagHelpers;
@ -23,8 +23,8 @@ namespace TestOutput
#pragma warning disable 1998 #pragma warning disable 1998
public override async Task ExecuteAsync() public override async Task ExecuteAsync()
{ {
Instrumentation.BeginContext(0, 47, true); Instrumentation.BeginContext(27, 49, true);
WriteLiteral("<div class=\"randomNonTagHelperAttribute\">\r\n "); WriteLiteral("\r\n<div class=\"randomNonTagHelperAttribute\">\r\n ");
Instrumentation.EndContext(); Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
__PTagHelper = CreateTagHelper<PTagHelper>(); __PTagHelper = CreateTagHelper<PTagHelper>();
@ -32,7 +32,7 @@ namespace TestOutput
__tagHelperExecutionContext.AddHtmlAttribute("class", "Hello World"); __tagHelperExecutionContext.AddHtmlAttribute("class", "Hello World");
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
Instrumentation.BeginContext(70, 10, true); Instrumentation.BeginContext(99, 10, true);
WriteLiteral("\r\n "); WriteLiteral("\r\n ");
Instrumentation.EndContext(); Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
@ -42,7 +42,7 @@ namespace TestOutput
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(87, 10, true); Instrumentation.BeginContext(116, 10, true);
WriteLiteral("\r\n "); WriteLiteral("\r\n ");
Instrumentation.EndContext(); Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
@ -57,7 +57,7 @@ namespace TestOutput
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(118, 10, true); Instrumentation.BeginContext(147, 10, true);
WriteLiteral("\r\n "); WriteLiteral("\r\n ");
Instrumentation.EndContext(); Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
@ -74,12 +74,12 @@ namespace TestOutput
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(167, 6, true); Instrumentation.BeginContext(196, 6, true);
WriteLiteral("\r\n "); WriteLiteral("\r\n ");
Instrumentation.EndContext(); Instrumentation.EndContext();
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(177, 8, true); Instrumentation.BeginContext(206, 8, true);
WriteLiteral("\r\n</div>"); WriteLiteral("\r\n</div>");
Instrumentation.EndContext(); Instrumentation.EndContext();
} }

View File

@ -1,4 +1,4 @@
#pragma checksum "ComplexTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "7540f76029963ad4e3c0a02077a63d0fe2cb0157" #pragma checksum "ComplexTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "cce31144cd1c3c35d241b49e41c4fc04ff044565"
namespace TestOutput namespace TestOutput
{ {
using Microsoft.AspNet.Razor.Runtime.TagHelpers; using Microsoft.AspNet.Razor.Runtime.TagHelpers;
@ -23,7 +23,10 @@ namespace TestOutput
#pragma warning disable 1998 #pragma warning disable 1998
public override async Task ExecuteAsync() public override async Task ExecuteAsync()
{ {
#line 1 "ComplexTagHelpers.cshtml" Instrumentation.BeginContext(27, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
#line 3 "ComplexTagHelpers.cshtml"
if (true) if (true)
{ {
var checkbox = "checkbox"; var checkbox = "checkbox";
@ -32,7 +35,7 @@ namespace TestOutput
#line default #line default
#line hidden #line hidden
Instrumentation.BeginContext(49, 55, true); Instrumentation.BeginContext(78, 55, true);
WriteLiteral(" <div class=\"randomNonTagHelperAttribute\">\r\n "); WriteLiteral(" <div class=\"randomNonTagHelperAttribute\">\r\n ");
Instrumentation.EndContext(); Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
@ -40,7 +43,7 @@ namespace TestOutput
__tagHelperExecutionContext.Add(__PTagHelper); __tagHelperExecutionContext.Add(__PTagHelper);
StartWritingScope(); StartWritingScope();
WriteLiteral("Current Time: "); WriteLiteral("Current Time: ");
#line 6 "ComplexTagHelpers.cshtml" #line 8 "ComplexTagHelpers.cshtml"
Write(DateTime.Now); Write(DateTime.Now);
#line default #line default
@ -49,23 +52,23 @@ Write(DateTime.Now);
__tagHelperExecutionContext.AddHtmlAttribute("time", __tagHelperStringValueBuffer.ToString()); __tagHelperExecutionContext.AddHtmlAttribute("time", __tagHelperStringValueBuffer.ToString());
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
Instrumentation.BeginContext(142, 34, true); Instrumentation.BeginContext(171, 34, true);
WriteLiteral("\r\n <h1>Set Time:</h1>\r\n"); WriteLiteral("\r\n <h1>Set Time:</h1>\r\n");
Instrumentation.EndContext(); Instrumentation.EndContext();
#line 8 "ComplexTagHelpers.cshtml" #line 10 "ComplexTagHelpers.cshtml"
#line default #line default
#line hidden #line hidden
#line 8 "ComplexTagHelpers.cshtml" #line 10 "ComplexTagHelpers.cshtml"
if (false) if (false)
{ {
#line default #line default
#line hidden #line hidden
Instrumentation.BeginContext(216, 16, true); Instrumentation.BeginContext(245, 16, true);
WriteLiteral(" "); WriteLiteral(" ");
Instrumentation.EndContext(); Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
@ -73,7 +76,7 @@ Write(DateTime.Now);
__tagHelperExecutionContext.Add(__PTagHelper); __tagHelperExecutionContext.Add(__PTagHelper);
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
Instrumentation.BeginContext(235, 10, true); Instrumentation.BeginContext(264, 10, true);
WriteLiteral("New Time: "); WriteLiteral("New Time: ");
Instrumentation.EndContext(); Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
@ -92,10 +95,10 @@ Write(DateTime.Now);
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(315, 2, true); Instrumentation.BeginContext(344, 2, true);
WriteLiteral("\r\n"); WriteLiteral("\r\n");
Instrumentation.EndContext(); Instrumentation.EndContext();
#line 11 "ComplexTagHelpers.cshtml" #line 13 "ComplexTagHelpers.cshtml"
} }
else else
{ {
@ -103,7 +106,7 @@ Write(DateTime.Now);
#line default #line default
#line hidden #line hidden
Instrumentation.BeginContext(365, 16, true); Instrumentation.BeginContext(394, 16, true);
WriteLiteral(" "); WriteLiteral(" ");
Instrumentation.EndContext(); Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
@ -111,14 +114,14 @@ Write(DateTime.Now);
__tagHelperExecutionContext.Add(__PTagHelper); __tagHelperExecutionContext.Add(__PTagHelper);
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
Instrumentation.BeginContext(384, 14, true); Instrumentation.BeginContext(413, 14, true);
WriteLiteral("Current Time: "); WriteLiteral("Current Time: ");
Instrumentation.EndContext(); Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
__InputTagHelper = CreateTagHelper<InputTagHelper>(); __InputTagHelper = CreateTagHelper<InputTagHelper>();
__tagHelperExecutionContext.Add(__InputTagHelper); __tagHelperExecutionContext.Add(__InputTagHelper);
StartWritingScope(); StartWritingScope();
#line 14 "ComplexTagHelpers.cshtml" #line 16 "ComplexTagHelpers.cshtml"
Write(checkbox); Write(checkbox);
#line default #line default
@ -137,14 +140,14 @@ Write(checkbox);
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(439, 18, true); Instrumentation.BeginContext(468, 18, true);
WriteLiteral("\r\n "); WriteLiteral("\r\n ");
Instrumentation.EndContext(); Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
__InputTagHelper = CreateTagHelper<InputTagHelper>(); __InputTagHelper = CreateTagHelper<InputTagHelper>();
__tagHelperExecutionContext.Add(__InputTagHelper); __tagHelperExecutionContext.Add(__InputTagHelper);
StartWritingScope(); StartWritingScope();
#line 15 "ComplexTagHelpers.cshtml" #line 17 "ComplexTagHelpers.cshtml"
Write(true ? "checkbox" : "anything"); Write(true ? "checkbox" : "anything");
#line default #line default
@ -159,28 +162,28 @@ Write(true ? "checkbox" : "anything");
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(507, 18, true); Instrumentation.BeginContext(536, 18, true);
WriteLiteral("\r\n "); WriteLiteral("\r\n ");
Instrumentation.EndContext(); Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
__InputTagHelper = CreateTagHelper<InputTagHelper>(); __InputTagHelper = CreateTagHelper<InputTagHelper>();
__tagHelperExecutionContext.Add(__InputTagHelper); __tagHelperExecutionContext.Add(__InputTagHelper);
StartWritingScope(); StartWritingScope();
#line 16 "ComplexTagHelpers.cshtml" #line 18 "ComplexTagHelpers.cshtml"
if(true) { if(true) {
#line default #line default
#line hidden #line hidden
WriteLiteral(" checkbox "); WriteLiteral(" checkbox ");
#line 16 "ComplexTagHelpers.cshtml" #line 18 "ComplexTagHelpers.cshtml"
} else { } else {
#line default #line default
#line hidden #line hidden
WriteLiteral(" anything "); WriteLiteral(" anything ");
#line 16 "ComplexTagHelpers.cshtml" #line 18 "ComplexTagHelpers.cshtml"
} }
#line default #line default
@ -196,24 +199,24 @@ if(true) {
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(608, 2, true); Instrumentation.BeginContext(637, 2, true);
WriteLiteral("\r\n"); WriteLiteral("\r\n");
Instrumentation.EndContext(); Instrumentation.EndContext();
#line 17 "ComplexTagHelpers.cshtml" #line 19 "ComplexTagHelpers.cshtml"
} }
#line default #line default
#line hidden #line hidden
Instrumentation.BeginContext(625, 8, true); Instrumentation.BeginContext(654, 8, true);
WriteLiteral(" "); WriteLiteral(" ");
Instrumentation.EndContext(); Instrumentation.EndContext();
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(637, 14, true); Instrumentation.BeginContext(666, 14, true);
WriteLiteral("\r\n </div>\r\n"); WriteLiteral("\r\n </div>\r\n");
Instrumentation.EndContext(); Instrumentation.EndContext();
#line 20 "ComplexTagHelpers.cshtml" #line 22 "ComplexTagHelpers.cshtml"
} }
#line default #line default

View File

@ -1,4 +1,4 @@
#pragma checksum "ContentBehaviorTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "27af4f673a178e8b27e320ea0d869aaf6a16a18b" #pragma checksum "ContentBehaviorTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5aeeb0a2b5283b353efaff2cd2fb0c739020b899"
namespace TestOutput namespace TestOutput
{ {
using Microsoft.AspNet.Razor.Runtime.TagHelpers; using Microsoft.AspNet.Razor.Runtime.TagHelpers;
@ -25,6 +25,9 @@ namespace TestOutput
#pragma warning disable 1998 #pragma warning disable 1998
public override async Task ExecuteAsync() public override async Task ExecuteAsync()
{ {
Instrumentation.BeginContext(27, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("modify"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("modify");
__ModifyTagHelper = CreateTagHelper<ModifyTagHelper>(); __ModifyTagHelper = CreateTagHelper<ModifyTagHelper>();
__tagHelperExecutionContext.Add(__ModifyTagHelper); __tagHelperExecutionContext.Add(__ModifyTagHelper);

View File

@ -1,4 +1,4 @@
#pragma checksum "SingleTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2c9b5f2ce383fe784f68f84cbb669ab04077c417" #pragma checksum "SingleTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "61bf4cc89584cdbbac4478b202fe04797ddeb68a"
namespace TestOutput namespace TestOutput
{ {
using Microsoft.AspNet.Razor.Runtime.TagHelpers; using Microsoft.AspNet.Razor.Runtime.TagHelpers;
@ -21,6 +21,9 @@ namespace TestOutput
#pragma warning disable 1998 #pragma warning disable 1998
public override async Task ExecuteAsync() public override async Task ExecuteAsync()
{ {
Instrumentation.BeginContext(27, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
__PTagHelper = CreateTagHelper<PTagHelper>(); __PTagHelper = CreateTagHelper<PTagHelper>();
__tagHelperExecutionContext.Add(__PTagHelper); __tagHelperExecutionContext.Add(__PTagHelper);
@ -29,7 +32,7 @@ namespace TestOutput
__tagHelperExecutionContext.AddHtmlAttribute("class", "Hello World"); __tagHelperExecutionContext.AddHtmlAttribute("class", "Hello World");
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
Instrumentation.BeginContext(34, 11, true); Instrumentation.BeginContext(63, 11, true);
WriteLiteral("Body of Tag"); WriteLiteral("Body of Tag");
Instrumentation.EndContext(); Instrumentation.EndContext();
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());

View File

@ -1,4 +1,4 @@
#pragma checksum "TagHelpersInHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "522348d1a7650330b24372fade70f418f61027bd" #pragma checksum "TagHelpersInHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "864bdf0afabc2aecf57904d5793a20bb6d12a6a3"
namespace TestOutput namespace TestOutput
{ {
using Microsoft.AspNet.Razor.Runtime.TagHelpers; using Microsoft.AspNet.Razor.Runtime.TagHelpers;
@ -8,20 +8,20 @@ namespace TestOutput
public class TagHelpersInHelper public class TagHelpersInHelper
{ {
public static Template public static Template
#line 1 "TagHelpersInHelper.cshtml" #line 3 "TagHelpersInHelper.cshtml"
MyHelper(string val) MyHelper(string val)
{ {
#line default #line default
#line hidden #line hidden
return new Template((__razor_helper_writer) => { return new Template((__razor_helper_writer) => {
#line 2 "TagHelpersInHelper.cshtml" #line 4 "TagHelpersInHelper.cshtml"
#line default #line default
#line hidden #line hidden
Instrumentation.BeginContext(33, 19, true); Instrumentation.BeginContext(62, 19, true);
WriteLiteralTo(__razor_helper_writer, " <div>\r\n "); WriteLiteralTo(__razor_helper_writer, " <div>\r\n ");
Instrumentation.EndContext(); Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper");
@ -29,7 +29,7 @@ MyHelper(string val)
__tagHelperExecutionContext.Add(__MyTagHelper); __tagHelperExecutionContext.Add(__MyTagHelper);
StartWritingScope(); StartWritingScope();
WriteLiteral("Current Time: "); WriteLiteral("Current Time: ");
#line 4 "TagHelpersInHelper.cshtml" #line 6 "TagHelpersInHelper.cshtml"
Write(DateTime.Now); Write(DateTime.Now);
#line default #line default
@ -39,7 +39,7 @@ Write(DateTime.Now);
__tagHelperExecutionContext.AddTagHelperAttribute("BoundProperty", __MyTagHelper.BoundProperty); __tagHelperExecutionContext.AddTagHelperAttribute("BoundProperty", __MyTagHelper.BoundProperty);
StartWritingScope(); StartWritingScope();
WriteLiteral("Current Time: "); WriteLiteral("Current Time: ");
#line 4 "TagHelpersInHelper.cshtml" #line 6 "TagHelpersInHelper.cshtml"
Write(DateTime.Now); Write(DateTime.Now);
#line default #line default
@ -48,7 +48,7 @@ Write(DateTime.Now);
__tagHelperExecutionContext.AddHtmlAttribute("unboundproperty", __tagHelperStringValueBuffer.ToString()); __tagHelperExecutionContext.AddHtmlAttribute("unboundproperty", __tagHelperStringValueBuffer.ToString());
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.Output.GenerateStartTag()); WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.Output.GenerateStartTag());
Instrumentation.BeginContext(155, 52, true); Instrumentation.BeginContext(184, 52, true);
WriteLiteralTo(__razor_helper_writer, "\r\n In None ContentBehavior.\r\n "); WriteLiteralTo(__razor_helper_writer, "\r\n In None ContentBehavior.\r\n ");
Instrumentation.EndContext(); Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper");
@ -56,7 +56,7 @@ Write(DateTime.Now);
__tagHelperExecutionContext.Add(__NestedTagHelper); __tagHelperExecutionContext.Add(__NestedTagHelper);
StartWritingScope(); StartWritingScope();
WriteLiteral("Some buffered values with a value of "); WriteLiteral("Some buffered values with a value of ");
#line 6 "TagHelpersInHelper.cshtml" #line 8 "TagHelpersInHelper.cshtml"
Write(val); Write(val);
#line default #line default
@ -67,22 +67,22 @@ Write(DateTime.Now);
WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.Output.GenerateContent()); WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.Output.GenerateContent());
WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.Output.GenerateEndTag()); WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.Output.GenerateEndTag());
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(283, 10, true); Instrumentation.BeginContext(312, 10, true);
WriteLiteralTo(__razor_helper_writer, "\r\n "); WriteLiteralTo(__razor_helper_writer, "\r\n ");
Instrumentation.EndContext(); Instrumentation.EndContext();
WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.Output.GenerateEndTag()); WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.Output.GenerateEndTag());
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(307, 14, true); Instrumentation.BeginContext(336, 14, true);
WriteLiteralTo(__razor_helper_writer, "\r\n </div>\r\n"); WriteLiteralTo(__razor_helper_writer, "\r\n </div>\r\n");
Instrumentation.EndContext(); Instrumentation.EndContext();
#line 9 "TagHelpersInHelper.cshtml" #line 11 "TagHelpersInHelper.cshtml"
#line default #line default
#line hidden #line hidden
} }
); );
#line 9 "TagHelpersInHelper.cshtml" #line 11 "TagHelpersInHelper.cshtml"
} }
#line default #line default
@ -103,13 +103,16 @@ Write(DateTime.Now);
#pragma warning disable 1998 #pragma warning disable 1998
public override async Task ExecuteAsync() public override async Task ExecuteAsync()
{ {
Instrumentation.BeginContext(27, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper");
__MyTagHelper = CreateTagHelper<MyTagHelper>(); __MyTagHelper = CreateTagHelper<MyTagHelper>();
__tagHelperExecutionContext.Add(__MyTagHelper); __tagHelperExecutionContext.Add(__MyTagHelper);
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
Instrumentation.BeginContext(338, 9, false); Instrumentation.BeginContext(367, 9, false);
#line 10 "TagHelpersInHelper.cshtml" #line 12 "TagHelpersInHelper.cshtml"
Write(MyHelper(item => new Template((__razor_template_writer) => { Write(MyHelper(item => new Template((__razor_template_writer) => {
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper");
__NestedTagHelper = CreateTagHelper<NestedTagHelper>(); __NestedTagHelper = CreateTagHelper<NestedTagHelper>();
@ -131,7 +134,7 @@ Write(MyHelper(item => new Template((__razor_template_writer) => {
Instrumentation.EndContext(); Instrumentation.EndContext();
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag()); WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(410, 2, true); Instrumentation.BeginContext(439, 2, true);
WriteLiteral("\r\n"); WriteLiteral("\r\n");
Instrumentation.EndContext(); Instrumentation.EndContext();
} }

View File

@ -1,4 +1,4 @@
#pragma checksum "TagHelpersInSection.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "bfe8d61279682f87dc473aa71134e86af554f55e" #pragma checksum "TagHelpersInSection.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "2571c1678f925672aa18f5e7ae50916089e8f5cb"
namespace TestOutput namespace TestOutput
{ {
using System; using System;
@ -21,18 +21,21 @@ namespace TestOutput
#pragma warning disable 1998 #pragma warning disable 1998
public override async Task ExecuteAsync() public override async Task ExecuteAsync()
{ {
#line 1 "TagHelpersInSection.cshtml" Instrumentation.BeginContext(27, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
#line 3 "TagHelpersInSection.cshtml"
var code = "some code"; var code = "some code";
#line default #line default
#line hidden #line hidden
Instrumentation.BeginContext(34, 4, true); Instrumentation.BeginContext(63, 4, true);
WriteLiteral("\r\n\r\n"); WriteLiteral("\r\n\r\n");
Instrumentation.EndContext(); Instrumentation.EndContext();
DefineSection("MySection", new Template((__razor_template_writer) => { DefineSection("MySection", new Template((__razor_template_writer) => {
Instrumentation.BeginContext(58, 21, true); Instrumentation.BeginContext(87, 21, true);
WriteLiteralTo(__razor_template_writer, "\r\n <div>\r\n "); WriteLiteralTo(__razor_template_writer, "\r\n <div>\r\n ");
Instrumentation.EndContext(); Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper");
@ -40,7 +43,7 @@ namespace TestOutput
__tagHelperExecutionContext.Add(__MyTagHelper); __tagHelperExecutionContext.Add(__MyTagHelper);
StartWritingScope(); StartWritingScope();
WriteLiteral("Current Time: "); WriteLiteral("Current Time: ");
#line 7 "TagHelpersInSection.cshtml" #line 9 "TagHelpersInSection.cshtml"
Write(DateTime.Now); Write(DateTime.Now);
#line default #line default
@ -50,7 +53,7 @@ Write(DateTime.Now);
__tagHelperExecutionContext.AddTagHelperAttribute("BoundProperty", __MyTagHelper.BoundProperty); __tagHelperExecutionContext.AddTagHelperAttribute("BoundProperty", __MyTagHelper.BoundProperty);
StartWritingScope(); StartWritingScope();
WriteLiteral("Current Time: "); WriteLiteral("Current Time: ");
#line 7 "TagHelpersInSection.cshtml" #line 9 "TagHelpersInSection.cshtml"
Write(DateTime.Now); Write(DateTime.Now);
#line default #line default
@ -59,7 +62,7 @@ Write(DateTime.Now);
__tagHelperExecutionContext.AddHtmlAttribute("unboundproperty", __tagHelperStringValueBuffer.ToString()); __tagHelperExecutionContext.AddHtmlAttribute("unboundproperty", __tagHelperStringValueBuffer.ToString());
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateStartTag()); WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateStartTag());
Instrumentation.BeginContext(182, 52, true); Instrumentation.BeginContext(211, 52, true);
WriteLiteralTo(__razor_template_writer, "\r\n In None ContentBehavior.\r\n "); WriteLiteralTo(__razor_template_writer, "\r\n In None ContentBehavior.\r\n ");
Instrumentation.EndContext(); Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper"); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper");
@ -67,7 +70,7 @@ Write(DateTime.Now);
__tagHelperExecutionContext.Add(__NestedTagHelper); __tagHelperExecutionContext.Add(__NestedTagHelper);
StartWritingScope(); StartWritingScope();
WriteLiteral("Some buffered values with "); WriteLiteral("Some buffered values with ");
#line 9 "TagHelpersInSection.cshtml" #line 11 "TagHelpersInSection.cshtml"
Write(code); Write(code);
#line default #line default
@ -78,12 +81,12 @@ Write(DateTime.Now);
WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateContent()); WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateContent());
WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateEndTag()); WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateEndTag());
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(300, 10, true); Instrumentation.BeginContext(329, 10, true);
WriteLiteralTo(__razor_template_writer, "\r\n "); WriteLiteralTo(__razor_template_writer, "\r\n ");
Instrumentation.EndContext(); Instrumentation.EndContext();
WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateEndTag()); WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateEndTag());
__tagHelperExecutionContext = __tagHelperScopeManager.End(); __tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(324, 14, true); Instrumentation.BeginContext(353, 14, true);
WriteLiteralTo(__razor_template_writer, "\r\n </div>\r\n"); WriteLiteralTo(__razor_template_writer, "\r\n </div>\r\n");
Instrumentation.EndContext(); Instrumentation.EndContext();
} }

View File

@ -0,0 +1 @@
@addtaghelper "something"

View File

@ -1,4 +1,6 @@
<div class="randomNonTagHelperAttribute"> @addtaghelper "something"
<div class="randomNonTagHelperAttribute">
<p class="Hello World"> <p class="Hello World">
<p></p> <p></p>
<input type="text" /> <input type="text" />

View File

@ -1,4 +1,6 @@
@if (true) @addtaghelper "something"
@if (true)
{ {
var checkbox = "checkbox"; var checkbox = "checkbox";

View File

@ -1,4 +1,6 @@
<modify> @addtaghelper "something"
<modify>
<none> <none>
<append> <append>
<prepend> <prepend>

View File

@ -1 +1,3 @@
<p class="Hello World" foo="1337">Body of Tag</p> @addtaghelper "something"
<p class="Hello World" foo="1337">Body of Tag</p>

View File

@ -1,4 +1,6 @@
@helper MyHelper(string val) @addtaghelper "something"
@helper MyHelper(string val)
{ {
<div> <div>
<mytaghelper boundproperty="Current Time: @DateTime.Now" unboundproperty="Current Time: @DateTime.Now"> <mytaghelper boundproperty="Current Time: @DateTime.Now" unboundproperty="Current Time: @DateTime.Now">

View File

@ -1,4 +1,6 @@
@{ @addtaghelper "something"
@{
var code = "some code"; var code = "some code";
} }