From 4e2cd0c2d61fda22f4a789db2021afca2acf6e9f Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Fri, 14 Apr 2017 17:15:48 -0700 Subject: [PATCH] Finish writer implementation of the remaining IR nodes and added tests - SetTagHelperPropertyIRNode - ChecksumIRNode - UsingStatementIRNode - Preallocated attributes target extension - HtmlAttributeIRNode and friends - Design time directive helper target extension - Removed renderers and rendering conventions - Regenerated IR baselines Issue - #846 and #1051 --- .../CodeGeneration/BasicWriter.cs | 8 + .../CSharpLiteralCodeConventions.cs | 16 - .../CSharpRedirectRenderingConventions.cs | 28 - .../CodeGeneration/CSharpRenderingContext.cs | 53 +- .../CSharpRenderingConventions.cs | 27 - .../CodeGeneration/DefaultDocumentWriter.cs | 57 ++- .../CodeGeneration/DefaultRuntimeTarget.cs | 12 +- .../CodeGeneration/DesignTimeBasicWriter.cs | 33 +- .../DesignTimeCSharpRenderer.cs | 373 -------------- .../DesignTimeDirectiveTargetExtension.cs | 134 +++++ .../DesignTimeTagHelperWriter.cs | 149 +++++- .../IDesignTimeDirectiveTargetExtension.cs | 12 + .../IPreallocatedAttributeTargetExtension.cs | 18 + .../LiteralRuntimeBasicWriter.cs | 10 + .../PageStructureCSharpRenderer.cs | 102 ---- .../PreallocatedAttributeTargetExtension.cs | 108 ++++ .../RedirectedRuntimeBasicWriter.cs | 120 ++++- .../RedirectedRuntimeTagHelperWriter.cs | 2 +- .../CodeGeneration/RuntimeBasicWriter.cs | 155 +++++- .../CodeGeneration/RuntimeCSharpRenderer.cs | 483 ------------------ .../CodeGeneration/RuntimeTagHelperWriter.cs | 174 ++++++- ...HelperHtmlAttributeRenderingConventions.cs | 16 - ...agHelperHtmlAttributeRuntimeBasicWriter.cs | 3 +- .../CodeGeneration/TemplateTargetExtension.cs | 5 - ...reallocatedTagHelperHtmlAttributeIRNode.cs | 18 +- ...arePreallocatedTagHelperAttributeIRNode.cs | 17 +- ...reallocatedTagHelperHtmlAttributeIRNode.cs | 17 +- .../Intermediate/DesignTimeDirectiveIRNode.cs | 34 ++ .../Intermediate/DirectiveTokenIRNode.cs | 2 +- .../Intermediate/RazorIRNodeVisitor.cs | 20 - .../SetPreallocatedTagHelperPropertyIRNode.cs | 17 +- .../RazorDesignTimeIRPass.cs | 70 +-- .../RazorEngine.cs | 7 + .../Basic_DesignTime.ir.txt | 10 +- .../InjectWithModel_DesignTime.ir.txt | 10 +- .../InjectWithSemicolon_DesignTime.ir.txt | 10 +- .../Inject_DesignTime.ir.txt | 10 +- .../MalformedPageDirective_DesignTime.ir.txt | 10 +- ...ModelExpressionTagHelper_DesignTime.ir.txt | 10 +- .../Model_DesignTime.ir.txt | 10 +- .../MultipleModels_DesignTime.ir.txt | 10 +- .../PageWithNamespace_DesignTime.ir.txt | 10 +- .../RazorPagesWithoutModel_DesignTime.ir.txt | 10 +- .../RazorPages_DesignTime.ir.txt | 10 +- .../ViewWithNamespace_DesignTime.ir.txt | 10 +- .../_ViewImports_DesignTime.ir.txt | 10 +- .../DefaultDocumentWriterTest.cs | 11 +- .../DesignTimeBasicWriterTest.cs | 66 +++ .../DesignTimeDirectiveTargetExtensionTest.cs | 258 ++++++++++ .../DesignTimeTagHelperWriterTest.cs | 219 +++++++- .../LiteralRuntimeBasicWriterTest.cs | 50 ++ ...reallocatedAttributeTargetExtensionTest.cs | 207 ++++++++ .../RedirectedRuntimeBasicWriterTest.cs | 152 +++++- .../RedirectedRuntimeTagHelperWriterTest.cs | 4 +- .../CodeGeneration/RuntimeBasicWriterTest.cs | 263 ++++++++++ .../RuntimeTagHelperWriterTest.cs | 263 +++++++--- ...lperHtmlAttributeRuntimeBasicWriterTest.cs | 135 +++++ .../TemplateTargetExtensionTest.cs | 3 +- .../AddTagHelperDirective_DesignTime.ir.txt | 10 +- ...ibuteTargetingTagHelpers_DesignTime.ir.txt | 10 +- .../Await_DesignTime.ir.txt | 10 +- .../BasicImports_DesignTime.ir.txt | 10 +- .../BasicTagHelpers_DesignTime.ir.txt | 10 +- ...BasicTagHelpers_Prefixed_DesignTime.ir.txt | 10 +- .../Blocks_DesignTime.ir.txt | 10 +- .../CSharp7_DesignTime.ir.txt | 10 +- .../CodeBlockAtEOF_DesignTime.ir.txt | 10 +- ...CodeBlockWithTextElement_DesignTime.ir.txt | 10 +- .../CodeBlock_DesignTime.ir.txt | 10 +- .../ComplexTagHelpers_DesignTime.ir.txt | 10 +- .../ConditionalAttributes_DesignTime.ir.txt | 10 +- .../DesignTime_DesignTime.ir.txt | 10 +- ...icateAttributeTagHelpers_DesignTime.ir.txt | 10 +- ...namicAttributeTagHelpers_DesignTime.ir.txt | 10 +- ...EmptyAttributeTagHelpers_DesignTime.ir.txt | 10 +- .../EmptyCodeBlock_DesignTime.ir.txt | 10 +- .../EmptyExplicitExpression_DesignTime.ir.txt | 10 +- ...ImplicitExpressionInCode_DesignTime.ir.txt | 10 +- .../EmptyImplicitExpression_DesignTime.ir.txt | 10 +- .../EnumTagHelpers_DesignTime.ir.txt | 10 +- .../EscapedTagHelpers_DesignTime.ir.txt | 10 +- .../ExplicitExpressionAtEOF_DesignTime.ir.txt | 10 +- ...icitExpressionWithMarkup_DesignTime.ir.txt | 10 +- .../ExplicitExpression_DesignTime.ir.txt | 10 +- .../ExpressionsInCode_DesignTime.ir.txt | 10 +- .../FunctionsBlockMinimal_DesignTime.ir.txt | 10 +- .../FunctionsBlock_DesignTime.ir.txt | 10 +- .../HiddenSpansInCode_DesignTime.ir.txt | 10 +- ...lCommentWithQuote_Double_DesignTime.ir.txt | 10 +- ...lCommentWithQuote_Single_DesignTime.ir.txt | 10 +- .../ImplicitExpressionAtEOF_DesignTime.ir.txt | 10 +- .../ImplicitExpression_DesignTime.ir.txt | 10 +- .../IncompleteTagHelper_DesignTime.ir.txt | 10 +- .../Inherits_DesignTime.ir.txt | 10 +- .../InlineBlocks_DesignTime.ir.txt | 10 +- .../Instrumented_DesignTime.ir.txt | 10 +- .../MarkupInCodeBlock_DesignTime.ir.txt | 10 +- .../MinimizedTagHelpers_DesignTime.ir.txt | 10 +- .../NestedCSharp_DesignTime.ir.txt | 10 +- .../NestedCodeBlocks_DesignTime.ir.txt | 10 +- ...estedScriptTagTagHelpers_DesignTime.ir.txt | 10 +- .../NestedTagHelpers_DesignTime.ir.txt | 10 +- .../NoLinePragmas_DesignTime.ir.txt | 10 +- ...llConditionalExpressions_DesignTime.ir.txt | 10 +- .../OpenedIf_DesignTime.ir.txt | 10 +- .../ParserError_DesignTime.ir.txt | 10 +- ...fixedAttributeTagHelpers_DesignTime.ir.txt | 10 +- .../RazorComments_DesignTime.ir.txt | 10 +- ...RemoveTagHelperDirective_DesignTime.ir.txt | 10 +- .../Sections_DesignTime.ir.txt | 10 +- .../SimpleTagHelpers_DesignTime.ir.txt | 10 +- .../SimpleUnspacedIf_DesignTime.ir.txt | 10 +- ...hNewlineBeforeAttributes_DesignTime.ir.txt | 10 +- .../SingleTagHelper_DesignTime.ir.txt | 10 +- .../StringLiterals_DesignTime.ir.txt | 10 +- .../SymbolBoundAttributes_DesignTime.ir.txt | 10 +- ...lpersWithBoundAttributes_DesignTime.ir.txt | 10 +- .../TagHelpersWithPrefix_DesignTime.ir.txt | 10 +- .../TagHelpersWithTemplate_DesignTime.ir.txt | 10 +- ...hWeirdlySpacedAttributes_DesignTime.ir.txt | 10 +- .../Templates.cshtml | 5 + .../Templates_DesignTime.codegen.cs | 47 +- .../Templates_DesignTime.ir.txt | 227 ++++---- .../Templates_DesignTime.mappings.txt | 97 ++-- .../Templates_Runtime.codegen.cs | 54 +- .../Templates_Runtime.ir.txt | 223 ++++---- ...onsInTagHelperAttributes_DesignTime.ir.txt | 10 +- ...finishedExpressionInCode_DesignTime.ir.txt | 10 +- .../Usings_DesignTime.ir.txt | 10 +- .../NamespaceToken.ir.txt | 10 +- .../IntegrationTests/RazorIRNodeWriter.cs | 36 +- 131 files changed, 3101 insertions(+), 2309 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpLiteralCodeConventions.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpRedirectRenderingConventions.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpRenderingConventions.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeCSharpRenderer.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeDirectiveTargetExtension.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/IDesignTimeDirectiveTargetExtension.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/IPreallocatedAttributeTargetExtension.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/LiteralRuntimeBasicWriter.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/PageStructureCSharpRenderer.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/PreallocatedAttributeTargetExtension.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeCSharpRenderer.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/TagHelperHtmlAttributeRenderingConventions.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/Intermediate/DesignTimeDirectiveIRNode.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DesignTimeDirectiveTargetExtensionTest.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/LiteralRuntimeBasicWriterTest.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/PreallocatedAttributeTargetExtensionTest.cs create mode 100644 test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/TagHelperHtmlAttributeRuntimeBasicWriterTest.cs diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/BasicWriter.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/BasicWriter.cs index a1f4dfcfbe..aa7ff41d8f 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/BasicWriter.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/BasicWriter.cs @@ -7,6 +7,10 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration { public abstract class BasicWriter { + public abstract void WriteChecksum(CSharpRenderingContext context, ChecksumIRNode node); + + public abstract void WriteUsingStatement(CSharpRenderingContext context, UsingStatementIRNode node); + public abstract void WriteCSharpExpression(CSharpRenderingContext context, CSharpExpressionIRNode node); public abstract void WriteCSharpStatement(CSharpRenderingContext context, CSharpStatementIRNode node); @@ -14,5 +18,9 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration public abstract void WriteHtmlContent(CSharpRenderingContext context, HtmlContentIRNode node); public abstract void WriteHtmlAttribute(CSharpRenderingContext context, HtmlAttributeIRNode node); + + public abstract void WriteHtmlAttributeValue(CSharpRenderingContext context, HtmlAttributeValueIRNode node); + + public abstract void WriteCSharpAttributeValue(CSharpRenderingContext context, CSharpAttributeValueIRNode node); } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpLiteralCodeConventions.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpLiteralCodeConventions.cs deleted file mode 100644 index 192d1702ef..0000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpLiteralCodeConventions.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.AspNetCore.Razor.Language.Legacy; - -namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration -{ - internal class CSharpLiteralCodeConventions : CSharpRenderingConventions - { - public CSharpLiteralCodeConventions(CSharpCodeWriter writer) : base(writer) - { - } - - public override string StartWriteMethod => StartWriteLiteralMethod; - } -} diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpRedirectRenderingConventions.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpRedirectRenderingConventions.cs deleted file mode 100644 index 9778c6ef34..0000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpRedirectRenderingConventions.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.AspNetCore.Razor.Language.Legacy; - -namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration -{ - internal class CSharpRedirectRenderingConventions : CSharpRenderingConventions - { - public CSharpRedirectRenderingConventions(string redirectWriter, CSharpCodeWriter writer) - : base(writer) - { - RedirectWriter = redirectWriter; - } - - public string RedirectWriter { get; } - - public override string StartWriteMethod => "WriteTo(" + RedirectWriter + ", " /* ORIGINAL: WriteToMethodName */; - - public override string StartWriteLiteralMethod => "WriteLiteralTo(" + RedirectWriter + ", " /* ORIGINAL: WriteLiteralToMethodName */; - - public override string StartBeginWriteAttributeMethod => "BeginWriteAttributeTo(" + RedirectWriter + ", " /* ORIGINAL: BeginWriteAttributeToMethodName */; - - public override string StartWriteAttributeValueMethod => "WriteAttributeValueTo(" + RedirectWriter + ", " /* ORIGINAL: WriteAttributeValueToMethodName */; - - public override string StartEndWriteAttributeMethod => "EndWriteAttributeTo(" + RedirectWriter /* ORIGINAL: EndWriteAttributeToMethodName */; - } -} diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpRenderingContext.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpRenderingContext.cs index 8a91ec03b3..45b23a94a1 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpRenderingContext.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpRenderingContext.cs @@ -10,8 +10,6 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration { public class CSharpRenderingContext { - private CSharpRenderingConventions _renderingConventions; - internal ICollection Directives { get; set; } internal Func IdGenerator { get; set; } = () => Guid.NewGuid().ToString("N"); @@ -20,23 +18,6 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration public CSharpCodeWriter Writer { get; set; } - internal CSharpRenderingConventions RenderingConventions - { - get - { - if (_renderingConventions == null) - { - _renderingConventions = new CSharpRenderingConventions(Writer); - } - - return _renderingConventions; - } - set - { - _renderingConventions = value; - } - } - internal IList Diagnostics { get; } = new List(); internal RazorCodeDocument CodeDocument { get; set; } @@ -101,6 +82,18 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration return scope; } + public TagHelperRenderingContextScope Push(TagHelperRenderingContext context) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + var scope = new TagHelperRenderingContextScope(this, TagHelperRenderingContext); + TagHelperRenderingContext = context; + return scope; + } + public struct BasicWriterScope : IDisposable { private readonly CSharpRenderingContext _context; @@ -154,5 +147,27 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration _context.TagHelperWriter = _writer; } } + + public struct TagHelperRenderingContextScope : IDisposable + { + private readonly CSharpRenderingContext _context; + private readonly TagHelperRenderingContext _renderingContext; + + public TagHelperRenderingContextScope(CSharpRenderingContext context, TagHelperRenderingContext renderingContext) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + _context = context; + _renderingContext = renderingContext; + } + + public void Dispose() + { + _context.TagHelperRenderingContext = _renderingContext; + } + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpRenderingConventions.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpRenderingConventions.cs deleted file mode 100644 index cf3cedfce9..0000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpRenderingConventions.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.AspNetCore.Razor.Language.Legacy; - -namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration -{ - internal class CSharpRenderingConventions - { - public CSharpRenderingConventions(CSharpCodeWriter writer) - { - Writer = writer; - } - - protected CSharpCodeWriter Writer { get; } - - public virtual string StartWriteMethod => "Write(" /* ORIGINAL: WriteMethodName */; - - public virtual string StartWriteLiteralMethod => "WriteLiteral(" /* ORIGINAL: WriteLiteralMethodName */; - - public virtual string StartBeginWriteAttributeMethod => "BeginWriteAttribute(" /* ORIGINAL: BeginWriteAttributeMethodName */; - - public virtual string StartWriteAttributeValueMethod => "WriteAttributeValue(" /* ORIGINAL: WriteAttributeValueMethodName */; - - public virtual string StartEndWriteAttributeMethod => "EndWriteAttribute(" /* ORIGINAL: EndWriteAttributeMethodName */; - } -} diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DefaultDocumentWriter.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DefaultDocumentWriter.cs index 79e00379f8..2699bfcbdf 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DefaultDocumentWriter.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DefaultDocumentWriter.cs @@ -10,9 +10,8 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration { private readonly CSharpRenderingContext _context; private readonly RuntimeTarget _target; - private readonly PageStructureCSharpRenderer _renderer; - public DefaultDocumentWriter(RuntimeTarget target, CSharpRenderingContext context, PageStructureCSharpRenderer renderer) + public DefaultDocumentWriter(RuntimeTarget target, CSharpRenderingContext context) { if (target == null) { @@ -24,14 +23,8 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration throw new ArgumentNullException(nameof(context)); } - if (renderer == null) - { - throw new ArgumentNullException(nameof(renderer)); - } - _target = target; _context = context; - _renderer = renderer; } public override void WriteDocument(DocumentIRNode node) @@ -41,7 +34,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration throw new ArgumentNullException(nameof(node)); } - var visitor = new Visitor(_target, _context, _renderer); + var visitor = new Visitor(_target, _context); _context.RenderChildren = visitor.RenderChildren; _context.RenderNode = visitor.Visit; @@ -56,13 +49,11 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration { private readonly CSharpRenderingContext _context; private readonly RuntimeTarget _target; - private readonly PageStructureCSharpRenderer _renderer; - public Visitor(RuntimeTarget target, CSharpRenderingContext context, PageStructureCSharpRenderer renderer) + public Visitor(RuntimeTarget target, CSharpRenderingContext context) { _target = target; _context = context; - _renderer = renderer; } private CSharpRenderingContext Context => _context; @@ -81,6 +72,16 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration RenderChildren(node); } + public override void VisitChecksum(ChecksumIRNode node) + { + Context.BasicWriter.WriteChecksum(Context, node); + } + + public override void VisitUsingStatement(UsingStatementIRNode node) + { + Context.BasicWriter.WriteUsingStatement(Context, node); + } + public override void VisitNamespace(NamespaceDeclarationIRNode node) { Context.Writer @@ -188,6 +189,21 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration Context.BasicWriter.WriteCSharpStatement(Context, node); } + public override void VisitHtmlAttribute(HtmlAttributeIRNode node) + { + Context.BasicWriter.WriteHtmlAttribute(Context, node); + } + + public override void VisitHtmlAttributeValue(HtmlAttributeValueIRNode node) + { + Context.BasicWriter.WriteHtmlAttributeValue(Context, node); + } + + public override void VisitCSharpAttributeValue(CSharpAttributeValueIRNode node) + { + Context.BasicWriter.WriteCSharpAttributeValue(Context, node); + } + public override void VisitHtml(HtmlContentIRNode node) { Context.BasicWriter.WriteHtmlContent(Context, node); @@ -200,10 +216,10 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration public override void VisitTagHelper(TagHelperIRNode node) { - var initialRenderingContext = Context.TagHelperRenderingContext; - Context.TagHelperRenderingContext = new TagHelperRenderingContext(); - Context.RenderChildren(node); - Context.TagHelperRenderingContext = initialRenderingContext; + using (Context.Push(new TagHelperRenderingContext())) + { + Context.RenderChildren(node); + } } public override void VisitInitializeTagHelperStructure(InitializeTagHelperStructureIRNode node) @@ -221,6 +237,11 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration Context.TagHelperWriter.WriteAddTagHelperHtmlAttribute(Context, node); } + public override void VisitSetTagHelperProperty(SetTagHelperPropertyIRNode node) + { + Context.TagHelperWriter.WriteSetTagHelperProperty(Context, node); + } + public override void VisitExecuteTagHelpers(ExecuteTagHelpersIRNode node) { Context.TagHelperWriter.WriteExecuteTagHelpers(Context, node); @@ -228,9 +249,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration public override void VisitDefault(RazorIRNode node) { - // This is a temporary bridge to the renderer, which allows us to move functionality piecemeal - // into this class. - _renderer.Visit(node); + Context.RenderChildren(node); } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DefaultRuntimeTarget.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DefaultRuntimeTarget.cs index 674d07b16e..548311cc56 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DefaultRuntimeTarget.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DefaultRuntimeTarget.cs @@ -21,17 +21,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration public override DocumentWriter CreateWriter(CSharpRenderingContext context) { - PageStructureCSharpRenderer renderer; - if (_options.DesignTimeMode) - { - renderer = new DesignTimeCSharpRenderer(this, context); - } - else - { - renderer = new RuntimeCSharpRenderer(this, context); - } - - return new DefaultDocumentWriter(this, context, renderer); + return new DefaultDocumentWriter(this, context); } public override TExtension GetExtension() diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeBasicWriter.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeBasicWriter.cs index 6920605193..02e446479f 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeBasicWriter.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeBasicWriter.cs @@ -8,6 +8,27 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration { public class DesignTimeBasicWriter : BasicWriter { + public override void WriteChecksum(CSharpRenderingContext context, ChecksumIRNode node) + { + // Do nothing + } + + public override void WriteUsingStatement(CSharpRenderingContext context, UsingStatementIRNode node) + { + if (node.Source.HasValue) + { + using (context.Writer.BuildLinePragma(node.Source.Value)) + { + context.AddLineMappingFor(node); + context.Writer.WriteUsing(node.Content); + } + } + else + { + context.Writer.WriteUsing(node.Content); + } + } + public override void WriteCSharpExpression(CSharpRenderingContext context, CSharpExpressionIRNode node) { if (context == null) @@ -124,7 +145,17 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration public override void WriteHtmlAttribute(CSharpRenderingContext context, HtmlAttributeIRNode node) { - throw new NotImplementedException(); + context.RenderChildren(node); + } + + public override void WriteHtmlAttributeValue(CSharpRenderingContext context, HtmlAttributeValueIRNode node) + { + context.RenderChildren(node); + } + + public override void WriteCSharpAttributeValue(CSharpRenderingContext context, CSharpAttributeValueIRNode node) + { + context.RenderChildren(node); } public override void WriteHtmlContent(CSharpRenderingContext context, HtmlContentIRNode node) diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeCSharpRenderer.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeCSharpRenderer.cs deleted file mode 100644 index 0992f46ed7..0000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeCSharpRenderer.cs +++ /dev/null @@ -1,373 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Linq; -using System.Text; -using Microsoft.AspNetCore.Razor.Language.Intermediate; -using Microsoft.AspNetCore.Razor.Language.Legacy; - -namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration -{ - internal class DesignTimeCSharpRenderer : PageStructureCSharpRenderer - { - public DesignTimeCSharpRenderer(RuntimeTarget target, CSharpRenderingContext context) - : base(target, context) - { - } - - public override void VisitCSharpExpression(CSharpExpressionIRNode node) - { - // We can't remove this yet, because it's still used recursively in a few places. - if (node.Children.Count == 0) - { - return; - } - - if (node.Source != null) - { - using (Context.Writer.BuildLinePragma(node.Source.Value)) - { - var offset = RazorDesignTimeIRPass.DesignTimeVariable.Length + " = ".Length; - var padding = BuildOffsetPadding(offset, node.Source.Value, Context); - - Context.Writer - .Write(padding) - .WriteStartAssignment(RazorDesignTimeIRPass.DesignTimeVariable); - - for (var i = 0; i < node.Children.Count; i++) - { - var token = node.Children[i] as RazorIRToken; - if (token != null && token.IsCSharp) - { - Context.AddLineMappingFor(token); - Context.Writer.Write(token.Content); - } - else - { - // There may be something else inside the expression like a Template or another extension node. - Visit(node.Children[i]); - } - } - - Context.Writer.WriteLine(";"); - } - } - else - { - Context.Writer.WriteStartAssignment(RazorDesignTimeIRPass.DesignTimeVariable); - VisitDefault(node); - Context.Writer.WriteLine(";"); - } - } - - public override void VisitUsingStatement(UsingStatementIRNode node) - { - if (node.Source.HasValue) - { - using (Context.Writer.BuildLinePragma(node.Source.Value)) - { - Context.AddLineMappingFor(node); - Context.Writer.WriteUsing(node.Content); - } - } - else - { - Context.Writer.WriteUsing(node.Content); - } - } - - public override void VisitCSharpStatement(CSharpStatementIRNode node) - { - // We can't remove this yet, because it's still used recursively in a few places. - var isWhitespaceStatement = true; - for (var i = 0; i < node.Children.Count; i++) - { - var token = node.Children[i] as RazorIRToken; - if (token == null || !string.IsNullOrWhiteSpace(token.Content)) - { - isWhitespaceStatement = false; - break; - } - } - - IDisposable linePragmaScope = null; - if (node.Source != null) - { - if (!isWhitespaceStatement) - { - linePragmaScope = Context.Writer.BuildLinePragma(node.Source.Value); - } - - var padding = BuildOffsetPadding(0, node.Source.Value, Context); - Context.Writer.Write(padding); - } - else if (isWhitespaceStatement) - { - // Don't write whitespace if there is no line mapping for it. - return; - } - - for (var i = 0; i < node.Children.Count; i++) - { - if (node.Children[i] is RazorIRToken token && token.IsCSharp) - { - Context.AddLineMappingFor(token); - Context.Writer.Write(token.Content); - } - else - { - // There may be something else inside the statement like an extension node. - Visit(node.Children[i]); - } - } - - if (linePragmaScope != null) - { - linePragmaScope.Dispose(); - } - else - { - Context.Writer.WriteLine(); - } - } - - public override void VisitDirectiveToken(DirectiveTokenIRNode node) - { - const string TypeHelper = "__typeHelper"; - - var tokenKind = node.Descriptor.Kind; - if (!node.Source.HasValue || - !string.Equals( - Context.SourceDocument.FileName, - node.Source.Value.FilePath, - StringComparison.OrdinalIgnoreCase)) - { - // We don't want to handle directives from imports. - return; - } - - // Wrap the directive token in a lambda to isolate variable names. - Context.Writer - .Write("((") - .Write(typeof(Action).FullName) - .Write(")("); - using (Context.Writer.BuildLambda(endLine: false)) - { - var originalIndent = Context.Writer.CurrentIndent; - Context.Writer.ResetIndent(); - switch (tokenKind) - { - case DirectiveTokenKind.Type: - - // {node.Content} __typeHelper = null; - - Context.AddLineMappingFor(node); - Context.Writer - .Write(node.Content) - .Write(" ") - .WriteStartAssignment(TypeHelper) - .WriteLine("null;"); - break; - - case DirectiveTokenKind.Member: - - // global::System.Object {node.content} = null; - - Context.Writer - .Write("global::") - .Write(typeof(object).FullName) - .Write(" "); - - Context.AddLineMappingFor(node); - Context.Writer - .Write(node.Content) - .WriteLine(" = null;"); - break; - - case DirectiveTokenKind.Namespace: - - // global::System.Object __typeHelper = nameof({node.Content}); - - Context.Writer - .Write("global::") - .Write(typeof(object).FullName) - .Write(" ") - .WriteStartAssignment(TypeHelper); - - Context.Writer.Write("nameof("); - - Context.AddLineMappingFor(node); - Context.Writer - .Write(node.Content) - .WriteLine(");"); - break; - - case DirectiveTokenKind.String: - - // global::System.Object __typeHelper = "{node.Content}"; - - Context.Writer - .Write("global::") - .Write(typeof(object).FullName) - .Write(" ") - .WriteStartAssignment(TypeHelper); - - if (node.Content.StartsWith("\"", StringComparison.Ordinal)) - { - Context.AddLineMappingFor(node); - Context.Writer.Write(node.Content); - } - else - { - Context.Writer.Write("\""); - Context.AddLineMappingFor(node); - Context.Writer - .Write(node.Content) - .Write("\""); - } - - Context.Writer.WriteLine(";"); - break; - } - Context.Writer.SetIndent(originalIndent); - } - Context.Writer.WriteLine("))();"); - } - - public override void VisitSetTagHelperProperty(SetTagHelperPropertyIRNode node) - { - var tagHelperVariableName = GetTagHelperVariableName(node.TagHelperTypeName); - var tagHelperRenderingContext = Context.TagHelperRenderingContext; - var propertyValueAccessor = GetTagHelperPropertyAccessor(node.IsIndexerNameMatch, tagHelperVariableName, node.AttributeName, node.Descriptor); - - if (tagHelperRenderingContext.RenderedBoundAttributes.TryGetValue(node.AttributeName, out string previousValueAccessor)) - { - Context.Writer - .WriteStartAssignment(propertyValueAccessor) - .Write(previousValueAccessor) - .WriteLine(";"); - - return; - } - else - { - tagHelperRenderingContext.RenderedBoundAttributes[node.AttributeName] = propertyValueAccessor; - } - - if (node.Descriptor.IsStringProperty || (node.IsIndexerNameMatch && node.Descriptor.IsIndexerStringProperty)) - { - VisitDefault(node); - - Context.Writer.WriteStartAssignment(propertyValueAccessor); - if (node.Children.Count == 1 && node.Children.First() is HtmlContentIRNode htmlNode) - { - var content = GetContent(htmlNode); - Context.Writer.WriteStringLiteral(content); - } - else - { - Context.Writer.Write("string.Empty"); - } - Context.Writer.WriteLine(";"); - } - else - { - var firstMappedChild = node.Children.FirstOrDefault(child => child.Source != null) as RazorIRNode; - var valueStart = firstMappedChild?.Source; - - using (Context.Writer.BuildLinePragma(node.Source.Value)) - { - var assignmentPrefixLength = propertyValueAccessor.Length + " = ".Length; - if (node.Descriptor.IsEnum && - node.Children.Count == 1 && - node.Children.First() is HtmlContentIRNode) - { - assignmentPrefixLength += $"global::{node.Descriptor.TypeName}.".Length; - - if (valueStart != null) - { - var padding = BuildOffsetPadding(assignmentPrefixLength, node.Source.Value, Context); - - Context.Writer.Write(padding); - } - - Context.Writer - .WriteStartAssignment(propertyValueAccessor) - .Write("global::") - .Write(node.Descriptor.TypeName) - .Write("."); - } - else - { - if (valueStart != null) - { - var padding = BuildOffsetPadding(assignmentPrefixLength, node.Source.Value, Context); - - Context.Writer.Write(padding); - } - - Context.Writer.WriteStartAssignment(propertyValueAccessor); - } - - RenderTagHelperAttributeInline(node, node.Source.Value); - - Context.Writer.WriteLine(";"); - } - } - } - - private void RenderTagHelperAttributeInline( - RazorIRNode node, - SourceSpan documentLocation) - { - if (node is SetTagHelperPropertyIRNode || node is CSharpExpressionIRNode || node is HtmlContentIRNode) - { - for (var i = 0; i < node.Children.Count; i++) - { - RenderTagHelperAttributeInline(node.Children[i], documentLocation); - } - } - else if (node is RazorIRToken token) - { - if (node.Source != null) - { - Context.AddLineMappingFor(node); - } - - Context.Writer.Write(token.Content); - } - else if (node is CSharpStatementIRNode) - { - var error = new RazorError( - LegacyResources.TagHelpers_CodeBlocks_NotSupported_InAttributes, - new SourceLocation(documentLocation.AbsoluteIndex, documentLocation.CharacterIndex, documentLocation.Length), - documentLocation.Length); - Context.Diagnostics.Add(RazorDiagnostic.Create(error)); - } - else if (node is TemplateIRNode) - { - var attributeValueNode = (SetTagHelperPropertyIRNode)node.Parent; - var error = new RazorError( - LegacyResources.FormatTagHelpers_InlineMarkupBlocks_NotSupported_InAttributes(attributeValueNode.Descriptor.TypeName), - new SourceLocation(documentLocation.AbsoluteIndex, documentLocation.CharacterIndex, documentLocation.Length), - documentLocation.Length); - Context.Diagnostics.Add(RazorDiagnostic.Create(error)); - } - } - - private string GetContent(HtmlContentIRNode node) - { - var builder = new StringBuilder(); - for (var i = 0; i < node.Children.Count; i++) - { - if (node.Children[i] is RazorIRToken token && token.IsHtml) - { - builder.Append(token.Content); - } - } - - return builder.ToString(); - } - } -} diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeDirectiveTargetExtension.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeDirectiveTargetExtension.cs new file mode 100644 index 0000000000..802a487f4c --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeDirectiveTargetExtension.cs @@ -0,0 +1,134 @@ +// Copyright (c) .NET Foundation. 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.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + internal class DesignTimeDirectiveTargetExtension : IDesignTimeDirectiveTargetExtension + { + private const string DirectiveTokenHelperMethodName = "__RazorDirectiveTokenHelpers__"; + private const string TypeHelper = "__typeHelper"; + + public void WriteDesignTimeDirective(CSharpRenderingContext context, DesignTimeDirectiveIRNode node) + { + context.Writer + .WritePragma("warning disable 219") + .WriteLine($"private void {DirectiveTokenHelperMethodName}() {{"); + + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is DirectiveTokenIRNode n) + { + WriteDesignTimeDirectiveToken(context, n); + } + } + + context.Writer + .WriteLine("}") + .WritePragma("warning restore 219"); + } + + private void WriteDesignTimeDirectiveToken(CSharpRenderingContext context, DirectiveTokenIRNode node) + { + var tokenKind = node.Descriptor.Kind; + if (!node.Source.HasValue || + !string.Equals( + context.SourceDocument?.FileName, + node.Source.Value.FilePath, + StringComparison.OrdinalIgnoreCase)) + { + // We don't want to handle directives from imports. + return; + } + + // Wrap the directive token in a lambda to isolate variable names. + context.Writer + .Write("((") + .Write(typeof(Action).FullName) + .Write(")("); + using (context.Writer.BuildLambda(endLine: false)) + { + var originalIndent = context.Writer.CurrentIndent; + context.Writer.ResetIndent(); + switch (tokenKind) + { + case DirectiveTokenKind.Type: + + // {node.Content} __typeHelper = null; + + context.AddLineMappingFor(node); + context.Writer + .Write(node.Content) + .Write(" ") + .WriteStartAssignment(TypeHelper) + .WriteLine("null;"); + break; + + case DirectiveTokenKind.Member: + + // global::System.Object {node.content} = null; + + context.Writer + .Write("global::") + .Write(typeof(object).FullName) + .Write(" "); + + context.AddLineMappingFor(node); + context.Writer + .Write(node.Content) + .WriteLine(" = null;"); + break; + + case DirectiveTokenKind.Namespace: + + // global::System.Object __typeHelper = nameof({node.Content}); + + context.Writer + .Write("global::") + .Write(typeof(object).FullName) + .Write(" ") + .WriteStartAssignment(TypeHelper); + + context.Writer.Write("nameof("); + + context.AddLineMappingFor(node); + context.Writer + .Write(node.Content) + .WriteLine(");"); + break; + + case DirectiveTokenKind.String: + + // global::System.Object __typeHelper = "{node.Content}"; + + context.Writer + .Write("global::") + .Write(typeof(object).FullName) + .Write(" ") + .WriteStartAssignment(TypeHelper); + + if (node.Content.StartsWith("\"", StringComparison.Ordinal)) + { + context.AddLineMappingFor(node); + context.Writer.Write(node.Content); + } + else + { + context.Writer.Write("\""); + context.AddLineMappingFor(node); + context.Writer + .Write(node.Content) + .Write("\""); + } + + context.Writer.WriteLine(";"); + break; + } + context.Writer.SetIndent(originalIndent); + } + context.Writer.WriteLine("))();"); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeTagHelperWriter.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeTagHelperWriter.cs index df7070a0b7..95634afee9 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeTagHelperWriter.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeTagHelperWriter.cs @@ -2,7 +2,10 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Linq; +using System.Text; using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration { @@ -53,9 +56,153 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration public override void WriteSetTagHelperProperty(CSharpRenderingContext context, SetTagHelperPropertyIRNode node) { - throw new NotImplementedException(); + var tagHelperVariableName = GetTagHelperVariableName(node.TagHelperTypeName); + var tagHelperRenderingContext = context.TagHelperRenderingContext; + var propertyValueAccessor = GetTagHelperPropertyAccessor(node.IsIndexerNameMatch, tagHelperVariableName, node.AttributeName, node.Descriptor); + + if (tagHelperRenderingContext.RenderedBoundAttributes.TryGetValue(node.AttributeName, out string previousValueAccessor)) + { + context.Writer + .WriteStartAssignment(propertyValueAccessor) + .Write(previousValueAccessor) + .WriteLine(";"); + + return; + } + else + { + tagHelperRenderingContext.RenderedBoundAttributes[node.AttributeName] = propertyValueAccessor; + } + + if (node.Descriptor.IsStringProperty || (node.IsIndexerNameMatch && node.Descriptor.IsIndexerStringProperty)) + { + context.RenderChildren(node); + + context.Writer.WriteStartAssignment(propertyValueAccessor); + if (node.Children.Count == 1 && node.Children.First() is HtmlContentIRNode htmlNode) + { + var content = GetContent(htmlNode); + context.Writer.WriteStringLiteral(content); + } + else + { + context.Writer.Write("string.Empty"); + } + context.Writer.WriteLine(";"); + } + else + { + var firstMappedChild = node.Children.FirstOrDefault(child => child.Source != null) as RazorIRNode; + var valueStart = firstMappedChild?.Source; + + using (context.Writer.BuildLinePragma(node.Source.Value)) + { + var assignmentPrefixLength = propertyValueAccessor.Length + " = ".Length; + if (node.Descriptor.IsEnum && + node.Children.Count == 1 && + node.Children.First() is HtmlContentIRNode) + { + assignmentPrefixLength += $"global::{node.Descriptor.TypeName}.".Length; + + if (valueStart != null) + { + context.Writer.WritePadding(assignmentPrefixLength, node.Source.Value, context); + } + + context.Writer + .WriteStartAssignment(propertyValueAccessor) + .Write("global::") + .Write(node.Descriptor.TypeName) + .Write("."); + } + else + { + if (valueStart != null) + { + context.Writer.WritePadding(assignmentPrefixLength, node.Source.Value, context); + } + + context.Writer.WriteStartAssignment(propertyValueAccessor); + } + + RenderTagHelperAttributeInline(context, node, node.Source.Value); + + context.Writer.WriteLine(";"); + } + } + } + + private void RenderTagHelperAttributeInline( + CSharpRenderingContext context, + RazorIRNode node, + SourceSpan documentLocation) + { + if (node is SetTagHelperPropertyIRNode || node is CSharpExpressionIRNode || node is HtmlContentIRNode) + { + for (var i = 0; i < node.Children.Count; i++) + { + RenderTagHelperAttributeInline(context, node.Children[i], documentLocation); + } + } + else if (node is RazorIRToken token) + { + if (node.Source != null) + { + context.AddLineMappingFor(node); + } + + context.Writer.Write(token.Content); + } + else if (node is CSharpStatementIRNode) + { + var error = new RazorError( + LegacyResources.TagHelpers_CodeBlocks_NotSupported_InAttributes, + new SourceLocation(documentLocation.AbsoluteIndex, documentLocation.CharacterIndex, documentLocation.Length), + documentLocation.Length); + context.Diagnostics.Add(RazorDiagnostic.Create(error)); + } + else if (node is TemplateIRNode) + { + var attributeValueNode = (SetTagHelperPropertyIRNode)node.Parent; + var error = new RazorError( + LegacyResources.FormatTagHelpers_InlineMarkupBlocks_NotSupported_InAttributes(attributeValueNode.Descriptor.TypeName), + new SourceLocation(documentLocation.AbsoluteIndex, documentLocation.CharacterIndex, documentLocation.Length), + documentLocation.Length); + context.Diagnostics.Add(RazorDiagnostic.Create(error)); + } + } + + private string GetContent(HtmlContentIRNode node) + { + var builder = new StringBuilder(); + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is RazorIRToken token && token.IsHtml) + { + builder.Append(token.Content); + } + } + + return builder.ToString(); } private static string GetTagHelperVariableName(string tagHelperTypeName) => "__" + tagHelperTypeName.Replace('.', '_'); + + private static string GetTagHelperPropertyAccessor( + bool isIndexerNameMatch, + string tagHelperVariableName, + string attributeName, + BoundAttributeDescriptor descriptor) + { + var propertyAccessor = $"{tagHelperVariableName}.{descriptor.Metadata[ITagHelperBoundAttributeDescriptorBuilder.PropertyNameKey]}"; + + if (isIndexerNameMatch) + { + var dictionaryKey = attributeName.Substring(descriptor.IndexerNamePrefix.Length); + propertyAccessor += $"[\"{dictionaryKey}\"]"; + } + + return propertyAccessor; + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/IDesignTimeDirectiveTargetExtension.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/IDesignTimeDirectiveTargetExtension.cs new file mode 100644 index 0000000000..a8c38ef76d --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/IDesignTimeDirectiveTargetExtension.cs @@ -0,0 +1,12 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + internal interface IDesignTimeDirectiveTargetExtension : IRuntimeTargetExtension + { + void WriteDesignTimeDirective(CSharpRenderingContext context, DesignTimeDirectiveIRNode node); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/IPreallocatedAttributeTargetExtension.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/IPreallocatedAttributeTargetExtension.cs new file mode 100644 index 0000000000..529a01281a --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/IPreallocatedAttributeTargetExtension.cs @@ -0,0 +1,18 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + internal interface IPreallocatedAttributeTargetExtension : IRuntimeTargetExtension + { + void WriteDeclarePreallocatedTagHelperHtmlAttribute(CSharpRenderingContext context, DeclarePreallocatedTagHelperHtmlAttributeIRNode node); + + void WriteAddPreallocatedTagHelperHtmlAttribute(CSharpRenderingContext context, AddPreallocatedTagHelperHtmlAttributeIRNode node); + + void WriteDeclarePreallocatedTagHelperAttribute(CSharpRenderingContext context, DeclarePreallocatedTagHelperAttributeIRNode node); + + void WriteSetPreallocatedTagHelperProperty(CSharpRenderingContext context, SetPreallocatedTagHelperPropertyIRNode node); + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/LiteralRuntimeBasicWriter.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/LiteralRuntimeBasicWriter.cs new file mode 100644 index 0000000000..484c3a7cd7 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/LiteralRuntimeBasicWriter.cs @@ -0,0 +1,10 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + internal class LiteralRuntimeBasicWriter : RuntimeBasicWriter + { + public override string WriteCSharpExpressionMethod { get; set; } = "WriteLiteral"; + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/PageStructureCSharpRenderer.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/PageStructureCSharpRenderer.cs deleted file mode 100644 index 3562a32279..0000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/PageStructureCSharpRenderer.cs +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) .NET Foundation. 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.AspNetCore.Razor.Language.Intermediate; - -namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration -{ - internal class PageStructureCSharpRenderer : RazorIRNodeWalker - { - protected readonly CSharpRenderingContext Context; - protected readonly RuntimeTarget Target; - - public PageStructureCSharpRenderer(RuntimeTarget target, CSharpRenderingContext context) - { - Context = context; - Target = target; - } - - public override void VisitExtension(ExtensionIRNode node) - { - // This needs to stay here until the rest of the code in the renderers is rewritten because - // and extension can occur at any level. - node.WriteNode(Target, Context); - } - - protected static void RenderExpressionInline(RazorIRNode node, CSharpRenderingContext context) - { - if (node is RazorIRToken token && token.IsCSharp) - { - context.Writer.Write(token.Content); - } - else - { - for (var i = 0; i < node.Children.Count; i++) - { - RenderExpressionInline(node.Children[i], context); - } - } - } - - protected static int CalculateExpressionPadding(SourceSpan sourceRange, CSharpRenderingContext context) - { - var spaceCount = 0; - for (var i = sourceRange.AbsoluteIndex - 1; i >= 0; i--) - { - var @char = context.SourceDocument[i]; - if (@char == '\n' || @char == '\r') - { - break; - } - else if (@char == '\t') - { - spaceCount += context.Options.TabSize; - } - else - { - spaceCount++; - } - } - - return spaceCount; - } - - protected static string BuildOffsetPadding(int generatedOffset, SourceSpan sourceRange, CSharpRenderingContext context) - { - var basePadding = CalculateExpressionPadding(sourceRange, context); - var resolvedPadding = Math.Max(basePadding - generatedOffset, 0); - - if (context.Options.IsIndentingWithTabs) - { - var spaces = resolvedPadding % context.Options.TabSize; - var tabs = resolvedPadding / context.Options.TabSize; - - return new string('\t', tabs) + new string(' ', spaces); - } - else - { - return new string(' ', resolvedPadding); - } - } - - protected static string GetTagHelperVariableName(string tagHelperTypeName) => "__" + tagHelperTypeName.Replace('.', '_'); - - protected static string GetTagHelperPropertyAccessor( - bool isIndexerNameMatch, - string tagHelperVariableName, - string attributeName, - BoundAttributeDescriptor descriptor) - { - var propertyAccessor = $"{tagHelperVariableName}.{descriptor.Metadata[ITagHelperBoundAttributeDescriptorBuilder.PropertyNameKey]}"; - - if (isIndexerNameMatch) - { - var dictionaryKey = attributeName.Substring(descriptor.IndexerNamePrefix.Length); - propertyAccessor += $"[\"{dictionaryKey}\"]"; - } - - return propertyAccessor; - } - } -} diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/PreallocatedAttributeTargetExtension.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/PreallocatedAttributeTargetExtension.cs new file mode 100644 index 0000000000..658bf77914 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/PreallocatedAttributeTargetExtension.cs @@ -0,0 +1,108 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.AspNetCore.Razor.Language.Legacy; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + internal class PreallocatedAttributeTargetExtension : IPreallocatedAttributeTargetExtension + { + public string TagHelperAttributeTypeName { get; set; } = "Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute"; + + public string EncodedHtmlStringTypeName { get; set; } = "Microsoft.AspNetCore.Html.HtmlString"; + + public string ExecutionContextVariableName { get; set; } = "__tagHelperExecutionContext"; + + public string ExecutionContextAddHtmlAttributeMethodName { get; set; } = "AddHtmlAttribute"; + + public string ExecutionContextAddTagHelperAttributeMethodName { get; set; } = "AddTagHelperAttribute"; + + public void WriteDeclarePreallocatedTagHelperHtmlAttribute(CSharpRenderingContext context, DeclarePreallocatedTagHelperHtmlAttributeIRNode node) + { + context.Writer + .Write("private static readonly global::") + .Write(TagHelperAttributeTypeName) + .Write(" ") + .Write(node.VariableName) + .Write(" = ") + .WriteStartNewObject("global::" + TagHelperAttributeTypeName) + .WriteStringLiteral(node.Name); + + if (node.ValueStyle == HtmlAttributeValueStyle.Minimized) + { + context.Writer.WriteEndMethodInvocation(); + } + else + { + context.Writer + .WriteParameterSeparator() + .WriteStartNewObject("global::" + EncodedHtmlStringTypeName) + .WriteStringLiteral(node.Value) + .WriteEndMethodInvocation(endLine: false) + .WriteParameterSeparator() + .Write($"global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.{node.ValueStyle}") + .WriteEndMethodInvocation(); + } + } + + public void WriteAddPreallocatedTagHelperHtmlAttribute(CSharpRenderingContext context, AddPreallocatedTagHelperHtmlAttributeIRNode node) + { + context.Writer + .WriteStartInstanceMethodInvocation(ExecutionContextVariableName, ExecutionContextAddHtmlAttributeMethodName) + .Write(node.VariableName) + .WriteEndMethodInvocation(); + } + + public void WriteDeclarePreallocatedTagHelperAttribute(CSharpRenderingContext context, DeclarePreallocatedTagHelperAttributeIRNode node) + { + context.Writer + .Write("private static readonly global::") + .Write(TagHelperAttributeTypeName) + .Write(" ") + .Write(node.VariableName) + .Write(" = ") + .WriteStartNewObject("global::" + TagHelperAttributeTypeName) + .WriteStringLiteral(node.Name) + .WriteParameterSeparator() + .WriteStringLiteral(node.Value) + .WriteParameterSeparator() + .Write($"global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.{node.ValueStyle}") + .WriteEndMethodInvocation(); + } + + public void WriteSetPreallocatedTagHelperProperty(CSharpRenderingContext context, SetPreallocatedTagHelperPropertyIRNode node) + { + var tagHelperVariableName = GetTagHelperVariableName(node.TagHelperTypeName); + var propertyValueAccessor = GetTagHelperPropertyAccessor(node.IsIndexerNameMatch, tagHelperVariableName, node.AttributeName, node.Descriptor); + var attributeValueAccessor = $"{node.VariableName}.Value" /* ORIGINAL: TagHelperAttributeValuePropertyName */; + context.Writer + .WriteStartAssignment(propertyValueAccessor) + .Write("(string)") + .Write(attributeValueAccessor) + .WriteLine(";") + .WriteStartInstanceMethodInvocation(ExecutionContextVariableName, ExecutionContextAddTagHelperAttributeMethodName) + .Write(node.VariableName) + .WriteEndMethodInvocation(); + } + + private static string GetTagHelperVariableName(string tagHelperTypeName) => "__" + tagHelperTypeName.Replace('.', '_'); + + private static string GetTagHelperPropertyAccessor( + bool isIndexerNameMatch, + string tagHelperVariableName, + string attributeName, + BoundAttributeDescriptor descriptor) + { + var propertyAccessor = $"{tagHelperVariableName}.{descriptor.Metadata[ITagHelperBoundAttributeDescriptorBuilder.PropertyNameKey]}"; + + if (isIndexerNameMatch) + { + var dictionaryKey = attributeName.Substring(descriptor.IndexerNamePrefix.Length); + propertyAccessor += $"[\"{dictionaryKey}\"]"; + } + + return propertyAccessor; + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RedirectedRuntimeBasicWriter.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RedirectedRuntimeBasicWriter.cs index 4953087e8b..c37acaad04 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RedirectedRuntimeBasicWriter.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RedirectedRuntimeBasicWriter.cs @@ -2,6 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Diagnostics; +using System.Globalization; +using System.Linq; using System.Text; using Microsoft.AspNetCore.Razor.Language.Intermediate; @@ -16,9 +19,15 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration _textWriter = textWriter; } - public new string WriteCSharpExpressionMethod { get; set; } = "WriteTo"; + public override string WriteCSharpExpressionMethod { get; set; } = "WriteTo"; - public new string WriteHtmlContentMethod { get; set; } = "WriteLiteralTo"; + public override string WriteHtmlContentMethod { get; set; } = "WriteLiteralTo"; + + public override string BeginWriteAttributeMethod { get; set; } = "BeginWriteAttributeTo"; + + public override string EndWriteAttributeMethod { get; set; } = "EndWriteAttributeTo"; + + public override string WriteAttributeValueMethod { get; set; } = "WriteAttributeValueTo"; public override void WriteCSharpExpression(CSharpRenderingContext context, CSharpExpressionIRNode node) { @@ -92,7 +101,112 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration .WriteEndMethodInvocation(); charactersConsumed += textToRender.Length; - } } + } + + public override void WriteHtmlAttribute(CSharpRenderingContext context, HtmlAttributeIRNode node) + { + var valuePieceCount = node + .Children + .Count(child => child is HtmlAttributeValueIRNode || child is CSharpAttributeValueIRNode); + var prefixLocation = node.Source.Value.AbsoluteIndex; + var suffixLocation = node.Source.Value.AbsoluteIndex + node.Source.Value.Length - node.Suffix.Length; + context.Writer + .WriteStartMethodInvocation(BeginWriteAttributeMethod) + .Write(_textWriter) + .WriteParameterSeparator() + .WriteStringLiteral(node.Name) + .WriteParameterSeparator() + .WriteStringLiteral(node.Prefix) + .WriteParameterSeparator() + .Write(prefixLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .WriteStringLiteral(node.Suffix) + .WriteParameterSeparator() + .Write(suffixLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .Write(valuePieceCount.ToString(CultureInfo.InvariantCulture)) + .WriteEndMethodInvocation(); + + context.RenderChildren(node); + + context.Writer + .WriteStartMethodInvocation(EndWriteAttributeMethod) + .Write(_textWriter) + .WriteEndMethodInvocation(); + } + + public override void WriteHtmlAttributeValue(CSharpRenderingContext context, HtmlAttributeValueIRNode node) + { + var prefixLocation = node.Source.Value.AbsoluteIndex; + var valueLocation = node.Source.Value.AbsoluteIndex + node.Prefix.Length; + var valueLength = node.Source.Value.Length; + context.Writer + .WriteStartMethodInvocation(WriteAttributeValueMethod) + .Write(_textWriter) + .WriteParameterSeparator() + .WriteStringLiteral(node.Prefix) + .WriteParameterSeparator() + .Write(prefixLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .WriteStringLiteral(node.Content) + .WriteParameterSeparator() + .Write(valueLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .Write(valueLength.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .WriteBooleanLiteral(true) + .WriteEndMethodInvocation(); + } + + public override void WriteCSharpAttributeValue(CSharpRenderingContext context, CSharpAttributeValueIRNode node) + { + const string ValueWriterName = "__razor_attribute_value_writer"; + + var expressionValue = node.Children.FirstOrDefault() as CSharpExpressionIRNode; + var linePragma = expressionValue != null ? context.Writer.BuildLinePragma(node.Source.Value) : null; + var prefixLocation = node.Source.Value.AbsoluteIndex; + var valueLocation = node.Source.Value.AbsoluteIndex + node.Prefix.Length; + var valueLength = node.Source.Value.Length - node.Prefix.Length; + context.Writer + .WriteStartMethodInvocation(WriteAttributeValueMethod) + .Write(_textWriter) + .WriteParameterSeparator() + .WriteStringLiteral(node.Prefix) + .WriteParameterSeparator() + .Write(prefixLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator(); + + if (expressionValue != null) + { + Debug.Assert(node.Children.Count == 1); + + RenderExpressionInline(context, expressionValue); + } + else + { + // Not an expression; need to buffer the result. + context.Writer.WriteStartNewObject(TemplateTypeName); + + using (context.Push(new RedirectedRuntimeBasicWriter(ValueWriterName))) + using (context.Writer.BuildAsyncLambda(endLine: false, parameterNames: ValueWriterName)) + { + context.RenderChildren(node); + } + + context.Writer.WriteEndMethodInvocation(false); + } + + context.Writer + .WriteParameterSeparator() + .Write(valueLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .Write(valueLength.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .WriteBooleanLiteral(false) + .WriteEndMethodInvocation(); + + linePragma?.Dispose(); + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RedirectedRuntimeTagHelperWriter.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RedirectedRuntimeTagHelperWriter.cs index 32e97805c7..f33cf7dfc7 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RedirectedRuntimeTagHelperWriter.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RedirectedRuntimeTagHelperWriter.cs @@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration _textWriter = textWriter; } - public new string WriteTagHelperOutputMethod { get; set; } = "WriteTo"; + public override string WriteTagHelperOutputMethod { get; set; } = "WriteTo"; public override void WriteExecuteTagHelpers(CSharpRenderingContext context, ExecuteTagHelpersIRNode node) { diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeBasicWriter.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeBasicWriter.cs index c0314e1283..13d95035b7 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeBasicWriter.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeBasicWriter.cs @@ -2,6 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Diagnostics; +using System.Globalization; +using System.Linq; using System.Text; using Microsoft.AspNetCore.Razor.Language.Intermediate; @@ -9,11 +12,47 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration { public class RuntimeBasicWriter : BasicWriter { - public string WriteCSharpExpressionMethod { get; set; } = "Write"; + public virtual string WriteCSharpExpressionMethod { get; set; } = "Write"; - public string WriteHtmlContentMethod { get; set; } = "WriteLiteral"; + public virtual string WriteHtmlContentMethod { get; set; } = "WriteLiteral"; - public string WriteAttributeValueMethod { get; set; } = "WriteAttributeValue"; + public virtual string BeginWriteAttributeMethod { get; set; } = "BeginWriteAttribute"; + + public virtual string EndWriteAttributeMethod { get; set; } = "EndWriteAttribute"; + + public virtual string WriteAttributeValueMethod { get; set; } = "WriteAttributeValue"; + + public string TemplateTypeName { get; set; } = "Microsoft.AspNetCore.Mvc.Razor.HelperResult"; + + public override void WriteChecksum(CSharpRenderingContext context, ChecksumIRNode node) + { + if (!string.IsNullOrEmpty(node.Bytes)) + { + context.Writer + .Write("#pragma checksum \"") + .Write(node.FileName) + .Write("\" \"") + .Write(node.Guid) + .Write("\" \"") + .Write(node.Bytes) + .WriteLine("\""); + } + } + + public override void WriteUsingStatement(CSharpRenderingContext context, UsingStatementIRNode node) + { + if (node.Source.HasValue) + { + using (context.Writer.BuildLinePragma(node.Source.Value)) + { + context.Writer.WriteUsing(node.Content); + } + } + else + { + context.Writer.WriteUsing(node.Content); + } + } public override void WriteCSharpExpression(CSharpRenderingContext context, CSharpExpressionIRNode node) { @@ -102,7 +141,100 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration public override void WriteHtmlAttribute(CSharpRenderingContext context, HtmlAttributeIRNode node) { - throw new NotImplementedException(); + var valuePieceCount = node + .Children + .Count(child => child is HtmlAttributeValueIRNode || child is CSharpAttributeValueIRNode); + var prefixLocation = node.Source.Value.AbsoluteIndex; + var suffixLocation = node.Source.Value.AbsoluteIndex + node.Source.Value.Length - node.Suffix.Length; + context.Writer + .WriteStartMethodInvocation(BeginWriteAttributeMethod) + .WriteStringLiteral(node.Name) + .WriteParameterSeparator() + .WriteStringLiteral(node.Prefix) + .WriteParameterSeparator() + .Write(prefixLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .WriteStringLiteral(node.Suffix) + .WriteParameterSeparator() + .Write(suffixLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .Write(valuePieceCount.ToString(CultureInfo.InvariantCulture)) + .WriteEndMethodInvocation(); + + context.RenderChildren(node); + + context.Writer + .WriteStartMethodInvocation(EndWriteAttributeMethod) + .WriteEndMethodInvocation(); + } + + public override void WriteHtmlAttributeValue(CSharpRenderingContext context, HtmlAttributeValueIRNode node) + { + var prefixLocation = node.Source.Value.AbsoluteIndex; + var valueLocation = node.Source.Value.AbsoluteIndex + node.Prefix.Length; + var valueLength = node.Source.Value.Length; + context.Writer + .WriteStartMethodInvocation(WriteAttributeValueMethod) + .WriteStringLiteral(node.Prefix) + .WriteParameterSeparator() + .Write(prefixLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .WriteStringLiteral(node.Content) + .WriteParameterSeparator() + .Write(valueLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .Write(valueLength.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .WriteBooleanLiteral(true) + .WriteEndMethodInvocation(); + } + + public override void WriteCSharpAttributeValue(CSharpRenderingContext context, CSharpAttributeValueIRNode node) + { + const string ValueWriterName = "__razor_attribute_value_writer"; + + var expressionValue = node.Children.FirstOrDefault() as CSharpExpressionIRNode; + var linePragma = expressionValue != null ? context.Writer.BuildLinePragma(node.Source.Value) : null; + var prefixLocation = node.Source.Value.AbsoluteIndex; + var valueLocation = node.Source.Value.AbsoluteIndex + node.Prefix.Length; + var valueLength = node.Source.Value.Length - node.Prefix.Length; + context.Writer + .WriteStartMethodInvocation(WriteAttributeValueMethod) + .WriteStringLiteral(node.Prefix) + .WriteParameterSeparator() + .Write(prefixLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator(); + + if (expressionValue != null) + { + Debug.Assert(node.Children.Count == 1); + + RenderExpressionInline(context, expressionValue); + } + else + { + // Not an expression; need to buffer the result. + context.Writer.WriteStartNewObject(TemplateTypeName); + + using (context.Push(new RedirectedRuntimeBasicWriter(ValueWriterName))) + using (context.Writer.BuildAsyncLambda(endLine: false, parameterNames: ValueWriterName)) + { + context.RenderChildren(node); + } + + context.Writer.WriteEndMethodInvocation(false); + } + + context.Writer + .WriteParameterSeparator() + .Write(valueLocation.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .Write(valueLength.ToString(CultureInfo.InvariantCulture)) + .WriteParameterSeparator() + .WriteBooleanLiteral(false) + .WriteEndMethodInvocation(); + + linePragma?.Dispose(); } public override void WriteHtmlContent(CSharpRenderingContext context, HtmlContentIRNode node) @@ -144,5 +276,20 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration charactersConsumed += textToRender.Length; } } + + protected static void RenderExpressionInline(CSharpRenderingContext context, RazorIRNode node) + { + if (node is RazorIRToken token && token.IsCSharp) + { + context.Writer.Write(token.Content); + } + else + { + for (var i = 0; i < node.Children.Count; i++) + { + RenderExpressionInline(context, node.Children[i]); + } + } + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeCSharpRenderer.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeCSharpRenderer.cs deleted file mode 100644 index 407705bd09..0000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeCSharpRenderer.cs +++ /dev/null @@ -1,483 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Diagnostics; -using System.Globalization; -using System.Linq; -using System.Text; -using Microsoft.AspNetCore.Razor.Language.Intermediate; -using Microsoft.AspNetCore.Razor.Language.Legacy; - -namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration -{ - internal class RuntimeCSharpRenderer : PageStructureCSharpRenderer - { - public RuntimeCSharpRenderer(RuntimeTarget target, CSharpRenderingContext context) - : base(target, context) - { - } - - public override void VisitChecksum(ChecksumIRNode node) - { - if (!string.IsNullOrEmpty(node.Bytes)) - { - Context.Writer - .Write("#pragma checksum \"") - .Write(node.FileName) - .Write("\" \"") - .Write(node.Guid) - .Write("\" \"") - .Write(node.Bytes) - .WriteLine("\""); - } - } - - public override void VisitHtml(HtmlContentIRNode node) - { - // We can't remove this yet, because it's still used recursively in a few places. - const int MaxStringLiteralLength = 1024; - - var builder = new StringBuilder(); - for (var i = 0; i < node.Children.Count; i++) - { - if (node.Children[i] is RazorIRToken token && token.IsHtml) - { - builder.Append(token.Content); - } - } - - var content = builder.ToString(); - - var charactersConsumed = 0; - - // Render the string in pieces to avoid Roslyn OOM exceptions at compile time: https://github.com/aspnet/External/issues/54 - while (charactersConsumed < content.Length) - { - string textToRender; - if (content.Length <= MaxStringLiteralLength) - { - textToRender = content; - } - else - { - var charactersToSubstring = Math.Min(MaxStringLiteralLength, content.Length - charactersConsumed); - textToRender = content.Substring(charactersConsumed, charactersToSubstring); - } - - Context.Writer - .Write(Context.RenderingConventions.StartWriteLiteralMethod) - .WriteStringLiteral(textToRender) - .WriteEndMethodInvocation(); - - charactersConsumed += textToRender.Length; - } - } - - public override void VisitCSharpExpression(CSharpExpressionIRNode node) - { - // We can't remove this yet, because it's still used recursively in a few places. - IDisposable linePragmaScope = null; - if (node.Source != null) - { - linePragmaScope = Context.Writer.BuildLinePragma(node.Source.Value); - var padding = BuildOffsetPadding(Context.RenderingConventions.StartWriteMethod.Length, node.Source.Value, Context); - Context.Writer.Write(padding); - } - - Context.Writer.Write(Context.RenderingConventions.StartWriteMethod); - - for (var i = 0; i < node.Children.Count; i++) - { - if (node.Children[i] is RazorIRToken token && token.IsCSharp) - { - Context.Writer.Write(token.Content); - } - else - { - // There may be something else inside the expression like a Template or another extension node. - Visit(node.Children[i]); - } - } - - Context.Writer.WriteEndMethodInvocation(); - - linePragmaScope?.Dispose(); - } - - public override void VisitUsingStatement(UsingStatementIRNode node) - { - if (node.Source.HasValue) - { - using (Context.Writer.BuildLinePragma(node.Source.Value)) - { - Context.Writer.WriteUsing(node.Content); - } - } - else - { - Context.Writer.WriteUsing(node.Content); - } - } - - public override void VisitHtmlAttribute(HtmlAttributeIRNode node) - { - var valuePieceCount = node - .Children - .Count(child => child is HtmlAttributeValueIRNode || child is CSharpAttributeValueIRNode); - var prefixLocation = node.Source.Value.AbsoluteIndex; - var suffixLocation = node.Source.Value.AbsoluteIndex + node.Source.Value.Length - node.Suffix.Length; - Context.Writer - .Write(Context.RenderingConventions.StartBeginWriteAttributeMethod) - .WriteStringLiteral(node.Name) - .WriteParameterSeparator() - .WriteStringLiteral(node.Prefix) - .WriteParameterSeparator() - .Write(prefixLocation.ToString(CultureInfo.InvariantCulture)) - .WriteParameterSeparator() - .WriteStringLiteral(node.Suffix) - .WriteParameterSeparator() - .Write(suffixLocation.ToString(CultureInfo.InvariantCulture)) - .WriteParameterSeparator() - .Write(valuePieceCount.ToString(CultureInfo.InvariantCulture)) - .WriteEndMethodInvocation(); - - VisitDefault(node); - - Context.Writer - .Write(Context.RenderingConventions.StartEndWriteAttributeMethod) - .WriteEndMethodInvocation(); - } - - public override void VisitHtmlAttributeValue(HtmlAttributeValueIRNode node) - { - var prefixLocation = node.Source.Value.AbsoluteIndex; - var valueLocation = node.Source.Value.AbsoluteIndex + node.Prefix.Length; - var valueLength = node.Source.Value.Length; - Context.Writer - .Write(Context.RenderingConventions.StartWriteAttributeValueMethod) - .WriteStringLiteral(node.Prefix) - .WriteParameterSeparator() - .Write(prefixLocation.ToString(CultureInfo.InvariantCulture)) - .WriteParameterSeparator() - .WriteStringLiteral(node.Content) - .WriteParameterSeparator() - .Write(valueLocation.ToString(CultureInfo.InvariantCulture)) - .WriteParameterSeparator() - .Write(valueLength.ToString(CultureInfo.InvariantCulture)) - .WriteParameterSeparator() - .WriteBooleanLiteral(true) - .WriteEndMethodInvocation(); - } - - public override void VisitCSharpAttributeValue(CSharpAttributeValueIRNode node) - { - const string ValueWriterName = "__razor_attribute_value_writer"; - - var expressionValue = node.Children.FirstOrDefault() as CSharpExpressionIRNode; - var linePragma = expressionValue != null ? Context.Writer.BuildLinePragma(node.Source.Value) : null; - var prefixLocation = node.Source.Value.AbsoluteIndex; - var valueLocation = node.Source.Value.AbsoluteIndex + node.Prefix.Length; - var valueLength = node.Source.Value.Length - node.Prefix.Length; - Context.Writer - .Write(Context.RenderingConventions.StartWriteAttributeValueMethod) - .WriteStringLiteral(node.Prefix) - .WriteParameterSeparator() - .Write(prefixLocation.ToString(CultureInfo.InvariantCulture)) - .WriteParameterSeparator(); - - if (expressionValue != null) - { - Debug.Assert(node.Children.Count == 1); - - RenderExpressionInline(expressionValue, Context); - } - else - { - // Not an expression; need to buffer the result. - Context.Writer.WriteStartNewObject("Microsoft.AspNetCore.Mvc.Razor.HelperResult" /* ORIGINAL: TemplateTypeName */); - - var initialRenderingConventions = Context.RenderingConventions; - Context.RenderingConventions = new CSharpRedirectRenderingConventions(ValueWriterName, Context.Writer); - using (Context.Writer.BuildAsyncLambda(endLine: false, parameterNames: ValueWriterName)) - { - VisitDefault(node); - } - Context.RenderingConventions = initialRenderingConventions; - - Context.Writer.WriteEndMethodInvocation(false); - } - - Context.Writer - .WriteParameterSeparator() - .Write(valueLocation.ToString(CultureInfo.InvariantCulture)) - .WriteParameterSeparator() - .Write(valueLength.ToString(CultureInfo.InvariantCulture)) - .WriteParameterSeparator() - .WriteBooleanLiteral(false) - .WriteEndMethodInvocation(); - - linePragma?.Dispose(); - } - - public override void VisitCSharpStatement(CSharpStatementIRNode node) - { - // We can't remove this yet, because it's still used recursively in a few places. - var isWhitespaceStatement = true; - for (var i = 0; i < node.Children.Count; i++) - { - var token = node.Children[i] as RazorIRToken; - if (token == null || !string.IsNullOrWhiteSpace(token.Content)) - { - isWhitespaceStatement = false; - break; - } - } - - if (isWhitespaceStatement) - { - return; - } - - IDisposable linePragmaScope = null; - if (node.Source != null) - { - linePragmaScope = Context.Writer.BuildLinePragma(node.Source.Value); - var padding = BuildOffsetPadding(0, node.Source.Value, Context); - Context.Writer.Write(padding); - } - - for (var i = 0; i < node.Children.Count; i++) - { - if (node.Children[i] is RazorIRToken token && token.IsCSharp) - { - Context.Writer.Write(token.Content); - } - else - { - // There may be something else inside the statement like an extension node. - Visit(node.Children[i]); - } - } - - if (linePragmaScope == null) - { - Context.Writer.WriteLine(); - } - - linePragmaScope?.Dispose(); - } - - public override void VisitAddPreallocatedTagHelperHtmlAttribute(AddPreallocatedTagHelperHtmlAttributeIRNode node) - { - Context.Writer - .WriteStartInstanceMethodInvocation( - "__tagHelperExecutionContext" /* ORIGINAL: ExecutionContextVariableName */, - "AddHtmlAttribute" /* ORIGINAL: ExecutionContextAddHtmlAttributeMethodName */) - .Write(node.VariableName) - .WriteEndMethodInvocation(); - } - - public override void VisitSetPreallocatedTagHelperProperty(SetPreallocatedTagHelperPropertyIRNode node) - { - var tagHelperVariableName = GetTagHelperVariableName(node.TagHelperTypeName); - var propertyValueAccessor = GetTagHelperPropertyAccessor(node.IsIndexerNameMatch, tagHelperVariableName, node.AttributeName, node.Descriptor); - var attributeValueAccessor = $"{node.VariableName}.Value" /* ORIGINAL: TagHelperAttributeValuePropertyName */; - Context.Writer - .WriteStartAssignment(propertyValueAccessor) - .Write("(string)") - .Write(attributeValueAccessor) - .WriteLine(";") - .WriteStartInstanceMethodInvocation( - "__tagHelperExecutionContext" /* ORIGINAL: ExecutionContextVariableName */, - "AddTagHelperAttribute" /* ORIGINAL: ExecutionContextAddTagHelperAttributeMethodName */) - .Write(node.VariableName) - .WriteEndMethodInvocation(); - } - - public override void VisitSetTagHelperProperty(SetTagHelperPropertyIRNode node) - { - var tagHelperVariableName = GetTagHelperVariableName(node.TagHelperTypeName); - var tagHelperRenderingContext = Context.TagHelperRenderingContext; - var propertyName = node.Descriptor.Metadata[ITagHelperBoundAttributeDescriptorBuilder.PropertyNameKey]; - - // Ensure that the property we're trying to set has initialized its dictionary bound properties. - if (node.IsIndexerNameMatch && - tagHelperRenderingContext.VerifiedPropertyDictionaries.Add(propertyName)) - { - // Throw a reasonable Exception at runtime if the dictionary property is null. - Context.Writer - .Write("if (") - .Write(tagHelperVariableName) - .Write(".") - .Write(propertyName) - .WriteLine(" == null)"); - using (Context.Writer.BuildScope()) - { - // System is in Host.NamespaceImports for all MVC scenarios. No need to generate FullName - // of InvalidOperationException type. - Context.Writer - .Write("throw ") - .WriteStartNewObject(nameof(InvalidOperationException)) - .WriteStartMethodInvocation("InvalidTagHelperIndexerAssignment" /* ORIGINAL: FormatInvalidIndexerAssignmentMethodName */) - .WriteStringLiteral(node.AttributeName) - .WriteParameterSeparator() - .WriteStringLiteral(node.TagHelperTypeName) - .WriteParameterSeparator() - .WriteStringLiteral(propertyName) - .WriteEndMethodInvocation(endLine: false) // End of method call - .WriteEndMethodInvocation(); // End of new expression / throw statement - } - } - - var propertyValueAccessor = GetTagHelperPropertyAccessor(node.IsIndexerNameMatch, tagHelperVariableName, node.AttributeName, node.Descriptor); - - string previousValueAccessor; - if (tagHelperRenderingContext.RenderedBoundAttributes.TryGetValue(node.AttributeName, out previousValueAccessor)) - { - Context.Writer - .WriteStartAssignment(propertyValueAccessor) - .Write(previousValueAccessor) - .WriteLine(";"); - - return; - } - else - { - tagHelperRenderingContext.RenderedBoundAttributes[node.AttributeName] = propertyValueAccessor; - } - - if (node.Descriptor.IsStringProperty || (node.IsIndexerNameMatch && node.Descriptor.IsIndexerStringProperty)) - { - Context.Writer.WriteMethodInvocation("BeginWriteTagHelperAttribute" /* ORIGINAL: BeginWriteTagHelperAttributeMethodName */); - - var initialRenderingConventions = Context.RenderingConventions; - Context.RenderingConventions = new CSharpLiteralCodeConventions(Context.Writer); - VisitDefault(node); - Context.RenderingConventions = initialRenderingConventions; - - Context.Writer - .WriteStartAssignment("__tagHelperStringValueBuffer" /* ORIGINAL: StringValueBufferVariableName */) - .WriteMethodInvocation("EndWriteTagHelperAttribute" /* ORIGINAL: EndWriteTagHelperAttributeMethodName */) - .WriteStartAssignment(propertyValueAccessor) - .Write("__tagHelperStringValueBuffer" /* ORIGINAL: StringValueBufferVariableName */) - .WriteLine(";"); - } - else - { - using (Context.Writer.BuildLinePragma(node.Source.Value)) - { - Context.Writer.WriteStartAssignment(propertyValueAccessor); - - if (node.Descriptor.IsEnum && - node.Children.Count == 1 && - node.Children.First() is HtmlContentIRNode) - { - Context.Writer - .Write("global::") - .Write(node.Descriptor.TypeName) - .Write("."); - } - - RenderTagHelperAttributeInline(node, node.Source.Value); - - Context.Writer.WriteLine(";"); - } - } - - // We need to inform the context of the attribute value. - Context.Writer - .WriteStartInstanceMethodInvocation( - "__tagHelperExecutionContext" /* ORIGINAL: ExecutionContextVariableName */, - "AddTagHelperAttribute" /* ORIGINAL: ExecutionContextAddTagHelperAttributeMethodName */) - .WriteStringLiteral(node.AttributeName) - .WriteParameterSeparator() - .Write(propertyValueAccessor) - .WriteParameterSeparator() - .Write($"global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.{node.ValueStyle}") - .WriteEndMethodInvocation(); - } - - public override void VisitDeclarePreallocatedTagHelperHtmlAttribute(DeclarePreallocatedTagHelperHtmlAttributeIRNode node) - { - Context.Writer - .Write("private static readonly global::") - .Write("Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute" /* ORIGINAL: TagHelperAttributeTypeName */) - .Write(" ") - .Write(node.VariableName) - .Write(" = ") - .WriteStartNewObject("global::" + "Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute" /* ORIGINAL: TagHelperAttributeTypeName */) - .WriteStringLiteral(node.Name); - - if (node.ValueStyle == HtmlAttributeValueStyle.Minimized) - { - Context.Writer.WriteEndMethodInvocation(); - } - else - { - Context.Writer - .WriteParameterSeparator() - .WriteStartNewObject("global::" + "Microsoft.AspNetCore.Html.HtmlString" /* ORIGINAL: EncodedHtmlStringTypeName */) - .WriteStringLiteral(node.Value) - .WriteEndMethodInvocation(endLine: false) - .WriteParameterSeparator() - .Write($"global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.{node.ValueStyle}") - .WriteEndMethodInvocation(); - } - } - - public override void VisitDeclarePreallocatedTagHelperAttribute(DeclarePreallocatedTagHelperAttributeIRNode node) - { - Context.Writer - .Write("private static readonly global::") - .Write("Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute" /* ORIGINAL: TagHelperAttributeTypeName */) - .Write(" ") - .Write(node.VariableName) - .Write(" = ") - .WriteStartNewObject("global::" + "Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute" /* ORIGINAL: TagHelperAttributeTypeName */) - .WriteStringLiteral(node.Name) - .WriteParameterSeparator() - .WriteStringLiteral(node.Value) - .WriteParameterSeparator() - .Write($"global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.{node.ValueStyle}") - .WriteEndMethodInvocation(); - } - - private void RenderTagHelperAttributeInline( - RazorIRNode node, - SourceSpan documentLocation) - { - if (node is SetTagHelperPropertyIRNode || node is CSharpExpressionIRNode || node is HtmlContentIRNode) - { - for (var i = 0; i < node.Children.Count; i++) - { - RenderTagHelperAttributeInline(node.Children[i], documentLocation); - } - } - else if (node is RazorIRToken token) - { - Context.Writer.Write(token.Content); - } - else if (node is CSharpStatementIRNode) - { - var error = new RazorError( - LegacyResources.TagHelpers_CodeBlocks_NotSupported_InAttributes, - new SourceLocation(documentLocation.AbsoluteIndex, documentLocation.CharacterIndex, documentLocation.Length), - documentLocation.Length); - Context.Diagnostics.Add(RazorDiagnostic.Create(error)); - } - else if (node is TemplateIRNode) - { - var attributeValueNode = (SetTagHelperPropertyIRNode)node.Parent; - var expectedTypeName = attributeValueNode.IsIndexerNameMatch ? - attributeValueNode.Descriptor.IndexerTypeName : - attributeValueNode.Descriptor.TypeName; - var error = new RazorError( - LegacyResources.FormatTagHelpers_InlineMarkupBlocks_NotSupported_InAttributes(expectedTypeName), - new SourceLocation(documentLocation.AbsoluteIndex, documentLocation.CharacterIndex, documentLocation.Length), - documentLocation.Length); - Context.Diagnostics.Add(RazorDiagnostic.Create(error)); - } - } - } -} diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeTagHelperWriter.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeTagHelperWriter.cs index c9803ac704..4b411f4954 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeTagHelperWriter.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeTagHelperWriter.cs @@ -5,11 +5,14 @@ using System; using System.Globalization; using System.Linq; using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration { public class RuntimeTagHelperWriter : TagHelperWriter { + public virtual string WriteTagHelperOutputMethod { get; set; } = "Write"; + public string StringValueBufferVariableName { get; set; } = "__tagHelperStringValueBuffer"; public string ExecutionContextTypeName { get; set; } = "global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext"; @@ -24,6 +27,8 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration public string ExecutionContextAddHtmlAttributeMethodName { get; set; } = "AddHtmlAttribute"; + public string ExecutionContextAddTagHelperAttributeMethodName { get; set; } = "AddTagHelperAttribute"; + public string RunnerTypeName { get; set; } = "global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner"; public string RunnerVariableName { get; set; } = "__tagHelperRunner"; @@ -58,7 +63,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration public string MarkAsHtmlEncodedMethodName { get; set; } = "Html.Raw"; - public string WriteTagHelperOutputMethod { get; set; } = "Write"; + public string FormatInvalidIndexerAssignmentMethodName { get; set; } = "InvalidTagHelperIndexerAssignment"; public override void WriteDeclareTagHelperFields(CSharpRenderingContext context, DeclareTagHelperFieldsIRNode node) { @@ -166,14 +171,10 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration .Write(attributeValueStyleParameter) .WriteEndMethodInvocation(); - // This can be removed once all the tag helper nodes are moved out of the renderers. - var initialRenderingConventions = context.RenderingConventions; - context.RenderingConventions = new TagHelperHtmlAttributeRenderingConventions(context.Writer); using (context.Push(new TagHelperHtmlAttributeRuntimeBasicWriter())) { context.RenderChildren(node); } - context.RenderingConventions = initialRenderingConventions; context.Writer .WriteMethodInvocation( @@ -192,15 +193,11 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration // We're building a writing scope around the provided chunks which captures everything written from the // page. Therefore, we do not want to write to any other buffer since we're using the pages buffer to // ensure we capture all content that's written, directly or indirectly. - // This can be removed once all the tag helper nodes are moved out of the renderers. - var initialRenderingConventions = context.RenderingConventions; - context.RenderingConventions = new CSharpRenderingConventions(context.Writer); using (context.Push(new RuntimeBasicWriter())) using (context.Push(new RuntimeTagHelperWriter())) { context.RenderChildren(node); } - context.RenderingConventions = initialRenderingConventions; context.Writer .WriteStartAssignment(StringValueBufferVariableName) @@ -296,10 +293,6 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration .WriteParameterSeparator(); // We remove and redirect writers so TagHelper authors can retrieve content. - // This can be removed once all the tag helper nodes are moved out of the renderers. - var initialRenderingConventions = context.RenderingConventions; - context.RenderingConventions = new CSharpRenderingConventions(context.Writer); - using (context.Push(new RuntimeBasicWriter())) using (context.Push(new RuntimeTagHelperWriter())) { @@ -308,14 +301,165 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration context.RenderChildren(node); } } - context.RenderingConventions = initialRenderingConventions; context.Writer.WriteEndMethodInvocation(); } public override void WriteSetTagHelperProperty(CSharpRenderingContext context, SetTagHelperPropertyIRNode node) { - throw new NotImplementedException(); + var tagHelperVariableName = GetTagHelperVariableName(node.TagHelperTypeName); + var tagHelperRenderingContext = context.TagHelperRenderingContext; + var propertyName = node.Descriptor.Metadata[ITagHelperBoundAttributeDescriptorBuilder.PropertyNameKey]; + + // Ensure that the property we're trying to set has initialized its dictionary bound properties. + if (node.IsIndexerNameMatch && + tagHelperRenderingContext.VerifiedPropertyDictionaries.Add(propertyName)) + { + // Throw a reasonable Exception at runtime if the dictionary property is null. + context.Writer + .Write("if (") + .Write(tagHelperVariableName) + .Write(".") + .Write(propertyName) + .WriteLine(" == null)"); + using (context.Writer.BuildScope()) + { + // System is in Host.NamespaceImports for all MVC scenarios. No need to generate FullName + // of InvalidOperationException type. + context.Writer + .Write("throw ") + .WriteStartNewObject(nameof(InvalidOperationException)) + .WriteStartMethodInvocation(FormatInvalidIndexerAssignmentMethodName) + .WriteStringLiteral(node.AttributeName) + .WriteParameterSeparator() + .WriteStringLiteral(node.TagHelperTypeName) + .WriteParameterSeparator() + .WriteStringLiteral(propertyName) + .WriteEndMethodInvocation(endLine: false) // End of method call + .WriteEndMethodInvocation(); // End of new expression / throw statement + } + } + + var propertyValueAccessor = GetTagHelperPropertyAccessor(node.IsIndexerNameMatch, tagHelperVariableName, node.AttributeName, node.Descriptor); + + if (tagHelperRenderingContext.RenderedBoundAttributes.TryGetValue(node.AttributeName, out var previousValueAccessor)) + { + context.Writer + .WriteStartAssignment(propertyValueAccessor) + .Write(previousValueAccessor) + .WriteLine(";"); + + return; + } + else + { + tagHelperRenderingContext.RenderedBoundAttributes[node.AttributeName] = propertyValueAccessor; + } + + if (node.Descriptor.IsStringProperty || (node.IsIndexerNameMatch && node.Descriptor.IsIndexerStringProperty)) + { + context.Writer.WriteMethodInvocation(BeginWriteTagHelperAttributeMethodName); + + using (context.Push(new LiteralRuntimeBasicWriter())) + { + context.RenderChildren(node); + } + + context.Writer + .WriteStartAssignment(StringValueBufferVariableName) + .WriteMethodInvocation(EndWriteTagHelperAttributeMethodName) + .WriteStartAssignment(propertyValueAccessor) + .Write(StringValueBufferVariableName) + .WriteLine(";"); + } + else + { + using (context.Writer.BuildLinePragma(node.Source.Value)) + { + context.Writer.WriteStartAssignment(propertyValueAccessor); + + if (node.Descriptor.IsEnum && + node.Children.Count == 1 && + node.Children.First() is HtmlContentIRNode) + { + context.Writer + .Write("global::") + .Write(node.Descriptor.TypeName) + .Write("."); + } + + RenderTagHelperAttributeInline(context, node, node.Source.Value); + + context.Writer.WriteLine(";"); + } + } + + // We need to inform the context of the attribute value. + context.Writer + .WriteStartInstanceMethodInvocation( + ExecutionContextVariableName, + ExecutionContextAddTagHelperAttributeMethodName) + .WriteStringLiteral(node.AttributeName) + .WriteParameterSeparator() + .Write(propertyValueAccessor) + .WriteParameterSeparator() + .Write($"global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.{node.ValueStyle}") + .WriteEndMethodInvocation(); + } + + private void RenderTagHelperAttributeInline( + CSharpRenderingContext context, + RazorIRNode node, + SourceSpan documentLocation) + { + if (node is SetTagHelperPropertyIRNode || node is CSharpExpressionIRNode || node is HtmlContentIRNode) + { + for (var i = 0; i < node.Children.Count; i++) + { + RenderTagHelperAttributeInline(context, node.Children[i], documentLocation); + } + } + else if (node is RazorIRToken token) + { + context.Writer.Write(token.Content); + } + else if (node is CSharpStatementIRNode) + { + var error = new RazorError( + LegacyResources.TagHelpers_CodeBlocks_NotSupported_InAttributes, + new SourceLocation(documentLocation.AbsoluteIndex, documentLocation.CharacterIndex, documentLocation.Length), + documentLocation.Length); + context.Diagnostics.Add(RazorDiagnostic.Create(error)); + } + else if (node is TemplateIRNode) + { + var attributeValueNode = (SetTagHelperPropertyIRNode)node.Parent; + var expectedTypeName = attributeValueNode.IsIndexerNameMatch ? + attributeValueNode.Descriptor.IndexerTypeName : + attributeValueNode.Descriptor.TypeName; + var error = new RazorError( + LegacyResources.FormatTagHelpers_InlineMarkupBlocks_NotSupported_InAttributes(expectedTypeName), + new SourceLocation(documentLocation.AbsoluteIndex, documentLocation.CharacterIndex, documentLocation.Length), + documentLocation.Length); + context.Diagnostics.Add(RazorDiagnostic.Create(error)); + } + } + + protected static string GetTagHelperPropertyAccessor( + bool isIndexerNameMatch, + string tagHelperVariableName, + string attributeName, + BoundAttributeDescriptor descriptor) + { + var propertyAccessor = $"{tagHelperVariableName}.{descriptor.Metadata[ITagHelperBoundAttributeDescriptorBuilder.PropertyNameKey]}"; + + if (isIndexerNameMatch) + { + var dictionaryKey = attributeName.Substring(descriptor.IndexerNamePrefix.Length); + propertyAccessor += $"[\"{dictionaryKey}\"]"; + } + + return propertyAccessor; } private static string GetTagHelperVariableName(string tagHelperTypeName) => "__" + tagHelperTypeName.Replace('.', '_'); diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/TagHelperHtmlAttributeRenderingConventions.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/TagHelperHtmlAttributeRenderingConventions.cs deleted file mode 100644 index 23963b0333..0000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/TagHelperHtmlAttributeRenderingConventions.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.AspNetCore.Razor.Language.Legacy; - -namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration -{ - internal class TagHelperHtmlAttributeRenderingConventions : CSharpRenderingConventions - { - public TagHelperHtmlAttributeRenderingConventions(CSharpCodeWriter writer) : base(writer) - { - } - - public override string StartWriteAttributeValueMethod => "AddHtmlAttributeValue(" /* ORIGINAL: AddHtmlAttributeValueMethodName */; - } -} diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/TagHelperHtmlAttributeRuntimeBasicWriter.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/TagHelperHtmlAttributeRuntimeBasicWriter.cs index 9fe135433e..f70bed7623 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/TagHelperHtmlAttributeRuntimeBasicWriter.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/TagHelperHtmlAttributeRuntimeBasicWriter.cs @@ -5,7 +5,6 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration { internal class TagHelperHtmlAttributeRuntimeBasicWriter : RuntimeBasicWriter { - // This will be used when HtmlAttributeValueIRNode and CSharpAttributeValueIRNode are moved to writers. - public new string WriteAttributeValueMethod { get; set; } = "AddHtmlAttributeValue"; + public override string WriteAttributeValueMethod { get; set; } = "AddHtmlAttributeValue"; } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/TemplateTargetExtension.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/TemplateTargetExtension.cs index 9eabfc7277..197ce79172 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/TemplateTargetExtension.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/TemplateTargetExtension.cs @@ -21,9 +21,6 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration .Write(ItemParameterName).Write(" => ") .WriteStartNewObject(TemplateTypeName); - var initialRenderingConventions = context.RenderingConventions; - context.RenderingConventions = new CSharpRedirectRenderingConventions(TemplateWriterName, context.Writer); - IDisposable basicWriterScope = null; IDisposable tagHelperWriterScope = null; if (!context.Options.DesignTimeMode) @@ -40,8 +37,6 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration basicWriterScope?.Dispose(); tagHelperWriterScope?.Dispose(); - context.RenderingConventions = initialRenderingConventions; - context.Writer.WriteEndMethodInvocation(endLine: false); } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/AddPreallocatedTagHelperHtmlAttributeIRNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/AddPreallocatedTagHelperHtmlAttributeIRNode.cs index 02bbb763eb..44f643d4e0 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/AddPreallocatedTagHelperHtmlAttributeIRNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/AddPreallocatedTagHelperHtmlAttributeIRNode.cs @@ -1,12 +1,13 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Collections.Generic; -using Microsoft.AspNetCore.Razor.Language.Legacy; +using Microsoft.AspNetCore.Razor.Language.CodeGeneration; namespace Microsoft.AspNetCore.Razor.Language.Intermediate { - public class AddPreallocatedTagHelperHtmlAttributeIRNode : RazorIRNode + public class AddPreallocatedTagHelperHtmlAttributeIRNode : ExtensionIRNode { public override IList Children { get; } = EmptyArray; @@ -18,7 +19,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate public override void Accept(RazorIRNodeVisitor visitor) { - visitor.VisitAddPreallocatedTagHelperHtmlAttribute(this); + if (visitor == null) + { + throw new ArgumentNullException(nameof(visitor)); + } + + AcceptExtensionNode(this, visitor); + } + + public override void WriteNode(RuntimeTarget target, CSharpRenderingContext context) + { + var extension = target.GetExtension(); + extension.WriteAddPreallocatedTagHelperHtmlAttribute(context, this); } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DeclarePreallocatedTagHelperAttributeIRNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DeclarePreallocatedTagHelperAttributeIRNode.cs index b73906a889..0727183265 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DeclarePreallocatedTagHelperAttributeIRNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DeclarePreallocatedTagHelperAttributeIRNode.cs @@ -1,12 +1,14 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Collections.Generic; +using Microsoft.AspNetCore.Razor.Language.CodeGeneration; using Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language.Intermediate { - public class DeclarePreallocatedTagHelperAttributeIRNode : RazorIRNode + public class DeclarePreallocatedTagHelperAttributeIRNode : ExtensionIRNode { public override IList Children { get; } = EmptyArray; @@ -24,7 +26,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate public override void Accept(RazorIRNodeVisitor visitor) { - visitor.VisitDeclarePreallocatedTagHelperAttribute(this); + if (visitor == null) + { + throw new ArgumentNullException(nameof(visitor)); + } + + AcceptExtensionNode(this, visitor); + } + + public override void WriteNode(RuntimeTarget target, CSharpRenderingContext context) + { + var extension = target.GetExtension(); + extension.WriteDeclarePreallocatedTagHelperAttribute(context, this); } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DeclarePreallocatedTagHelperHtmlAttributeIRNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DeclarePreallocatedTagHelperHtmlAttributeIRNode.cs index 21b8143d5b..183198c352 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DeclarePreallocatedTagHelperHtmlAttributeIRNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DeclarePreallocatedTagHelperHtmlAttributeIRNode.cs @@ -1,12 +1,14 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Collections.Generic; +using Microsoft.AspNetCore.Razor.Language.CodeGeneration; using Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language.Intermediate { - public class DeclarePreallocatedTagHelperHtmlAttributeIRNode : RazorIRNode + public class DeclarePreallocatedTagHelperHtmlAttributeIRNode : ExtensionIRNode { public override IList Children { get; } = EmptyArray; @@ -24,7 +26,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate public override void Accept(RazorIRNodeVisitor visitor) { - visitor.VisitDeclarePreallocatedTagHelperHtmlAttribute(this); + if (visitor == null) + { + throw new ArgumentNullException(nameof(visitor)); + } + + AcceptExtensionNode(this, visitor); + } + + public override void WriteNode(RuntimeTarget target, CSharpRenderingContext context) + { + var extension = target.GetExtension(); + extension.WriteDeclarePreallocatedTagHelperHtmlAttribute(context, this); } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DesignTimeDirectiveIRNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DesignTimeDirectiveIRNode.cs new file mode 100644 index 0000000000..8f2a3c19f5 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DesignTimeDirectiveIRNode.cs @@ -0,0 +1,34 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using Microsoft.AspNetCore.Razor.Language.CodeGeneration; + +namespace Microsoft.AspNetCore.Razor.Language.Intermediate +{ + internal class DesignTimeDirectiveIRNode : ExtensionIRNode + { + public override IList Children { get; } = new List(); + + public override RazorIRNode Parent { get; set; } + + public override SourceSpan? Source { get; set; } + + public override void Accept(RazorIRNodeVisitor visitor) + { + if (visitor == null) + { + throw new ArgumentNullException(nameof(visitor)); + } + + AcceptExtensionNode(this, visitor); + } + + public override void WriteNode(RuntimeTarget target, CSharpRenderingContext context) + { + var extension = target.GetExtension(); + extension.WriteDesignTimeDirective(context, this); + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveTokenIRNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveTokenIRNode.cs index 9f24a63d54..65b6c46dfe 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveTokenIRNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveTokenIRNode.cs @@ -1,8 +1,8 @@ // Copyright(c) .NET Foundation.All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Collections.Generic; -using Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language.Intermediate { diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/RazorIRNodeVisitor.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/RazorIRNodeVisitor.cs index 2ee1b86fce..d6cd6d6a7d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/RazorIRNodeVisitor.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/RazorIRNodeVisitor.cs @@ -128,25 +128,5 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { VisitDefault(node); } - - public virtual void VisitDeclarePreallocatedTagHelperHtmlAttribute(DeclarePreallocatedTagHelperHtmlAttributeIRNode node) - { - VisitDefault(node); - } - - public virtual void VisitAddPreallocatedTagHelperHtmlAttribute(AddPreallocatedTagHelperHtmlAttributeIRNode node) - { - VisitDefault(node); - } - - public virtual void VisitDeclarePreallocatedTagHelperAttribute(DeclarePreallocatedTagHelperAttributeIRNode node) - { - VisitDefault(node); - } - - public virtual void VisitSetPreallocatedTagHelperProperty(SetPreallocatedTagHelperPropertyIRNode node) - { - VisitDefault(node); - } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/SetPreallocatedTagHelperPropertyIRNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/SetPreallocatedTagHelperPropertyIRNode.cs index d253bc07b1..c07a5d7a0d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/SetPreallocatedTagHelperPropertyIRNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/SetPreallocatedTagHelperPropertyIRNode.cs @@ -1,12 +1,14 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Collections.Generic; +using Microsoft.AspNetCore.Razor.Language.CodeGeneration; using Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language.Intermediate { - public class SetPreallocatedTagHelperPropertyIRNode : RazorIRNode + public class SetPreallocatedTagHelperPropertyIRNode : ExtensionIRNode { public override IList Children { get; } = EmptyArray; @@ -30,7 +32,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate public override void Accept(RazorIRNodeVisitor visitor) { - visitor.VisitSetPreallocatedTagHelperProperty(this); + if (visitor == null) + { + throw new ArgumentNullException(nameof(visitor)); + } + + AcceptExtensionNode(this, visitor); + } + + public override void WriteNode(RuntimeTarget target, CSharpRenderingContext context) + { + var extension = target.GetExtension(); + extension.WriteSetPreallocatedTagHelperProperty(context, this); } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorDesignTimeIRPass.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorDesignTimeIRPass.cs index 17898b975a..ea0da4a321 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorDesignTimeIRPass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorDesignTimeIRPass.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Collections.Generic; using Microsoft.AspNetCore.Razor.Language.Intermediate; namespace Microsoft.AspNetCore.Razor.Language @@ -21,7 +20,7 @@ namespace Microsoft.AspNetCore.Razor.Language internal class DesignTimeHelperWalker : RazorIRNodeWalker { - private DirectiveTokenHelperIRNode _directiveTokenHelper; + private DesignTimeDirectiveIRNode _designTimeDirectiveIRNode; public override void VisitClass(ClassDeclarationIRNode node) { @@ -35,77 +34,16 @@ namespace Microsoft.AspNetCore.Razor.Language node.Children.Insert(0, designTimeHelperDeclaration); - _directiveTokenHelper = new DirectiveTokenHelperIRNode(); + _designTimeDirectiveIRNode = new DesignTimeDirectiveIRNode(); VisitDefault(node); - node.Children.Insert(0, _directiveTokenHelper); + node.Children.Insert(0, _designTimeDirectiveIRNode); } public override void VisitDirectiveToken(DirectiveTokenIRNode node) { - _directiveTokenHelper.AddToMethodBody(node); - } - - private class DirectiveTokenHelperIRNode : RazorIRNode - { - private const string DirectiveTokenHelperMethodName = "__RazorDirectiveTokenHelpers__"; - private int _methodBodyIndex = 2; - - public DirectiveTokenHelperIRNode() - { - var disableWarningPragma = new CSharpStatementIRNode(); - RazorIRBuilder.Create(disableWarningPragma) - .Add(new RazorIRToken() - { - Kind = RazorIRToken.TokenKind.CSharp, - Content = "#pragma warning disable 219", - }); - Children.Add(disableWarningPragma); - - var methodStartNode = new CSharpStatementIRNode(); - RazorIRBuilder.Create(methodStartNode) - .Add(new RazorIRToken() - { - Kind = RazorIRToken.TokenKind.CSharp, - Content = "private void " + DirectiveTokenHelperMethodName + "() {" - }); - Children.Add(methodStartNode); - - var methodEndNode = new CSharpStatementIRNode(); - RazorIRBuilder.Create(methodEndNode) - .Add(new RazorIRToken() - { - Kind = RazorIRToken.TokenKind.CSharp, - Content = "}" - }); - Children.Add(methodEndNode); - - var restoreWarningPragma = new CSharpStatementIRNode(); - RazorIRBuilder.Create(restoreWarningPragma) - .Add(new RazorIRToken() - { - Kind = RazorIRToken.TokenKind.CSharp, - Content = "#pragma warning restore 219", - }); - Children.Add(restoreWarningPragma); - } - - public override IList Children { get; } = new List(); - - public override RazorIRNode Parent { get; set; } - - public override SourceSpan? Source { get; set; } - - public void AddToMethodBody(RazorIRNode node) - { - Children.Insert(_methodBodyIndex++, node); - } - - public override void Accept(RazorIRNodeVisitor visitor) - { - visitor.VisitDefault(this); - } + _designTimeDirectiveIRNode.Children.Add(node); } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorEngine.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorEngine.cs index d3ca05cccd..8db56a7118 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/RazorEngine.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/RazorEngine.cs @@ -75,6 +75,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Default Runtime Targets builder.AddTargetExtension(new TemplateTargetExtension()); + builder.AddTargetExtension(new PreallocatedAttributeTargetExtension()); // Default configuration var configurationFeature = new DefaultDocumentClassifierPassFeature(); @@ -107,8 +108,14 @@ namespace Microsoft.AspNetCore.Razor.Language internal static void AddDesignTimeDefaults(IRazorEngineBuilder builder) { + // Configure options builder.Features.Add(new DesignTimeParserOptionsFeature()); + + // IR Passes builder.Features.Add(new RazorDesignTimeIRPass()); + + // DesignTime Runtime Targets + builder.AddTargetExtension(new DesignTimeDirectiveTargetExtension()); } public abstract IReadOnlyList Features { get; } diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt index 434fe6c4df..b39fa1066d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic_DesignTime.ir.txt @@ -10,11 +10,7 @@ Document - UsingStatement - (104:4,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingStatement - (147:5,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (200:6,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (263:6,71 [4] ) - Html DirectiveToken - (277:7,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper @@ -28,10 +24,6 @@ Document - DirectiveToken - (586:11,14 [96] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (698:12,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (801:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async, override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt index aa502b24a2..970446d0c2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel_DesignTime.ir.txt @@ -10,11 +10,7 @@ Document - UsingStatement - (104:4,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingStatement - (147:5,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (200:6,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (263:6,71 [4] ) - Html DirectiveToken - (277:7,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper @@ -33,10 +29,6 @@ Document - DirectiveToken - (30:1,14 [14] InjectWithModel.cshtml) - MyPropertyName DirectiveToken - (54:2,8 [17] InjectWithModel.cshtml) - MyService DirectiveToken - (72:2,26 [4] InjectWithModel.cshtml) - Html - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async, override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt index f07839fb2d..13d782fa29 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon_DesignTime.ir.txt @@ -10,11 +10,7 @@ Document - UsingStatement - (104:4,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingStatement - (147:5,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (200:6,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (263:6,71 [4] ) - Html DirectiveToken - (277:7,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper @@ -37,10 +33,6 @@ Document - DirectiveToken - (99:3,14 [15] InjectWithSemicolon.cshtml) - MyPropertyName2 DirectiveToken - (129:4,8 [17] InjectWithSemicolon.cshtml) - MyService DirectiveToken - (147:4,26 [5] InjectWithSemicolon.cshtml) - Html2 - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async, override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt index 4bd1d4c324..80c3b39acc 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject_DesignTime.ir.txt @@ -11,11 +11,7 @@ Document - UsingStatement - (147:5,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures UsingStatement - (1:0,1 [17] Inject.cshtml) - MyNamespace ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (200:6,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (263:6,71 [4] ) - Html DirectiveToken - (277:7,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper @@ -31,10 +27,6 @@ Document - DirectiveToken - (801:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (28:1,8 [5] Inject.cshtml) - MyApp DirectiveToken - (34:1,14 [14] Inject.cshtml) - MyPropertyName - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async, override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.ir.txt index a8b90ab1ff..a4788b3a3c 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MalformedPageDirective_DesignTime.ir.txt @@ -10,11 +10,7 @@ Document - UsingStatement - (104:4,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingStatement - (147:5,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (200:6,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (263:6,71 [4] ) - Html DirectiveToken - (277:7,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper @@ -29,10 +25,6 @@ Document - DirectiveToken - (698:12,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (801:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (6:0,6 [4] MalformedPageDirective.cshtml) - "foo - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async, override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt index 446775dbce..7e11b22245 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper_DesignTime.ir.txt @@ -10,11 +10,7 @@ Document - UsingStatement - (104:4,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingStatement - (147:5,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (200:6,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (263:6,71 [4] ) - Html DirectiveToken - (277:7,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper @@ -30,10 +26,6 @@ Document - DirectiveToken - (801:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (7:0,7 [8] ModelExpressionTagHelper.cshtml) - DateTime DirectiveToken - (33:2,14 [108] ModelExpressionTagHelper.cshtml) - Microsoft.AspNetCore.Mvc.Razor.Extensions.InputTestTagHelper, Microsoft.AspNetCore.Mvc.Razor.Extensions.Test - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - Microsoft.AspNetCore.Mvc.Razor.Extensions.InputTestTagHelper diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt index 64e0717c5d..176a4793e6 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model_DesignTime.ir.txt @@ -10,11 +10,7 @@ Document - UsingStatement - (104:4,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingStatement - (147:5,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (200:6,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (263:6,71 [4] ) - Html DirectiveToken - (277:7,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper @@ -29,10 +25,6 @@ Document - DirectiveToken - (698:12,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (801:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (7:0,7 [30] Model.cshtml) - System.Collections.IEnumerable - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async, override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt index 8c181abef1..9ac000ac50 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels_DesignTime.ir.txt @@ -10,11 +10,7 @@ Document - UsingStatement - (104:4,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingStatement - (147:5,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MultipleModels_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (200:6,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (263:6,71 [4] ) - Html DirectiveToken - (277:7,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper @@ -30,10 +26,6 @@ Document - DirectiveToken - (801:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (7:0,7 [21] MultipleModels.cshtml) - ThisShouldBeGenerated DirectiveToken - (37:1,7 [30] MultipleModels.cshtml) - System.Collections.IEnumerable - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async, override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.ir.txt index 8e4b04dcac..cd853ae146 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace_DesignTime.ir.txt @@ -10,11 +10,7 @@ Document - UsingStatement - (104:4,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingStatement - (147:5,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures ClassDeclaration - - public - PageWithNamespace_Page - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (200:6,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (263:6,71 [4] ) - Html DirectiveToken - (277:7,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper @@ -29,10 +25,6 @@ Document - DirectiveToken - (698:12,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (801:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (18:1,11 [14] PageWithNamespace.cshtml) - Test.Namespace - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async, override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.ir.txt index f594ca6554..b414518513 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel_DesignTime.ir.txt @@ -11,11 +11,7 @@ Document - UsingStatement - (147:5,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures UsingStatement - (43:3,1 [41] RazorPagesWithoutModel.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (200:6,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (263:6,71 [4] ) - Html DirectiveToken - (277:7,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper @@ -30,10 +26,6 @@ Document - DirectiveToken - (698:12,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (801:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (23:2,14 [17] RazorPagesWithoutModel.cshtml) - "*, TestAssembly" - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - DivTagHelper diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.ir.txt index 3efc17a2f2..d9d20573c6 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages_DesignTime.ir.txt @@ -11,11 +11,7 @@ Document - UsingStatement - (147:5,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures UsingStatement - (60:4,1 [41] RazorPages.cshtml) - Microsoft.AspNetCore.Mvc.RazorPages ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages_cshtml - global::Microsoft.AspNetCore.Mvc.RazorPages.Page - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (200:6,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (263:6,71 [4] ) - Html DirectiveToken - (277:7,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper @@ -31,10 +27,6 @@ Document - DirectiveToken - (801:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (16:2,7 [8] RazorPages.cshtml) - NewModel DirectiveToken - (40:3,14 [17] RazorPages.cshtml) - "*, TestAssembly" - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - DivTagHelper diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.ir.txt index e8cd81f770..182196e08e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace_DesignTime.ir.txt @@ -10,11 +10,7 @@ Document - UsingStatement - (104:4,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingStatement - (147:5,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures ClassDeclaration - - public - ViewWithNamespace_View - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (200:6,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (263:6,71 [4] ) - Html DirectiveToken - (277:7,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper @@ -29,10 +25,6 @@ Document - DirectiveToken - (698:12,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (801:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (11:0,11 [14] ViewWithNamespace.cshtml) - Test.Namespace - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async, override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt index da033f8e92..93f033f252 100644 --- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports_DesignTime.ir.txt @@ -10,11 +10,7 @@ Document - UsingStatement - (104:4,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering UsingStatement - (147:5,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (200:6,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper DirectiveToken - (263:6,71 [4] ) - Html DirectiveToken - (277:7,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper @@ -30,10 +26,6 @@ Document - DirectiveToken - (801:13,14 [87] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor DirectiveToken - (8:0,8 [19] _ViewImports.cshtml) - IHtmlHelper DirectiveToken - (28:0,28 [5] _ViewImports.cshtml) - Model - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async, override - global::System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DefaultDocumentWriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DefaultDocumentWriterTest.cs index ac723a5e4f..2e836af8ff 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DefaultDocumentWriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DefaultDocumentWriterTest.cs @@ -22,9 +22,8 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration Options = options, Writer = new Legacy.CSharpCodeWriter(), }; - var renderer = new RuntimeCSharpRenderer(target, context); - var writer = new DefaultDocumentWriter(target, context, renderer); + var writer = new DefaultDocumentWriter(target, context); var builder = RazorIRBuilder.Document(); builder.Add(new NamespaceDeclarationIRNode() @@ -62,9 +61,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration Options = options, Writer = new Legacy.CSharpCodeWriter(), }; - var renderer = new RuntimeCSharpRenderer(target, context); - - var writer = new DefaultDocumentWriter(target, context, renderer); + var writer = new DefaultDocumentWriter(target, context); var builder = RazorIRBuilder.Document(); builder.Add(new ClassDeclarationIRNode() @@ -104,9 +101,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration Options = options, Writer = new Legacy.CSharpCodeWriter(), }; - var renderer = new RuntimeCSharpRenderer(target, context); - - var writer = new DefaultDocumentWriter(target, context, renderer); + var writer = new DefaultDocumentWriter(target, context); var builder = RazorIRBuilder.Document(); builder.Add(new RazorMethodDeclarationIRNode() diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DesignTimeBasicWriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DesignTimeBasicWriterTest.cs index d8efff369c..97b24be2a3 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DesignTimeBasicWriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DesignTimeBasicWriterTest.cs @@ -10,6 +10,72 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration { public class DesignTimeBasicWriterTest { + [Fact] + public void WriteUsingStatement_NoSource_WritesContent() + { + // Arrange + var writer = new DesignTimeBasicWriter(); + var context = new CSharpRenderingContext() + { + Writer = new Legacy.CSharpCodeWriter() + }; + + var node = new UsingStatementIRNode() + { + Content = "System", + }; + + // Act + writer.WriteUsingStatement(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"using System; +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteUsingStatement_WithSource_WritesContentWithLinePragmaAndMapping() + { + // Arrange + var writer = new DesignTimeBasicWriter(); + var sourceDocument = TestRazorSourceDocument.Create("@using System;"); + var context = new CSharpRenderingContext() + { + Writer = new Legacy.CSharpCodeWriter(), + CodeDocument = RazorCodeDocument.Create(sourceDocument) + }; + + var originalSpan = new SourceSpan("test.cshtml", 0, 0, 0, 6); + var generatedSpan = new SourceSpan(null, 23, 1, 0, 6); + var expectedLineMapping = new LineMapping(originalSpan, generatedSpan); + var node = new UsingStatementIRNode() + { + Content = "System", + Source = originalSpan, + }; + + // Act + writer.WriteUsingStatement(context, node); + + // Assert + var mapping = Assert.Single(context.LineMappings); + Assert.Equal(expectedLineMapping, mapping); + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"#line 1 ""test.cshtml"" +using System; + +#line default +#line hidden +", + csharp, + ignoreLineEndingDifferences: true); + } + [Fact] public void WriteCSharpExpression_SkipsLinePragma_WithoutSource() { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DesignTimeDirectiveTargetExtensionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DesignTimeDirectiveTargetExtensionTest.cs new file mode 100644 index 0000000000..a3cf9463de --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DesignTimeDirectiveTargetExtensionTest.cs @@ -0,0 +1,258 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.AspNetCore.Razor.Language.Legacy; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + public class DesignTimeDirectiveTargetExtensionTest + { + [Fact] + public void WriteDesignTimeDirective_NoChildren_WritesEmptyMethod_WithPragma() + { + // Arrange + var extension = new DesignTimeDirectiveTargetExtension(); + var context = new CSharpRenderingContext() + { + Writer = new CSharpCodeWriter() + }; + + var node = new DesignTimeDirectiveIRNode(); + + // Act + extension.WriteDesignTimeDirective(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"#pragma warning disable 219 +private void __RazorDirectiveTokenHelpers__() { +} +#pragma warning restore 219 +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteDesignTimeDirective_WithTypeToken_WritesLambda() + { + // Arrange + var extension = new DesignTimeDirectiveTargetExtension(); + var context = new CSharpRenderingContext() + { + Writer = new CSharpCodeWriter(), + CodeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("test content", "test.cshtml")) + }; + + var node = new DesignTimeDirectiveIRNode(); + var token = new DirectiveTokenIRNode() + { + Source = new SourceSpan("test.cshtml", 0, 0, 0, 5), + Content = "System.String", + Descriptor = new DirectiveTokenDescriptor() + { + Kind = DirectiveTokenKind.Type + } + }; + node.Children.Add(token); + + // Act + extension.WriteDesignTimeDirective(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"#pragma warning disable 219 +private void __RazorDirectiveTokenHelpers__() { +((System.Action)(() => { +System.String __typeHelper = null; +} +))(); +} +#pragma warning restore 219 +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteDesignTimeDirective_WithNamespaceToken_WritesLambda() + { + // Arrange + var extension = new DesignTimeDirectiveTargetExtension(); + var context = new CSharpRenderingContext() + { + Writer = new CSharpCodeWriter(), + CodeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("test content", "test.cshtml")) + }; + + var node = new DesignTimeDirectiveIRNode(); + var token = new DirectiveTokenIRNode() + { + Source = new SourceSpan("test.cshtml", 0, 0, 0, 5), + Content = "System.Collections.Generic", + Descriptor = new DirectiveTokenDescriptor() + { + Kind = DirectiveTokenKind.Namespace + } + }; + node.Children.Add(token); + + // Act + extension.WriteDesignTimeDirective(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"#pragma warning disable 219 +private void __RazorDirectiveTokenHelpers__() { +((System.Action)(() => { +global::System.Object __typeHelper = nameof(System.Collections.Generic); +} +))(); +} +#pragma warning restore 219 +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteDesignTimeDirective_WithMemberToken_WritesLambda() + { + // Arrange + var extension = new DesignTimeDirectiveTargetExtension(); + var context = new CSharpRenderingContext() + { + Writer = new CSharpCodeWriter(), + CodeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("test content", "test.cshtml")) + }; + + var node = new DesignTimeDirectiveIRNode(); + var token = new DirectiveTokenIRNode() + { + Source = new SourceSpan("test.cshtml", 0, 0, 0, 5), + Content = "Foo", + Descriptor = new DirectiveTokenDescriptor() + { + Kind = DirectiveTokenKind.Member + } + }; + node.Children.Add(token); + + // Act + extension.WriteDesignTimeDirective(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"#pragma warning disable 219 +private void __RazorDirectiveTokenHelpers__() { +((System.Action)(() => { +global::System.Object Foo = null; +} +))(); +} +#pragma warning restore 219 +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteDesignTimeDirective_WithStringToken_WritesLambda() + { + // Arrange + var extension = new DesignTimeDirectiveTargetExtension(); + var context = new CSharpRenderingContext() + { + Writer = new CSharpCodeWriter(), + CodeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("test content", "test.cshtml")) + }; + + var node = new DesignTimeDirectiveIRNode(); + var token = new DirectiveTokenIRNode() + { + Source = new SourceSpan("test.cshtml", 0, 0, 0, 5), + Content = "Value", + Descriptor = new DirectiveTokenDescriptor() + { + Kind = DirectiveTokenKind.String + } + }; + var tokenWithQuotedContent = new DirectiveTokenIRNode() + { + Source = new SourceSpan("test.cshtml", 0, 0, 0, 5), + Content = "\"Value\"", + Descriptor = new DirectiveTokenDescriptor() + { + Kind = DirectiveTokenKind.String + } + }; + node.Children.Add(token); + node.Children.Add(tokenWithQuotedContent); + + // Act + extension.WriteDesignTimeDirective(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"#pragma warning disable 219 +private void __RazorDirectiveTokenHelpers__() { +((System.Action)(() => { +global::System.Object __typeHelper = ""Value""; +} +))(); +((System.Action)(() => { +global::System.Object __typeHelper = ""Value""; +} +))(); +} +#pragma warning restore 219 +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteDesignTimeDirective_ChildrenWithNoSource_WritesEmptyMethod_WithPragma() + { + // Arrange + var extension = new DesignTimeDirectiveTargetExtension(); + var context = new CSharpRenderingContext() + { + Writer = new CSharpCodeWriter(), + CodeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("test content", "test.cshtml")) + }; + + var node = new DesignTimeDirectiveIRNode(); + var token = new DirectiveTokenIRNode() + { + Content = "Value", + Descriptor = new DirectiveTokenDescriptor() + { + Kind = DirectiveTokenKind.String + } + }; + node.Children.Add(token); + + // Act + extension.WriteDesignTimeDirective(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"#pragma warning disable 219 +private void __RazorDirectiveTokenHelpers__() { +} +#pragma warning restore 219 +", + csharp, + ignoreLineEndingDifferences: true); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DesignTimeTagHelperWriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DesignTimeTagHelperWriterTest.cs index 7b307bdd0e..10b1193ed9 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DesignTimeTagHelperWriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/DesignTimeTagHelperWriterTest.cs @@ -1,6 +1,9 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; +using System.Collections.Generic; +using System.Linq; using Microsoft.AspNetCore.Razor.Language.Intermediate; using Xunit; @@ -13,10 +16,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration { // Arrange var writer = new DesignTimeTagHelperWriter(); - var context = new CSharpRenderingContext() - { - Writer = new Legacy.CSharpCodeWriter(), - }; + var context = GetCSharpRenderingContext(writer); var node = new DeclareTagHelperFieldsIRNode(); node.UsedTagHelperTypeNames.Add("PTagHelper"); node.UsedTagHelperTypeNames.Add("MyTagHelper"); @@ -39,10 +39,7 @@ private global::MyTagHelper __MyTagHelper = null; { // Arrange var writer = new DesignTimeTagHelperWriter(); - var context = new CSharpRenderingContext() - { - Writer = new Legacy.CSharpCodeWriter(), - }; + var context = GetCSharpRenderingContext(writer); var node = new CreateTagHelperIRNode() { TagHelperTypeName = "TestNamespace.MyTagHelper" @@ -59,5 +56,211 @@ private global::MyTagHelper __MyTagHelper = null; csharp, ignoreLineEndingDifferences: true); } + + [Fact] + public void WriteSetTagHelperProperty_RendersCorrectly() + { + // Arrange + var descriptors = new[] + { + CreateTagHelperDescriptor( + tagName: "input", + typeName: "InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("bound") + .PropertyName("FooProp") + .TypeName("System.String"), + }) + }; + var engine = RazorEngine.Create(builder => builder.AddTagHelpers(descriptors)); + var content = @" +@addTagHelper *, TestAssembly +"; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var irDocument = Lower(codeDocument, engine); + var node = irDocument.Children.Last().Children[2] as SetTagHelperPropertyIRNode; + + var writer = new DesignTimeTagHelperWriter(); + var context = GetCSharpRenderingContext(writer, codeDocument); + + // Act + writer.WriteSetTagHelperProperty(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"Render Children +__InputTagHelper.FooProp = ""value""; +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteSetTagHelperProperty_NonStringAttribute_RendersCorrectly() + { + // Arrange + var descriptors = new[] + { + CreateTagHelperDescriptor( + tagName: "input", + typeName: "InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("bound") + .PropertyName("FooProp") + .TypeName("System.Int32"), + }) + }; + var engine = RazorEngine.Create(builder => builder.AddTagHelpers(descriptors)); + var content = @" +@addTagHelper *, TestAssembly +"; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var irDocument = Lower(codeDocument, engine); + var node = irDocument.Children.Last().Children[2] as SetTagHelperPropertyIRNode; + + var writer = new DesignTimeTagHelperWriter(); + var context = GetCSharpRenderingContext(writer, codeDocument); + + // Act + writer.WriteSetTagHelperProperty(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"#line 3 ""test.cshtml"" +__InputTagHelper.FooProp = 42; + +#line default +#line hidden +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteSetTagHelperProperty_IndexerAttribute_RendersCorrectly() + { + // Arrange + var descriptors = new[] + { + CreateTagHelperDescriptor( + tagName: "input", + typeName: "InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("bound") + .PropertyName("FooProp") + .TypeName("System.Collections.Generic.Dictionary") + .AsDictionary("foo-", "System.Int32"), + }) + }; + var engine = RazorEngine.Create(builder => builder.AddTagHelpers(descriptors)); + var content = @" +@addTagHelper *, TestAssembly +"; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var irDocument = Lower(codeDocument, engine); + var node = irDocument.Children.Last().Children[2] as SetTagHelperPropertyIRNode; + + var writer = new DesignTimeTagHelperWriter(); + var context = GetCSharpRenderingContext(writer, codeDocument); + + // Act + writer.WriteSetTagHelperProperty(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"#line 3 ""test.cshtml"" +__InputTagHelper.FooProp[""bound""] = 42; + +#line default +#line hidden +", + csharp, + ignoreLineEndingDifferences: true); + } + + private static CSharpRenderingContext GetCSharpRenderingContext(TagHelperWriter writer, RazorCodeDocument codeDocument = null) + { + var options = RazorParserOptions.CreateDefaultOptions(); + var codeWriter = new Legacy.CSharpCodeWriter(); + var context = new CSharpRenderingContext() + { + Writer = codeWriter, + Options = options, + BasicWriter = new DesignTimeBasicWriter(), + TagHelperWriter = writer, + TagHelperRenderingContext = new TagHelperRenderingContext(), + CodeDocument = codeDocument, + RenderChildren = n => + { + codeWriter.WriteLine("Render Children"); + } + }; + + return context; + } + + private static DocumentIRNode Lower(RazorCodeDocument codeDocument) + { + var engine = RazorEngine.Create(); + + return Lower(codeDocument, engine); + } + + private static DocumentIRNode Lower(RazorCodeDocument codeDocument, RazorEngine engine) + { + for (var i = 0; i < engine.Phases.Count; i++) + { + var phase = engine.Phases[i]; + phase.Execute(codeDocument); + + if (phase is IRazorIRLoweringPhase) + { + break; + } + } + + var irDocument = codeDocument.GetIRDocument(); + Assert.NotNull(irDocument); + + return irDocument; + } + + private static TagHelperDescriptor CreateTagHelperDescriptor( + string tagName, + string typeName, + string assemblyName, + IEnumerable> attributes = null) + { + var builder = TagHelperDescriptorBuilder.Create(typeName, assemblyName); + + if (attributes != null) + { + foreach (var attributeBuilder in attributes) + { + builder.BindAttribute(attributeBuilder); + } + } + + builder.TagMatchingRule(ruleBuilder => ruleBuilder.RequireTagName(tagName)); + + var descriptor = builder.Build(); + + return descriptor; + } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/LiteralRuntimeBasicWriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/LiteralRuntimeBasicWriterTest.cs new file mode 100644 index 0000000000..16edb5ffac --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/LiteralRuntimeBasicWriterTest.cs @@ -0,0 +1,50 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + public class LiteralRuntimeBasicWriterTest + { + [Fact] + public void WriteCSharpExpression_UsesWriteLiteral_WritesLinePragma_WithSource() + { + // Arrange + var writer = new LiteralRuntimeBasicWriter(); + + var context = new CSharpRenderingContext() + { + Options = RazorParserOptions.CreateDefaultOptions(), + Writer = new Legacy.CSharpCodeWriter(), + }; + + var node = new CSharpExpressionIRNode() + { + Source = new SourceSpan("test.cshtml", 0, 0, 0, 3), + }; + var builder = RazorIRBuilder.Create(node); + builder.Add(new RazorIRToken() + { + Content = "i++", + Kind = RazorIRToken.TokenKind.CSharp, + }); + + // Act + writer.WriteCSharpExpression(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"#line 1 ""test.cshtml"" +WriteLiteral(i++); + +#line default +#line hidden +", + csharp, + ignoreLineEndingDifferences: true); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/PreallocatedAttributeTargetExtensionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/PreallocatedAttributeTargetExtensionTest.cs new file mode 100644 index 0000000000..e799dd0e20 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/PreallocatedAttributeTargetExtensionTest.cs @@ -0,0 +1,207 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Microsoft.AspNetCore.Razor.Language.Legacy; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + public class PreallocatedAttributeTargetExtensionTest + { + [Fact] + public void WriteDeclarePreallocatedTagHelperHtmlAttribute_RendersCorrectly() + { + // Arrange + var extension = new PreallocatedAttributeTargetExtension(); + var context = new CSharpRenderingContext() + { + Writer = new CSharpCodeWriter() + }; + + var node = new DeclarePreallocatedTagHelperHtmlAttributeIRNode() + { + Name = "Foo", + Value = "Bar", + ValueStyle = HtmlAttributeValueStyle.DoubleQuotes, + VariableName = "MyProp" + }; + + // Act + extension.WriteDeclarePreallocatedTagHelperHtmlAttribute(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute MyProp = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute(""Foo"", new global::Microsoft.AspNetCore.Html.HtmlString(""Bar""), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteDeclarePreallocatedTagHelperHtmlAttribute_Minimized_RendersCorrectly() + { + // Arrange + var extension = new PreallocatedAttributeTargetExtension(); + var context = new CSharpRenderingContext() + { + Writer = new CSharpCodeWriter() + }; + + var node = new DeclarePreallocatedTagHelperHtmlAttributeIRNode() + { + Name = "Foo", + Value = "Bar", + ValueStyle = HtmlAttributeValueStyle.Minimized, + VariableName = "_tagHelper1" + }; + + // Act + extension.WriteDeclarePreallocatedTagHelperHtmlAttribute(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute _tagHelper1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute(""Foo""); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteAddPreallocatedTagHelperHtmlAttribute_RendersCorrectly() + { + // Arrange + var extension = new PreallocatedAttributeTargetExtension(); + var context = new CSharpRenderingContext() + { + Writer = new CSharpCodeWriter() + }; + + var node = new AddPreallocatedTagHelperHtmlAttributeIRNode() + { + VariableName = "_tagHelper1" + }; + + // Act + extension.WriteAddPreallocatedTagHelperHtmlAttribute(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"__tagHelperExecutionContext.AddHtmlAttribute(_tagHelper1); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteDeclarePreallocatedTagHelperAttribute_RendersCorrectly() + { + // Arrange + var extension = new PreallocatedAttributeTargetExtension(); + var context = new CSharpRenderingContext() + { + Writer = new CSharpCodeWriter() + }; + + var node = new DeclarePreallocatedTagHelperAttributeIRNode() + { + Name = "Foo", + Value = "Bar", + ValueStyle = HtmlAttributeValueStyle.DoubleQuotes, + VariableName = "_tagHelper1", + }; + + // Act + extension.WriteDeclarePreallocatedTagHelperAttribute(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute _tagHelper1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute(""Foo"", ""Bar"", global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteSetPreallocatedTagHelperProperty_RendersCorrectly() + { + // Arrange + var extension = new PreallocatedAttributeTargetExtension(); + var context = new CSharpRenderingContext() + { + Writer = new CSharpCodeWriter() + }; + + var descriptor = ITagHelperBoundAttributeDescriptorBuilder + .Create("FooTagHelper") + .Name("Foo") + .TypeName("System.String") + .PropertyName("FooProp") + .Build(); + + var node = new SetPreallocatedTagHelperPropertyIRNode() + { + AttributeName = descriptor.Name, + TagHelperTypeName = "FooTagHelper", + VariableName = "_tagHelper1", + Descriptor = descriptor, + }; + + // Act + extension.WriteSetPreallocatedTagHelperProperty(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"__FooTagHelper.FooProp = (string)_tagHelper1.Value; +__tagHelperExecutionContext.AddTagHelperAttribute(_tagHelper1); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteSetPreallocatedTagHelperProperty_IndexerAttribute_RendersCorrectly() + { + // Arrange + var extension = new PreallocatedAttributeTargetExtension(); + var context = new CSharpRenderingContext() + { + Writer = new CSharpCodeWriter() + }; + + var descriptor = ITagHelperBoundAttributeDescriptorBuilder + .Create("FooTagHelper") + .Name("Foo") + .TypeName("System.Collections.Generic.Dictionary") + .AsDictionary("pre-", "System.String") + .PropertyName("FooProp") + .Build(); + + var node = new SetPreallocatedTagHelperPropertyIRNode() + { + AttributeName = "pre-Foo", + TagHelperTypeName = "FooTagHelper", + VariableName = "_tagHelper1", + Descriptor = descriptor, + IsIndexerNameMatch = true + }; + + // Act + extension.WriteSetPreallocatedTagHelperProperty(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"__FooTagHelper.FooProp[""Foo""] = (string)_tagHelper1.Value; +__tagHelperExecutionContext.AddTagHelperAttribute(_tagHelper1); +", + csharp, + ignoreLineEndingDifferences: true); + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RedirectedRuntimeBasicWriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RedirectedRuntimeBasicWriterTest.cs index 28a1407da5..498e219d1e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RedirectedRuntimeBasicWriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RedirectedRuntimeBasicWriterTest.cs @@ -3,12 +3,13 @@ using System; using System.Collections.Generic; +using System.Linq; using Microsoft.AspNetCore.Razor.Language.Intermediate; using Xunit; namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration { - public class RedirectedBasicWriterTest + public class RedirectedRuntimeBasicWriterTest { [Fact] public void WriteCSharpExpression_Runtime_SkipsLinePragma_WithoutSource() @@ -243,6 +244,155 @@ WriteLiteralTo(test_writer, @""{1}""); ignoreLineEndingDifferences: true); } + [Fact] + public void WriteHtmlAttribute_RendersCorrectly() + { + var writer = new RedirectedRuntimeBasicWriter("test_writer"); + var context = GetCSharpRenderingContext(writer); + + var content = ""; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var irDocument = Lower(codeDocument); + var node = irDocument.Children.OfType().Single(); + + // Act + writer.WriteHtmlAttribute(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"BeginWriteAttributeTo(test_writer, ""checked"", "" checked=\"""", 6, ""\"""", 34, 2); +Render Children +EndWriteAttributeTo(test_writer); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteHtmlAttributeValue_RendersCorrectly() + { + var writer = new RedirectedRuntimeBasicWriter("test_writer"); + var context = GetCSharpRenderingContext(writer); + + var content = ""; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var irDocument = Lower(codeDocument); + var node = irDocument.Children.OfType().Single().Children[0] as HtmlAttributeValueIRNode; + + // Act + writer.WriteHtmlAttributeValue(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"WriteAttributeValueTo(test_writer, """", 16, ""hello-world"", 16, 11, true); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteCSharpAttributeValue_RendersCorrectly() + { + var writer = new RedirectedRuntimeBasicWriter("test_writer"); + var context = GetCSharpRenderingContext(writer); + + var content = ""; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var irDocument = Lower(codeDocument); + var node = irDocument.Children.OfType().Single().Children[1] as CSharpAttributeValueIRNode; + + // Act + writer.WriteCSharpAttributeValue(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"#line 1 ""test.cshtml"" +WriteAttributeValueTo(test_writer, "" "", 27, false, 28, 6, false); + +#line default +#line hidden +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteCSharpAttributeValue_NonExpression_BuffersResult() + { + var writer = new RedirectedRuntimeBasicWriter("test_writer"); + var context = GetCSharpRenderingContext(writer); + + var content = ""; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var irDocument = Lower(codeDocument); + var node = irDocument.Children.OfType().Single().Children[1] as CSharpAttributeValueIRNode; + + // Act + writer.WriteCSharpAttributeValue(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"WriteAttributeValueTo(test_writer, "" "", 27, new Microsoft.AspNetCore.Mvc.Razor.HelperResult(async(__razor_attribute_value_writer) => { + Render Children +} +), 28, 13, false); +", + csharp, + ignoreLineEndingDifferences: true); + } + + private static CSharpRenderingContext GetCSharpRenderingContext(BasicWriter writer) + { + var options = RazorParserOptions.CreateDefaultOptions(); + var codeWriter = new Legacy.CSharpCodeWriter(); + var context = new CSharpRenderingContext() + { + Writer = codeWriter, + Options = options, + BasicWriter = writer, + RenderChildren = n => + { + codeWriter.WriteLine("Render Children"); + } + }; + + return context; + } + + private static DocumentIRNode Lower(RazorCodeDocument codeDocument) + { + var engine = RazorEngine.Create(); + + return Lower(codeDocument, engine); + } + + private static DocumentIRNode Lower(RazorCodeDocument codeDocument, RazorEngine engine) + { + for (var i = 0; i < engine.Phases.Count; i++) + { + var phase = engine.Phases[i]; + phase.Execute(codeDocument); + + if (phase is IRazorIRLoweringPhase) + { + break; + } + } + + var irDocument = codeDocument.GetIRDocument(); + Assert.NotNull(irDocument); + + return irDocument; + } + private class MyExtensionIRNode : ExtensionIRNode { public override IList Children => throw new NotImplementedException(); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RedirectedRuntimeTagHelperWriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RedirectedRuntimeTagHelperWriterTest.cs index 9ca1b00db5..53a1bc33f5 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RedirectedRuntimeTagHelperWriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RedirectedRuntimeTagHelperWriterTest.cs @@ -1,14 +1,12 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; -using System.Collections.Generic; using Microsoft.AspNetCore.Razor.Language.Intermediate; using Xunit; namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration { - public class RedirectedTagHelperWriterTest + public class RedirectedRuntimeTagHelperWriterTest { [Fact] public void WriteExecuteTagHelpers_Runtime_RendersWithRedirectWriter() diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RuntimeBasicWriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RuntimeBasicWriterTest.cs index 6a1fe473f8..03989cb39f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RuntimeBasicWriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RuntimeBasicWriterTest.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Linq; using Microsoft.AspNetCore.Razor.Language.Intermediate; using Xunit; @@ -10,6 +11,119 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration { public class RuntimeBasicWriterTest { + [Fact] + public void WriteChecksum_WritesPragmaChecksum() + { + // Arrange + var writer = new RuntimeBasicWriter(); + var context = new CSharpRenderingContext() + { + Writer = new Legacy.CSharpCodeWriter() + }; + + var node = new ChecksumIRNode() + { + FileName = "test.cshtml", + Guid = "SomeGuid", + Bytes = "SomeFileHash" + }; + + // Act + writer.WriteChecksum(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"#pragma checksum ""test.cshtml"" ""SomeGuid"" ""SomeFileHash"" +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteChecksum_EmptyBytes_WritesNothing() + { + // Arrange + var writer = new RuntimeBasicWriter(); + var context = new CSharpRenderingContext() + { + Writer = new Legacy.CSharpCodeWriter() + }; + + var node = new ChecksumIRNode() + { + FileName = "test.cshtml", + Guid = "SomeGuid", + Bytes = string.Empty + }; + + // Act + writer.WriteChecksum(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Empty(csharp); + } + + [Fact] + public void WriteUsingStatement_NoSource_WritesContent() + { + // Arrange + var writer = new RuntimeBasicWriter(); + var context = new CSharpRenderingContext() + { + Writer = new Legacy.CSharpCodeWriter() + }; + + var node = new UsingStatementIRNode() + { + Content = "System", + }; + + // Act + writer.WriteUsingStatement(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"using System; +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteUsingStatement_WithSource_WritesContentWithLinePragma() + { + // Arrange + var writer = new RuntimeBasicWriter(); + var context = new CSharpRenderingContext() + { + Writer = new Legacy.CSharpCodeWriter() + }; + + var node = new UsingStatementIRNode() + { + Content = "System", + Source = new SourceSpan("test.cshtml", 0, 0, 0, 3), + }; + + // Act + writer.WriteUsingStatement(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"#line 1 ""test.cshtml"" +using System; + +#line default +#line hidden +", + csharp, + ignoreLineEndingDifferences: true); + } + [Fact] public void WriteCSharpExpression_SkipsLinePragma_WithoutSource() { @@ -378,6 +492,155 @@ WriteLiteral(@""{1}""); ignoreLineEndingDifferences: true); } + [Fact] + public void WriteHtmlAttribute_RendersCorrectly() + { + var writer = new RuntimeBasicWriter(); + var context = GetCSharpRenderingContext(writer); + + var content = ""; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var irDocument = Lower(codeDocument); + var node = irDocument.Children.OfType().Single(); + + // Act + writer.WriteHtmlAttribute(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"BeginWriteAttribute(""checked"", "" checked=\"""", 6, ""\"""", 34, 2); +Render Children +EndWriteAttribute(); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteHtmlAttributeValue_RendersCorrectly() + { + var writer = new RuntimeBasicWriter(); + var context = GetCSharpRenderingContext(writer); + + var content = ""; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var irDocument = Lower(codeDocument); + var node = irDocument.Children.OfType().Single().Children[0] as HtmlAttributeValueIRNode; + + // Act + writer.WriteHtmlAttributeValue(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"WriteAttributeValue("""", 16, ""hello-world"", 16, 11, true); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteCSharpAttributeValue_RendersCorrectly() + { + var writer = new RuntimeBasicWriter(); + var context = GetCSharpRenderingContext(writer); + + var content = ""; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var irDocument = Lower(codeDocument); + var node = irDocument.Children.OfType().Single().Children[1] as CSharpAttributeValueIRNode; + + // Act + writer.WriteCSharpAttributeValue(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"#line 1 ""test.cshtml"" +WriteAttributeValue("" "", 27, false, 28, 6, false); + +#line default +#line hidden +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteCSharpAttributeValue_NonExpression_BuffersResult() + { + var writer = new RuntimeBasicWriter(); + var context = GetCSharpRenderingContext(writer); + + var content = ""; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var irDocument = Lower(codeDocument); + var node = irDocument.Children.OfType().Single().Children[1] as CSharpAttributeValueIRNode; + + // Act + writer.WriteCSharpAttributeValue(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"WriteAttributeValue("" "", 27, new Microsoft.AspNetCore.Mvc.Razor.HelperResult(async(__razor_attribute_value_writer) => { + Render Children +} +), 28, 13, false); +", + csharp, + ignoreLineEndingDifferences: true); + } + + private static CSharpRenderingContext GetCSharpRenderingContext(BasicWriter writer) + { + var options = RazorParserOptions.CreateDefaultOptions(); + var codeWriter = new Legacy.CSharpCodeWriter(); + var context = new CSharpRenderingContext() + { + Writer = codeWriter, + Options = options, + BasicWriter = writer, + RenderChildren = n => + { + codeWriter.WriteLine("Render Children"); + } + }; + + return context; + } + + private static DocumentIRNode Lower(RazorCodeDocument codeDocument) + { + var engine = RazorEngine.Create(); + + return Lower(codeDocument, engine); + } + + private static DocumentIRNode Lower(RazorCodeDocument codeDocument, RazorEngine engine) + { + for (var i = 0; i < engine.Phases.Count; i++) + { + var phase = engine.Phases[i]; + phase.Execute(codeDocument); + + if (phase is IRazorIRLoweringPhase) + { + break; + } + } + + var irDocument = codeDocument.GetIRDocument(); + Assert.NotNull(irDocument); + + return irDocument; + } + private class MyExtensionIRNode : ExtensionIRNode { public override IList Children => throw new NotImplementedException(); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RuntimeTagHelperWriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RuntimeTagHelperWriterTest.cs index c93d6a2a3a..77c018b462 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RuntimeTagHelperWriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RuntimeTagHelperWriterTest.cs @@ -15,12 +15,9 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration public void WriteDeclareTagHelperFields_DeclaresRequiredFields() { // Arrange - var writer = new RuntimeTagHelperWriter(); - var context = new CSharpRenderingContext() - { - Writer = new Legacy.CSharpCodeWriter(), - }; var node = new DeclareTagHelperFieldsIRNode(); + var writer = new RuntimeTagHelperWriter(); + var context = GetCSharpRenderingContext(writer); // Act writer.WriteDeclareTagHelperFields(context, node); @@ -55,15 +52,13 @@ private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeMana public void WriteDeclareTagHelperFields_DeclaresUsedTagHelperTypes() { // Arrange - var writer = new RuntimeTagHelperWriter(); - var context = new CSharpRenderingContext() - { - Writer = new Legacy.CSharpCodeWriter(), - }; var node = new DeclareTagHelperFieldsIRNode(); node.UsedTagHelperTypeNames.Add("PTagHelper"); node.UsedTagHelperTypeNames.Add("MyTagHelper"); + var writer = new RuntimeTagHelperWriter(); + var context = GetCSharpRenderingContext(writer); + // Act writer.WriteDeclareTagHelperFields(context, node); @@ -99,20 +94,14 @@ private global::MyTagHelper __MyTagHelper = null; public void WriteInitializeTagHelperStructure_RendersCorrectly_UsesTagNameAndModeFromIRNode() { // Arrange - var writer = new RuntimeTagHelperWriter(); - var context = new CSharpRenderingContext() - { - Writer = new Legacy.CSharpCodeWriter(), - BasicWriter = new RuntimeBasicWriter(), - TagHelperWriter = new RuntimeTagHelperWriter(), - IdGenerator = () => "test", - RenderChildren = n => { } - }; var node = new InitializeTagHelperStructureIRNode() { TagName = "p", TagMode = TagMode.SelfClosing }; + var writer = new RuntimeTagHelperWriter(); + var context = GetCSharpRenderingContext(writer); + context.IdGenerator = () => "test"; // Act writer.WriteInitializeTagHelperStructure(context, node); @@ -121,6 +110,7 @@ private global::MyTagHelper __MyTagHelper = null; var csharp = context.Writer.Builder.ToString(); Assert.Equal( @"__tagHelperExecutionContext = __tagHelperScopeManager.Begin(""p"", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, ""test"", async() => { + Render Children } ); ", @@ -132,15 +122,12 @@ private global::MyTagHelper __MyTagHelper = null; public void WriteCreateTagHelper_RendersCorrectly_UsesSpecifiedTagHelperType() { // Arrange - var writer = new RuntimeTagHelperWriter(); - var context = new CSharpRenderingContext() - { - Writer = new Legacy.CSharpCodeWriter(), - }; var node = new CreateTagHelperIRNode() { TagHelperTypeName = "TestNamespace.MyTagHelper" }; + var writer = new RuntimeTagHelperWriter(); + var context = GetCSharpRenderingContext(writer); // Act writer.WriteCreateTagHelper(context, node); @@ -159,12 +146,9 @@ __tagHelperExecutionContext.Add(__TestNamespace_MyTagHelper); public void WriteExecuteTagHelpers_RendersCorrectly() { // Arrange - var writer = new RuntimeTagHelperWriter(); - var context = new CSharpRenderingContext() - { - Writer = new Legacy.CSharpCodeWriter(), - }; var node = new ExecuteTagHelpersIRNode(); + var writer = new RuntimeTagHelperWriter(); + var context = GetCSharpRenderingContext(writer); // Act writer.WriteExecuteTagHelpers(context, node); @@ -188,21 +172,6 @@ __tagHelperExecutionContext = __tagHelperScopeManager.End(); public void WriteAddTagHelperHtmlAttribute_RendersCorrectly() { // Arrange - var writer = new RuntimeTagHelperWriter(); - var options = RazorParserOptions.CreateDefaultOptions(); - var codeWriter = new Legacy.CSharpCodeWriter(); - var context = new CSharpRenderingContext() - { - Writer = codeWriter, - Options = options, - BasicWriter = new RuntimeBasicWriter(), - TagHelperWriter = writer, - RenderChildren = n => - { - codeWriter.WriteLine("Render Children"); - } - }; - var descriptors = new[] { CreateTagHelperDescriptor( @@ -219,6 +188,9 @@ __tagHelperExecutionContext = __tagHelperScopeManager.End(); var irDocument = Lower(codeDocument, engine); var node = irDocument.Children.Last().Children[2] as AddTagHelperHtmlAttributeIRNode; + var writer = new RuntimeTagHelperWriter(); + var context = GetCSharpRenderingContext(writer, codeDocument); + // Act writer.WriteAddTagHelperHtmlAttribute(context, node); @@ -238,21 +210,6 @@ __tagHelperExecutionContext.AddHtmlAttribute(""name"", Html.Raw(__tagHelperStrin public void WriteAddTagHelperHtmlAttribute_DataAttribute_RendersCorrectly() { // Arrange - var writer = new RuntimeTagHelperWriter(); - var options = RazorParserOptions.CreateDefaultOptions(); - var codeWriter = new Legacy.CSharpCodeWriter(); - var context = new CSharpRenderingContext() - { - Writer = codeWriter, - Options = options, - BasicWriter = new RuntimeBasicWriter(), - TagHelperWriter = writer, - RenderChildren = n => - { - codeWriter.WriteLine("Render Children"); - } - }; - var descriptors = new[] { CreateTagHelperDescriptor( @@ -269,6 +226,9 @@ __tagHelperExecutionContext.AddHtmlAttribute(""name"", Html.Raw(__tagHelperStrin var irDocument = Lower(codeDocument, engine); var node = irDocument.Children.Last().Children[2] as AddTagHelperHtmlAttributeIRNode; + var writer = new RuntimeTagHelperWriter(); + var context = GetCSharpRenderingContext(writer, codeDocument); + // Act writer.WriteAddTagHelperHtmlAttribute(context, node); @@ -288,21 +248,6 @@ __tagHelperExecutionContext.AddHtmlAttribute(""data-test"", Html.Raw(__tagHelper public void WriteAddTagHelperHtmlAttribute_DynamicAttribute_RendersCorrectly() { // Arrange - var writer = new RuntimeTagHelperWriter(); - var options = RazorParserOptions.CreateDefaultOptions(); - var codeWriter = new Legacy.CSharpCodeWriter(); - var context = new CSharpRenderingContext() - { - Writer = codeWriter, - Options = options, - BasicWriter = new RuntimeBasicWriter(), - TagHelperWriter = writer, - RenderChildren = n => - { - codeWriter.WriteLine("Render Children"); - } - }; - var descriptors = new[] { CreateTagHelperDescriptor( @@ -319,6 +264,9 @@ __tagHelperExecutionContext.AddHtmlAttribute(""data-test"", Html.Raw(__tagHelper var irDocument = Lower(codeDocument, engine); var node = irDocument.Children.Last().Children[2] as AddTagHelperHtmlAttributeIRNode; + var writer = new RuntimeTagHelperWriter(); + var context = GetCSharpRenderingContext(writer, codeDocument); + // Act writer.WriteAddTagHelperHtmlAttribute(context, node); @@ -333,6 +281,173 @@ EndAddHtmlAttributeValues(__tagHelperExecutionContext); ignoreLineEndingDifferences: true); } + [Fact] + public void WriteSetTagHelperProperty_RendersCorrectly() + { + // Arrange + var descriptors = new[] + { + CreateTagHelperDescriptor( + tagName: "input", + typeName: "InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("bound") + .PropertyName("FooProp") + .TypeName("System.String"), + }) + }; + var engine = RazorEngine.Create(builder => builder.AddTagHelpers(descriptors)); + var content = @" +@addTagHelper *, TestAssembly +"; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var irDocument = Lower(codeDocument, engine); + var node = irDocument.Children.Last().Children[2] as SetTagHelperPropertyIRNode; + + var writer = new RuntimeTagHelperWriter(); + var context = GetCSharpRenderingContext(writer, codeDocument); + + // Act + writer.WriteSetTagHelperProperty(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + + // The attribute value is not rendered inline because we are not using the preallocated writer. + Assert.Equal( +@"BeginWriteTagHelperAttribute(); +Render Children +__tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); +__InputTagHelper.FooProp = __tagHelperStringValueBuffer; +__tagHelperExecutionContext.AddTagHelperAttribute(""bound"", __InputTagHelper.FooProp, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteSetTagHelperProperty_NonStringAttribute_RendersCorrectly() + { + // Arrange + var descriptors = new[] + { + CreateTagHelperDescriptor( + tagName: "input", + typeName: "InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("bound") + .PropertyName("FooProp") + .TypeName("System.Int32"), + }) + }; + var engine = RazorEngine.Create(builder => builder.AddTagHelpers(descriptors)); + var content = @" +@addTagHelper *, TestAssembly +"; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var irDocument = Lower(codeDocument, engine); + var node = irDocument.Children.Last().Children[2] as SetTagHelperPropertyIRNode; + + var writer = new RuntimeTagHelperWriter(); + var context = GetCSharpRenderingContext(writer, codeDocument); + + // Act + writer.WriteSetTagHelperProperty(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"#line 3 ""test.cshtml"" +__InputTagHelper.FooProp = 42; + +#line default +#line hidden +__tagHelperExecutionContext.AddTagHelperAttribute(""bound"", __InputTagHelper.FooProp, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteSetTagHelperProperty_IndexerAttribute_RendersCorrectly() + { + // Arrange + var descriptors = new[] + { + CreateTagHelperDescriptor( + tagName: "input", + typeName: "InputTagHelper", + assemblyName: "TestAssembly", + attributes: new Action[] + { + builder => builder + .Name("bound") + .PropertyName("FooProp") + .TypeName("System.Collections.Generic.Dictionary") + .AsDictionary("foo-", "System.Int32"), + }) + }; + var engine = RazorEngine.Create(builder => builder.AddTagHelpers(descriptors)); + var content = @" +@addTagHelper *, TestAssembly +"; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var irDocument = Lower(codeDocument, engine); + var node = irDocument.Children.Last().Children[2] as SetTagHelperPropertyIRNode; + + var writer = new RuntimeTagHelperWriter(); + var context = GetCSharpRenderingContext(writer, codeDocument); + + // Act + writer.WriteSetTagHelperProperty(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"if (__InputTagHelper.FooProp == null) +{ + throw new InvalidOperationException(InvalidTagHelperIndexerAssignment(""foo-bound"", ""InputTagHelper"", ""FooProp"")); +} +#line 3 ""test.cshtml"" +__InputTagHelper.FooProp[""bound""] = 42; + +#line default +#line hidden +__tagHelperExecutionContext.AddTagHelperAttribute(""foo-bound"", __InputTagHelper.FooProp[""bound""], global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); +", + csharp, + ignoreLineEndingDifferences: true); + } + + private static CSharpRenderingContext GetCSharpRenderingContext(TagHelperWriter writer, RazorCodeDocument codeDocument = null) + { + var options = RazorParserOptions.CreateDefaultOptions(); + var codeWriter = new Legacy.CSharpCodeWriter(); + var context = new CSharpRenderingContext() + { + Writer = codeWriter, + Options = options, + BasicWriter = new RuntimeBasicWriter(), + TagHelperWriter = writer, + TagHelperRenderingContext = new TagHelperRenderingContext(), + RenderChildren = n => + { + codeWriter.WriteLine("Render Children"); + } + }; + + return context; + } + private static DocumentIRNode Lower(RazorCodeDocument codeDocument) { var engine = RazorEngine.Create(); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/TagHelperHtmlAttributeRuntimeBasicWriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/TagHelperHtmlAttributeRuntimeBasicWriterTest.cs new file mode 100644 index 0000000000..47ea6f7db5 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/TagHelperHtmlAttributeRuntimeBasicWriterTest.cs @@ -0,0 +1,135 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Linq; +using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration +{ + public class TagHelperHtmlAttributeRuntimeBasicWriterTest + { + [Fact] + public void WriteHtmlAttributeValue_RendersCorrectly() + { + var writer = new TagHelperHtmlAttributeRuntimeBasicWriter(); + var context = GetCSharpRenderingContext(writer); + + var content = ""; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var irDocument = Lower(codeDocument); + var node = irDocument.Children.OfType().Single().Children[0] as HtmlAttributeValueIRNode; + + // Act + writer.WriteHtmlAttributeValue(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"AddHtmlAttributeValue("""", 16, ""hello-world"", 16, 11, true); +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteCSharpAttributeValue_RendersCorrectly() + { + var writer = new TagHelperHtmlAttributeRuntimeBasicWriter(); + var context = GetCSharpRenderingContext(writer); + + var content = ""; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var irDocument = Lower(codeDocument); + var node = irDocument.Children.OfType().Single().Children[1] as CSharpAttributeValueIRNode; + + // Act + writer.WriteCSharpAttributeValue(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"#line 1 ""test.cshtml"" +AddHtmlAttributeValue("" "", 27, false, 28, 6, false); + +#line default +#line hidden +", + csharp, + ignoreLineEndingDifferences: true); + } + + [Fact] + public void WriteCSharpAttributeValue_NonExpression_BuffersResult() + { + var writer = new TagHelperHtmlAttributeRuntimeBasicWriter(); + var context = GetCSharpRenderingContext(writer); + + var content = ""; + var sourceDocument = TestRazorSourceDocument.Create(content); + var codeDocument = RazorCodeDocument.Create(sourceDocument); + var irDocument = Lower(codeDocument); + var node = irDocument.Children.OfType().Single().Children[1] as CSharpAttributeValueIRNode; + + // Act + writer.WriteCSharpAttributeValue(context, node); + + // Assert + var csharp = context.Writer.Builder.ToString(); + Assert.Equal( +@"AddHtmlAttributeValue("" "", 27, new Microsoft.AspNetCore.Mvc.Razor.HelperResult(async(__razor_attribute_value_writer) => { + Render Children +} +), 28, 13, false); +", + csharp, + ignoreLineEndingDifferences: true); + } + + private static CSharpRenderingContext GetCSharpRenderingContext(BasicWriter writer) + { + var options = RazorParserOptions.CreateDefaultOptions(); + var codeWriter = new Legacy.CSharpCodeWriter(); + var context = new CSharpRenderingContext() + { + Writer = codeWriter, + Options = options, + BasicWriter = writer, + RenderChildren = n => + { + codeWriter.WriteLine("Render Children"); + } + }; + + return context; + } + + private static DocumentIRNode Lower(RazorCodeDocument codeDocument) + { + var engine = RazorEngine.Create(); + + return Lower(codeDocument, engine); + } + + private static DocumentIRNode Lower(RazorCodeDocument codeDocument, RazorEngine engine) + { + for (var i = 0; i < engine.Phases.Count; i++) + { + var phase = engine.Phases[i]; + phase.Execute(codeDocument); + + if (phase is IRazorIRLoweringPhase) + { + break; + } + } + + var irDocument = codeDocument.GetIRDocument(); + Assert.NotNull(irDocument); + + return irDocument; + } + } +} diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/TemplateTargetExtensionTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/TemplateTargetExtensionTest.cs index 10c83a0ce0..c57ac79ca8 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/TemplateTargetExtensionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/TemplateTargetExtensionTest.cs @@ -32,8 +32,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration { Assert.Same(node, n); - var conventions = Assert.IsType(context.RenderingConventions); - Assert.Equal("__razor_template_writer", conventions.RedirectWriter); + Assert.IsType(context.BasicWriter); context.Writer.Write(" var s = \"Inside\""); }; diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective_DesignTime.ir.txt index 3b204d182b..e20e03a673 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AddTagHelperDirective_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AddTagHelperDirective_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [17] AddTagHelperDirective.cshtml) - "*, TestAssembly" - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_DesignTime.ir.txt index bf9d7a1b0a..12c2767f05 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/AttributeTargetingTagHelpers_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_AttributeTargetingTagHelpers_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [15] AttributeTargetingTagHelpers.cshtml) - *, TestAssembly - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - TestNamespace.PTagHelper - TestNamespace.CatchAllTagHelper - TestNamespace.InputTagHelper - TestNamespace.InputTagHelper2 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.ir.txt index f93bf6d0b3..a84e6022a9 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Await_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Await_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_DesignTime.ir.txt index 4212571999..8b27cc6c03 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicImports_DesignTime.ir.txt @@ -7,16 +7,8 @@ Document - UsingStatement - (80:3,1 [27] BasicImports_Imports0.cshtml) - System.ComponentModel UsingStatement - (23:1,1 [18] BasicImports_Imports1.cshtml) - System.Text ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicImports_DesignTime - Hello - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (119:4,10 [5] BasicImports_Imports0.cshtml) - Hello - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_DesignTime.ir.txt index 26ae10c963..d195ebe04c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [17] BasicTagHelpers.cshtml) - "*, TestAssembly" - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - TestNamespace.PTagHelper - TestNamespace.InputTagHelper - TestNamespace.InputTagHelper2 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_DesignTime.ir.txt index b03e44ecef..311edfae21 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicTagHelpers_Prefixed_DesignTime.ir.txt @@ -4,17 +4,9 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_BasicTagHelpers_Prefixed_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (17:0,17 [5] BasicTagHelpers_Prefixed.cshtml) - "THS" DirectiveToken - (38:1,14 [17] BasicTagHelpers_Prefixed.cshtml) - "*, TestAssembly" - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - TestNamespace.PTagHelper - TestNamespace.InputTagHelper - TestNamespace.InputTagHelper2 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_DesignTime.ir.txt index 3e15db9d55..343d90f0d1 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Blocks_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Blocks_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_DesignTime.ir.txt index df633e2dc8..145d18f28b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CSharp7_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CSharp7_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.ir.txt index 7d1936ca4e..659640ae01 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockAtEOF_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockAtEOF_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.ir.txt index 88812640e0..7dd8a1f75d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlockWithTextElement_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlockWithTextElement_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_DesignTime.ir.txt index 4b2eab9a84..19c147de8e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/CodeBlock_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_CodeBlock_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.ir.txt index 0ed50c5d1c..05016a806c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ComplexTagHelpers_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ComplexTagHelpers_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [17] ComplexTagHelpers.cshtml) - "*, TestAssembly" - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - TestNamespace.PTagHelper - TestNamespace.InputTagHelper - TestNamespace.InputTagHelper2 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.ir.txt index 967d393dd5..98b6d1ab82 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ConditionalAttributes_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ConditionalAttributes_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime_DesignTime.ir.txt index e079d658d3..9c1452635d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DesignTime_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DesignTime_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (173:11,9 [6] DesignTime.cshtml) - Footer - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_DesignTime.ir.txt index fc886e1296..428498c0c8 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DuplicateAttributeTagHelpers_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DuplicateAttributeTagHelpers_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [17] DuplicateAttributeTagHelpers.cshtml) - "*, TestAssembly" - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - TestNamespace.PTagHelper - TestNamespace.InputTagHelper - TestNamespace.InputTagHelper2 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_DesignTime.ir.txt index c2d84bad04..ff84378e67 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/DynamicAttributeTagHelpers_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_DynamicAttributeTagHelpers_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [17] DynamicAttributeTagHelpers.cshtml) - "*, TestAssembly" - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - TestNamespace.InputTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.ir.txt index 496da283d4..db35c95c64 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyAttributeTagHelpers_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyAttributeTagHelpers_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [15] EmptyAttributeTagHelpers.cshtml) - *, TestAssembly - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - TestNamespace.InputTagHelper - TestNamespace.InputTagHelper2 - TestNamespace.PTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.ir.txt index 7a07761b0d..960ed1e704 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyCodeBlock_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyCodeBlock_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_DesignTime.ir.txt index 1cd3817ecd..5a4258e609 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyExplicitExpression_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.ir.txt index efbc6e970c..bbdddfaaa8 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpressionInCode_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.ir.txt index 6731e3c081..fe90bc7056 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpression_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_DesignTime.ir.txt index 72ffee3616..99449ccb29 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EnumTagHelpers_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EnumTagHelpers_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [17] EnumTagHelpers.cshtml) - "*, TestAssembly" - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - TestNamespace.InputTagHelper - TestNamespace.CatchAllTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_DesignTime.ir.txt index db8bd9fc4f..f3f0fa2b68 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EscapedTagHelpers_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EscapedTagHelpers_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [15] EscapedTagHelpers.cshtml) - *, TestAssembly - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - TestNamespace.InputTagHelper - TestNamespace.InputTagHelper2 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.ir.txt index 8ab3b3599d..0d20e4b4a9 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionAtEOF_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.ir.txt index 7805a45c8c..0f610f00b0 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionWithMarkup_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_DesignTime.ir.txt index 4f816e2480..c47b6df3e2 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpression_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpression_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_DesignTime.ir.txt index 786b4c6be8..34104cb16c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExpressionsInCode_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExpressionsInCode_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_DesignTime.ir.txt index 97333fd642..c007572c76 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlockMinimal_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlockMinimal_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.ir.txt index b3e390db20..8762191634 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/FunctionsBlock_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_FunctionsBlock_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.ir.txt index 3b947900f3..ef808f8a8d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HiddenSpansInCode_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HiddenSpansInCode_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_DesignTime.ir.txt index 2b1d575016..11fa6227ae 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Double_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Double_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_DesignTime.ir.txt index a036261305..d1f130eccc 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/HtmlCommentWithQuote_Single_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_HtmlCommentWithQuote_Single_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.ir.txt index 197bd5bb1d..5bc473acc9 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpressionAtEOF_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_DesignTime.ir.txt index 675c91eb90..6f652ae74a 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpression_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpression_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_DesignTime.ir.txt index bec89170da..d5acd33fdd 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteTagHelper_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteTagHelper_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [17] IncompleteTagHelper.cshtml) - "*, TestAssembly" - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - TestNamespace.PTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_DesignTime.ir.txt index 2ffb04156e..2fff761e3e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inherits_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inherits_DesignTime - foo.bar>.boz - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (20:2,10 [21] Inherits.cshtml) - foo.bar>.boz - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_DesignTime.ir.txt index ed3fced1be..5c70e6e09c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InlineBlocks_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InlineBlocks_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (9:0,9 [4] InlineBlocks.cshtml) - Link - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.ir.txt index 9e29f8dc6a..f315c1552d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Instrumented_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Instrumented_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_DesignTime.ir.txt index 96835df96b..d600a7554d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MarkupInCodeBlock_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MarkupInCodeBlock_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_DesignTime.ir.txt index 35e3967766..10bebb8c3a 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MinimizedTagHelpers_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MinimizedTagHelpers_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [17] MinimizedTagHelpers.cshtml) - "*, TestAssembly" - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - TestNamespace.CatchAllTagHelper - TestNamespace.InputTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.ir.txt index 3abd017276..ae8bce01a7 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCSharp_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCSharp_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_DesignTime.ir.txt index ba62b471e9..e6c3f586de 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedCodeBlocks_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedCodeBlocks_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_DesignTime.ir.txt index 940db83294..c36a40e7e8 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedScriptTagTagHelpers_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedScriptTagTagHelpers_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [17] NestedScriptTagTagHelpers.cshtml) - "*, TestAssembly" - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - TestNamespace.PTagHelper - TestNamespace.InputTagHelper - TestNamespace.InputTagHelper2 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_DesignTime.ir.txt index 0d1d13055a..60d8e08c49 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NestedTagHelpers_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NestedTagHelpers_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [15] NestedTagHelpers.cshtml) - *, TestAssembly - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - SpanTagHelper - DivTagHelper - InputTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.ir.txt index d2311a889a..376d64ff42 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NoLinePragmas_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NoLinePragmas_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.ir.txt index 5981c92c50..acb15a3586 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/NullConditionalExpressions_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_NullConditionalExpressions_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.ir.txt index 10c3b32e86..2677cb977c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/OpenedIf_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_OpenedIf_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.ir.txt index 8d60d9f13e..9161a9b2d3 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ParserError_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ParserError_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_DesignTime.ir.txt index 2cc612e75d..4a028a8bf1 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PrefixedAttributeTagHelpers_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_PrefixedAttributeTagHelpers_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [17] PrefixedAttributeTagHelpers.cshtml) - "*, TestAssembly" - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - TestNamespace.InputTagHelper1 - TestNamespace.InputTagHelper2 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.ir.txt index 61bcafb658..b942b59f5c 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorComments_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorComments_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective_DesignTime.ir.txt index 63f86078a7..6ff89480a9 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RemoveTagHelperDirective_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RemoveTagHelperDirective_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (17:0,17 [15] RemoveTagHelperDirective.cshtml) - *, TestAssembly - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt index 08838797d9..f122fb92ac 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Sections_DesignTime.ir.txt @@ -4,18 +4,10 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Sections_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (89:6,9 [8] Sections.cshtml) - Section2 DirectiveToken - (172:10,9 [8] Sections.cshtml) - Section1 DirectiveToken - (235:14,9 [15] Sections.cshtml) - NestedDelegates - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_DesignTime.ir.txt index c8b99abaed..79b41474cb 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleTagHelpers_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleTagHelpers_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [15] SimpleTagHelpers.cshtml) - *, TestAssembly - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - InputTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_DesignTime.ir.txt index 6b0724916f..e620c74652 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SimpleUnspacedIf_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SimpleUnspacedIf_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_DesignTime.ir.txt index dd3677974c..6dc536e0e2 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelperWithNewlineBeforeAttributes_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelperWithNewlineBeforeAttributes_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [17] SingleTagHelperWithNewlineBeforeAttributes.cshtml) - "*, TestAssembly" - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - TestNamespace.PTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_DesignTime.ir.txt index 2a0c68edcb..16eef35c41 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SingleTagHelper_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SingleTagHelper_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [17] SingleTagHelper.cshtml) - "*, TestAssembly" - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - TestNamespace.PTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_DesignTime.ir.txt index fec227b9f9..c192f7c944 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/StringLiterals_DesignTime.ir.txt @@ -4,17 +4,9 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_StringLiterals_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (2022:85,9 [21] StringLiterals.cshtml) - WriteLiteralsToInHere DirectiveToken - (5701:205,9 [25] StringLiterals.cshtml) - WriteLiteralsToInHereAlso - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_DesignTime.ir.txt index 6a9fcce924..735ba3a16f 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/SymbolBoundAttributes_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_SymbolBoundAttributes_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [15] SymbolBoundAttributes.cshtml) - *, TestAssembly - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - TestNamespace.CatchAllTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_DesignTime.ir.txt index 7021dd7c04..1692abefd3 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithBoundAttributes_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithBoundAttributes_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [15] TagHelpersWithBoundAttributes.cshtml) - *, TestAssembly - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - InputTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_DesignTime.ir.txt index 8b5b35140c..f98de3dd4d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithPrefix_DesignTime.ir.txt @@ -4,17 +4,9 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithPrefix_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [15] TagHelpersWithPrefix.cshtml) - *, TestAssembly DirectiveToken - (48:1,17 [5] TagHelpersWithPrefix.cshtml) - cool: - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - InputTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_DesignTime.ir.txt index 41fc9438fb..8a8cc759fb 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithTemplate_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithTemplate_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [17] TagHelpersWithTemplate.cshtml) - "*, TestAssembly" - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - DivTagHelper - InputTagHelper diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_DesignTime.ir.txt index 497954fc26..e62af5d3d8 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/TagHelpersWithWeirdlySpacedAttributes_DesignTime.ir.txt @@ -4,16 +4,8 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_TagHelpersWithWeirdlySpacedAttributes_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { + DesignTimeDirective - DirectiveToken - (14:0,14 [17] TagHelpersWithWeirdlySpacedAttributes.cshtml) - "*, TestAssembly" - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; DeclareTagHelperFields - - TestNamespace.PTagHelper - TestNamespace.InputTagHelper - TestNamespace.InputTagHelper2 diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml index 1edba0340b..467329dc4d 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml @@ -13,6 +13,11 @@ @foo("") } +@{ + Func bar = @

Hello

; + @bar("myclass") +} +
    @(Repeat(10, @
  • Item #@item
  • ))
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.codegen.cs index dce34707a4..8cd00f2c1b 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.codegen.cs @@ -40,9 +40,36 @@ __o = foo(""); #line hidden +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + + Func bar = + +#line default +#line hidden + item => new Microsoft.AspNetCore.Mvc.Razor.HelperResult(async(__razor_template_writer) => { #line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + __o = item; + +#line default +#line hidden + } + ) +#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + ; + + +#line default +#line hidden +#line 18 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" +__o = bar("myclass"); + +#line default +#line hidden + + +#line 22 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" __o = Repeat(10, item => new Microsoft.AspNetCore.Mvc.Razor.HelperResult(async(__razor_template_writer) => { -#line 17 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" +#line 22 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" __o = item; #line default @@ -52,10 +79,10 @@ __o = Repeat(10, item => new Microsoft.AspNetCore.Mvc.Razor.HelperResult(async(_ #line default #line hidden -#line 21 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" +#line 26 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" __o = Repeat(10, item => new Microsoft.AspNetCore.Mvc.Razor.HelperResult(async(__razor_template_writer) => { -#line 22 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" +#line 27 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" __o = item; #line default @@ -65,10 +92,10 @@ __o = Repeat(10, #line default #line hidden -#line 27 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" +#line 32 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" __o = Repeat(10, item => new Microsoft.AspNetCore.Mvc.Razor.HelperResult(async(__razor_template_writer) => { -#line 28 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" +#line 33 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" __o = item; #line default @@ -78,10 +105,10 @@ __o = Repeat(10, #line default #line hidden -#line 33 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" +#line 38 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" __o = Repeat(10, item => new Microsoft.AspNetCore.Mvc.Razor.HelperResult(async(__razor_template_writer) => { -#line 34 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" +#line 39 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" __o = item; #line default @@ -91,14 +118,14 @@ __o = Repeat(10, #line default #line hidden -#line 40 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" +#line 45 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" __o = Repeat(10, item => new Microsoft.AspNetCore.Mvc.Razor.HelperResult(async(__razor_template_writer) => { -#line 41 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" +#line 46 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" __o = item; #line default #line hidden -#line 42 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" +#line 47 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" var parent = item; #line default diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.ir.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.ir.txt index 7270095b4e..33c67b6fe7 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.ir.txt @@ -4,15 +4,7 @@ Document - UsingStatement - - System UsingStatement - - System.Threading.Tasks ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Templates_DesignTime - - - DirectiveTokenHelper - - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning disable 219 - CSharpStatement - - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - CSharpStatement - - RazorIRToken - - CSharp - } - CSharpStatement - - RazorIRToken - - CSharp - #pragma warning restore 219 + DesignTimeDirective - CSharpStatement - RazorIRToken - - CSharp - private static System.Object __o = null; RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync @@ -33,104 +25,125 @@ Document - RazorIRToken - (357:12,5 [7] Templates.cshtml) - CSharp - foo("") CSharpStatement - (364:12,12 [2] Templates.cshtml) RazorIRToken - (364:12,12 [2] Templates.cshtml) - CSharp - \n - HtmlContent - (369:14,0 [8] Templates.cshtml) + HtmlContent - (369:14,0 [2] Templates.cshtml) RazorIRToken - (369:14,0 [2] Templates.cshtml) - Html - \n - RazorIRToken - (371:15,0 [4] Templates.cshtml) - Html -
    - RazorIRToken - (375:15,4 [2] Templates.cshtml) - Html - \n - CSharpExpression - (379:16,2 [31] Templates.cshtml) - RazorIRToken - (379:16,2 [11] Templates.cshtml) - CSharp - Repeat(10, - Template - (391:16,14 [19] Templates.cshtml) - HtmlContent - (391:16,14 [10] Templates.cshtml) - RazorIRToken - (391:16,14 [4] Templates.cshtml) - Html -
  • - RazorIRToken - (395:16,18 [6] Templates.cshtml) - Html - Item # - CSharpExpression - (402:16,25 [4] Templates.cshtml) - RazorIRToken - (402:16,25 [4] Templates.cshtml) - CSharp - item - HtmlContent - (406:16,29 [5] Templates.cshtml) - RazorIRToken - (406:16,29 [5] Templates.cshtml) - Html -
  • - RazorIRToken - (411:16,34 [1] Templates.cshtml) - CSharp - ) - HtmlContent - (413:16,36 [16] Templates.cshtml) - RazorIRToken - (413:16,36 [2] Templates.cshtml) - Html - \n - RazorIRToken - (415:17,0 [5] Templates.cshtml) - Html -
- RazorIRToken - (420:17,5 [4] Templates.cshtml) - Html - \n\n - RazorIRToken - (424:19,0 [3] Templates.cshtml) - Html -

- RazorIRToken - (427:19,3 [2] Templates.cshtml) - Html - \n - CSharpExpression - (430:20,1 [52] Templates.cshtml) - RazorIRToken - (430:20,1 [16] Templates.cshtml) - CSharp - Repeat(10,\n - Template - (448:21,6 [35] Templates.cshtml) - HtmlContent - (448:21,6 [14] Templates.cshtml) - RazorIRToken - (448:21,6 [14] Templates.cshtml) - Html - This is line# - CSharpExpression - (463:21,21 [4] Templates.cshtml) - RazorIRToken - (463:21,21 [4] Templates.cshtml) - CSharp - item - HtmlContent - (467:21,25 [17] Templates.cshtml) - RazorIRToken - (467:21,25 [17] Templates.cshtml) - Html - of markup
\n - RazorIRToken - (484:22,0 [1] Templates.cshtml) - CSharp - ) - HtmlContent - (485:22,1 [15] Templates.cshtml) - RazorIRToken - (485:22,1 [2] Templates.cshtml) - Html - \n - RazorIRToken - (487:23,0 [4] Templates.cshtml) - Html -

- RazorIRToken - (491:23,4 [4] Templates.cshtml) - Html - \n\n - RazorIRToken - (495:25,0 [3] Templates.cshtml) - Html -

- RazorIRToken - (498:25,3 [2] Templates.cshtml) - Html - \n - CSharpExpression - (501:26,1 [54] Templates.cshtml) - RazorIRToken - (501:26,1 [16] Templates.cshtml) - CSharp - Repeat(10,\n - Template - (519:27,6 [37] Templates.cshtml) - HtmlContent - (519:27,6 [15] Templates.cshtml) - RazorIRToken - (519:27,6 [15] Templates.cshtml) - Html - : This is line# - CSharpExpression - (535:27,22 [4] Templates.cshtml) - RazorIRToken - (535:27,22 [4] Templates.cshtml) - CSharp - item - HtmlContent - (539:27,26 [18] Templates.cshtml) - RazorIRToken - (539:27,26 [18] Templates.cshtml) - Html - of markup
\n - RazorIRToken - (557:28,0 [1] Templates.cshtml) - CSharp - ) - HtmlContent - (558:28,1 [15] Templates.cshtml) - RazorIRToken - (558:28,1 [2] Templates.cshtml) - Html - \n - RazorIRToken - (560:29,0 [4] Templates.cshtml) - Html -

- RazorIRToken - (564:29,4 [4] Templates.cshtml) - Html - \n\n - RazorIRToken - (568:31,0 [3] Templates.cshtml) - Html -

- RazorIRToken - (571:31,3 [2] Templates.cshtml) - Html - \n - CSharpExpression - (574:32,1 [55] Templates.cshtml) - RazorIRToken - (574:32,1 [16] Templates.cshtml) - CSharp - Repeat(10,\n - Template - (592:33,6 [38] Templates.cshtml) - HtmlContent - (592:33,6 [16] Templates.cshtml) - RazorIRToken - (592:33,6 [16] Templates.cshtml) - Html - :: This is line# - CSharpExpression - (609:33,23 [4] Templates.cshtml) - RazorIRToken - (609:33,23 [4] Templates.cshtml) - CSharp - item - HtmlContent - (613:33,27 [18] Templates.cshtml) - RazorIRToken - (613:33,27 [18] Templates.cshtml) - Html - of markup
\n - RazorIRToken - (631:34,0 [1] Templates.cshtml) - CSharp - ) - HtmlContent - (632:34,1 [22] Templates.cshtml) - RazorIRToken - (632:34,1 [2] Templates.cshtml) - Html - \n - RazorIRToken - (634:35,0 [4] Templates.cshtml) - Html -

- RazorIRToken - (638:35,4 [6] Templates.cshtml) - Html - \n\n\n - RazorIRToken - (644:38,0 [4] Templates.cshtml) - Html -
    - RazorIRToken - (648:38,4 [6] Templates.cshtml) - Html - \n - CSharpExpression - (655:39,5 [141] Templates.cshtml) - RazorIRToken - (655:39,5 [11] Templates.cshtml) - CSharp - Repeat(10, - Template - (667:39,17 [129] Templates.cshtml) - HtmlContent - (667:39,17 [20] Templates.cshtml) - RazorIRToken - (667:39,17 [4] Templates.cshtml) - Html -
  • - RazorIRToken - (671:39,21 [16] Templates.cshtml) - Html - \n Item # - CSharpExpression - (688:40,15 [4] Templates.cshtml) - RazorIRToken - (688:40,15 [4] Templates.cshtml) - CSharp - item - HtmlContent - (692:40,19 [10] Templates.cshtml) - RazorIRToken - (692:40,19 [10] Templates.cshtml) - Html - \n - CSharpStatement - (704:41,10 [18] Templates.cshtml) - RazorIRToken - (704:41,10 [18] Templates.cshtml) - CSharp - var parent = item; - HtmlContent - (725:42,0 [53] Templates.cshtml) - RazorIRToken - (725:42,0 [8] Templates.cshtml) - Html - - RazorIRToken - (733:42,8 [4] Templates.cshtml) - Html -
      - RazorIRToken - (737:42,12 [14] Templates.cshtml) - Html - \n - RazorIRToken - (751:43,12 [4] Templates.cshtml) - Html -
    • - RazorIRToken - (755:43,16 [16] Templates.cshtml) - Html - Child Items... ? - RazorIRToken - (771:43,32 [5] Templates.cshtml) - Html -
    • - RazorIRToken - (776:43,37 [2] Templates.cshtml) - Html - \n - HtmlContent - (839:45,0 [24] Templates.cshtml) - RazorIRToken - (839:45,0 [8] Templates.cshtml) - Html - - RazorIRToken - (847:45,8 [5] Templates.cshtml) - Html -
    - RazorIRToken - (852:45,13 [6] Templates.cshtml) - Html - \n - RazorIRToken - (858:46,4 [5] Templates.cshtml) - Html -
  • - RazorIRToken - (863:46,9 [1] Templates.cshtml) - CSharp - ) - HtmlContent - (864:46,10 [8] Templates.cshtml) - RazorIRToken - (864:46,10 [2] Templates.cshtml) - Html - \n - RazorIRToken - (866:47,0 [5] Templates.cshtml) - Html -
- RazorIRToken - (871:47,5 [1] Templates.cshtml) - Html - + CSharpStatement - (373:15,2 [35] Templates.cshtml) + RazorIRToken - (373:15,2 [35] Templates.cshtml) - CSharp - \n Func bar = + Template - (409:16,33 [26] Templates.cshtml) + HtmlContent - (409:16,33 [2] Templates.cshtml) + RazorIRToken - (409:16,33 [2] Templates.cshtml) - Html -

+ RazorIRToken - (426:16,50 [5] Templates.cshtml) - Html - Hello + RazorIRToken - (431:16,55 [4] Templates.cshtml) - Html -

+ CSharpStatement - (435:16,59 [7] Templates.cshtml) + RazorIRToken - (435:16,59 [7] Templates.cshtml) - CSharp - ;\n + CSharpExpression - (443:17,5 [14] Templates.cshtml) + RazorIRToken - (443:17,5 [14] Templates.cshtml) - CSharp - bar("myclass") + CSharpStatement - (457:17,19 [2] Templates.cshtml) + RazorIRToken - (457:17,19 [2] Templates.cshtml) - CSharp - \n + HtmlContent - (462:19,0 [8] Templates.cshtml) + RazorIRToken - (462:19,0 [2] Templates.cshtml) - Html - \n + RazorIRToken - (464:20,0 [4] Templates.cshtml) - Html -
    + RazorIRToken - (468:20,4 [2] Templates.cshtml) - Html - \n + CSharpExpression - (472:21,2 [31] Templates.cshtml) + RazorIRToken - (472:21,2 [11] Templates.cshtml) - CSharp - Repeat(10, + Template - (484:21,14 [19] Templates.cshtml) + HtmlContent - (484:21,14 [10] Templates.cshtml) + RazorIRToken - (484:21,14 [4] Templates.cshtml) - Html -
  • + RazorIRToken - (488:21,18 [6] Templates.cshtml) - Html - Item # + CSharpExpression - (495:21,25 [4] Templates.cshtml) + RazorIRToken - (495:21,25 [4] Templates.cshtml) - CSharp - item + HtmlContent - (499:21,29 [5] Templates.cshtml) + RazorIRToken - (499:21,29 [5] Templates.cshtml) - Html -
  • + RazorIRToken - (504:21,34 [1] Templates.cshtml) - CSharp - ) + HtmlContent - (506:21,36 [16] Templates.cshtml) + RazorIRToken - (506:21,36 [2] Templates.cshtml) - Html - \n + RazorIRToken - (508:22,0 [5] Templates.cshtml) - Html -
+ RazorIRToken - (513:22,5 [4] Templates.cshtml) - Html - \n\n + RazorIRToken - (517:24,0 [3] Templates.cshtml) - Html -

+ RazorIRToken - (520:24,3 [2] Templates.cshtml) - Html - \n + CSharpExpression - (523:25,1 [52] Templates.cshtml) + RazorIRToken - (523:25,1 [16] Templates.cshtml) - CSharp - Repeat(10,\n + Template - (541:26,6 [35] Templates.cshtml) + HtmlContent - (541:26,6 [14] Templates.cshtml) + RazorIRToken - (541:26,6 [14] Templates.cshtml) - Html - This is line# + CSharpExpression - (556:26,21 [4] Templates.cshtml) + RazorIRToken - (556:26,21 [4] Templates.cshtml) - CSharp - item + HtmlContent - (560:26,25 [17] Templates.cshtml) + RazorIRToken - (560:26,25 [17] Templates.cshtml) - Html - of markup
\n + RazorIRToken - (577:27,0 [1] Templates.cshtml) - CSharp - ) + HtmlContent - (578:27,1 [15] Templates.cshtml) + RazorIRToken - (578:27,1 [2] Templates.cshtml) - Html - \n + RazorIRToken - (580:28,0 [4] Templates.cshtml) - Html -

+ RazorIRToken - (584:28,4 [4] Templates.cshtml) - Html - \n\n + RazorIRToken - (588:30,0 [3] Templates.cshtml) - Html -

+ RazorIRToken - (591:30,3 [2] Templates.cshtml) - Html - \n + CSharpExpression - (594:31,1 [54] Templates.cshtml) + RazorIRToken - (594:31,1 [16] Templates.cshtml) - CSharp - Repeat(10,\n + Template - (612:32,6 [37] Templates.cshtml) + HtmlContent - (612:32,6 [15] Templates.cshtml) + RazorIRToken - (612:32,6 [15] Templates.cshtml) - Html - : This is line# + CSharpExpression - (628:32,22 [4] Templates.cshtml) + RazorIRToken - (628:32,22 [4] Templates.cshtml) - CSharp - item + HtmlContent - (632:32,26 [18] Templates.cshtml) + RazorIRToken - (632:32,26 [18] Templates.cshtml) - Html - of markup
\n + RazorIRToken - (650:33,0 [1] Templates.cshtml) - CSharp - ) + HtmlContent - (651:33,1 [15] Templates.cshtml) + RazorIRToken - (651:33,1 [2] Templates.cshtml) - Html - \n + RazorIRToken - (653:34,0 [4] Templates.cshtml) - Html -

+ RazorIRToken - (657:34,4 [4] Templates.cshtml) - Html - \n\n + RazorIRToken - (661:36,0 [3] Templates.cshtml) - Html -

+ RazorIRToken - (664:36,3 [2] Templates.cshtml) - Html - \n + CSharpExpression - (667:37,1 [55] Templates.cshtml) + RazorIRToken - (667:37,1 [16] Templates.cshtml) - CSharp - Repeat(10,\n + Template - (685:38,6 [38] Templates.cshtml) + HtmlContent - (685:38,6 [16] Templates.cshtml) + RazorIRToken - (685:38,6 [16] Templates.cshtml) - Html - :: This is line# + CSharpExpression - (702:38,23 [4] Templates.cshtml) + RazorIRToken - (702:38,23 [4] Templates.cshtml) - CSharp - item + HtmlContent - (706:38,27 [18] Templates.cshtml) + RazorIRToken - (706:38,27 [18] Templates.cshtml) - Html - of markup
\n + RazorIRToken - (724:39,0 [1] Templates.cshtml) - CSharp - ) + HtmlContent - (725:39,1 [22] Templates.cshtml) + RazorIRToken - (725:39,1 [2] Templates.cshtml) - Html - \n + RazorIRToken - (727:40,0 [4] Templates.cshtml) - Html -

+ RazorIRToken - (731:40,4 [6] Templates.cshtml) - Html - \n\n\n + RazorIRToken - (737:43,0 [4] Templates.cshtml) - Html -
    + RazorIRToken - (741:43,4 [6] Templates.cshtml) - Html - \n + CSharpExpression - (748:44,5 [141] Templates.cshtml) + RazorIRToken - (748:44,5 [11] Templates.cshtml) - CSharp - Repeat(10, + Template - (760:44,17 [129] Templates.cshtml) + HtmlContent - (760:44,17 [20] Templates.cshtml) + RazorIRToken - (760:44,17 [4] Templates.cshtml) - Html -
  • + RazorIRToken - (764:44,21 [16] Templates.cshtml) - Html - \n Item # + CSharpExpression - (781:45,15 [4] Templates.cshtml) + RazorIRToken - (781:45,15 [4] Templates.cshtml) - CSharp - item + HtmlContent - (785:45,19 [10] Templates.cshtml) + RazorIRToken - (785:45,19 [10] Templates.cshtml) - Html - \n + CSharpStatement - (797:46,10 [18] Templates.cshtml) + RazorIRToken - (797:46,10 [18] Templates.cshtml) - CSharp - var parent = item; + HtmlContent - (818:47,0 [53] Templates.cshtml) + RazorIRToken - (818:47,0 [8] Templates.cshtml) - Html - + RazorIRToken - (826:47,8 [4] Templates.cshtml) - Html -
      + RazorIRToken - (830:47,12 [14] Templates.cshtml) - Html - \n + RazorIRToken - (844:48,12 [4] Templates.cshtml) - Html -
    • + RazorIRToken - (848:48,16 [16] Templates.cshtml) - Html - Child Items... ? + RazorIRToken - (864:48,32 [5] Templates.cshtml) - Html -
    • + RazorIRToken - (869:48,37 [2] Templates.cshtml) - Html - \n + HtmlContent - (932:50,0 [24] Templates.cshtml) + RazorIRToken - (932:50,0 [8] Templates.cshtml) - Html - + RazorIRToken - (940:50,8 [5] Templates.cshtml) - Html -
    + RazorIRToken - (945:50,13 [6] Templates.cshtml) - Html - \n + RazorIRToken - (951:51,4 [5] Templates.cshtml) - Html -
  • + RazorIRToken - (956:51,9 [1] Templates.cshtml) - CSharp - ) + HtmlContent - (957:51,10 [8] Templates.cshtml) + RazorIRToken - (957:51,10 [2] Templates.cshtml) - Html - \n + RazorIRToken - (959:52,0 [5] Templates.cshtml) - Html -
+ RazorIRToken - (964:52,5 [1] Templates.cshtml) - Html - CSharpStatement - (12:0,12 [265] Templates.cshtml) RazorIRToken - (12:0,12 [265] Templates.cshtml) - CSharp - \n public HelperResult Repeat(int times, Func template) {\n return new HelperResult((writer) => {\n for(int i = 0; i < times; i++) {\n ((HelperResult)template(i)).WriteTo(writer);\n }\n });\n }\n diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.mappings.txt b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.mappings.txt index 71abaaf995..34277cc202 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.mappings.txt +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_DesignTime.mappings.txt @@ -29,90 +29,121 @@ Generated Location: (1369:40,24 [2] ) | | -Source Location: (379:16,2 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +Source Location: (373:15,2 [35] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +| + Func bar = | +Generated Location: (1461:43,2 [35] ) +| + Func bar = | + +Source Location: (420:16,44 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|item| +Generated Location: (1764:50,44 [4] ) +|item| + +Source Location: (435:16,59 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|; + | +Generated Location: (1977:57,59 [7] ) +|; + | + +Source Location: (443:17,5 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +|bar("myclass")| +Generated Location: (2109:63,6 [14] ) +|bar("myclass")| + +Source Location: (457:17,19 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +| +| +Generated Location: (2188:67,31 [2] ) +| +| + +Source Location: (472:21,2 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |Repeat(10, | -Generated Location: (1465:43,6 [11] ) +Generated Location: (2284:70,6 [11] ) |Repeat(10, | -Source Location: (402:16,25 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +Source Location: (495:21,25 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |item| -Generated Location: (1680:45,25 [4] ) +Generated Location: (2499:72,25 [4] ) |item| -Source Location: (411:16,34 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +Source Location: (504:21,34 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |)| -Generated Location: (1722:50,1 [1] ) +Generated Location: (2541:77,1 [1] ) |)| -Source Location: (430:20,1 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +Source Location: (523:25,1 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |Repeat(10, | -Generated Location: (1849:55,6 [16] ) +Generated Location: (2668:82,6 [16] ) |Repeat(10, | -Source Location: (463:21,21 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +Source Location: (556:26,21 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |item| -Generated Location: (2065:58,21 [4] ) +Generated Location: (2884:85,21 [4] ) |item| -Source Location: (484:22,0 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +Source Location: (577:27,0 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |)| -Generated Location: (2107:63,1 [1] ) +Generated Location: (2926:90,1 [1] ) |)| -Source Location: (501:26,1 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +Source Location: (594:31,1 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |Repeat(10, | -Generated Location: (2234:68,6 [16] ) +Generated Location: (3053:95,6 [16] ) |Repeat(10, | -Source Location: (535:27,22 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +Source Location: (628:32,22 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |item| -Generated Location: (2451:71,22 [4] ) +Generated Location: (3270:98,22 [4] ) |item| -Source Location: (557:28,0 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +Source Location: (650:33,0 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |)| -Generated Location: (2493:76,1 [1] ) +Generated Location: (3312:103,1 [1] ) |)| -Source Location: (574:32,1 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +Source Location: (667:37,1 [16] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |Repeat(10, | -Generated Location: (2620:81,6 [16] ) +Generated Location: (3439:108,6 [16] ) |Repeat(10, | -Source Location: (609:33,23 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +Source Location: (702:38,23 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |item| -Generated Location: (2838:84,23 [4] ) +Generated Location: (3657:111,23 [4] ) |item| -Source Location: (631:34,0 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +Source Location: (724:39,0 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |)| -Generated Location: (2880:89,1 [1] ) +Generated Location: (3699:116,1 [1] ) |)| -Source Location: (655:39,5 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +Source Location: (748:44,5 [11] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |Repeat(10, | -Generated Location: (3007:94,6 [11] ) +Generated Location: (3826:121,6 [11] ) |Repeat(10, | -Source Location: (688:40,15 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +Source Location: (781:45,15 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |item| -Generated Location: (3212:96,15 [4] ) +Generated Location: (4031:123,15 [4] ) |item| -Source Location: (704:41,10 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +Source Location: (797:46,10 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |var parent = item;| -Generated Location: (3346:101,10 [18] ) +Generated Location: (4165:128,10 [18] ) |var parent = item;| -Source Location: (863:46,9 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) +Source Location: (956:51,9 [1] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) |)| -Generated Location: (3401:106,1 [1] ) +Generated Location: (4220:133,1 [1] ) |)| Source Location: (12:0,12 [265] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml) @@ -125,7 +156,7 @@ Source Location: (12:0,12 [265] TestFiles/IntegrationTests/CodeGenerationIntegra }); } | -Generated Location: (3582:113,12 [265] ) +Generated Location: (4401:140,12 [265] ) | public HelperResult Repeat(int times, Func template) { return new HelperResult((writer) => { diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.codegen.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.codegen.cs index 70636ffbc9..bbb283c971 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates_Runtime.codegen.cs @@ -1,4 +1,4 @@ -#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "ecd19ba0b3ae7ac597e19534c93fd2023208ae59" +#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8a16b856f52a2ed469347984184b8ac48080234f" namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests.TestFiles { #line hidden @@ -37,11 +37,41 @@ Write(foo("")); #line default #line hidden - WriteLiteral("\r\n
    \r\n"); + WriteLiteral("\r\n"); +#line 16 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Templates.cshtml" + + Func bar = + +#line default +#line hidden + item => new Microsoft.AspNetCore.Mvc.Razor.HelperResult(async(__razor_template_writer) => { + WriteLiteralTo(__razor_template_writer, "