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:
parent
b67b8dae3d
commit
7db4ed7f7e
|
|
@ -300,6 +300,11 @@ namespace Microsoft.AspNet.Razor.Test.Framework
|
|||
return _self.With(new RazorDirectiveAttributeCodeGenerator(key, value));
|
||||
}
|
||||
|
||||
public SpanConstructor AsAddTagHelper(string lookupText)
|
||||
{
|
||||
return _self.With(new AddTagHelperCodeGenerator(lookupText));
|
||||
}
|
||||
|
||||
public SpanConstructor As(ISpanCodeGenerator codeGenerator)
|
||||
{
|
||||
return _self.With(codeGenerator);
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
documentLocation: new MappingLocation(new SourceLocation(documentAbsoluteIndex, documentLineIndex, documentCharacterOffsetIndex), contentLength),
|
||||
generatedLocation: new MappingLocation(new SourceLocation(generatedAbsoluteIndex, generatedLineIndex, generatedCharacterOffsetIndex), contentLength)
|
||||
documentLocation: new MappingLocation(
|
||||
new SourceLocation(documentAbsoluteIndex,
|
||||
documentLineIndex,
|
||||
documentCharacterOffsetIndex),
|
||||
contentLength),
|
||||
generatedLocation: new MappingLocation(
|
||||
new SourceLocation(generatedAbsoluteIndex,
|
||||
generatedLineIndex,
|
||||
generatedCharacterOffsetIndex),
|
||||
contentLength)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNet.Razor.Generator.Compiler;
|
||||
using Microsoft.AspNet.Razor.TagHelpers;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
|
@ -10,6 +12,34 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
|||
{
|
||||
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]
|
||||
[InlineData("TagHelpersInSection")]
|
||||
[InlineData("TagHelpersInHelper")]
|
||||
|
|
@ -19,21 +49,20 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
|||
var propertyInfoMock = new Mock<PropertyInfo>();
|
||||
propertyInfoMock.Setup(propertyInfo => propertyInfo.PropertyType).Returns(typeof(string));
|
||||
propertyInfoMock.Setup(propertyInfo => propertyInfo.Name).Returns("BoundProperty");
|
||||
var tagHelperDescriptorProvider = new TagHelperDescriptorProvider(
|
||||
new TagHelperDescriptor[]
|
||||
{
|
||||
new TagHelperDescriptor("MyTagHelper",
|
||||
"MyTagHelper",
|
||||
ContentBehavior.None,
|
||||
new [] {
|
||||
new TagHelperAttributeDescriptor("BoundProperty",
|
||||
propertyInfoMock.Object)
|
||||
}),
|
||||
new TagHelperDescriptor("NestedTagHelper", "NestedTagHelper", ContentBehavior.Modify)
|
||||
});
|
||||
var tagHelperDescriptors = new TagHelperDescriptor[]
|
||||
{
|
||||
new TagHelperDescriptor("MyTagHelper",
|
||||
"MyTagHelper",
|
||||
ContentBehavior.None,
|
||||
new [] {
|
||||
new TagHelperAttributeDescriptor("BoundProperty",
|
||||
propertyInfoMock.Object)
|
||||
}),
|
||||
new TagHelperDescriptor("NestedTagHelper", "NestedTagHelper", ContentBehavior.Modify)
|
||||
};
|
||||
|
||||
// Act & Assert
|
||||
RunTagHelperTest(testType, tagHelperDescriptorProvider: tagHelperDescriptorProvider);
|
||||
RunTagHelperTest(testType, tagHelperDescriptors: tagHelperDescriptors);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -52,50 +81,48 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
|||
var checkedPropertyInfo = new Mock<PropertyInfo>();
|
||||
checkedPropertyInfo.Setup(propertyInfo => propertyInfo.PropertyType).Returns(typeof(bool));
|
||||
checkedPropertyInfo.Setup(propertyInfo => propertyInfo.Name).Returns("Checked");
|
||||
var tagHelperDescriptorProvider = new TagHelperDescriptorProvider(
|
||||
new TagHelperDescriptor[]
|
||||
{
|
||||
new TagHelperDescriptor("p",
|
||||
"PTagHelper",
|
||||
ContentBehavior.None,
|
||||
new [] {
|
||||
new TagHelperAttributeDescriptor("foo", pFooPropertyInfo.Object)
|
||||
}),
|
||||
new TagHelperDescriptor("input",
|
||||
"InputTagHelper",
|
||||
ContentBehavior.None,
|
||||
new TagHelperAttributeDescriptor[] {
|
||||
new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object)
|
||||
}),
|
||||
new TagHelperDescriptor("input",
|
||||
"InputTagHelper2",
|
||||
ContentBehavior.None,
|
||||
new TagHelperAttributeDescriptor[] {
|
||||
new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object),
|
||||
new TagHelperAttributeDescriptor("checked", checkedPropertyInfo.Object)
|
||||
}),
|
||||
});
|
||||
var tagHelperDescriptors = new TagHelperDescriptor[]
|
||||
{
|
||||
new TagHelperDescriptor("p",
|
||||
"PTagHelper",
|
||||
ContentBehavior.None,
|
||||
new [] {
|
||||
new TagHelperAttributeDescriptor("foo", pFooPropertyInfo.Object)
|
||||
}),
|
||||
new TagHelperDescriptor("input",
|
||||
"InputTagHelper",
|
||||
ContentBehavior.None,
|
||||
new TagHelperAttributeDescriptor[] {
|
||||
new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object)
|
||||
}),
|
||||
new TagHelperDescriptor("input",
|
||||
"InputTagHelper2",
|
||||
ContentBehavior.None,
|
||||
new TagHelperAttributeDescriptor[] {
|
||||
new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object),
|
||||
new TagHelperAttributeDescriptor("checked", checkedPropertyInfo.Object)
|
||||
})
|
||||
};
|
||||
|
||||
// Act & Assert
|
||||
RunTagHelperTest(testType, tagHelperDescriptorProvider: tagHelperDescriptorProvider);
|
||||
RunTagHelperTest(testType, tagHelperDescriptors: tagHelperDescriptors);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TagHelpers_WithContentBehaviors_GenerateExpectedOutput()
|
||||
{
|
||||
// Arrange
|
||||
var tagHelperDescriptorProvider = new TagHelperDescriptorProvider(
|
||||
new TagHelperDescriptor[]
|
||||
{
|
||||
var tagHelperDescriptors = new TagHelperDescriptor[]
|
||||
{
|
||||
new TagHelperDescriptor("modify", "ModifyTagHelper", ContentBehavior.Modify),
|
||||
new TagHelperDescriptor("none", "NoneTagHelper", ContentBehavior.None),
|
||||
new TagHelperDescriptor("append", "AppendTagHelper", ContentBehavior.Append),
|
||||
new TagHelperDescriptor("prepend", "PrependTagHelper", ContentBehavior.Prepend),
|
||||
new TagHelperDescriptor("replace", "ReplaceTagHelper", ContentBehavior.Replace),
|
||||
});
|
||||
};
|
||||
|
||||
// Act & Assert
|
||||
RunTagHelperTest("ContentBehaviorTagHelpers", tagHelperDescriptorProvider: tagHelperDescriptorProvider);
|
||||
RunTagHelperTest("ContentBehaviorTagHelpers", tagHelperDescriptors: tagHelperDescriptors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ using System.Linq;
|
|||
using Microsoft.AspNet.Razor.Generator.Compiler.CSharp;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.TagHelpers;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Generator
|
||||
|
|
@ -221,7 +222,9 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
|||
{
|
||||
Assert.True(spanIndex > 0);
|
||||
|
||||
var parser = new RazorParser(new CSharpCodeParser(), new HtmlMarkupParser());
|
||||
var parser = new RazorParser(new CSharpCodeParser(),
|
||||
new HtmlMarkupParser(),
|
||||
tagHelperDescriptorResolver: null);
|
||||
|
||||
Span[] spans;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,29 +24,28 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
|||
var checkedPropertyInfo = new Mock<PropertyInfo>();
|
||||
checkedPropertyInfo.Setup(propertyInfo => propertyInfo.PropertyType).Returns(typeof(bool));
|
||||
checkedPropertyInfo.Setup(propertyInfo => propertyInfo.Name).Returns("Checked");
|
||||
var tagHelperDescriptorProvider = new TagHelperDescriptorProvider(
|
||||
new TagHelperDescriptor[]
|
||||
{
|
||||
new TagHelperDescriptor("p", "PTagHelper", ContentBehavior.None),
|
||||
new TagHelperDescriptor("input",
|
||||
"InputTagHelper",
|
||||
ContentBehavior.None,
|
||||
new TagHelperAttributeDescriptor[] {
|
||||
new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object)
|
||||
}),
|
||||
new TagHelperDescriptor("input",
|
||||
"InputTagHelper2",
|
||||
ContentBehavior.None,
|
||||
new TagHelperAttributeDescriptor[] {
|
||||
new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object),
|
||||
new TagHelperAttributeDescriptor("checked", checkedPropertyInfo.Object)
|
||||
}),
|
||||
});
|
||||
var tagHelperDescriptors = new TagHelperDescriptor[]
|
||||
{
|
||||
new TagHelperDescriptor("p", "PTagHelper", ContentBehavior.None),
|
||||
new TagHelperDescriptor("input",
|
||||
"InputTagHelper",
|
||||
ContentBehavior.None,
|
||||
new TagHelperAttributeDescriptor[] {
|
||||
new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object)
|
||||
}),
|
||||
new TagHelperDescriptor("input",
|
||||
"InputTagHelper2",
|
||||
ContentBehavior.None,
|
||||
new TagHelperAttributeDescriptor[] {
|
||||
new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object),
|
||||
new TagHelperAttributeDescriptor("checked", checkedPropertyInfo.Object)
|
||||
})
|
||||
};
|
||||
|
||||
// Act & Assert
|
||||
RunTagHelperTest(testName: "BasicTagHelpers",
|
||||
baseLineName: "BasicTagHelpers.CustomAttributeCodeGenerator",
|
||||
tagHelperDescriptorProvider: tagHelperDescriptorProvider,
|
||||
tagHelperDescriptors: tagHelperDescriptors,
|
||||
hostConfig: (host) =>
|
||||
{
|
||||
return new CodeBuilderReplacingHost(host);
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Razor.Generator.Compiler;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.TagHelpers.Internal;
|
||||
using Microsoft.AspNet.Razor.TagHelpers;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test.Generator
|
||||
|
|
@ -13,43 +14,56 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
|||
{
|
||||
protected void RunTagHelperTest(string testName,
|
||||
string baseLineName = null,
|
||||
TagHelperDescriptorProvider tagHelperDescriptorProvider = null,
|
||||
Func<RazorEngineHost, RazorEngineHost> hostConfig = null)
|
||||
bool designTimeMode = false,
|
||||
IEnumerable<TagHelperDescriptor> tagHelperDescriptors = null,
|
||||
Func<RazorEngineHost, RazorEngineHost> hostConfig = null,
|
||||
IList<LineMapping> expectedDesignTimePragmas = null)
|
||||
{
|
||||
RunTest(name: testName,
|
||||
baselineName: baseLineName,
|
||||
designTimeMode: designTimeMode,
|
||||
tabTest: TabTest.NoTabs,
|
||||
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 TagHelperDescriptorProvider _tagHelperDescriptorProvider;
|
||||
private IEnumerable<TagHelperDescriptor> _tagHelperDescriptors;
|
||||
|
||||
public TagHelperTemplateEngine(RazorTemplateEngine engine, TagHelperDescriptorProvider tagHelperDescriptorProvider)
|
||||
public TagHelperTemplateEngine(RazorTemplateEngine engine,
|
||||
IEnumerable<TagHelperDescriptor> tagHelperDescriptors)
|
||||
: base(engine.Host)
|
||||
{
|
||||
_tagHelperDescriptorProvider = tagHelperDescriptorProvider;
|
||||
_tagHelperDescriptors = tagHelperDescriptors;
|
||||
}
|
||||
|
||||
protected internal override RazorParser CreateParser()
|
||||
{
|
||||
var parser = base.CreateParser();
|
||||
var tagHelperParseTreeRewriter = new TagHelperParseTreeRewriter(_tagHelperDescriptorProvider);
|
||||
|
||||
for (var i = 0; i < parser.Optimizers.Count; i++)
|
||||
{
|
||||
if (parser.Optimizers[i] is TagHelperParseTreeRewriter)
|
||||
{
|
||||
parser.Optimizers[i] = tagHelperParseTreeRewriter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return parser;
|
||||
return new RazorParser(parser.CodeParser,
|
||||
parser.MarkupParser,
|
||||
new CustomTagHelperDescriptorResolver(_tagHelperDescriptors));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,93 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
|
|||
{
|
||||
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]
|
||||
public void InheritsDirective()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System;
|
|||
using System.IO;
|
||||
using Microsoft.AspNet.Razor.Parser;
|
||||
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
||||
using Microsoft.AspNet.Razor.TagHelpers;
|
||||
using Microsoft.AspNet.Razor.Test.Framework;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -12,25 +13,15 @@ namespace Microsoft.AspNet.Razor.Test.Parser
|
|||
{
|
||||
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]
|
||||
public void ParseMethodCallsParseDocumentOnMarkupParserAndReturnsResults()
|
||||
{
|
||||
var factory = SpanFactory.CreateCsHtml();
|
||||
|
||||
// Arrange
|
||||
RazorParser parser = new RazorParser(new CSharpCodeParser(), new HtmlMarkupParser());
|
||||
RazorParser parser = new RazorParser(new CSharpCodeParser(),
|
||||
new HtmlMarkupParser(),
|
||||
tagHelperDescriptorResolver: null);
|
||||
|
||||
// Act/Assert
|
||||
ParserTestBase.EvaluateResults(parser.Parse(new StringReader("foo @bar baz")),
|
||||
|
|
@ -50,7 +41,9 @@ namespace Microsoft.AspNet.Razor.Test.Parser
|
|||
var factory = SpanFactory.CreateCsHtml();
|
||||
|
||||
// Arrange
|
||||
RazorParser parser = new RazorParser(new CSharpCodeParser(), new HtmlMarkupParser());
|
||||
RazorParser parser = new RazorParser(new CSharpCodeParser(),
|
||||
new HtmlMarkupParser(),
|
||||
tagHelperDescriptorResolver: null);
|
||||
|
||||
// Act
|
||||
ParserResults results = parser.Parse(new StringReader("foo @bar baz"));
|
||||
|
|
@ -78,7 +71,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser
|
|||
// Arrange
|
||||
ParserBase markupParser = new MockMarkupParser();
|
||||
ParserBase codeParser = new CSharpCodeParser();
|
||||
RazorParser parser = new RazorParser(codeParser, markupParser);
|
||||
RazorParser parser = new RazorParser(codeParser, markupParser, tagHelperDescriptorResolver: null);
|
||||
TextReader expectedReader = new StringReader("foo");
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
{
|
||||
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
|
||||
|
|
@ -22,8 +22,8 @@ namespace TestOutput
|
|||
#pragma warning disable 1998
|
||||
public override async Task ExecuteAsync()
|
||||
{
|
||||
Instrumentation.BeginContext(0, 47, true);
|
||||
WriteLiteral("<div class=\"randomNonTagHelperAttribute\">\r\n ");
|
||||
Instrumentation.BeginContext(27, 49, true);
|
||||
WriteLiteral("\r\n<div class=\"randomNonTagHelperAttribute\">\r\n ");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
|
||||
__PTagHelper = CreateTagHelper<PTagHelper>();
|
||||
|
|
@ -31,7 +31,7 @@ namespace TestOutput
|
|||
__tagHelperExecutionContext.AddHtmlAttribute("class", "Hello World");
|
||||
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
|
||||
Instrumentation.BeginContext(70, 10, true);
|
||||
Instrumentation.BeginContext(99, 10, true);
|
||||
WriteLiteral("\r\n ");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
|
||||
|
|
@ -41,7 +41,7 @@ namespace TestOutput
|
|||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
Instrumentation.BeginContext(87, 10, true);
|
||||
Instrumentation.BeginContext(116, 10, true);
|
||||
WriteLiteral("\r\n ");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
|
||||
|
|
@ -56,7 +56,7 @@ namespace TestOutput
|
|||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
Instrumentation.BeginContext(118, 10, true);
|
||||
Instrumentation.BeginContext(147, 10, true);
|
||||
WriteLiteral("\r\n ");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
|
||||
|
|
@ -73,12 +73,12 @@ namespace TestOutput
|
|||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
Instrumentation.BeginContext(167, 6, true);
|
||||
Instrumentation.BeginContext(196, 6, true);
|
||||
WriteLiteral("\r\n ");
|
||||
Instrumentation.EndContext();
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
Instrumentation.BeginContext(177, 8, true);
|
||||
Instrumentation.BeginContext(206, 8, true);
|
||||
WriteLiteral("\r\n</div>");
|
||||
Instrumentation.EndContext();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
|
||||
|
|
@ -23,8 +23,8 @@ namespace TestOutput
|
|||
#pragma warning disable 1998
|
||||
public override async Task ExecuteAsync()
|
||||
{
|
||||
Instrumentation.BeginContext(0, 47, true);
|
||||
WriteLiteral("<div class=\"randomNonTagHelperAttribute\">\r\n ");
|
||||
Instrumentation.BeginContext(27, 49, true);
|
||||
WriteLiteral("\r\n<div class=\"randomNonTagHelperAttribute\">\r\n ");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
|
||||
__PTagHelper = CreateTagHelper<PTagHelper>();
|
||||
|
|
@ -32,7 +32,7 @@ namespace TestOutput
|
|||
__tagHelperExecutionContext.AddHtmlAttribute("class", "Hello World");
|
||||
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
|
||||
Instrumentation.BeginContext(70, 10, true);
|
||||
Instrumentation.BeginContext(99, 10, true);
|
||||
WriteLiteral("\r\n ");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
|
||||
|
|
@ -42,7 +42,7 @@ namespace TestOutput
|
|||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
Instrumentation.BeginContext(87, 10, true);
|
||||
Instrumentation.BeginContext(116, 10, true);
|
||||
WriteLiteral("\r\n ");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
|
||||
|
|
@ -57,7 +57,7 @@ namespace TestOutput
|
|||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
Instrumentation.BeginContext(118, 10, true);
|
||||
Instrumentation.BeginContext(147, 10, true);
|
||||
WriteLiteral("\r\n ");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
|
||||
|
|
@ -74,12 +74,12 @@ namespace TestOutput
|
|||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
Instrumentation.BeginContext(167, 6, true);
|
||||
Instrumentation.BeginContext(196, 6, true);
|
||||
WriteLiteral("\r\n ");
|
||||
Instrumentation.EndContext();
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
Instrumentation.BeginContext(177, 8, true);
|
||||
Instrumentation.BeginContext(206, 8, true);
|
||||
WriteLiteral("\r\n</div>");
|
||||
Instrumentation.EndContext();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
|
||||
|
|
@ -23,7 +23,10 @@ namespace TestOutput
|
|||
#pragma warning disable 1998
|
||||
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)
|
||||
{
|
||||
var checkbox = "checkbox";
|
||||
|
|
@ -32,7 +35,7 @@ namespace TestOutput
|
|||
#line default
|
||||
#line hidden
|
||||
|
||||
Instrumentation.BeginContext(49, 55, true);
|
||||
Instrumentation.BeginContext(78, 55, true);
|
||||
WriteLiteral(" <div class=\"randomNonTagHelperAttribute\">\r\n ");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
|
||||
|
|
@ -40,7 +43,7 @@ namespace TestOutput
|
|||
__tagHelperExecutionContext.Add(__PTagHelper);
|
||||
StartWritingScope();
|
||||
WriteLiteral("Current Time: ");
|
||||
#line 6 "ComplexTagHelpers.cshtml"
|
||||
#line 8 "ComplexTagHelpers.cshtml"
|
||||
Write(DateTime.Now);
|
||||
|
||||
#line default
|
||||
|
|
@ -49,23 +52,23 @@ Write(DateTime.Now);
|
|||
__tagHelperExecutionContext.AddHtmlAttribute("time", __tagHelperStringValueBuffer.ToString());
|
||||
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
|
||||
Instrumentation.BeginContext(142, 34, true);
|
||||
Instrumentation.BeginContext(171, 34, true);
|
||||
WriteLiteral("\r\n <h1>Set Time:</h1>\r\n");
|
||||
Instrumentation.EndContext();
|
||||
#line 8 "ComplexTagHelpers.cshtml"
|
||||
#line 10 "ComplexTagHelpers.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 8 "ComplexTagHelpers.cshtml"
|
||||
#line 10 "ComplexTagHelpers.cshtml"
|
||||
if (false)
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
Instrumentation.BeginContext(216, 16, true);
|
||||
Instrumentation.BeginContext(245, 16, true);
|
||||
WriteLiteral(" ");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
|
||||
|
|
@ -73,7 +76,7 @@ Write(DateTime.Now);
|
|||
__tagHelperExecutionContext.Add(__PTagHelper);
|
||||
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
|
||||
Instrumentation.BeginContext(235, 10, true);
|
||||
Instrumentation.BeginContext(264, 10, true);
|
||||
WriteLiteral("New Time: ");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
|
||||
|
|
@ -92,10 +95,10 @@ Write(DateTime.Now);
|
|||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
Instrumentation.BeginContext(315, 2, true);
|
||||
Instrumentation.BeginContext(344, 2, true);
|
||||
WriteLiteral("\r\n");
|
||||
Instrumentation.EndContext();
|
||||
#line 11 "ComplexTagHelpers.cshtml"
|
||||
#line 13 "ComplexTagHelpers.cshtml"
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -103,7 +106,7 @@ Write(DateTime.Now);
|
|||
#line default
|
||||
#line hidden
|
||||
|
||||
Instrumentation.BeginContext(365, 16, true);
|
||||
Instrumentation.BeginContext(394, 16, true);
|
||||
WriteLiteral(" ");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
|
||||
|
|
@ -111,14 +114,14 @@ Write(DateTime.Now);
|
|||
__tagHelperExecutionContext.Add(__PTagHelper);
|
||||
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
|
||||
Instrumentation.BeginContext(384, 14, true);
|
||||
Instrumentation.BeginContext(413, 14, true);
|
||||
WriteLiteral("Current Time: ");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
|
||||
__InputTagHelper = CreateTagHelper<InputTagHelper>();
|
||||
__tagHelperExecutionContext.Add(__InputTagHelper);
|
||||
StartWritingScope();
|
||||
#line 14 "ComplexTagHelpers.cshtml"
|
||||
#line 16 "ComplexTagHelpers.cshtml"
|
||||
Write(checkbox);
|
||||
|
||||
#line default
|
||||
|
|
@ -137,14 +140,14 @@ Write(checkbox);
|
|||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
Instrumentation.BeginContext(439, 18, true);
|
||||
Instrumentation.BeginContext(468, 18, true);
|
||||
WriteLiteral("\r\n ");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
|
||||
__InputTagHelper = CreateTagHelper<InputTagHelper>();
|
||||
__tagHelperExecutionContext.Add(__InputTagHelper);
|
||||
StartWritingScope();
|
||||
#line 15 "ComplexTagHelpers.cshtml"
|
||||
#line 17 "ComplexTagHelpers.cshtml"
|
||||
Write(true ? "checkbox" : "anything");
|
||||
|
||||
#line default
|
||||
|
|
@ -159,28 +162,28 @@ Write(true ? "checkbox" : "anything");
|
|||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
Instrumentation.BeginContext(507, 18, true);
|
||||
Instrumentation.BeginContext(536, 18, true);
|
||||
WriteLiteral("\r\n ");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input");
|
||||
__InputTagHelper = CreateTagHelper<InputTagHelper>();
|
||||
__tagHelperExecutionContext.Add(__InputTagHelper);
|
||||
StartWritingScope();
|
||||
#line 16 "ComplexTagHelpers.cshtml"
|
||||
#line 18 "ComplexTagHelpers.cshtml"
|
||||
if(true) {
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteral(" checkbox ");
|
||||
#line 16 "ComplexTagHelpers.cshtml"
|
||||
#line 18 "ComplexTagHelpers.cshtml"
|
||||
} else {
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteral(" anything ");
|
||||
#line 16 "ComplexTagHelpers.cshtml"
|
||||
#line 18 "ComplexTagHelpers.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
|
|
@ -196,24 +199,24 @@ if(true) {
|
|||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
Instrumentation.BeginContext(608, 2, true);
|
||||
Instrumentation.BeginContext(637, 2, true);
|
||||
WriteLiteral("\r\n");
|
||||
Instrumentation.EndContext();
|
||||
#line 17 "ComplexTagHelpers.cshtml"
|
||||
#line 19 "ComplexTagHelpers.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
Instrumentation.BeginContext(625, 8, true);
|
||||
Instrumentation.BeginContext(654, 8, true);
|
||||
WriteLiteral(" ");
|
||||
Instrumentation.EndContext();
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
Instrumentation.BeginContext(637, 14, true);
|
||||
Instrumentation.BeginContext(666, 14, true);
|
||||
WriteLiteral("\r\n </div>\r\n");
|
||||
Instrumentation.EndContext();
|
||||
#line 20 "ComplexTagHelpers.cshtml"
|
||||
#line 22 "ComplexTagHelpers.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
|
||||
|
|
@ -25,6 +25,9 @@ namespace TestOutput
|
|||
#pragma warning disable 1998
|
||||
public override async Task ExecuteAsync()
|
||||
{
|
||||
Instrumentation.BeginContext(27, 2, true);
|
||||
WriteLiteral("\r\n");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("modify");
|
||||
__ModifyTagHelper = CreateTagHelper<ModifyTagHelper>();
|
||||
__tagHelperExecutionContext.Add(__ModifyTagHelper);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
|
||||
|
|
@ -21,6 +21,9 @@ namespace TestOutput
|
|||
#pragma warning disable 1998
|
||||
public override async Task ExecuteAsync()
|
||||
{
|
||||
Instrumentation.BeginContext(27, 2, true);
|
||||
WriteLiteral("\r\n");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p");
|
||||
__PTagHelper = CreateTagHelper<PTagHelper>();
|
||||
__tagHelperExecutionContext.Add(__PTagHelper);
|
||||
|
|
@ -29,7 +32,7 @@ namespace TestOutput
|
|||
__tagHelperExecutionContext.AddHtmlAttribute("class", "Hello World");
|
||||
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
|
||||
Instrumentation.BeginContext(34, 11, true);
|
||||
Instrumentation.BeginContext(63, 11, true);
|
||||
WriteLiteral("Body of Tag");
|
||||
Instrumentation.EndContext();
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
|
||||
|
|
@ -8,20 +8,20 @@ namespace TestOutput
|
|||
public class TagHelpersInHelper
|
||||
{
|
||||
public static Template
|
||||
#line 1 "TagHelpersInHelper.cshtml"
|
||||
#line 3 "TagHelpersInHelper.cshtml"
|
||||
MyHelper(string val)
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return new Template((__razor_helper_writer) => {
|
||||
#line 2 "TagHelpersInHelper.cshtml"
|
||||
#line 4 "TagHelpersInHelper.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
Instrumentation.BeginContext(33, 19, true);
|
||||
Instrumentation.BeginContext(62, 19, true);
|
||||
WriteLiteralTo(__razor_helper_writer, " <div>\r\n ");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper");
|
||||
|
|
@ -29,7 +29,7 @@ MyHelper(string val)
|
|||
__tagHelperExecutionContext.Add(__MyTagHelper);
|
||||
StartWritingScope();
|
||||
WriteLiteral("Current Time: ");
|
||||
#line 4 "TagHelpersInHelper.cshtml"
|
||||
#line 6 "TagHelpersInHelper.cshtml"
|
||||
Write(DateTime.Now);
|
||||
|
||||
#line default
|
||||
|
|
@ -39,7 +39,7 @@ Write(DateTime.Now);
|
|||
__tagHelperExecutionContext.AddTagHelperAttribute("BoundProperty", __MyTagHelper.BoundProperty);
|
||||
StartWritingScope();
|
||||
WriteLiteral("Current Time: ");
|
||||
#line 4 "TagHelpersInHelper.cshtml"
|
||||
#line 6 "TagHelpersInHelper.cshtml"
|
||||
Write(DateTime.Now);
|
||||
|
||||
#line default
|
||||
|
|
@ -48,7 +48,7 @@ Write(DateTime.Now);
|
|||
__tagHelperExecutionContext.AddHtmlAttribute("unboundproperty", __tagHelperStringValueBuffer.ToString());
|
||||
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
|
||||
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 ");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper");
|
||||
|
|
@ -56,7 +56,7 @@ Write(DateTime.Now);
|
|||
__tagHelperExecutionContext.Add(__NestedTagHelper);
|
||||
StartWritingScope();
|
||||
WriteLiteral("Some buffered values with a value of ");
|
||||
#line 6 "TagHelpersInHelper.cshtml"
|
||||
#line 8 "TagHelpersInHelper.cshtml"
|
||||
Write(val);
|
||||
|
||||
#line default
|
||||
|
|
@ -67,22 +67,22 @@ Write(DateTime.Now);
|
|||
WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.Output.GenerateContent());
|
||||
WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.Output.GenerateEndTag());
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
Instrumentation.BeginContext(283, 10, true);
|
||||
Instrumentation.BeginContext(312, 10, true);
|
||||
WriteLiteralTo(__razor_helper_writer, "\r\n ");
|
||||
Instrumentation.EndContext();
|
||||
WriteLiteralTo(__razor_helper_writer, __tagHelperExecutionContext.Output.GenerateEndTag());
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
Instrumentation.BeginContext(307, 14, true);
|
||||
Instrumentation.BeginContext(336, 14, true);
|
||||
WriteLiteralTo(__razor_helper_writer, "\r\n </div>\r\n");
|
||||
Instrumentation.EndContext();
|
||||
#line 9 "TagHelpersInHelper.cshtml"
|
||||
#line 11 "TagHelpersInHelper.cshtml"
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
}
|
||||
);
|
||||
#line 9 "TagHelpersInHelper.cshtml"
|
||||
#line 11 "TagHelpersInHelper.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
|
|
@ -103,13 +103,16 @@ Write(DateTime.Now);
|
|||
#pragma warning disable 1998
|
||||
public override async Task ExecuteAsync()
|
||||
{
|
||||
Instrumentation.BeginContext(27, 2, true);
|
||||
WriteLiteral("\r\n");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper");
|
||||
__MyTagHelper = CreateTagHelper<MyTagHelper>();
|
||||
__tagHelperExecutionContext.Add(__MyTagHelper);
|
||||
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateStartTag());
|
||||
Instrumentation.BeginContext(338, 9, false);
|
||||
#line 10 "TagHelpersInHelper.cshtml"
|
||||
Instrumentation.BeginContext(367, 9, false);
|
||||
#line 12 "TagHelpersInHelper.cshtml"
|
||||
Write(MyHelper(item => new Template((__razor_template_writer) => {
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper");
|
||||
__NestedTagHelper = CreateTagHelper<NestedTagHelper>();
|
||||
|
|
@ -131,7 +134,7 @@ Write(MyHelper(item => new Template((__razor_template_writer) => {
|
|||
Instrumentation.EndContext();
|
||||
WriteLiteral(__tagHelperExecutionContext.Output.GenerateEndTag());
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
Instrumentation.BeginContext(410, 2, true);
|
||||
Instrumentation.BeginContext(439, 2, true);
|
||||
WriteLiteral("\r\n");
|
||||
Instrumentation.EndContext();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
using System;
|
||||
|
|
@ -21,18 +21,21 @@ namespace TestOutput
|
|||
#pragma warning disable 1998
|
||||
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";
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
Instrumentation.BeginContext(34, 4, true);
|
||||
Instrumentation.BeginContext(63, 4, true);
|
||||
WriteLiteral("\r\n\r\n");
|
||||
Instrumentation.EndContext();
|
||||
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 ");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper");
|
||||
|
|
@ -40,7 +43,7 @@ namespace TestOutput
|
|||
__tagHelperExecutionContext.Add(__MyTagHelper);
|
||||
StartWritingScope();
|
||||
WriteLiteral("Current Time: ");
|
||||
#line 7 "TagHelpersInSection.cshtml"
|
||||
#line 9 "TagHelpersInSection.cshtml"
|
||||
Write(DateTime.Now);
|
||||
|
||||
#line default
|
||||
|
|
@ -50,7 +53,7 @@ Write(DateTime.Now);
|
|||
__tagHelperExecutionContext.AddTagHelperAttribute("BoundProperty", __MyTagHelper.BoundProperty);
|
||||
StartWritingScope();
|
||||
WriteLiteral("Current Time: ");
|
||||
#line 7 "TagHelpersInSection.cshtml"
|
||||
#line 9 "TagHelpersInSection.cshtml"
|
||||
Write(DateTime.Now);
|
||||
|
||||
#line default
|
||||
|
|
@ -59,7 +62,7 @@ Write(DateTime.Now);
|
|||
__tagHelperExecutionContext.AddHtmlAttribute("unboundproperty", __tagHelperStringValueBuffer.ToString());
|
||||
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
|
||||
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 ");
|
||||
Instrumentation.EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper");
|
||||
|
|
@ -67,7 +70,7 @@ Write(DateTime.Now);
|
|||
__tagHelperExecutionContext.Add(__NestedTagHelper);
|
||||
StartWritingScope();
|
||||
WriteLiteral("Some buffered values with ");
|
||||
#line 9 "TagHelpersInSection.cshtml"
|
||||
#line 11 "TagHelpersInSection.cshtml"
|
||||
Write(code);
|
||||
|
||||
#line default
|
||||
|
|
@ -78,12 +81,12 @@ Write(DateTime.Now);
|
|||
WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateContent());
|
||||
WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateEndTag());
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
Instrumentation.BeginContext(300, 10, true);
|
||||
Instrumentation.BeginContext(329, 10, true);
|
||||
WriteLiteralTo(__razor_template_writer, "\r\n ");
|
||||
Instrumentation.EndContext();
|
||||
WriteLiteralTo(__razor_template_writer, __tagHelperExecutionContext.Output.GenerateEndTag());
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
Instrumentation.BeginContext(324, 14, true);
|
||||
Instrumentation.BeginContext(353, 14, true);
|
||||
WriteLiteralTo(__razor_template_writer, "\r\n </div>\r\n");
|
||||
Instrumentation.EndContext();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
@addtaghelper "something"
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
<div class="randomNonTagHelperAttribute">
|
||||
@addtaghelper "something"
|
||||
|
||||
<div class="randomNonTagHelperAttribute">
|
||||
<p class="Hello World">
|
||||
<p></p>
|
||||
<input type="text" />
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
@if (true)
|
||||
@addtaghelper "something"
|
||||
|
||||
@if (true)
|
||||
{
|
||||
var checkbox = "checkbox";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<modify>
|
||||
@addtaghelper "something"
|
||||
|
||||
<modify>
|
||||
<none>
|
||||
<append>
|
||||
<prepend>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
@helper MyHelper(string val)
|
||||
@addtaghelper "something"
|
||||
|
||||
@helper MyHelper(string val)
|
||||
{
|
||||
<div>
|
||||
<mytaghelper boundproperty="Current Time: @DateTime.Now" unboundproperty="Current Time: @DateTime.Now">
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
@{
|
||||
@addtaghelper "something"
|
||||
|
||||
@{
|
||||
var code = "some code";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue