diff --git a/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/CSharpCodeBuilder.cs b/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/CSharpCodeBuilder.cs index 7d45dff65..222677597 100644 --- a/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/CSharpCodeBuilder.cs +++ b/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/CSharpCodeBuilder.cs @@ -52,7 +52,6 @@ public override CodeBuilderResult Build() 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); diff --git a/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/Visitors/CSharpHelperVisitor.cs b/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/Visitors/CSharpHelperVisitor.cs deleted file mode 100644 index 5ca07d9b4..000000000 --- a/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/Visitors/CSharpHelperVisitor.cs +++ /dev/null @@ -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 - { - 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(); - } - } -} diff --git a/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/ChunkVisitor.cs b/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/ChunkVisitor.cs index f8ba39b70..73c25b337 100644 --- a/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/ChunkVisitor.cs +++ b/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/ChunkVisitor.cs @@ -85,10 +85,6 @@ public virtual void Accept(Chunk chunk) { Visit((UsingChunk)chunk); } - else if (chunk is HelperChunk) - { - Visit((HelperChunk)chunk); - } else if (chunk is SetBaseTypeChunk) { Visit((SetBaseTypeChunk)chunk); @@ -131,7 +127,6 @@ public virtual void Accept(Chunk chunk) 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); diff --git a/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CodeVisitor.cs b/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CodeVisitor.cs index 1227d96a4..dedeb3ae6 100644 --- a/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CodeVisitor.cs +++ b/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CodeVisitor.cs @@ -48,9 +48,6 @@ protected override void Visit(LiteralCodeAttributeChunk chunk) protected override void Visit(CodeAttributeChunk chunk) { } - protected override void Visit(HelperChunk chunk) - { - } protected override void Visit(SectionChunk chunk) { } diff --git a/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeTree/Chunks/HelperChunk.cs b/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeTree/Chunks/HelperChunk.cs deleted file mode 100644 index 269b2ff7f..000000000 --- a/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeTree/Chunks/HelperChunk.cs +++ /dev/null @@ -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 Signature { get; set; } - public LocationTagged Footer { get; set; } - public bool HeaderComplete { get; set; } - } -} diff --git a/src/Microsoft.AspNet.Razor/Generator/HelperCodeGenerator.cs b/src/Microsoft.AspNet.Razor/Generator/HelperCodeGenerator.cs deleted file mode 100644 index 68d21ecc8..000000000 --- a/src/Microsoft.AspNet.Razor/Generator/HelperCodeGenerator.cs +++ /dev/null @@ -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 signature, bool headerComplete) - { - Signature = signature; - HeaderComplete = headerComplete; - } - - public LocationTagged Signature { get; private set; } - public LocationTagged Footer { get; set; } - public bool HeaderComplete { get; private set; } - - public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context) - { - var chunk = context.CodeTreeBuilder.StartChunkBlock(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"); - } - } -} diff --git a/src/Microsoft.AspNet.Razor/Parser/CSharpCodeParser.Directives.cs b/src/Microsoft.AspNet.Razor/Parser/CSharpCodeParser.Directives.cs index 21206c049..4135c10ff 100644 --- a/src/Microsoft.AspNet.Razor/Parser/CSharpCodeParser.Directives.cs +++ b/src/Microsoft.AspNet.Razor/Parser/CSharpCodeParser.Directives.cs @@ -24,7 +24,6 @@ private void SetupDirectives() 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 @@ protected virtual void LayoutDirective() 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 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 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); diff --git a/src/Microsoft.AspNet.Razor/Parser/CSharpCodeParser.cs b/src/Microsoft.AspNet.Razor/Parser/CSharpCodeParser.cs index bba1a82dd..d03e883e8 100644 --- a/src/Microsoft.AspNet.Razor/Parser/CSharpCodeParser.cs +++ b/src/Microsoft.AspNet.Razor/Parser/CSharpCodeParser.cs @@ -33,7 +33,6 @@ public partial class CSharpCodeParser : TokenizerBackedParser - /// Expected a "{0}" after the helper parameters. - /// - internal static string ParseError_MissingCharAfterHelperParameters - { - get { return GetString("ParseError_MissingCharAfterHelperParameters"); } - } - - /// - /// Expected a "{0}" after the helper parameters. - /// - internal static string FormatParseError_MissingCharAfterHelperParameters(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("ParseError_MissingCharAfterHelperParameters"), p0); - } - - /// - /// Expected a "{0}" after the helper name. - /// - internal static string ParseError_MissingCharAfterHelperName - { - get { return GetString("ParseError_MissingCharAfterHelperName"); } - } - - /// - /// Expected a "{0}" after the helper name. - /// - internal static string FormatParseError_MissingCharAfterHelperName(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("ParseError_MissingCharAfterHelperName"), p0); - } - - /// - /// Helper parameter list is missing a closing ")". - /// - internal static string ParseError_UnterminatedHelperParameterList - { - get { return GetString("ParseError_UnterminatedHelperParameterList"); } - } - - /// - /// Helper parameter list is missing a closing ")". - /// - internal static string FormatParseError_UnterminatedHelperParameterList() - { - return GetString("ParseError_UnterminatedHelperParameterList"); - } - - /// - /// Helper blocks cannot be nested within each other. - /// - internal static string ParseError_Helpers_Cannot_Be_Nested - { - get { return GetString("ParseError_Helpers_Cannot_Be_Nested"); } - } - - /// - /// Helper blocks cannot be nested within each other. - /// - internal static string FormatParseError_Helpers_Cannot_Be_Nested() - { - return GetString("ParseError_Helpers_Cannot_Be_Nested"); - } - /// /// Parser was started with a null Context property. The Context property must be set BEFORE calling any methods on the parser. /// @@ -662,22 +598,6 @@ internal static string FormatParseError_ReservedWord(object p0) return string.Format(CultureInfo.CurrentCulture, GetString("ParseError_ReservedWord"), p0); } - /// - /// 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. - /// - internal static string ParseError_Unexpected_Character_At_Helper_Name_Start - { - get { return GetString("ParseError_Unexpected_Character_At_Helper_Name_Start"); } - } - - /// - /// 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. - /// - 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); - } - /// /// Cannot resume this symbol. Only the symbol immediately preceding the current one can be resumed. /// diff --git a/src/Microsoft.AspNet.Razor/RazorResources.resx b/src/Microsoft.AspNet.Razor/RazorResources.resx index ffcaec714..cb104d238 100644 --- a/src/Microsoft.AspNet.Razor/RazorResources.resx +++ b/src/Microsoft.AspNet.Razor/RazorResources.resx @@ -240,27 +240,12 @@ Instead, wrap the contents of the block in "{{}}": The {0} property of the {1} structure cannot be null. - - Expected a "{0}" after the helper parameters. - - - Expected a "{0}" after the helper name. - - - Helper parameter list is missing a closing ")". - - - Helper blocks cannot be nested within each other. - Parser was started with a null Context property. The Context property must be set BEFORE calling any methods on the parser. "{0}" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used. - - 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. - Cannot resume this symbol. Only the symbol immediately preceding the current one can be resumed. diff --git a/test/Microsoft.AspNet.Razor.Test/Framework/BlockTypes.cs b/test/Microsoft.AspNet.Razor.Test/Framework/BlockTypes.cs index 2b3b96717..17ae9ca15 100644 --- a/test/Microsoft.AspNet.Razor.Test/Framework/BlockTypes.cs +++ b/test/Microsoft.AspNet.Razor.Test/Framework/BlockTypes.cs @@ -110,31 +110,6 @@ public ExpressionBlock(IEnumerable children) } } - public class HelperBlock : Block - { - private const BlockType ThisBlockType = BlockType.Helper; - - public HelperBlock(IBlockCodeGenerator codeGenerator, IEnumerable children) - : base(ThisBlockType, children, codeGenerator) - { - } - - public HelperBlock(IBlockCodeGenerator codeGenerator, params SyntaxTreeNode[] children) - : this(codeGenerator, (IEnumerable)children) - { - } - - public HelperBlock(params SyntaxTreeNode[] children) - : this(BlockCodeGenerator.Null, children) - { - } - - public HelperBlock(IEnumerable children) - : this(BlockCodeGenerator.Null, children) - { - } - } - public class MarkupTagBlock : Block { private const BlockType ThisBlockType = BlockType.Tag; diff --git a/test/Microsoft.AspNet.Razor.Test/Generator/CSharpRazorCodeGeneratorTest.cs b/test/Microsoft.AspNet.Razor.Test/Generator/CSharpRazorCodeGeneratorTest.cs index 6a9d854d1..2996d75a0 100644 --- a/test/Microsoft.AspNet.Razor.Test/Generator/CSharpRazorCodeGeneratorTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Generator/CSharpRazorCodeGeneratorTest.cs @@ -75,11 +75,6 @@ public void ConstructorRequiresNonNullHost() [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 @@ public void CSharpCodeGeneratorCorrectlyGeneratesDesignTimePragmasMarkupAndExpre tabTest: TabTest.NoTabs, expectedDesignTimePragmas: new List() { - 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 @@ public void CSharpCodeGeneratorDoesNotRenderLinePragmasIfGenerateLinePragmasIsSe RunTest("NoLinePragmas", generatePragmas: false); } - [Fact] - public void CSharpCodeGeneratorRendersHelpersBlockCorrectlyWhenInstanceHelperRequested() - { - RunTest("Helpers", - baselineName: "Helpers.Instance", - hostConfig: host => - { - host.StaticHelpers = false; - - return host; - }); - } - [Fact] public void CSharpCodeGeneratorCorrectlyInstrumentsRazorCodeWhenInstrumentationRequested() { diff --git a/test/Microsoft.AspNet.Razor.Test/Generator/CSharpTagHelperRenderingTest.cs b/test/Microsoft.AspNet.Razor.Test/Generator/CSharpTagHelperRenderingTest.cs index 317301c0c..31c51b2ac 100644 --- a/test/Microsoft.AspNet.Razor.Test/Generator/CSharpTagHelperRenderingTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Generator/CSharpTagHelperRenderingTest.cs @@ -386,10 +386,8 @@ public void TagHelpers_Directive_GenerateDesignTimeMappings() }); } - [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 @@ public void TagHelpers_WithinHelpersAndSections_GeneratesExpectedOutput(string t }; // Act & Assert - RunTagHelperTest(testType, tagHelperDescriptors: tagHelperDescriptors); + RunTagHelperTest("TagHelpersInSection", tagHelperDescriptors: tagHelperDescriptors); } private static IEnumerable BuildPAndInputTagHelperDescriptors(string prefix) diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpAutoCompleteTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpAutoCompleteTest.cs index 4c12e71a8..99e57057a 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpAutoCompleteTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpAutoCompleteTest.cs @@ -33,27 +33,6 @@ public void FunctionsDirectiveAutoCompleteAtEOF() 1, 0, 1)); } - [Fact] - public void HelperDirectiveAutoCompleteAtEOF() - { - ParseBlockTest("@helper Strong(string value) {", - new HelperBlock(new HelperCodeGenerator(new LocationTagged("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 @@ public void FunctionsDirectiveAutoCompleteAtStartOfFile() 1, 0, 1)); } - [Fact] - public void HelperDirectiveAutoCompleteAtStartOfFile() - { - ParseBlockTest("@helper Strong(string value) {" + Environment.NewLine - + "

", - new HelperBlock(new HelperCodeGenerator(new LocationTagged("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("

").Accepts(AcceptedCharacters.None)), - new MarkupTagBlock( - Factory.Markup("

").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() { diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpDirectivesTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpDirectivesTest.cs index 0ca2be065..33e16708d 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpDirectivesTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpDirectivesTest.cs @@ -389,25 +389,5 @@ public void SectionDirective() Factory.MetaCode("}") .Accepts(AcceptedCharacters.None))); } - - [Fact] - public void HelperDirective() - { - ParseBlockTest("@helper Strong(string value) { foo(); }", - new HelperBlock(new HelperCodeGenerator(new LocationTagged("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))); - } } } diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpHelperTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpHelperTest.cs deleted file mode 100644 index 6051574b6..000000000 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpHelperTest.cs +++ /dev/null @@ -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("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("() {", 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.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(" ", 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("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("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("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 - + "

Foo

", - new MarkupBlock( - Factory.EmptyHtml(), - new HelperBlock(new HelperCodeGenerator(new LocationTagged("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("

").Accepts(AcceptedCharacters.None)), - Factory.Markup("Foo"), - new MarkupTagBlock( - Factory.Markup("

").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 - + "

@foo

" + Environment.NewLine - + "}", - new MarkupBlock( - Factory.EmptyHtml(), - new HelperBlock(new HelperCodeGenerator(new LocationTagged("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("

").Accepts(AcceptedCharacters.None)), - Factory.EmptyHtml(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("foo") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharacters.NonWhiteSpace)), - new MarkupTagBlock( - Factory.Markup("

").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 - + "

@foo

" + Environment.NewLine - + "}", - new MarkupBlock( - Factory.EmptyHtml(), - new HelperBlock(new HelperCodeGenerator(new LocationTagged("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("

").Accepts(AcceptedCharacters.None)), - Factory.EmptyHtml(), - new ExpressionBlock( - Factory.CodeTransition(), - Factory.Code("foo") - .AsImplicitExpression(CSharpCodeParser.DefaultKeywords) - .Accepts(AcceptedCharacters.NonWhiteSpace)), - new MarkupTagBlock( - Factory.Markup("

").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("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("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("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) - }); - } - } -} diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/PartialParsing/CSharpPartialParsingTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/PartialParsing/CSharpPartialParsingTest.cs index 7e2ba59aa..ba0edbc80 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/PartialParsing/CSharpPartialParsingTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/PartialParsing/CSharpPartialParsingTest.cs @@ -624,12 +624,6 @@ public void ImplicitExpressionCorrectlyTriggersReparseIfInheritsKeywordTyped() RunTypeKeywordTest("inherits"); } - [Fact] - public void ImplicitExpressionCorrectlyTriggersReparseIfHelperKeywordTyped() - { - RunTypeKeywordTest("helper"); - } - [Fact] public void ImplicitExpressionCorrectlyTriggersReparseIfFunctionsKeywordTyped() { diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/DesignTime.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/DesignTime.cs index b99092ae5..3bf505381 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/DesignTime.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/DesignTime.cs @@ -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 diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Helpers.Instance.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Helpers.Instance.cs deleted file mode 100644 index e43d406a0..000000000 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Helpers.Instance.cs +++ /dev/null @@ -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, " "); - 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, "\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, " "); - 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, "\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 - } -} diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Helpers.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Helpers.cs deleted file mode 100644 index 3d7cad04b..000000000 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Helpers.cs +++ /dev/null @@ -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, " "); - 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, "\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, " "); - 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, "\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 - } -} diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingCloseParen.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingCloseParen.cs deleted file mode 100644 index 891889be6..000000000 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingCloseParen.cs +++ /dev/null @@ -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, " "); - 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, "\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 - } -} diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingOpenBrace.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingOpenBrace.cs deleted file mode 100644 index b29b6abb4..000000000 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingOpenBrace.cs +++ /dev/null @@ -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, " "); - 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, "\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 - } -} diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingOpenParen.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingOpenParen.cs deleted file mode 100644 index 8472cdf44..000000000 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/HelpersMissingOpenParen.cs +++ /dev/null @@ -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, " "); - 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, "\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 - } -} diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/InlineBlocks.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/InlineBlocks.cs index 254f7a0df..85f3739ca 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/InlineBlocks.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/InlineBlocks.cs @@ -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 default -#line hidden - return new Template((__razor_helper_writer) => { -#line 1 "InlineBlocks.cshtml" - - -#line default -#line hidden + #line hidden + public InlineBlocks() + { + } - Instrumentation.BeginContext(29, 6, true); - WriteLiteralTo(__razor_helper_writer, " { + } + ); + Instrumentation.BeginContext(13, 23, true); + WriteLiteral("(string link) {\r\n (new Template((__razor_attribute_value_writer) => { + WriteAttribute("href", Tuple.Create(" href=\"", 36), Tuple.Create("\"", 94), + Tuple.Create(Tuple.Create("", 43), Tuple.Create(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 @@ public static Template #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 @@ public static Template #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 } diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Instrumented.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Instrumented.cs index 6c56ceb2e..3e2161028 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Instrumented.cs +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Instrumented.cs @@ -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, " "); - 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, "\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 @@ public Instrumented() #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 @@ public override async Task ExecuteAsync() #line hidden item => new Template((__razor_template_writer) => { - Instrumentation.BeginContext(93, 10, true); + Instrumentation.BeginContext(35, 10, true); WriteLiteralTo(__razor_template_writer, "

Bar

"); 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

Hello, World

\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("

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("

\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("

We wrote 10 lines!

\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("

No really, we wrote 10 lines!

\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("

Actually, we didn\'t...

\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("

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("

\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("

That time, we wrote 5 lines!

\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("

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("

\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("

This block is locked, for your security!

\r\n"); Instrumentation.EndContext(); -#line 42 "Instrumented.cshtml" +#line 38 "Instrumented.cshtml" } #line default diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/NestedHelpers.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/NestedHelpers.cs deleted file mode 100644 index ece6e9d69..000000000 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/NestedHelpers.cs +++ /dev/null @@ -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, " "); - 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, "\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, " "); - 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, "\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 - } -} diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/TagHelpersInHelper.cs b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/TagHelpersInHelper.cs deleted file mode 100644 index 2cb75d699..000000000 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/TagHelpersInHelper.cs +++ /dev/null @@ -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, "
\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(); - __tagHelperExecutionContext.Add(__NestedTagHelper); - __tagHelperExecutionContext.Output = __tagHelperRunner.RunAsync(__tagHelperExecutionContext).Result; - WriteTagHelperAsync(__tagHelperExecutionContext).Wait(); - __tagHelperExecutionContext = __tagHelperScopeManager.End(); - WriteLiteral("\r\n "); - } - , StartTagHelperWritingScope, EndTagHelperWritingScope); - __MyTagHelper = CreateTagHelper(); - __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
\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(); - __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(); - __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 - } -} diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/DesignTime.cshtml b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/DesignTime.cshtml index 581b164dc..5dcaeebdb 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/DesignTime.cshtml +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/DesignTime.cshtml @@ -12,10 +12,4 @@ @section Footer {

Foo

@bar -} - -@helper Foo() { - if(true) { -

Foo

- } } \ No newline at end of file diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/Helpers.cshtml b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/Helpers.cshtml deleted file mode 100644 index 7ad443fe9..000000000 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/Helpers.cshtml +++ /dev/null @@ -1,11 +0,0 @@ -@helper Bold(string s) { - s = s.ToUpper(); - @s -} - -@helper Italic(string s) { - s = s.ToUpper(); - @s -} - -@Bold("Hello") \ No newline at end of file diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/HelpersMissingCloseParen.cshtml b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/HelpersMissingCloseParen.cshtml deleted file mode 100644 index e787dea27..000000000 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/HelpersMissingCloseParen.cshtml +++ /dev/null @@ -1,7 +0,0 @@ -@helper Bold(string s) { - s = s.ToUpper(); - @s -} - -@helper Italic(string s -@Bold("Hello") \ No newline at end of file diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/HelpersMissingOpenBrace.cshtml b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/HelpersMissingOpenBrace.cshtml deleted file mode 100644 index b9702e38a..000000000 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/HelpersMissingOpenBrace.cshtml +++ /dev/null @@ -1,7 +0,0 @@ -@helper Bold(string s) { - s = s.ToUpper(); - @s -} - -@helper Italic(string s) -@Italic(s) \ No newline at end of file diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/HelpersMissingOpenParen.cshtml b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/HelpersMissingOpenParen.cshtml deleted file mode 100644 index f3825f7e9..000000000 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/HelpersMissingOpenParen.cshtml +++ /dev/null @@ -1,7 +0,0 @@ -@helper Bold(string s) { - s = s.ToUpper(); - @s -} - -@helper Italic -@Bold("Hello") \ No newline at end of file diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/InlineBlocks.cshtml b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/InlineBlocks.cshtml index 0a8b3d8f4..2a4ba7216 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/InlineBlocks.cshtml +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/InlineBlocks.cshtml @@ -1,3 +1,3 @@ -@helper Link(string link) { +@section Link(string link) { } \ No newline at end of file diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/Instrumented.cshtml b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/Instrumented.cshtml index 4d9b03eb8..bd273c57e 100644 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/Instrumented.cshtml +++ b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/Instrumented.cshtml @@ -1,8 +1,4 @@ -@helper Strong(string s) { - @s -} - -@{ +@{ int i = 1; var foo = @

Bar

; @:Hello, World diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/NestedHelpers.cshtml b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/NestedHelpers.cshtml deleted file mode 100644 index 63158ff0e..000000000 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/NestedHelpers.cshtml +++ /dev/null @@ -1,10 +0,0 @@ -@helper Italic(string s) { - s = s.ToUpper(); - @helper Bold(string s) { - s = s.ToUpper(); - @s - } - @Bold(s) -} - -@Italic("Hello") \ No newline at end of file diff --git a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/TagHelpersInHelper.cshtml b/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/TagHelpersInHelper.cshtml deleted file mode 100644 index 57f8f18a6..000000000 --- a/test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/TagHelpersInHelper.cshtml +++ /dev/null @@ -1,12 +0,0 @@ -@addTagHelper "something, nice" - -@helper MyHelper(string val) -{ -
- - In None ContentBehavior. - Some buffered values with a value of @val - -
-} -@MyHelper(@Custom Value)