Removed @helper directive

This commit is contained in:
Ajay Bhargav Baaskaran 2015-03-16 17:50:00 -07:00
parent 7daec14e49
commit b3c60976a4
37 changed files with 75 additions and 1835 deletions

View File

@ -52,7 +52,6 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
var csharpCodeVisitor = CreateCSharpCodeVisitor(writer, Context);
new CSharpHelperVisitor(csharpCodeVisitor, writer, Context).Accept(Tree.Chunks);
new CSharpTypeMemberVisitor(csharpCodeVisitor, writer, Context).Accept(Tree.Chunks);
new CSharpDesignTimeHelpersVisitor(csharpCodeVisitor, writer, Context).AcceptTree(Tree);
new CSharpTagHelperFieldDeclarationVisitor(writer, Context).Accept(Tree.Chunks);

View File

@ -1,72 +0,0 @@
// 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;
namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
{
public class CSharpHelperVisitor : CodeVisitor<CSharpCodeWriter>
{
private const string HelperWriterName = "__razor_helper_writer";
private CSharpCodeVisitor _csharpCodeVisitor;
public CSharpHelperVisitor([NotNull] CSharpCodeVisitor csharpCodeVisitor,
[NotNull] CSharpCodeWriter writer,
[NotNull] CodeBuilderContext context)
: base(writer, context)
{
_csharpCodeVisitor = csharpCodeVisitor;
}
protected override void Visit(HelperChunk chunk)
{
IDisposable lambdaScope = null;
var accessibility = "public " + (Context.Host.StaticHelpers ? "static" : String.Empty);
// We want to write the method signature at 0 indentation so if helper's are formatted they format correctly.
var currentIndentation = Writer.CurrentIndent;
Writer.ResetIndent();
Writer.Write(accessibility).Write(" ").Write(Context.Host.GeneratedClassContext.TemplateTypeName).Write(" ");
Writer.SetIndent(currentIndentation);
using (Writer.BuildLineMapping(chunk.Signature.Location, chunk.Signature.Value.Length, Context.SourceFile))
{
Writer.Write(chunk.Signature);
}
if (chunk.HeaderComplete)
{
Writer.WriteStartReturn()
.WriteStartNewObject(Context.Host.GeneratedClassContext.TemplateTypeName);
lambdaScope = Writer.BuildLambda(endLine: false, parameterNames: HelperWriterName);
}
var currentTargetWriterName = Context.TargetWriterName;
Context.TargetWriterName = HelperWriterName;
// Generate children code
_csharpCodeVisitor.Accept(chunk.Children);
Context.TargetWriterName = currentTargetWriterName;
if (chunk.HeaderComplete)
{
lambdaScope.Dispose();
Writer.WriteEndMethodInvocation();
}
if (chunk.Footer != null && !String.IsNullOrEmpty(chunk.Footer.Value))
{
using (Writer.BuildLineMapping(chunk.Footer.Location, chunk.Footer.Value.Length, Context.SourceFile))
{
Writer.Write(chunk.Footer);
}
}
Writer.WriteLine();
}
}
}

View File

@ -85,10 +85,6 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler
{
Visit((UsingChunk)chunk);
}
else if (chunk is HelperChunk)
{
Visit((HelperChunk)chunk);
}
else if (chunk is SetBaseTypeChunk)
{
Visit((SetBaseTypeChunk)chunk);
@ -131,7 +127,6 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler
protected abstract void Visit(DynamicCodeAttributeChunk chunk);
protected abstract void Visit(LiteralCodeAttributeChunk chunk);
protected abstract void Visit(CodeAttributeChunk chunk);
protected abstract void Visit(HelperChunk chunk);
protected abstract void Visit(SectionChunk chunk);
protected abstract void Visit(TypeMemberChunk chunk);
protected abstract void Visit(ResolveUrlChunk chunk);

View File

@ -48,9 +48,6 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler
protected override void Visit(CodeAttributeChunk chunk)
{
}
protected override void Visit(HelperChunk chunk)
{
}
protected override void Visit(SectionChunk chunk)
{
}

View File

@ -1,14 +0,0 @@
// 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 Microsoft.AspNet.Razor.Text;
namespace Microsoft.AspNet.Razor.Generator.Compiler
{
public class HelperChunk : ChunkBlock
{
public LocationTagged<string> Signature { get; set; }
public LocationTagged<string> Footer { get; set; }
public bool HeaderComplete { get; set; }
}
}

View File

@ -1,60 +0,0 @@
// 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.Globalization;
using Microsoft.AspNet.Razor.Generator.Compiler;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Text;
using Microsoft.Internal.Web.Utils;
namespace Microsoft.AspNet.Razor.Generator
{
public class HelperCodeGenerator : BlockCodeGenerator
{
public HelperCodeGenerator(LocationTagged<string> signature, bool headerComplete)
{
Signature = signature;
HeaderComplete = headerComplete;
}
public LocationTagged<string> Signature { get; private set; }
public LocationTagged<string> Footer { get; set; }
public bool HeaderComplete { get; private set; }
public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context)
{
var chunk = context.CodeTreeBuilder.StartChunkBlock<HelperChunk>(target, topLevel: true);
chunk.Signature = Signature;
chunk.Footer = Footer;
chunk.HeaderComplete = HeaderComplete;
}
public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context)
{
context.CodeTreeBuilder.EndChunkBlock();
}
public override bool Equals(object obj)
{
var other = obj as HelperCodeGenerator;
return other != null &&
base.Equals(other) &&
HeaderComplete == other.HeaderComplete &&
Equals(Signature, other.Signature);
}
public override int GetHashCode()
{
return HashCodeCombiner.Start()
.Add(base.GetHashCode())
.Add(Signature)
.CombinedHash;
}
public override string ToString()
{
return "Helper:" + Signature.ToString("F", CultureInfo.CurrentCulture) + ";" + (HeaderComplete ? "C" : "I");
}
}
}

View File

@ -24,7 +24,6 @@ namespace Microsoft.AspNet.Razor.Parser
MapDirectives(InheritsDirective, SyntaxConstants.CSharp.InheritsKeyword);
MapDirectives(FunctionsDirective, SyntaxConstants.CSharp.FunctionsKeyword);
MapDirectives(SectionDirective, SyntaxConstants.CSharp.SectionKeyword);
MapDirectives(HelperDirective, SyntaxConstants.CSharp.HelperKeyword);
MapDirectives(LayoutDirective, SyntaxConstants.CSharp.LayoutKeyword);
}
@ -71,178 +70,6 @@ namespace Microsoft.AspNet.Razor.Parser
Output(SpanKind.MetaCode, foundNewline ? AcceptedCharacters.None : AcceptedCharacters.Any);
}
[SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "Coupling will be reviewed at a later date")]
[SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "C# Keywords are always lower-case")]
protected virtual void HelperDirective()
{
var nested = Context.IsWithin(BlockType.Helper);
// Set the block and span type
Context.CurrentBlock.Type = BlockType.Helper;
// Verify we're on "helper" and accept
AssertDirective(SyntaxConstants.CSharp.HelperKeyword);
var block = new Block(CurrentSymbol.Content.ToString().ToLowerInvariant(), CurrentLocation);
AcceptAndMoveNext();
if (nested)
{
Context.OnError(CurrentLocation, RazorResources.ParseError_Helpers_Cannot_Be_Nested);
}
// Accept a single whitespace character if present, if not, we should stop now
if (!At(CSharpSymbolType.WhiteSpace))
{
string error;
if (At(CSharpSymbolType.NewLine))
{
error = RazorResources.ErrorComponent_Newline;
}
else if (EndOfFile)
{
error = RazorResources.ErrorComponent_EndOfFile;
}
else
{
error = RazorResources.FormatErrorComponent_Character(CurrentSymbol.Content);
}
Context.OnError(
CurrentLocation,
RazorResources.FormatParseError_Unexpected_Character_At_Helper_Name_Start(error));
PutCurrentBack();
Output(SpanKind.MetaCode);
return;
}
var remainingWs = AcceptSingleWhiteSpaceCharacter();
// Output metacode and continue
Output(SpanKind.MetaCode);
if (remainingWs != null)
{
Accept(remainingWs);
}
AcceptWhile(IsSpacingToken(includeNewLines: false, includeComments: true)); // Don't accept newlines.
// Expecting an identifier (helper name)
var errorReported = !Required(CSharpSymbolType.Identifier, errorIfNotFound: true, errorBase: RazorResources.FormatParseError_Unexpected_Character_At_Helper_Name_Start);
if (!errorReported)
{
Assert(CSharpSymbolType.Identifier);
AcceptAndMoveNext();
}
AcceptWhile(IsSpacingToken(includeNewLines: false, includeComments: true));
// Expecting parameter list start: "("
var bracketErrorPos = CurrentLocation;
if (!Optional(CSharpSymbolType.LeftParenthesis))
{
if (!errorReported)
{
errorReported = true;
Context.OnError(
CurrentLocation,
RazorResources.FormatParseError_MissingCharAfterHelperName("("));
}
}
else
{
var bracketStart = CurrentLocation;
if (!Balance(BalancingModes.NoErrorOnFailure,
CSharpSymbolType.LeftParenthesis,
CSharpSymbolType.RightParenthesis,
bracketStart))
{
errorReported = true;
Context.OnError(
bracketErrorPos,
RazorResources.ParseError_UnterminatedHelperParameterList);
}
Optional(CSharpSymbolType.RightParenthesis);
}
var bookmark = CurrentLocation.AbsoluteIndex;
IEnumerable<CSharpSymbol> ws = ReadWhile(IsSpacingToken(includeNewLines: true, includeComments: true));
// Expecting a "{"
var errorLocation = CurrentLocation;
var headerComplete = At(CSharpSymbolType.LeftBrace);
if (headerComplete)
{
Accept(ws);
AcceptAndMoveNext();
}
else
{
Context.Source.Position = bookmark;
NextToken();
AcceptWhile(IsSpacingToken(includeNewLines: false, includeComments: true));
if (!errorReported)
{
Context.OnError(
errorLocation,
RazorResources.FormatParseError_MissingCharAfterHelperParameters(
Language.GetSample(CSharpSymbolType.LeftBrace)));
}
}
// Grab the signature and build the code generator
AddMarkerSymbolIfNecessary();
LocationTagged<string> signature = Span.GetContent();
var blockGen = new HelperCodeGenerator(signature, headerComplete);
Context.CurrentBlock.CodeGenerator = blockGen;
// The block will generate appropriate code,
Span.CodeGenerator = SpanCodeGenerator.Null;
if (!headerComplete)
{
CompleteBlock();
Output(SpanKind.Code);
return;
}
else
{
Span.EditHandler.AcceptedCharacters = AcceptedCharacters.None;
Output(SpanKind.Code);
}
// We're valid, so parse the nested block
var bodyEditHandler = new AutoCompleteEditHandler(Language.TokenizeString);
using (PushSpanConfig(DefaultSpanConfig))
{
using (Context.StartBlock(BlockType.Statement))
{
Span.EditHandler = bodyEditHandler;
CodeBlock(false, block);
CompleteBlock(insertMarkerIfNecessary: true);
Output(SpanKind.Code);
}
}
Initialize(Span);
EnsureCurrent();
Span.CodeGenerator = SpanCodeGenerator.Null; // The block will generate the footer code.
if (!Optional(CSharpSymbolType.RightBrace))
{
// The } is missing, so set the initial signature span to use it as an autocomplete string
bodyEditHandler.AutoCompleteString = "}";
// Need to be able to accept anything to properly handle the autocomplete
bodyEditHandler.AcceptedCharacters = AcceptedCharacters.Any;
}
else
{
blockGen.Footer = Span.GetContent();
Span.EditHandler.AcceptedCharacters = AcceptedCharacters.None;
}
CompleteBlock();
Output(SpanKind.Code);
}
protected virtual void SectionDirective()
{
var nested = Context.IsWithin(BlockType.Section);

View File

@ -33,7 +33,6 @@ namespace Microsoft.AspNet.Razor.Parser
"using",
"section",
"inherits",
"helper",
"functions",
"namespace",
"class",

View File

@ -24,7 +24,6 @@ namespace Microsoft.AspNet.Razor.Parser
public static readonly string InheritsKeyword = "inherits";
public static readonly string FunctionsKeyword = "functions";
public static readonly string SectionKeyword = "section";
public static readonly string HelperKeyword = "helper";
public static readonly string ElseIfKeyword = "else if";
public static readonly string NamespaceKeyword = "namespace";
public static readonly string ClassKeyword = "class";

View File

@ -566,70 +566,6 @@ namespace Microsoft.AspNet.Razor
return string.Format(CultureInfo.CurrentCulture, GetString("Structure_Member_CannotBeNull"), p0, p1);
}
/// <summary>
/// Expected a "{0}" after the helper parameters.
/// </summary>
internal static string ParseError_MissingCharAfterHelperParameters
{
get { return GetString("ParseError_MissingCharAfterHelperParameters"); }
}
/// <summary>
/// Expected a "{0}" after the helper parameters.
/// </summary>
internal static string FormatParseError_MissingCharAfterHelperParameters(object p0)
{
return string.Format(CultureInfo.CurrentCulture, GetString("ParseError_MissingCharAfterHelperParameters"), p0);
}
/// <summary>
/// Expected a "{0}" after the helper name.
/// </summary>
internal static string ParseError_MissingCharAfterHelperName
{
get { return GetString("ParseError_MissingCharAfterHelperName"); }
}
/// <summary>
/// Expected a "{0}" after the helper name.
/// </summary>
internal static string FormatParseError_MissingCharAfterHelperName(object p0)
{
return string.Format(CultureInfo.CurrentCulture, GetString("ParseError_MissingCharAfterHelperName"), p0);
}
/// <summary>
/// Helper parameter list is missing a closing ")".
/// </summary>
internal static string ParseError_UnterminatedHelperParameterList
{
get { return GetString("ParseError_UnterminatedHelperParameterList"); }
}
/// <summary>
/// Helper parameter list is missing a closing ")".
/// </summary>
internal static string FormatParseError_UnterminatedHelperParameterList()
{
return GetString("ParseError_UnterminatedHelperParameterList");
}
/// <summary>
/// Helper blocks cannot be nested within each other.
/// </summary>
internal static string ParseError_Helpers_Cannot_Be_Nested
{
get { return GetString("ParseError_Helpers_Cannot_Be_Nested"); }
}
/// <summary>
/// Helper blocks cannot be nested within each other.
/// </summary>
internal static string FormatParseError_Helpers_Cannot_Be_Nested()
{
return GetString("ParseError_Helpers_Cannot_Be_Nested");
}
/// <summary>
/// Parser was started with a null Context property. The Context property must be set BEFORE calling any methods on the parser.
/// </summary>
@ -662,22 +598,6 @@ namespace Microsoft.AspNet.Razor
return string.Format(CultureInfo.CurrentCulture, GetString("ParseError_ReservedWord"), p0);
}
/// <summary>
/// Unexpected {0} after helper keyword. All helpers must have a name which starts with an "_" or alphabetic character. The remaining characters must be either "_" or alphanumeric.
/// </summary>
internal static string ParseError_Unexpected_Character_At_Helper_Name_Start
{
get { return GetString("ParseError_Unexpected_Character_At_Helper_Name_Start"); }
}
/// <summary>
/// Unexpected {0} after helper keyword. All helpers must have a name which starts with an "_" or alphabetic character. The remaining characters must be either "_" or alphanumeric.
/// </summary>
internal static string FormatParseError_Unexpected_Character_At_Helper_Name_Start(object p0)
{
return string.Format(CultureInfo.CurrentCulture, GetString("ParseError_Unexpected_Character_At_Helper_Name_Start"), p0);
}
/// <summary>
/// Cannot resume this symbol. Only the symbol immediately preceding the current one can be resumed.
/// </summary>

View File

@ -240,27 +240,12 @@ Instead, wrap the contents of the block in "{{}}":
<data name="Structure_Member_CannotBeNull" xml:space="preserve">
<value>The {0} property of the {1} structure cannot be null.</value>
</data>
<data name="ParseError_MissingCharAfterHelperParameters" xml:space="preserve">
<value>Expected a "{0}" after the helper parameters.</value>
</data>
<data name="ParseError_MissingCharAfterHelperName" xml:space="preserve">
<value>Expected a "{0}" after the helper name.</value>
</data>
<data name="ParseError_UnterminatedHelperParameterList" xml:space="preserve">
<value>Helper parameter list is missing a closing ")".</value>
</data>
<data name="ParseError_Helpers_Cannot_Be_Nested" xml:space="preserve">
<value>Helper blocks cannot be nested within each other.</value>
</data>
<data name="Parser_Context_Not_Set" xml:space="preserve">
<value>Parser was started with a null Context property. The Context property must be set BEFORE calling any methods on the parser.</value>
</data>
<data name="ParseError_ReservedWord" xml:space="preserve">
<value>"{0}" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used.</value>
</data>
<data name="ParseError_Unexpected_Character_At_Helper_Name_Start" xml:space="preserve">
<value>Unexpected {0} after helper keyword. All helpers must have a name which starts with an "_" or alphabetic character. The remaining characters must be either "_" or alphanumeric.</value>
</data>
<data name="Tokenizer_CannotResumeSymbolUnlessIsPrevious" xml:space="preserve">
<value>Cannot resume this symbol. Only the symbol immediately preceding the current one can be resumed.</value>
</data>

View File

@ -110,31 +110,6 @@ namespace Microsoft.AspNet.Razor.Test.Framework
}
}
public class HelperBlock : Block
{
private const BlockType ThisBlockType = BlockType.Helper;
public HelperBlock(IBlockCodeGenerator codeGenerator, IEnumerable<SyntaxTreeNode> children)
: base(ThisBlockType, children, codeGenerator)
{
}
public HelperBlock(IBlockCodeGenerator codeGenerator, params SyntaxTreeNode[] children)
: this(codeGenerator, (IEnumerable<SyntaxTreeNode>)children)
{
}
public HelperBlock(params SyntaxTreeNode[] children)
: this(BlockCodeGenerator.Null, children)
{
}
public HelperBlock(IEnumerable<SyntaxTreeNode> children)
: this(BlockCodeGenerator.Null, children)
{
}
}
public class MarkupTagBlock : Block
{
private const BlockType ThisBlockType = BlockType.Tag;

View File

@ -75,11 +75,6 @@ namespace Microsoft.AspNet.Razor.Test.Generator
[InlineData("Templates")]
[InlineData("Sections")]
[InlineData("RazorComments")]
[InlineData("Helpers")]
[InlineData("HelpersMissingCloseParen")]
[InlineData("HelpersMissingOpenBrace")]
[InlineData("HelpersMissingOpenParen")]
[InlineData("NestedHelpers")]
[InlineData("InlineBlocks")]
[InlineData("LayoutDirective")]
[InlineData("ConditionalAttributes")]
@ -284,17 +279,13 @@ namespace Microsoft.AspNet.Razor.Test.Generator
tabTest: TabTest.NoTabs,
expectedDesignTimePragmas: new List<LineMapping>()
{
BuildLineMapping(222, 16, 8, 209, 10, 0, 7),
BuildLineMapping(229, 16, 352, 16, 15, 26),
BuildLineMapping(265, 18, 461, 24, 18, 9),
BuildLineMapping(274, 20, 556, 33, 0, 1),
BuildLineMapping(20, 1, 13, 964, 52, 12, 36),
BuildLineMapping(74, 2, 1086, 59, 22, 1),
BuildLineMapping(79, 2, 1177, 64, 27, 15),
BuildLineMapping(113, 7, 2, 1262, 71, 6, 12),
BuildLineMapping(129, 8, 1, 1343, 76, 6, 4),
BuildLineMapping(142, 8, 1443, 78, 14, 3),
BuildLineMapping(204, 13, 5, 1630, 90, 6, 3)
BuildLineMapping(20, 1, 13, 526, 22, 12, 36),
BuildLineMapping(74, 2, 22, 648, 29, 22, 1),
BuildLineMapping(79, 2, 27, 739, 34, 27, 15),
BuildLineMapping(113, 7, 2, 824, 41, 6, 12),
BuildLineMapping(129, 8, 1, 905, 46, 6, 4),
BuildLineMapping(142, 8, 1005, 48, 14, 3),
BuildLineMapping(204, 13, 5, 1192, 60, 6, 3)
});
}
@ -384,19 +375,6 @@ namespace Microsoft.AspNet.Razor.Test.Generator
RunTest("NoLinePragmas", generatePragmas: false);
}
[Fact]
public void CSharpCodeGeneratorRendersHelpersBlockCorrectlyWhenInstanceHelperRequested()
{
RunTest("Helpers",
baselineName: "Helpers.Instance",
hostConfig: host =>
{
host.StaticHelpers = false;
return host;
});
}
[Fact]
public void CSharpCodeGeneratorCorrectlyInstrumentsRazorCodeWhenInstrumentationRequested()
{

View File

@ -386,10 +386,8 @@ namespace Microsoft.AspNet.Razor.Test.Generator
});
}
[Theory]
[InlineData("TagHelpersInSection")]
[InlineData("TagHelpersInHelper")]
public void TagHelpers_WithinHelpersAndSections_GeneratesExpectedOutput(string testType)
[Fact]
public void TagHelpers_WithinHelpersAndSections_GeneratesExpectedOutput()
{
// Arrange
var propertyInfo = typeof(TestType).GetProperty("BoundProperty");
@ -406,7 +404,7 @@ namespace Microsoft.AspNet.Razor.Test.Generator
};
// Act & Assert
RunTagHelperTest(testType, tagHelperDescriptors: tagHelperDescriptors);
RunTagHelperTest("TagHelpersInSection", tagHelperDescriptors: tagHelperDescriptors);
}
private static IEnumerable<TagHelperDescriptor> BuildPAndInputTagHelperDescriptors(string prefix)

View File

@ -33,27 +33,6 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
1, 0, 1));
}
[Fact]
public void HelperDirectiveAutoCompleteAtEOF()
{
ParseBlockTest("@helper Strong(string value) {",
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Strong(string value) {", 8, 0, 8), headerComplete: true),
Factory.CodeTransition(),
Factory.MetaCode("helper ")
.Accepts(AcceptedCharacters.None),
Factory.Code("Strong(string value) {")
.Hidden()
.Accepts(AcceptedCharacters.None),
new StatementBlock(
Factory.EmptyCSharp()
.AsStatement()
.With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" })
)
),
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("helper", "}", "{"),
1, 0, 1));
}
[Fact]
public void SectionDirectiveAutoCompleteAtEOF()
{
@ -104,35 +83,6 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
1, 0, 1));
}
[Fact]
public void HelperDirectiveAutoCompleteAtStartOfFile()
{
ParseBlockTest("@helper Strong(string value) {" + Environment.NewLine
+ "<p></p>",
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Strong(string value) {", 8, 0, 8), headerComplete: true),
Factory.CodeTransition(),
Factory.MetaCode("helper ")
.Accepts(AcceptedCharacters.None),
Factory.Code("Strong(string value) {")
.Hidden()
.Accepts(AcceptedCharacters.None),
new StatementBlock(
Factory.Code("\r\n")
.AsStatement()
.With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" }),
new MarkupBlock(
new MarkupTagBlock(
Factory.Markup("<p>").Accepts(AcceptedCharacters.None)),
new MarkupTagBlock(
Factory.Markup("</p>").Accepts(AcceptedCharacters.None))),
Factory.Span(SpanKind.Code, new CSharpSymbol(Factory.LocationTracker.CurrentLocation, String.Empty, CSharpSymbolType.Unknown))
.With(new StatementCodeGenerator())
)
),
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("helper", "}", "{"),
1, 0, 1));
}
[Fact]
public void SectionDirectiveAutoCompleteAtStartOfFile()
{

View File

@ -389,25 +389,5 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.MetaCode("}")
.Accepts(AcceptedCharacters.None)));
}
[Fact]
public void HelperDirective()
{
ParseBlockTest("@helper Strong(string value) { foo(); }",
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Strong(string value) {", new SourceLocation(8, 0, 8)), headerComplete: true),
Factory.CodeTransition(),
Factory.MetaCode("helper ")
.Accepts(AcceptedCharacters.None),
Factory.Code("Strong(string value) {")
.Hidden()
.Accepts(AcceptedCharacters.None),
new StatementBlock(
Factory.Code(" foo(); ")
.AsStatement()
.With(new StatementCodeGenerator())),
Factory.Code("}")
.Hidden()
.Accepts(AcceptedCharacters.None)));
}
}
}

View File

@ -1,344 +0,0 @@
// 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;
using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{
public class CSharpHelperTest : CsHtmlMarkupParserTestBase
{
[Fact]
public void ParseHelperCorrectlyParsesHelperWithNoSpaceInBody()
{
ParseDocumentTest("@helper Foo(){@Bar()}",
new MarkupBlock(
Factory.EmptyHtml(),
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Foo(){", 8, 0, 8), headerComplete: true),
Factory.CodeTransition(),
Factory.MetaCode("helper ").Accepts(AcceptedCharacters.None),
Factory.Code("Foo(){").Hidden().Accepts(AcceptedCharacters.None),
new StatementBlock(
Factory.EmptyCSharp().AsStatement(),
new ExpressionBlock(
Factory.CodeTransition(),
Factory.Code("Bar()")
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: true)
.Accepts(AcceptedCharacters.NonWhiteSpace)),
Factory.EmptyCSharp().AsStatement()),
Factory.Code("}").Hidden().Accepts(AcceptedCharacters.None)),
Factory.EmptyHtml()));
}
[Fact]
public void ParseHelperCorrectlyParsesIncompleteHelperPreceedingCodeBlock()
{
ParseDocumentTest("@helper" + Environment.NewLine
+ "@{}",
new MarkupBlock(
Factory.EmptyHtml(),
new HelperBlock(
Factory.CodeTransition(),
Factory.MetaCode("helper")),
Factory.Markup("\r\n"),
new StatementBlock(
Factory.CodeTransition(),
Factory.MetaCode("{").Accepts(AcceptedCharacters.None),
Factory.EmptyCSharp().AsStatement(),
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)),
Factory.EmptyHtml()),
new RazorError(
RazorResources.FormatParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_Newline),
7, 0, 7));
}
[Fact]
public void ParseHelperRequiresSpaceBeforeSignature()
{
ParseDocumentTest("@helper{",
new MarkupBlock(
Factory.EmptyHtml(),
new HelperBlock(
Factory.CodeTransition(),
Factory.MetaCode("helper")),
Factory.Markup("{")),
new RazorError(
RazorResources.FormatParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.FormatErrorComponent_Character("{")),
7, 0, 7));
}
[Fact]
public void ParseHelperOutputsErrorButContinuesIfLParenFoundAfterHelperKeyword()
{
ParseDocumentTest("@helper () {",
new MarkupBlock(
Factory.EmptyHtml(),
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("() {", 8, 0, 8), headerComplete: true),
Factory.CodeTransition(),
Factory.MetaCode("helper ").Accepts(AcceptedCharacters.None),
Factory.Code("() {").Hidden().Accepts(AcceptedCharacters.None),
new StatementBlock(
Factory.EmptyCSharp()
.AsStatement()
.AutoCompleteWith("}")))),
new RazorError(
RazorResources.FormatParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.FormatErrorComponent_Character("(")),
8, 0, 8),
new RazorError(
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("helper", "}", "{"),
1, 0, 1));
}
[Fact]
public void ParseHelperStatementOutputsMarkerHelperHeaderSpanOnceKeywordComplete()
{
ParseDocumentTest("@helper ",
new MarkupBlock(
Factory.EmptyHtml(),
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>(String.Empty, 8, 0, 8), headerComplete: false),
Factory.CodeTransition(),
Factory.MetaCode("helper ").Accepts(AcceptedCharacters.None),
Factory.EmptyCSharp().Hidden())),
new RazorError(
RazorResources.FormatParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_EndOfFile),
8, 0, 8));
}
[Fact]
public void ParseHelperStatementMarksHelperSpanAsCanGrowIfMissingTrailingSpace()
{
ParseDocumentTest("@helper",
new MarkupBlock(
Factory.EmptyHtml(),
new HelperBlock(
Factory.CodeTransition(),
Factory.MetaCode("helper").Accepts(AcceptedCharacters.Any))),
new RazorError(
RazorResources.FormatParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_EndOfFile),
7, 0, 7));
}
[Fact]
public void ParseHelperStatementCapturesWhitespaceToEndOfLineIfHelperStatementMissingName()
{
ParseDocumentTest("@helper " + Environment.NewLine
+ " ",
new MarkupBlock(
Factory.EmptyHtml(),
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>(" ", 8, 0, 8), headerComplete: false),
Factory.CodeTransition(),
Factory.MetaCode("helper ").Accepts(AcceptedCharacters.None),
Factory.Code(" \r\n").Hidden()),
Factory.Markup(@" ")),
new RazorError(
RazorResources.FormatParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_Newline),
30, 0, 30));
}
[Fact]
public void ParseHelperStatementCapturesWhitespaceToEndOfLineIfHelperStatementMissingOpenParen()
{
ParseDocumentTest("@helper Foo " + Environment.NewLine
+ " ",
new MarkupBlock(
Factory.EmptyHtml(),
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Foo ", 8, 0, 8), headerComplete: false),
Factory.CodeTransition(),
Factory.MetaCode("helper ").Accepts(AcceptedCharacters.None),
Factory.Code("Foo \r\n").Hidden()),
Factory.Markup(" ")),
new RazorError(
RazorResources.FormatParseError_MissingCharAfterHelperName("("),
15, 0, 15));
}
[Fact]
public void ParseHelperStatementCapturesAllContentToEndOfFileIfHelperStatementMissingCloseParenInParameterList()
{
ParseDocumentTest("@helper Foo(Foo Bar" + Environment.NewLine
+ "Biz" + Environment.NewLine
+ "Boz",
new MarkupBlock(
Factory.EmptyHtml(),
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Foo(Foo Bar\r\nBiz\r\nBoz", 8, 0, 8), headerComplete: false),
Factory.CodeTransition(),
Factory.MetaCode("helper ").Accepts(AcceptedCharacters.None),
Factory.Code("Foo(Foo Bar\r\nBiz\r\nBoz").Hidden())),
new RazorError(
RazorResources.ParseError_UnterminatedHelperParameterList,
11, 0, 11));
}
[Fact]
public void ParseHelperStatementCapturesWhitespaceToEndOfLineIfHelperStatementMissingOpenBraceAfterParameterList()
{
ParseDocumentTest("@helper Foo(string foo) " + Environment.NewLine,
new MarkupBlock(
Factory.EmptyHtml(),
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Foo(string foo) ", 8, 0, 8), headerComplete: false),
Factory.CodeTransition(),
Factory.MetaCode("helper ").Accepts(AcceptedCharacters.None),
Factory.Code("Foo(string foo) \r\n").Hidden())),
new RazorError(
RazorResources.FormatParseError_MissingCharAfterHelperParameters("{"),
29, 1, 0));
}
[Fact]
public void ParseHelperStatementContinuesParsingHelperUntilEOF()
{
ParseDocumentTest("@helper Foo(string foo) { " + Environment.NewLine
+ " <p>Foo</p>",
new MarkupBlock(
Factory.EmptyHtml(),
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Foo(string foo) {", 8, 0, 8), headerComplete: true),
Factory.CodeTransition(),
Factory.MetaCode("helper ").Accepts(AcceptedCharacters.None),
Factory.Code(@"Foo(string foo) {").Hidden().Accepts(AcceptedCharacters.None),
new StatementBlock(
Factory.Code(" \r\n")
.AsStatement()
.AutoCompleteWith("}"),
new MarkupBlock(
Factory.Markup(" "),
new MarkupTagBlock(
Factory.Markup("<p>").Accepts(AcceptedCharacters.None)),
Factory.Markup("Foo"),
new MarkupTagBlock(
Factory.Markup("</p>").Accepts(AcceptedCharacters.None))),
Factory.EmptyCSharp().AsStatement()))),
new RazorError(
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("helper", "}", "{"),
1, 0, 1));
}
[Fact]
public void ParseHelperStatementCorrectlyParsesHelperWithEmbeddedCode()
{
ParseDocumentTest("@helper Foo(string foo) { " + Environment.NewLine
+ " <p>@foo</p>" + Environment.NewLine
+ "}",
new MarkupBlock(
Factory.EmptyHtml(),
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Foo(string foo) {", 8, 0, 8), headerComplete: true),
Factory.CodeTransition(),
Factory.MetaCode("helper ").Accepts(AcceptedCharacters.None),
Factory.Code(@"Foo(string foo) {").Hidden().Accepts(AcceptedCharacters.None),
new StatementBlock(
Factory.Code(" \r\n").AsStatement(),
new MarkupBlock(
Factory.Markup(" "),
new MarkupTagBlock(
Factory.Markup("<p>").Accepts(AcceptedCharacters.None)),
Factory.EmptyHtml(),
new ExpressionBlock(
Factory.CodeTransition(),
Factory.Code("foo")
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
.Accepts(AcceptedCharacters.NonWhiteSpace)),
new MarkupTagBlock(
Factory.Markup("</p>").Accepts(AcceptedCharacters.None)),
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)),
Factory.EmptyCSharp().AsStatement()),
Factory.Code("}").Hidden().Accepts(AcceptedCharacters.None)),
Factory.EmptyHtml()));
}
[Fact]
public void ParseHelperStatementCorrectlyParsesHelperWithNewlinesBetweenCloseParenAndOpenBrace()
{
ParseDocumentTest("@helper Foo(string foo)" + Environment.NewLine
+ Environment.NewLine
+ Environment.NewLine
+ Environment.NewLine
+ "{ " + Environment.NewLine
+ " <p>@foo</p>" + Environment.NewLine
+ "}",
new MarkupBlock(
Factory.EmptyHtml(),
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Foo(string foo)\r\n\r\n\r\n\r\n{", 8, 0, 8), headerComplete: true),
Factory.CodeTransition(),
Factory.MetaCode("helper ").Accepts(AcceptedCharacters.None),
Factory.Code("Foo(string foo)\r\n\r\n\r\n\r\n{").Hidden().Accepts(AcceptedCharacters.None),
new StatementBlock(
Factory.Code(" \r\n").AsStatement(),
new MarkupBlock(
Factory.Markup(@" "),
new MarkupTagBlock(
Factory.Markup("<p>").Accepts(AcceptedCharacters.None)),
Factory.EmptyHtml(),
new ExpressionBlock(
Factory.CodeTransition(),
Factory.Code("foo")
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
.Accepts(AcceptedCharacters.NonWhiteSpace)),
new MarkupTagBlock(
Factory.Markup("</p>").Accepts(AcceptedCharacters.None)),
Factory.Markup("\r\n").Accepts(AcceptedCharacters.None)),
Factory.EmptyCSharp().AsStatement()),
Factory.Code("}").Hidden().Accepts(AcceptedCharacters.None)),
Factory.EmptyHtml()));
}
[Fact]
public void ParseHelperStatementGivesWhitespaceAfterOpenBraceToMarkupInDesignMode()
{
ParseDocumentTest("@helper Foo(string foo) { " + Environment.NewLine
+ " ",
new MarkupBlock(
Factory.EmptyHtml(),
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Foo(string foo) {", 8, 0, 8), headerComplete: true),
Factory.CodeTransition(),
Factory.MetaCode("helper ").Accepts(AcceptedCharacters.None),
Factory.Code(@"Foo(string foo) {").Hidden().Accepts(AcceptedCharacters.None),
new StatementBlock(
Factory.Code(" \r\n ")
.AsStatement()
.AutoCompleteWith("}")))),
designTimeParser: true,
expectedErrors: new[]
{
new RazorError(
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("helper", "}", "{"),
new SourceLocation(1, 0, 1))
});
}
[Fact]
public void ParseHelperAcceptsNestedHelpersButOutputsError()
{
ParseDocumentTest(@"@helper Foo(string foo) {" + Environment.NewLine
+ " @helper Bar(string baz) {" + Environment.NewLine
+ " }" + Environment.NewLine
+ "}",
new MarkupBlock(
Factory.EmptyHtml(),
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Foo(string foo) {", 8, 0, 8), headerComplete: true),
Factory.CodeTransition(),
Factory.MetaCode("helper ").Accepts(AcceptedCharacters.None),
Factory.Code(@"Foo(string foo) {").Hidden().Accepts(AcceptedCharacters.None),
new StatementBlock(
Factory.Code("\r\n ").AsStatement(),
new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Bar(string baz) {", 39, 1, 12), headerComplete: true),
Factory.CodeTransition(),
Factory.MetaCode("helper ").Accepts(AcceptedCharacters.None),
Factory.Code(@"Bar(string baz) {").Hidden().Accepts(AcceptedCharacters.None),
new StatementBlock(
Factory.Code("\r\n ").AsStatement()),
Factory.Code("}").Hidden().Accepts(AcceptedCharacters.None)),
Factory.Code("\r\n").AsStatement()),
Factory.Code("}").Hidden().Accepts(AcceptedCharacters.None)),
Factory.EmptyHtml()),
designTimeParser: true,
expectedErrors: new[]
{
new RazorError(RazorResources.ParseError_Helpers_Cannot_Be_Nested, 38, 1, 11)
});
}
}
}

View File

@ -624,12 +624,6 @@ namespace Microsoft.AspNet.Razor.Test.Parser.PartialParsing
RunTypeKeywordTest("inherits");
}
[Fact]
public void ImplicitExpressionCorrectlyTriggersReparseIfHelperKeywordTyped()
{
RunTypeKeywordTest("helper");
}
[Fact]
public void ImplicitExpressionCorrectlyTriggersReparseIfFunctionsKeywordTyped()
{

View File

@ -6,36 +6,6 @@ namespace TestOutput
public class DesignTime
{
private static object @__o;
public static Template
#line 17 "DesignTime.cshtml"
Foo() {
#line default
#line hidden
return new Template((__razor_helper_writer) => {
#line 17 "DesignTime.cshtml"
if(true) {
#line default
#line hidden
#line 19 "DesignTime.cshtml"
}
#line default
#line hidden
}
);
#line 21 "DesignTime.cshtml"
}
#line default
#line hidden
private void @__RazorDesignTimeHelpers__()
{
#pragma warning disable 219

View File

@ -1,113 +0,0 @@
#pragma checksum "Helpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "228b0ea0de0f06806d10a9768bb4afd7e0ecb878"
namespace TestOutput
{
using System;
using System.Threading.Tasks;
public class Helpers
{
public Template
#line 1 "Helpers.cshtml"
Bold(string s) {
#line default
#line hidden
return new Template((__razor_helper_writer) => {
#line 1 "Helpers.cshtml"
s = s.ToUpper();
#line default
#line hidden
Instrumentation.BeginContext(48, 12, true);
WriteLiteralTo(__razor_helper_writer, " <strong>");
Instrumentation.EndContext();
Instrumentation.BeginContext(61, 1, false);
#line 3 "Helpers.cshtml"
WriteTo(__razor_helper_writer, s);
#line default
#line hidden
Instrumentation.EndContext();
Instrumentation.BeginContext(62, 11, true);
WriteLiteralTo(__razor_helper_writer, "</strong>\r\n");
Instrumentation.EndContext();
#line 4 "Helpers.cshtml"
#line default
#line hidden
}
);
#line 4 "Helpers.cshtml"
}
#line default
#line hidden
public Template
#line 6 "Helpers.cshtml"
Italic(string s) {
#line default
#line hidden
return new Template((__razor_helper_writer) => {
#line 6 "Helpers.cshtml"
s = s.ToUpper();
#line default
#line hidden
Instrumentation.BeginContext(128, 8, true);
WriteLiteralTo(__razor_helper_writer, " <em>");
Instrumentation.EndContext();
Instrumentation.BeginContext(137, 1, false);
#line 8 "Helpers.cshtml"
WriteTo(__razor_helper_writer, s);
#line default
#line hidden
Instrumentation.EndContext();
Instrumentation.BeginContext(138, 7, true);
WriteLiteralTo(__razor_helper_writer, "</em>\r\n");
Instrumentation.EndContext();
#line 9 "Helpers.cshtml"
#line default
#line hidden
}
);
#line 9 "Helpers.cshtml"
}
#line default
#line hidden
#line hidden
public Helpers()
{
}
#pragma warning disable 1998
public override async Task ExecuteAsync()
{
Instrumentation.BeginContext(76, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
Instrumentation.BeginContext(148, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
Instrumentation.BeginContext(151, 13, false);
#line 11 "Helpers.cshtml"
Write(Bold("Hello"));
#line default
#line hidden
Instrumentation.EndContext();
}
#pragma warning restore 1998
}
}

View File

@ -1,113 +0,0 @@
#pragma checksum "Helpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "228b0ea0de0f06806d10a9768bb4afd7e0ecb878"
namespace TestOutput
{
using System;
using System.Threading.Tasks;
public class Helpers
{
public static Template
#line 1 "Helpers.cshtml"
Bold(string s) {
#line default
#line hidden
return new Template((__razor_helper_writer) => {
#line 1 "Helpers.cshtml"
s = s.ToUpper();
#line default
#line hidden
Instrumentation.BeginContext(48, 12, true);
WriteLiteralTo(__razor_helper_writer, " <strong>");
Instrumentation.EndContext();
Instrumentation.BeginContext(61, 1, false);
#line 3 "Helpers.cshtml"
WriteTo(__razor_helper_writer, s);
#line default
#line hidden
Instrumentation.EndContext();
Instrumentation.BeginContext(62, 11, true);
WriteLiteralTo(__razor_helper_writer, "</strong>\r\n");
Instrumentation.EndContext();
#line 4 "Helpers.cshtml"
#line default
#line hidden
}
);
#line 4 "Helpers.cshtml"
}
#line default
#line hidden
public static Template
#line 6 "Helpers.cshtml"
Italic(string s) {
#line default
#line hidden
return new Template((__razor_helper_writer) => {
#line 6 "Helpers.cshtml"
s = s.ToUpper();
#line default
#line hidden
Instrumentation.BeginContext(128, 8, true);
WriteLiteralTo(__razor_helper_writer, " <em>");
Instrumentation.EndContext();
Instrumentation.BeginContext(137, 1, false);
#line 8 "Helpers.cshtml"
WriteTo(__razor_helper_writer, s);
#line default
#line hidden
Instrumentation.EndContext();
Instrumentation.BeginContext(138, 7, true);
WriteLiteralTo(__razor_helper_writer, "</em>\r\n");
Instrumentation.EndContext();
#line 9 "Helpers.cshtml"
#line default
#line hidden
}
);
#line 9 "Helpers.cshtml"
}
#line default
#line hidden
#line hidden
public Helpers()
{
}
#pragma warning disable 1998
public override async Task ExecuteAsync()
{
Instrumentation.BeginContext(76, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
Instrumentation.BeginContext(148, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
Instrumentation.BeginContext(151, 13, false);
#line 11 "Helpers.cshtml"
Write(Bold("Hello"));
#line default
#line hidden
Instrumentation.EndContext();
}
#pragma warning restore 1998
}
}

View File

@ -1,71 +0,0 @@
#pragma checksum "HelpersMissingCloseParen.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a59fed8a1d7b5333e081339188fe2dba59c71e41"
namespace TestOutput
{
using System;
using System.Threading.Tasks;
public class HelpersMissingCloseParen
{
public static Template
#line 1 "HelpersMissingCloseParen.cshtml"
Bold(string s) {
#line default
#line hidden
return new Template((__razor_helper_writer) => {
#line 1 "HelpersMissingCloseParen.cshtml"
s = s.ToUpper();
#line default
#line hidden
Instrumentation.BeginContext(48, 12, true);
WriteLiteralTo(__razor_helper_writer, " <strong>");
Instrumentation.EndContext();
Instrumentation.BeginContext(61, 1, false);
#line 3 "HelpersMissingCloseParen.cshtml"
WriteTo(__razor_helper_writer, s);
#line default
#line hidden
Instrumentation.EndContext();
Instrumentation.BeginContext(62, 11, true);
WriteLiteralTo(__razor_helper_writer, "</strong>\r\n");
Instrumentation.EndContext();
#line 4 "HelpersMissingCloseParen.cshtml"
#line default
#line hidden
}
);
#line 4 "HelpersMissingCloseParen.cshtml"
}
#line default
#line hidden
public static Template
#line 6 "HelpersMissingCloseParen.cshtml"
Italic(string s
@Bold("Hello")
#line default
#line hidden
#line hidden
public HelpersMissingCloseParen()
{
}
#pragma warning disable 1998
public override async Task ExecuteAsync()
{
Instrumentation.BeginContext(76, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
}
#pragma warning restore 1998
}
}

View File

@ -1,77 +0,0 @@
#pragma checksum "HelpersMissingOpenBrace.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "f81212c85e39fa08cb4c95e2339817caa725397c"
namespace TestOutput
{
using System;
using System.Threading.Tasks;
public class HelpersMissingOpenBrace
{
public static Template
#line 1 "HelpersMissingOpenBrace.cshtml"
Bold(string s) {
#line default
#line hidden
return new Template((__razor_helper_writer) => {
#line 1 "HelpersMissingOpenBrace.cshtml"
s = s.ToUpper();
#line default
#line hidden
Instrumentation.BeginContext(48, 12, true);
WriteLiteralTo(__razor_helper_writer, " <strong>");
Instrumentation.EndContext();
Instrumentation.BeginContext(61, 1, false);
#line 3 "HelpersMissingOpenBrace.cshtml"
WriteTo(__razor_helper_writer, s);
#line default
#line hidden
Instrumentation.EndContext();
Instrumentation.BeginContext(62, 11, true);
WriteLiteralTo(__razor_helper_writer, "</strong>\r\n");
Instrumentation.EndContext();
#line 4 "HelpersMissingOpenBrace.cshtml"
#line default
#line hidden
}
);
#line 4 "HelpersMissingOpenBrace.cshtml"
}
#line default
#line hidden
public static Template
#line 6 "HelpersMissingOpenBrace.cshtml"
Italic(string s)
#line default
#line hidden
#line hidden
public HelpersMissingOpenBrace()
{
}
#pragma warning disable 1998
public override async Task ExecuteAsync()
{
Instrumentation.BeginContext(76, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
Instrumentation.BeginContext(106, 9, false);
#line 7 "HelpersMissingOpenBrace.cshtml"
Write(Italic(s));
#line default
#line hidden
Instrumentation.EndContext();
}
#pragma warning restore 1998
}
}

View File

@ -1,77 +0,0 @@
#pragma checksum "HelpersMissingOpenParen.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "dc407d9349ea9a1595c65660d41a63970de65729"
namespace TestOutput
{
using System;
using System.Threading.Tasks;
public class HelpersMissingOpenParen
{
public static Template
#line 1 "HelpersMissingOpenParen.cshtml"
Bold(string s) {
#line default
#line hidden
return new Template((__razor_helper_writer) => {
#line 1 "HelpersMissingOpenParen.cshtml"
s = s.ToUpper();
#line default
#line hidden
Instrumentation.BeginContext(48, 12, true);
WriteLiteralTo(__razor_helper_writer, " <strong>");
Instrumentation.EndContext();
Instrumentation.BeginContext(61, 1, false);
#line 3 "HelpersMissingOpenParen.cshtml"
WriteTo(__razor_helper_writer, s);
#line default
#line hidden
Instrumentation.EndContext();
Instrumentation.BeginContext(62, 11, true);
WriteLiteralTo(__razor_helper_writer, "</strong>\r\n");
Instrumentation.EndContext();
#line 4 "HelpersMissingOpenParen.cshtml"
#line default
#line hidden
}
);
#line 4 "HelpersMissingOpenParen.cshtml"
}
#line default
#line hidden
public static Template
#line 6 "HelpersMissingOpenParen.cshtml"
Italic
#line default
#line hidden
#line hidden
public HelpersMissingOpenParen()
{
}
#pragma warning disable 1998
public override async Task ExecuteAsync()
{
Instrumentation.BeginContext(76, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
Instrumentation.BeginContext(95, 13, false);
#line 7 "HelpersMissingOpenParen.cshtml"
Write(Bold("Hello"));
#line default
#line hidden
Instrumentation.EndContext();
}
#pragma warning restore 1998
}
}

View File

@ -1,4 +1,4 @@
#pragma checksum "InlineBlocks.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "85fc1bd0306a5a6164d3d866bd690ff95cba0a8e"
#pragma checksum "InlineBlocks.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e7fa74a13b1e78fed87942ccd83aa733810e8664"
namespace TestOutput
{
using System;
@ -6,31 +6,29 @@ namespace TestOutput
public class InlineBlocks
{
public static Template
#line 1 "InlineBlocks.cshtml"
Link(string link) {
#line hidden
public InlineBlocks()
{
}
#line default
#line hidden
return new Template((__razor_helper_writer) => {
#line 1 "InlineBlocks.cshtml"
#line default
#line hidden
Instrumentation.BeginContext(29, 6, true);
WriteLiteralTo(__razor_helper_writer, " <a");
#pragma warning disable 1998
public override async Task ExecuteAsync()
{
DefineSection("Link", async(__razor_template_writer) => {
}
);
Instrumentation.BeginContext(13, 23, true);
WriteLiteral("(string link) {\r\n <a");
Instrumentation.EndContext();
WriteAttributeTo(__razor_helper_writer, "href", Tuple.Create(" href=\"", 35), Tuple.Create("\"", 93),
Tuple.Create(Tuple.Create("", 42), Tuple.Create<System.Object, System.Int32>(new Template((__razor_attribute_value_writer) => {
WriteAttribute("href", Tuple.Create(" href=\"", 36), Tuple.Create("\"", 94),
Tuple.Create(Tuple.Create("", 43), Tuple.Create<System.Object, System.Int32>(new Template((__razor_attribute_value_writer) => {
#line 2 "InlineBlocks.cshtml"
if(link != null) {
#line default
#line hidden
Instrumentation.BeginContext(63, 4, false);
Instrumentation.BeginContext(64, 4, false);
#line 2 "InlineBlocks.cshtml"
WriteTo(__razor_attribute_value_writer, link);
@ -43,7 +41,7 @@ WriteTo(__razor_attribute_value_writer, link);
#line default
#line hidden
Instrumentation.BeginContext(76, 3, true);
Instrumentation.BeginContext(77, 3, true);
WriteLiteralTo(__razor_attribute_value_writer, " # ");
Instrumentation.EndContext();
#line 2 "InlineBlocks.cshtml"
@ -53,31 +51,10 @@ WriteTo(__razor_attribute_value_writer, link);
#line hidden
}
), 42), false));
Instrumentation.BeginContext(94, 5, true);
WriteLiteralTo(__razor_helper_writer, " />\r\n");
), 43), false));
Instrumentation.BeginContext(95, 6, true);
WriteLiteral(" />\r\n}");
Instrumentation.EndContext();
#line 3 "InlineBlocks.cshtml"
#line default
#line hidden
}
);
#line 3 "InlineBlocks.cshtml"
}
#line default
#line hidden
#line hidden
public InlineBlocks()
{
}
#pragma warning disable 1998
public override async Task ExecuteAsync()
{
}
#pragma warning restore 1998
}

View File

@ -1,4 +1,4 @@
#pragma checksum "Instrumented.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "24ae301f33f984680e86aa6c7ae226809531ffe9"
#pragma checksum "Instrumented.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "3d0d9c94b62eeccf0a2a106b257a1ea1e22412a9"
namespace TestOutput
{
using System;
@ -6,45 +6,6 @@ namespace TestOutput
public class Instrumented
{
public static Template
#line 1 "Instrumented.cshtml"
Strong(string s) {
#line default
#line hidden
return new Template((__razor_helper_writer) => {
#line 1 "Instrumented.cshtml"
#line default
#line hidden
Instrumentation.BeginContext(28, 12, true);
WriteLiteralTo(__razor_helper_writer, " <strong>");
Instrumentation.EndContext();
Instrumentation.BeginContext(41, 1, false);
#line 2 "Instrumented.cshtml"
WriteTo(__razor_helper_writer, s);
#line default
#line hidden
Instrumentation.EndContext();
Instrumentation.BeginContext(42, 11, true);
WriteLiteralTo(__razor_helper_writer, "</strong>\r\n");
Instrumentation.EndContext();
#line 3 "Instrumented.cshtml"
#line default
#line hidden
}
);
#line 3 "Instrumented.cshtml"
}
#line default
#line hidden
#line hidden
public Instrumented()
{
@ -53,10 +14,7 @@ WriteTo(__razor_helper_writer, s);
#pragma warning disable 1998
public override async Task ExecuteAsync()
{
Instrumentation.BeginContext(56, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
#line 5 "Instrumented.cshtml"
#line 1 "Instrumented.cshtml"
int i = 1;
var foo =
@ -65,180 +23,180 @@ WriteTo(__razor_helper_writer, s);
#line hidden
item => new Template((__razor_template_writer) => {
Instrumentation.BeginContext(93, 10, true);
Instrumentation.BeginContext(35, 10, true);
WriteLiteralTo(__razor_template_writer, "<p>Bar</p>");
Instrumentation.EndContext();
}
)
#line 7 "Instrumented.cshtml"
#line 3 "Instrumented.cshtml"
;
#line default
#line hidden
Instrumentation.BeginContext(106, 43, true);
Instrumentation.BeginContext(48, 43, true);
WriteLiteral(" Hello, World\r\n <p>Hello, World</p>\r\n");
Instrumentation.EndContext();
#line 10 "Instrumented.cshtml"
#line 6 "Instrumented.cshtml"
#line default
#line hidden
Instrumentation.BeginContext(152, 4, true);
Instrumentation.BeginContext(94, 4, true);
WriteLiteral("\r\n\r\n");
Instrumentation.EndContext();
#line 12 "Instrumented.cshtml"
#line 8 "Instrumented.cshtml"
while(i <= 10) {
#line default
#line hidden
Instrumentation.BeginContext(175, 23, true);
Instrumentation.BeginContext(117, 23, true);
WriteLiteral(" <p>Hello from C#, #");
Instrumentation.EndContext();
Instrumentation.BeginContext(200, 1, false);
#line 13 "Instrumented.cshtml"
Instrumentation.BeginContext(142, 1, false);
#line 9 "Instrumented.cshtml"
Write(i);
#line default
#line hidden
Instrumentation.EndContext();
Instrumentation.BeginContext(202, 6, true);
Instrumentation.BeginContext(144, 6, true);
WriteLiteral("</p>\r\n");
Instrumentation.EndContext();
#line 14 "Instrumented.cshtml"
#line 10 "Instrumented.cshtml"
i += 1;
}
#line default
#line hidden
Instrumentation.BeginContext(224, 2, true);
Instrumentation.BeginContext(166, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
#line 17 "Instrumented.cshtml"
#line 13 "Instrumented.cshtml"
if(i == 11) {
#line default
#line hidden
Instrumentation.BeginContext(242, 31, true);
Instrumentation.BeginContext(184, 31, true);
WriteLiteral(" <p>We wrote 10 lines!</p>\r\n");
Instrumentation.EndContext();
#line 19 "Instrumented.cshtml"
#line 15 "Instrumented.cshtml"
}
#line default
#line hidden
Instrumentation.BeginContext(276, 2, true);
Instrumentation.BeginContext(218, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
#line 21 "Instrumented.cshtml"
#line 17 "Instrumented.cshtml"
switch(i) {
case 11:
#line default
#line hidden
Instrumentation.BeginContext(306, 46, true);
Instrumentation.BeginContext(248, 46, true);
WriteLiteral(" <p>No really, we wrote 10 lines!</p>\r\n");
Instrumentation.EndContext();
#line 24 "Instrumented.cshtml"
#line 20 "Instrumented.cshtml"
break;
default:
#line default
#line hidden
Instrumentation.BeginContext(382, 39, true);
Instrumentation.BeginContext(324, 39, true);
WriteLiteral(" <p>Actually, we didn\'t...</p>\r\n");
Instrumentation.EndContext();
#line 27 "Instrumented.cshtml"
#line 23 "Instrumented.cshtml"
break;
}
#line default
#line hidden
Instrumentation.BeginContext(440, 2, true);
Instrumentation.BeginContext(382, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
#line 30 "Instrumented.cshtml"
#line 26 "Instrumented.cshtml"
for(int j = 1; j <= 10; j += 2) {
#line default
#line hidden
Instrumentation.BeginContext(478, 29, true);
Instrumentation.BeginContext(420, 29, true);
WriteLiteral(" <p>Hello again from C#, #");
Instrumentation.EndContext();
Instrumentation.BeginContext(509, 1, false);
#line 31 "Instrumented.cshtml"
Instrumentation.BeginContext(451, 1, false);
#line 27 "Instrumented.cshtml"
Write(j);
#line default
#line hidden
Instrumentation.EndContext();
Instrumentation.BeginContext(511, 6, true);
Instrumentation.BeginContext(453, 6, true);
WriteLiteral("</p>\r\n");
Instrumentation.EndContext();
#line 32 "Instrumented.cshtml"
#line 28 "Instrumented.cshtml"
}
#line default
#line hidden
Instrumentation.BeginContext(520, 2, true);
Instrumentation.BeginContext(462, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
#line 34 "Instrumented.cshtml"
#line 30 "Instrumented.cshtml"
try {
#line default
#line hidden
Instrumentation.BeginContext(530, 41, true);
Instrumentation.BeginContext(472, 41, true);
WriteLiteral(" <p>That time, we wrote 5 lines!</p>\r\n");
Instrumentation.EndContext();
#line 36 "Instrumented.cshtml"
#line 32 "Instrumented.cshtml"
} catch(Exception ex) {
#line default
#line hidden
Instrumentation.BeginContext(596, 33, true);
Instrumentation.BeginContext(538, 33, true);
WriteLiteral(" <p>Oh no! An error occurred: ");
Instrumentation.EndContext();
Instrumentation.BeginContext(631, 10, false);
#line 37 "Instrumented.cshtml"
Instrumentation.BeginContext(573, 10, false);
#line 33 "Instrumented.cshtml"
Write(ex.Message);
#line default
#line hidden
Instrumentation.EndContext();
Instrumentation.BeginContext(642, 6, true);
Instrumentation.BeginContext(584, 6, true);
WriteLiteral("</p>\r\n");
Instrumentation.EndContext();
#line 38 "Instrumented.cshtml"
#line 34 "Instrumented.cshtml"
}
#line default
#line hidden
Instrumentation.BeginContext(651, 2, true);
Instrumentation.BeginContext(593, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
#line 40 "Instrumented.cshtml"
#line 36 "Instrumented.cshtml"
lock(new object()) {
#line default
#line hidden
Instrumentation.BeginContext(676, 53, true);
Instrumentation.BeginContext(618, 53, true);
WriteLiteral(" <p>This block is locked, for your security!</p>\r\n");
Instrumentation.EndContext();
#line 42 "Instrumented.cshtml"
#line 38 "Instrumented.cshtml"
}
#line default

View File

@ -1,118 +0,0 @@
#pragma checksum "NestedHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e8232b2b30af7dadb0698abf8ba08851f401963d"
namespace TestOutput
{
using System;
using System.Threading.Tasks;
public class NestedHelpers
{
public static Template
#line 1 "NestedHelpers.cshtml"
Italic(string s) {
#line default
#line hidden
return new Template((__razor_helper_writer) => {
#line 1 "NestedHelpers.cshtml"
s = s.ToUpper();
#line default
#line hidden
#line 6 "NestedHelpers.cshtml"
#line default
#line hidden
Instrumentation.BeginContext(142, 8, true);
WriteLiteralTo(__razor_helper_writer, " <em>");
Instrumentation.EndContext();
Instrumentation.BeginContext(151, 7, false);
#line 7 "NestedHelpers.cshtml"
WriteTo(__razor_helper_writer, Bold(s));
#line default
#line hidden
Instrumentation.EndContext();
Instrumentation.BeginContext(158, 7, true);
WriteLiteralTo(__razor_helper_writer, "</em>\r\n");
Instrumentation.EndContext();
#line 8 "NestedHelpers.cshtml"
#line default
#line hidden
}
);
#line 8 "NestedHelpers.cshtml"
}
#line default
#line hidden
public static Template
#line 3 "NestedHelpers.cshtml"
Bold(string s) {
#line default
#line hidden
return new Template((__razor_helper_writer) => {
#line 3 "NestedHelpers.cshtml"
s = s.ToUpper();
#line default
#line hidden
Instrumentation.BeginContext(106, 16, true);
WriteLiteralTo(__razor_helper_writer, " <strong>");
Instrumentation.EndContext();
Instrumentation.BeginContext(123, 1, false);
#line 5 "NestedHelpers.cshtml"
WriteTo(__razor_helper_writer, s);
#line default
#line hidden
Instrumentation.EndContext();
Instrumentation.BeginContext(124, 11, true);
WriteLiteralTo(__razor_helper_writer, "</strong>\r\n");
Instrumentation.EndContext();
#line 6 "NestedHelpers.cshtml"
#line default
#line hidden
}
);
#line 6 "NestedHelpers.cshtml"
}
#line default
#line hidden
#line hidden
public NestedHelpers()
{
}
#pragma warning disable 1998
public override async Task ExecuteAsync()
{
Instrumentation.BeginContext(168, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
Instrumentation.BeginContext(171, 15, false);
#line 10 "NestedHelpers.cshtml"
Write(Italic("Hello"));
#line default
#line hidden
Instrumentation.EndContext();
}
#pragma warning restore 1998
}
}

View File

@ -1,138 +0,0 @@
#pragma checksum "TagHelpersInHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5f28fe84901bdeb20db8296b1da1e9a1f1da1023"
namespace TestOutput
{
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
using System;
using System.Threading.Tasks;
public class TagHelpersInHelper
{
public static Template
#line 3 "TagHelpersInHelper.cshtml"
MyHelper(string val)
{
#line default
#line hidden
return new Template((__razor_helper_writer) => {
#line 4 "TagHelpersInHelper.cshtml"
#line default
#line hidden
Instrumentation.BeginContext(68, 19, true);
WriteLiteralTo(__razor_helper_writer, " <div>\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper", false, "test", async() => {
WriteLiteral("\r\n In None ContentBehavior.\r\n ");
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper", false, "test", async() => {
WriteLiteral("Some buffered values with a value of ");
#line 8 "TagHelpersInHelper.cshtml"
Write(val);
#line default
#line hidden
}
, StartTagHelperWritingScope, EndTagHelperWritingScope);
__NestedTagHelper = CreateTagHelper<NestedTagHelper>();
__tagHelperExecutionContext.Add(__NestedTagHelper);
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
WriteTagHelperAsync(__tagHelperExecutionContext).Wait();
__tagHelperExecutionContext = __tagHelperScopeManager.End();
WriteLiteral("\r\n ");
}
, StartTagHelperWritingScope, EndTagHelperWritingScope);
__MyTagHelper = CreateTagHelper<MyTagHelper>();
__tagHelperExecutionContext.Add(__MyTagHelper);
StartTagHelperWritingScope();
WriteLiteral("Current Time: ");
#line 6 "TagHelpersInHelper.cshtml"
Write(DateTime.Now);
#line default
#line hidden
__tagHelperStringValueBuffer = EndTagHelperWritingScope();
__MyTagHelper.BoundProperty = __tagHelperStringValueBuffer.ToString();
__tagHelperExecutionContext.AddTagHelperAttribute("BoundProperty", __MyTagHelper.BoundProperty);
StartTagHelperWritingScope();
WriteLiteral("Current Time: ");
#line 6 "TagHelpersInHelper.cshtml"
Write(DateTime.Now);
#line default
#line hidden
__tagHelperStringValueBuffer = EndTagHelperWritingScope();
__tagHelperExecutionContext.AddHtmlAttribute("unboundproperty", __tagHelperStringValueBuffer.ToString());
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
WriteTagHelperToAsync(__razor_helper_writer, __tagHelperExecutionContext).Wait();
__tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(342, 14, true);
WriteLiteralTo(__razor_helper_writer, "\r\n </div>\r\n");
Instrumentation.EndContext();
#line 11 "TagHelpersInHelper.cshtml"
#line default
#line hidden
}
);
#line 11 "TagHelpersInHelper.cshtml"
}
#line default
#line hidden
#line hidden
#pragma warning disable 0414
private TagHelperContent __tagHelperStringValueBuffer = null;
#pragma warning restore 0414
private TagHelperExecutionContext __tagHelperExecutionContext = null;
private TagHelperRunner __tagHelperRunner = null;
private TagHelperScopeManager __tagHelperScopeManager = new TagHelperScopeManager();
private MyTagHelper __MyTagHelper = null;
private NestedTagHelper __NestedTagHelper = null;
#line hidden
public TagHelpersInHelper()
{
}
#pragma warning disable 1998
public override async Task ExecuteAsync()
{
__tagHelperRunner = __tagHelperRunner ?? new TagHelperRunner();
Instrumentation.BeginContext(33, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("mytaghelper", false, "test", async() => {
#line 12 "TagHelpersInHelper.cshtml"
Write(MyHelper(item => new Template((__razor_template_writer) => {
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("nestedtaghelper", false, "test", async() => {
WriteLiteral("Custom Value");
}
, StartTagHelperWritingScope, EndTagHelperWritingScope);
__NestedTagHelper = CreateTagHelper<NestedTagHelper>();
__tagHelperExecutionContext.Add(__NestedTagHelper);
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
WriteTagHelperToAsync(__razor_template_writer, __tagHelperExecutionContext).Wait();
__tagHelperExecutionContext = __tagHelperScopeManager.End();
}
)
));
#line default
#line hidden
}
, StartTagHelperWritingScope, EndTagHelperWritingScope);
__MyTagHelper = CreateTagHelper<MyTagHelper>();
__tagHelperExecutionContext.Add(__MyTagHelper);
__tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result;
WriteTagHelperAsync(__tagHelperExecutionContext).Wait();
__tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(445, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
}
#pragma warning restore 1998
}
}

View File

@ -12,10 +12,4 @@
@section Footer {
<p>Foo</p>
@bar
}
@helper Foo() {
if(true) {
<p>Foo</p>
}
}

View File

@ -1,11 +0,0 @@
@helper Bold(string s) {
s = s.ToUpper();
<strong>@s</strong>
}
@helper Italic(string s) {
s = s.ToUpper();
<em>@s</em>
}
@Bold("Hello")

View File

@ -1,7 +0,0 @@
@helper Bold(string s) {
s = s.ToUpper();
<strong>@s</strong>
}
@helper Italic(string s
@Bold("Hello")

View File

@ -1,7 +0,0 @@
@helper Bold(string s) {
s = s.ToUpper();
<strong>@s</strong>
}
@helper Italic(string s)
@Italic(s)

View File

@ -1,7 +0,0 @@
@helper Bold(string s) {
s = s.ToUpper();
<strong>@s</strong>
}
@helper Italic
@Bold("Hello")

View File

@ -1,3 +1,3 @@
@helper Link(string link) {
@section Link(string link) {
<a href="@if(link != null) { @link } else { <text>#</text> }" />
}

View File

@ -1,8 +1,4 @@
@helper Strong(string s) {
<strong>@s</strong>
}
@{
@{
int i = 1;
var foo = @<p>Bar</p>;
@:Hello, World

View File

@ -1,10 +0,0 @@
@helper Italic(string s) {
s = s.ToUpper();
@helper Bold(string s) {
s = s.ToUpper();
<strong>@s</strong>
}
<em>@Bold(s)</em>
}
@Italic("Hello")

View File

@ -1,12 +0,0 @@
@addTagHelper "something, nice"
@helper MyHelper(string val)
{
<div>
<mytaghelper boundproperty="Current Time: @DateTime.Now" unboundproperty="Current Time: @DateTime.Now">
In None ContentBehavior.
<nestedtaghelper>Some buffered values with a value of @val</nestedtaghelper>
</mytaghelper>
</div>
}
<mytaghelper>@MyHelper(@<nestedtaghelper>Custom Value</nestedtaghelper>)</mytaghelper>