Added TagHelperContext.UniqueId:

- The ID is created at view compilation time and is unique per TagHelperExecutionContext and thus per HTML element in the source for which Tag Helpers will run
- #241
This commit is contained in:
DamianEdwards 2014-11-24 22:18:05 -08:00
parent 170b7a76fd
commit 7890a1b34c
16 changed files with 305 additions and 40 deletions

View File

@ -14,14 +14,21 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
/// Instantiates a new <see cref="TagHelperContext"/>.
/// </summary>
/// <param name="allAttributes">Every attribute associated with the current HTML element.</param>
public TagHelperContext([NotNull] IDictionary<string, object> allAttributes)
/// <param name="uniqueId">The unique identifier for the source element this <see cref="TagHelperContext" /> applies to.</param>
public TagHelperContext([NotNull] IDictionary<string, object> allAttributes, [NotNull] string uniqueId)
{
AllAttributes = allAttributes;
UniqueId = uniqueId;
}
/// <summary>
/// Every attribute associated with the current HTML element.
/// </summary>
public IDictionary<string, object> AllAttributes { get; private set; }
/// <summary>
/// An identifier unique to the HTML element this context is for.
/// </summary>
public string UniqueId { get; private set; }
}
}

View File

@ -17,12 +17,22 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
/// Instantiates a new <see cref="TagHelperExecutionContext"/>.
/// </summary>
/// <param name="tagName">The HTML tag name in the Razor source.</param>
public TagHelperExecutionContext([NotNull] string tagName)
public TagHelperExecutionContext([NotNull] string tagName, [NotNull] string uniqueId)
{
AllAttributes = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
HTMLAttributes = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
_tagHelpers = new List<ITagHelper>();
TagName = tagName;
UniqueId = uniqueId;
}
/// <summary>
/// Internal for testing purposes only.
/// </summary>
internal TagHelperExecutionContext([NotNull] string tagName)
: this(tagName, string.Empty)
{
}
/// <summary>
@ -35,6 +45,11 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
/// </summary>
public IDictionary<string, object> AllAttributes { get; private set; }
/// <summary>
/// An identifier unique to the HTML element this context is for.
/// </summary>
public string UniqueId { get; private set; }
/// <summary>
/// <see cref="ITagHelper"/>s that should be run.
/// </summary>

View File

@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
private async Task<TagHelperOutput> RunAsyncCore(TagHelperExecutionContext executionContext, string outputContent)
{
var tagHelperContext = new TagHelperContext(executionContext.AllAttributes);
var tagHelperContext = new TagHelperContext(executionContext.AllAttributes, executionContext.UniqueId);
var tagHelperOutput = new TagHelperOutput(executionContext.TagName,
executionContext.HTMLAttributes,
outputContent);

View File

@ -25,10 +25,11 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
/// Starts a <see cref="TagHelperExecutionContext"/> scope.
/// </summary>
/// <param name="tagName">The HTML tag name that the scope is associated with.</param>
/// <param name="uniqueId">An identifier unique to the HTML element this scope is for.</param>
/// <returns>A <see cref="TagHelperExecutionContext"/> to use.</returns>
public TagHelperExecutionContext Begin(string tagName)
public TagHelperExecutionContext Begin(string tagName, string uniqueId)
{
var executionContext = new TagHelperExecutionContext(tagName);
var executionContext = new TagHelperExecutionContext(tagName, uniqueId);
_executionScopes.Push(executionContext);

View File

@ -135,10 +135,26 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
_writer.WriteStartAssignment(ExecutionContextVariableName)
.WriteStartInstanceMethodInvocation(ScopeManagerVariableName,
_tagHelperContext.ScopeManagerBeginMethodName);
// Assign a unique ID for this instance of the source HTML tag. This must be unique
// per call site, e.g. if the tag is on the view twice, there should be two IDs.
_writer.WriteStringLiteral(tagName)
.WriteParameterSeparator()
.WriteStringLiteral(GenerateUniqueId())
.WriteEndMethodInvocation();
}
/// <summary>
/// Generates a unique ID for an HTML element.
/// </summary>
/// <returns>
/// A globally unique ID.
/// </returns>
protected virtual string GenerateUniqueId()
{
return Guid.NewGuid().ToString("N");
}
private void RenderTagHelpersCreation(TagHelperChunk chunk)
{
var tagHelperDescriptors = chunk.Descriptors;

View File

@ -16,7 +16,7 @@ namespace Microsoft.AspNet.Razor.Runtime.Test.TagHelpers
var scopeManager = new TagHelperScopeManager();
// Act
var executionContext = scopeManager.Begin("p");
var executionContext = scopeManager.Begin("p", string.Empty);
// Assert
Assert.Equal("p", executionContext.TagName);
@ -29,8 +29,8 @@ namespace Microsoft.AspNet.Razor.Runtime.Test.TagHelpers
var scopeManager = new TagHelperScopeManager();
// Act
var executionContext = scopeManager.Begin("p");
executionContext = scopeManager.Begin("div");
var executionContext = scopeManager.Begin("p", string.Empty);
executionContext = scopeManager.Begin("div", string.Empty);
// Assert
Assert.Equal("div", executionContext.TagName);
@ -43,8 +43,8 @@ namespace Microsoft.AspNet.Razor.Runtime.Test.TagHelpers
var scopeManager = new TagHelperScopeManager();
// Act
var executionContext = scopeManager.Begin("p");
executionContext = scopeManager.Begin("div");
var executionContext = scopeManager.Begin("p", string.Empty);
executionContext = scopeManager.Begin("div", string.Empty);
executionContext = scopeManager.End();
// Assert
@ -58,8 +58,8 @@ namespace Microsoft.AspNet.Razor.Runtime.Test.TagHelpers
var scopeManager = new TagHelperScopeManager();
// Act
var executionContext = scopeManager.Begin("p");
executionContext = scopeManager.Begin("div");
var executionContext = scopeManager.Begin("p", string.Empty);
executionContext = scopeManager.Begin("div", string.Empty);
executionContext = scopeManager.End();
executionContext = scopeManager.End();

View File

@ -0,0 +1,187 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Generator.Compiler;
using Microsoft.AspNet.Razor.Generator.Compiler.CSharp;
using Microsoft.AspNet.Razor.TagHelpers;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Generator
{
public class CSharpTagHelperRenderingUnitTest
{
[Fact]
public void CreatesAUniqueIdForSingleTagHelperChunk()
{
// Arrange
var chunk = CreateTagHelperChunk("div", new[] {
new TagHelperDescriptor("div", "DivTagHelper", "FakeAssemblyName", ContentBehavior.None)
});
var codeRenderer = CreateCodeRenderer();
// Act
codeRenderer.RenderTagHelper(chunk);
// Assert
Assert.Equal(1, codeRenderer.GenerateUniqueIdCount);
}
[Fact]
public void UsesTheSameUniqueIdForTagHelperChunkWithMultipleTagHelpers()
{
// Arrange
var chunk = CreateTagHelperChunk("div", new[] {
new TagHelperDescriptor("div", "DivTagHelper", "FakeAssemblyName", ContentBehavior.None),
new TagHelperDescriptor("div", "Div2TagHelper", "FakeAssemblyName", ContentBehavior.None)
});
var codeRenderer = CreateCodeRenderer();
// Act
codeRenderer.RenderTagHelper(chunk);
// Assert
Assert.Equal(1, codeRenderer.GenerateUniqueIdCount);
}
[Fact]
public void UsesDifferentUniqueIdForMultipleTagHelperChunksForSameTagHelper()
{
// Arrange
var chunk1 = CreateTagHelperChunk("div", new[] {
new TagHelperDescriptor("div", "DivTagHelper", "FakeAssemblyName", ContentBehavior.None)
});
var chunk2 = CreateTagHelperChunk("div", new[] {
new TagHelperDescriptor("div", "DivTagHelper", "FakeAssemblyName", ContentBehavior.None)
});
var codeRenderer = CreateCodeRenderer();
// Act
codeRenderer.RenderTagHelper(chunk1);
codeRenderer.RenderTagHelper(chunk2);
// Assert
Assert.Equal(2, codeRenderer.GenerateUniqueIdCount);
}
[Fact]
public void UsesDifferentUniqueIdForNestedTagHelperChunksForSameTagHelper()
{
// Arrange
var parentChunk = CreateTagHelperChunk("div", new[] {
new TagHelperDescriptor("div", "DivTagHelper", "FakeAssemblyName", ContentBehavior.None)
});
var childChunk = CreateTagHelperChunk("div", new[] {
new TagHelperDescriptor("div", "DivTagHelper", "FakeAssemblyName", ContentBehavior.None)
});
parentChunk.Children.Add(childChunk);
var codeRenderer = CreateCodeRenderer();
// Act
codeRenderer.RenderTagHelper(parentChunk);
// Assert
Assert.Equal(2, codeRenderer.GenerateUniqueIdCount);
}
[Fact]
public void UsesDifferentUniqueIdForMultipleTagHelperChunksForDifferentTagHelpers()
{
// Arrange
var divChunk = CreateTagHelperChunk("div", new[] {
new TagHelperDescriptor("div", "DivTagHelper", "FakeAssemblyName", ContentBehavior.None)
});
var spanChunk = CreateTagHelperChunk("span", new[] {
new TagHelperDescriptor("span", "SpanTagHelper", "FakeAssemblyName", ContentBehavior.None)
});
var codeRenderer = CreateCodeRenderer();
// Act
codeRenderer.RenderTagHelper(divChunk);
codeRenderer.RenderTagHelper(spanChunk);
// Assert
Assert.Equal(2, codeRenderer.GenerateUniqueIdCount);
}
[Fact]
public void UsesCorrectUniqueIdForMultipleTagHelperChunksSomeWithSameSameTagHelpersSomeWithDifferentTagHelpers()
{
// Arrange
var chunk1 = CreateTagHelperChunk("div", new[] {
new TagHelperDescriptor("div", "DivTagHelper", "FakeAssemblyName", ContentBehavior.None),
new TagHelperDescriptor("div", "Div2TagHelper", "FakeAssemblyName", ContentBehavior.None)
});
var chunk2 = CreateTagHelperChunk("span", new[] {
new TagHelperDescriptor("span", "SpanTagHelper", "FakeAssemblyName", ContentBehavior.None)
});
var chunk3 = CreateTagHelperChunk("span", new[] {
new TagHelperDescriptor("span", "SpanTagHelper", "FakeAssemblyName", ContentBehavior.None),
new TagHelperDescriptor("span", "Span2TagHelper", "FakeAssemblyName", ContentBehavior.None)
});
var codeRenderer = CreateCodeRenderer();
// Act
codeRenderer.RenderTagHelper(chunk1);
codeRenderer.RenderTagHelper(chunk2);
codeRenderer.RenderTagHelper(chunk3);
// Assert
Assert.Equal(3, codeRenderer.GenerateUniqueIdCount);
}
private static TagHelperChunk CreateTagHelperChunk(string tagName, IEnumerable<TagHelperDescriptor> tagHelperDescriptors)
{
return new TagHelperChunk
{
TagName = tagName,
Descriptors = tagHelperDescriptors,
Children = new List<Chunk>(),
Attributes = new Dictionary<string, Chunk>()
};
}
private static TrackingUniqueIdsTagHelperCodeRenderer CreateCodeRenderer()
{
var writer = new CSharpCodeWriter();
var codeBuilderContext = CreateContext();
var visitor = new CSharpCodeVisitor(writer, codeBuilderContext);
var codeRenderer = new TrackingUniqueIdsTagHelperCodeRenderer(
visitor,
writer,
codeBuilderContext);
visitor.TagHelperRenderer = codeRenderer;
return codeRenderer;
}
private static CodeBuilderContext CreateContext()
{
return new CodeBuilderContext(
new CodeGeneratorContext(
new RazorEngineHost(new CSharpRazorCodeLanguage()),
"MyClass",
"MyNamespace",
string.Empty,
shouldGenerateLinePragmas: true));
}
private class TrackingUniqueIdsTagHelperCodeRenderer : CSharpTagHelperCodeRenderer
{
public TrackingUniqueIdsTagHelperCodeRenderer(
IChunkVisitor bodyVisitor,
CSharpCodeWriter writer,
CodeBuilderContext context)
: base(bodyVisitor, writer, context)
{
}
protected override string GenerateUniqueId()
{
GenerateUniqueIdCount++;
return "test";
}
public int GenerateUniqueIdCount { get; private set; }
}
}
}

View File

@ -65,7 +65,7 @@ namespace Microsoft.AspNet.Razor.Test.Generator
}
}
private class AttributeCodeGeneratorReplacingCodeBuilder : CSharpCodeBuilder
private class AttributeCodeGeneratorReplacingCodeBuilder : TestCSharpCodeBuilder
{
public AttributeCodeGeneratorReplacingCodeBuilder(CodeBuilderContext context)
: base(context)

View File

@ -5,7 +5,9 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Generator.Compiler;
using Microsoft.AspNet.Razor.Generator.Compiler.CSharp;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.TagHelpers;
using Xunit;
@ -78,6 +80,11 @@ namespace Microsoft.AspNet.Razor.Test.Generator
_tagHelperDescriptors = tagHelperDescriptors;
}
protected internal override CodeBuilder CreateCodeBuilder(CodeBuilderContext context)
{
return Host.DecorateCodeBuilder(new TestCSharpCodeBuilder(context), context);
}
protected internal override RazorParser CreateParser(string fileName)
{
var parser = base.CreateParser(fileName);
@ -87,5 +94,37 @@ namespace Microsoft.AspNet.Razor.Test.Generator
new CustomTagHelperDescriptorResolver(_tagHelperDescriptors));
}
}
protected class TestCSharpCodeBuilder : CSharpCodeBuilder
{
public TestCSharpCodeBuilder(CodeBuilderContext context)
: base(context)
{
}
protected override CSharpCodeVisitor CreateCSharpCodeVisitor(CSharpCodeWriter writer, CodeBuilderContext context)
{
var visitor = base.CreateCSharpCodeVisitor(writer, context);
visitor.TagHelperRenderer = new NoUniqueIdsTagHelperCodeRenderer(visitor, writer, context);
return visitor;
}
private class NoUniqueIdsTagHelperCodeRenderer : CSharpTagHelperCodeRenderer
{
public NoUniqueIdsTagHelperCodeRenderer(IChunkVisitor bodyVisitor,
CSharpCodeWriter writer,
CodeBuilderContext context)
: base(bodyVisitor, writer, context)
{
}
protected override string GenerateUniqueId()
{
return "test";
}
}
}
}
}

View File

@ -25,7 +25,7 @@ namespace TestOutput
Instrumentation.BeginContext(27, 49, true);
WriteLiteral("\r\n<div class=\"randomNonTagHelperAttribute\">\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test");
__PTagHelper = CreateTagHelper<PTagHelper>();
__tagHelperExecutionContext.Add(__PTagHelper);
__tagHelperExecutionContext.AddHtmlAttribute("class", "Hello World");
@ -34,7 +34,7 @@ namespace TestOutput
Instrumentation.BeginContext(99, 10, true);
WriteLiteral("\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test");
__PTagHelper = CreateTagHelper<PTagHelper>();
__tagHelperExecutionContext.Add(__PTagHelper);
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
@ -44,7 +44,7 @@ namespace TestOutput
Instrumentation.BeginContext(116, 10, true);
WriteLiteral("\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test");
__InputTagHelper = CreateTagHelper<InputTagHelper>();
__tagHelperExecutionContext.Add(__InputTagHelper);
__InputTagHelper.Type = **From custom attribute code renderer**: "text";
@ -59,7 +59,7 @@ namespace TestOutput
Instrumentation.BeginContext(147, 10, true);
WriteLiteral("\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test");
__InputTagHelper = CreateTagHelper<InputTagHelper>();
__tagHelperExecutionContext.Add(__InputTagHelper);
__InputTagHelper.Type = **From custom attribute code renderer**: "checkbox";

View File

@ -26,7 +26,7 @@ namespace TestOutput
Instrumentation.BeginContext(27, 49, true);
WriteLiteral("\r\n<div class=\"randomNonTagHelperAttribute\">\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test");
__PTagHelper = CreateTagHelper<PTagHelper>();
__tagHelperExecutionContext.Add(__PTagHelper);
__tagHelperExecutionContext.AddHtmlAttribute("class", "Hello World");
@ -35,7 +35,7 @@ namespace TestOutput
Instrumentation.BeginContext(99, 10, true);
WriteLiteral("\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test");
__PTagHelper = CreateTagHelper<PTagHelper>();
__tagHelperExecutionContext.Add(__PTagHelper);
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
@ -45,7 +45,7 @@ namespace TestOutput
Instrumentation.BeginContext(116, 10, true);
WriteLiteral("\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test");
__InputTagHelper = CreateTagHelper<InputTagHelper>();
__tagHelperExecutionContext.Add(__InputTagHelper);
__InputTagHelper.Type = "text";
@ -60,7 +60,7 @@ namespace TestOutput
Instrumentation.BeginContext(147, 10, true);
WriteLiteral("\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test");
__InputTagHelper = CreateTagHelper<InputTagHelper>();
__tagHelperExecutionContext.Add(__InputTagHelper);
__InputTagHelper.Type = "checkbox";

View File

@ -38,7 +38,7 @@ namespace TestOutput
Instrumentation.BeginContext(78, 55, true);
WriteLiteral(" <div class=\"randomNonTagHelperAttribute\">\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test");
__PTagHelper = CreateTagHelper<PTagHelper>();
__tagHelperExecutionContext.Add(__PTagHelper);
StartWritingScope();
@ -71,7 +71,7 @@ Write(DateTime.Now);
Instrumentation.BeginContext(245, 16, true);
WriteLiteral(" ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test");
__PTagHelper = CreateTagHelper<PTagHelper>();
__tagHelperExecutionContext.Add(__PTagHelper);
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
@ -79,7 +79,7 @@ Write(DateTime.Now);
Instrumentation.BeginContext(264, 10, true);
WriteLiteral("New Time: ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test");
__InputTagHelper = CreateTagHelper<InputTagHelper>();
__tagHelperExecutionContext.Add(__InputTagHelper);
__InputTagHelper.Type = "text";
@ -109,7 +109,7 @@ Write(DateTime.Now);
Instrumentation.BeginContext(394, 16, true);
WriteLiteral(" ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test");
__PTagHelper = CreateTagHelper<PTagHelper>();
__tagHelperExecutionContext.Add(__PTagHelper);
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
@ -117,7 +117,7 @@ Write(DateTime.Now);
Instrumentation.BeginContext(413, 14, true);
WriteLiteral("Current Time: ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test");
__InputTagHelper = CreateTagHelper<InputTagHelper>();
__tagHelperExecutionContext.Add(__InputTagHelper);
StartWritingScope();
@ -143,7 +143,7 @@ Write(checkbox);
Instrumentation.BeginContext(468, 18, true);
WriteLiteral("\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test");
__InputTagHelper = CreateTagHelper<InputTagHelper>();
__tagHelperExecutionContext.Add(__InputTagHelper);
StartWritingScope();
@ -165,7 +165,7 @@ Write(true ? "checkbox" : "anything");
Instrumentation.BeginContext(536, 18, true);
WriteLiteral("\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", "test");
__InputTagHelper = CreateTagHelper<InputTagHelper>();
__tagHelperExecutionContext.Add(__InputTagHelper);
StartWritingScope();

View File

@ -28,31 +28,31 @@ namespace TestOutput
Instrumentation.BeginContext(27, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("modify");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("modify", "test");
__ModifyTagHelper = CreateTagHelper<ModifyTagHelper>();
__tagHelperExecutionContext.Add(__ModifyTagHelper);
StartWritingScope();
WriteLiteral("\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("none");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("none", "test");
__NoneTagHelper = CreateTagHelper<NoneTagHelper>();
__tagHelperExecutionContext.Add(__NoneTagHelper);
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
WriteLiteral("\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("append");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("append", "test");
__AppendTagHelper = CreateTagHelper<AppendTagHelper>();
__tagHelperExecutionContext.Add(__AppendTagHelper);
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
WriteLiteral("\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("prepend");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("prepend", "test");
__PrependTagHelper = CreateTagHelper<PrependTagHelper>();
__tagHelperExecutionContext.Add(__PrependTagHelper);
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
WriteLiteral(__tagHelperExecutionContext.Output.GenerateContent());
WriteLiteral("\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("replace");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("replace", "test");
__ReplaceTagHelper = CreateTagHelper<ReplaceTagHelper>();
__tagHelperExecutionContext.Add(__ReplaceTagHelper);
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;

View File

@ -24,7 +24,7 @@ namespace TestOutput
Instrumentation.BeginContext(27, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", "test");
__PTagHelper = CreateTagHelper<PTagHelper>();
__tagHelperExecutionContext.Add(__PTagHelper);
__PTagHelper.Age = 1337;

View File

@ -24,7 +24,7 @@ MyHelper(string val)
Instrumentation.BeginContext(62, 19, true);
WriteLiteralTo(__razor_helper_writer, " <div>\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper", "test");
__MyTagHelper = CreateTagHelper<MyTagHelper>();
__tagHelperExecutionContext.Add(__MyTagHelper);
StartWritingScope();
@ -51,7 +51,7 @@ Write(DateTime.Now);
Instrumentation.BeginContext(184, 52, true);
WriteLiteralTo(__razor_helper_writer, "\r\n In None ContentBehavior.\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper", "test");
__NestedTagHelper = CreateTagHelper<NestedTagHelper>();
__tagHelperExecutionContext.Add(__NestedTagHelper);
StartWritingScope();
@ -106,7 +106,7 @@ Write(DateTime.Now);
Instrumentation.BeginContext(27, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper", "test");
__MyTagHelper = CreateTagHelper<MyTagHelper>();
__tagHelperExecutionContext.Add(__MyTagHelper);
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
@ -114,7 +114,7 @@ Write(DateTime.Now);
Instrumentation.BeginContext(367, 9, false);
#line 12 "TagHelpersInHelper.cshtml"
Write(MyHelper(item => new Template((__razor_template_writer) => {
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper", "test");
__NestedTagHelper = CreateTagHelper<NestedTagHelper>();
__tagHelperExecutionContext.Add(__NestedTagHelper);
StartWritingScope();

View File

@ -38,7 +38,7 @@ namespace TestOutput
Instrumentation.BeginContext(87, 21, true);
WriteLiteralTo(__razor_template_writer, "\r\n <div>\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper", "test");
__MyTagHelper = CreateTagHelper<MyTagHelper>();
__tagHelperExecutionContext.Add(__MyTagHelper);
StartWritingScope();
@ -65,7 +65,7 @@ Write(DateTime.Now);
Instrumentation.BeginContext(211, 52, true);
WriteLiteralTo(__razor_template_writer, "\r\n In None ContentBehavior.\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper", "test");
__NestedTagHelper = CreateTagHelper<NestedTagHelper>();
__tagHelperExecutionContext.Add(__NestedTagHelper);
StartWritingScope();