From eb769315789467772c14b0af6503ef57a78e911c Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Tue, 30 Jun 2020 15:49:28 +0100 Subject: [PATCH 1/5] Strip insignificant whitespace at compile time (#23385) * Define @preservewhitespace directive attribute * Have ComponentWhitespacePass respect preservewhitespace option * Tests for overriding the preservewhitespace option (and fix implementation) * Begin adding test infrastucture for ComponentWhitespacePass * Remove leading/trailing whitespace from markup elements recursively * Update baselines * Add test showing we don't remove whitespace between sibling elements * Remove whitespace before/after C# code statements (not expressions) * Update baselines * Slight improvements to test * Remove leading/trailing whitespace inside component child content * Update baselines * Fix Razor tests * Fix MVC test * Better fix for MVC test * CR: Make ComponentPreserveWhitespaceDirective conditional on langversion >= 5.0 --- .../RazorComponents/FetchData.razor | 3 +- .../BasicComponent_Runtime.codegen.cs | 1 - .../BasicComponent_Runtime.ir.txt | 2 - .../src/ComponentResources.resx | 9 + .../ComponentPreserveWhitespaceDirective.cs | 30 +++ .../src/Components/ComponentWhitespacePass.cs | 72 ++++++- .../DirectiveDescriptorBuilderExtensions.cs | 22 +++ .../src/DirectiveTokenKind.cs | 1 + .../src/Legacy/CSharpCodeParser.cs | 25 ++- .../src/RazorDiagnosticFactory.cs | 10 + .../src/RazorProjectEngine.cs | 9 +- .../src/Resources.resx | 3 + .../ComponentMarkupBlockPassTest.cs | 15 +- .../Components/ComponentWhitespacePassTest.cs | 183 ++++++++++++++++++ .../ComponentCodeGenerationTestBase.cs | 147 +++++++++++++- .../TestComponent.codegen.cs | 34 ++++ .../TestComponent.ir.txt | 31 +++ .../TestComponent.mappings.txt | 5 + .../TestComponent.codegen.cs | 37 ++++ .../TestComponent.ir.txt | 34 ++++ .../TestComponent.mappings.txt | 5 + .../TestComponent.codegen.cs | 54 ++++++ .../TestComponent.ir.txt | 37 ++++ .../TestComponent.mappings.txt | 21 ++ .../TestComponent.codegen.cs | 42 ++++ .../TestComponent.ir.txt | 24 +++ .../TestComponent.mappings.txt | 14 ++ .../TestComponent.codegen.cs | 54 ++++++ .../TestComponent.ir.txt | 37 ++++ .../TestComponent.mappings.txt | 21 ++ .../TestComponent.codegen.cs | 14 ++ .../TestComponent.ir.txt | 29 ++- .../TestComponent.mappings.txt | 10 + .../TestComponent.codegen.cs | 48 +++++ .../TestComponent.ir.txt | 34 ++++ .../TestComponent.mappings.txt | 14 ++ .../TestComponent.codegen.cs | 6 +- .../TestComponent.ir.txt | 4 - .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 6 +- .../TestComponent.ir.txt | 4 - .../TestComponent.codegen.cs | 6 +- .../TestComponent.ir.txt | 4 - .../TestComponent.codegen.cs | 5 +- .../TestComponent.ir.txt | 6 - .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 5 +- .../TestComponent.ir.txt | 3 - .../TestComponent.codegen.cs | 5 +- .../TestComponent.ir.txt | 3 - .../TestComponent.codegen.cs | 1 - .../TestComponent.ir.txt | 2 - .../TestComponent.codegen.cs | 1 - .../TestComponent.ir.txt | 2 - .../TestComponent.codegen.cs | 11 +- .../TestComponent.ir.txt | 9 +- .../TestComponent.mappings.txt | 6 +- .../TestComponent.codegen.cs | 38 ++++ .../TestComponent.ir.txt | 23 +++ .../TestComponent.codegen.cs | 33 ++++ .../TestComponent.ir.txt | 13 ++ .../TestComponent.codegen.cs | 3 +- .../TestComponent.ir.txt | 2 - .../TestComponent.mappings.txt | 4 +- .../TestComponent.codegen.cs | 3 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.codegen.cs | 48 +++++ .../TestComponent.ir.txt | 19 ++ .../TestComponent.mappings.txt | 16 ++ .../TestComponent.codegen.cs | 55 ++++++ .../TestComponent.ir.txt | 34 ++++ .../TestComponent.mappings.txt | 16 ++ .../TestComponent.codegen.cs | 12 +- .../TestComponent.ir.txt | 4 - .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 14 +- .../TestComponent.ir.txt | 4 - .../TestComponent.codegen.cs | 12 +- .../TestComponent.ir.txt | 4 - .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 12 +- .../TestComponent.ir.txt | 4 - .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 10 +- .../TestComponent.ir.txt | 4 - .../TestComponent.codegen.cs | 16 +- .../TestComponent.ir.txt | 4 - .../TestComponent.codegen.cs | 6 +- .../TestComponent.ir.txt | 4 - .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 6 +- .../TestComponent.ir.txt | 4 - .../TestComponent.codegen.cs | 32 ++- .../TestComponent.ir.txt | 19 +- .../TestComponent.codegen.cs | 1 - .../TestComponent.ir.txt | 1 - .../TestComponent.codegen.cs | 4 +- .../TestComponent.ir.txt | 4 - .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 10 +- .../TestComponent.ir.txt | 4 - .../TestComponent.codegen.cs | 8 +- .../TestComponent.ir.txt | 4 - .../TestComponent.codegen.cs | 43 ++++ .../TestComponent.ir.txt | 19 ++ .../TestComponent.mappings.txt | 9 + 106 files changed, 1591 insertions(+), 234 deletions(-) create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentPreserveWhitespaceDirective.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentWhitespacePassTest.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_Invalid/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_Invalid/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_Invalid/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.mappings.txt diff --git a/src/Mvc/test/WebSites/BasicWebSite/RazorComponents/FetchData.razor b/src/Mvc/test/WebSites/BasicWebSite/RazorComponents/FetchData.razor index d2d7e9ea66..03c3c8a957 100644 --- a/src/Mvc/test/WebSites/BasicWebSite/RazorComponents/FetchData.razor +++ b/src/Mvc/test/WebSites/BasicWebSite/RazorComponents/FetchData.razor @@ -1,6 +1,6 @@ @using BasicWebSite.Services @inject WeatherForecastService ForecastService - +@preservewhitespace true

Weather forecast

This component demonstrates fetching data from the server.

@@ -34,7 +34,6 @@ else } - @code { [Parameter] public DateTime StartDate { get; set; } diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.codegen.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.codegen.cs index f1f8cd28b9..c3df65cf63 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.codegen.cs @@ -34,7 +34,6 @@ namespace __GeneratedComponent #line hidden #nullable disable ); - __builder.AddMarkupContent(4, "\r\n"); __builder.CloseElement(); } #pragma warning restore 1998 diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.ir.txt b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.ir.txt index 46b8dd5f06..a1f78b09a3 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/TestFiles/IntegrationTests/CodeGenerationIntegrationTest/BasicComponent_Runtime.ir.txt @@ -16,7 +16,5 @@ Document - LazyIntermediateToken - (74:3,0 [4] BasicComponent.cshtml) - Html - CSharpExpression - (79:3,5 [29] BasicComponent.cshtml) LazyIntermediateToken - (79:3,5 [29] BasicComponent.cshtml) - CSharp - string.Format("{0}", "Hello") - HtmlContent - (108:3,34 [2] BasicComponent.cshtml) - LazyIntermediateToken - (108:3,34 [2] BasicComponent.cshtml) - Html - \n CSharpCode - (132:6,12 [37] BasicComponent.cshtml) LazyIntermediateToken - (132:6,12 [37] BasicComponent.cshtml) - CSharp - \n void IDisposable.Dispose(){ }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx index b457a1f9f7..cbadc7ee10 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx @@ -201,6 +201,15 @@ route template + + True if whitespace should be preserved, otherwise false. + + + Preserve + + + Specifies whether or not whitespace should be preserved exactly. Defaults to false for better performance. + Populates the specified field or property with a reference to the element or component. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentPreserveWhitespaceDirective.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentPreserveWhitespaceDirective.cs new file mode 100644 index 0000000000..72f657aac7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentPreserveWhitespaceDirective.cs @@ -0,0 +1,30 @@ +// 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; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal static class ComponentPreserveWhitespaceDirective + { + public static readonly DirectiveDescriptor Directive = DirectiveDescriptor.CreateDirective( + "preservewhitespace", + DirectiveKind.SingleLine, + builder => + { + builder.AddBooleanToken(ComponentResources.PreserveWhitespaceDirective_BooleanToken_Name, ComponentResources.PreserveWhitespaceDirective_BooleanToken_Description); + builder.Usage = DirectiveUsage.FileScopedMultipleOccurring; + builder.Description = ComponentResources.PreserveWhitespaceDirective_Description; + }); + + public static void Register(RazorProjectEngineBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.AddDirective(Directive, FileKinds.Component, FileKinds.ComponentImport); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentWhitespacePass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentWhitespacePass.cs index 08eec3ae80..761e3eb8f4 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentWhitespacePass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentWhitespacePass.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Linq; using Microsoft.AspNetCore.Razor.Language.Intermediate; namespace Microsoft.AspNetCore.Razor.Language.Components @@ -38,17 +39,45 @@ namespace Microsoft.AspNetCore.Razor.Language.Components return; } + // Respect @preservewhitespace directives + if (PreserveWhitespaceIsEnabled(documentNode)) + { + return; + } + var method = documentNode.FindPrimaryMethod(); if (method != null) { RemoveContiguousWhitespace(method.Children, TraversalDirection.Forwards); RemoveContiguousWhitespace(method.Children, TraversalDirection.Backwards); + + var visitor = new Visitor(); + visitor.Visit(method); } } - private static void RemoveContiguousWhitespace(IntermediateNodeCollection nodes, TraversalDirection direction) + private static bool PreserveWhitespaceIsEnabled(DocumentIntermediateNode documentNode) { - var position = direction == TraversalDirection.Forwards ? 0 : nodes.Count - 1; + // If there's no @preservewhitespace attribute, the default is that we *don't* preserve whitespace + var shouldPreserveWhitespace = false; + + foreach (var preserveWhitespaceDirective in documentNode.FindDirectiveReferences(ComponentPreserveWhitespaceDirective.Directive)) + { + var token = ((DirectiveIntermediateNode)preserveWhitespaceDirective.Node).Tokens.FirstOrDefault(); + var shouldPreserveWhitespaceContent = token?.Content; + if (shouldPreserveWhitespaceContent != null) + { + shouldPreserveWhitespace = string.Equals(shouldPreserveWhitespaceContent, "true", StringComparison.Ordinal); + } + } + + return shouldPreserveWhitespace; + } + + private static int RemoveContiguousWhitespace(IntermediateNodeCollection nodes, TraversalDirection direction, int? startIndex = null) + { + var position = startIndex.GetValueOrDefault(direction == TraversalDirection.Forwards ? 0 : nodes.Count - 1); + var countRemoved = 0; while (position >= 0 && position < nodes.Count) { var node = nodes[position]; @@ -76,7 +105,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components shouldContinueIteration = false; break; - case CSharpCodeIntermediateNode codeIntermediateNode: + case CSharpCodeIntermediateNode _: shouldRemoveNode = false; shouldContinueIteration = false; break; @@ -90,6 +119,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components if (shouldRemoveNode) { nodes.RemoveAt(position); + countRemoved++; if (direction == TraversalDirection.Forwards) { position--; @@ -103,6 +133,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Components break; } } + + return countRemoved; } enum TraversalDirection @@ -110,5 +142,39 @@ namespace Microsoft.AspNetCore.Razor.Language.Components Forwards, Backwards } + + class Visitor : IntermediateNodeWalker + { + public override void VisitMarkupElement(MarkupElementIntermediateNode node) + { + RemoveContiguousWhitespace(node.Children, TraversalDirection.Forwards); + RemoveContiguousWhitespace(node.Children, TraversalDirection.Backwards); + VisitDefault(node); + } + + public override void VisitTagHelperBody(TagHelperBodyIntermediateNode node) + { + // The goal here is to remove leading/trailing whitespace inside component child content. However, + // at the time this whitespace pass runs, ComponentChildContent is still TagHelperBody in the tree. + RemoveContiguousWhitespace(node.Children, TraversalDirection.Forwards); + RemoveContiguousWhitespace(node.Children, TraversalDirection.Backwards); + VisitDefault(node); + } + + public override void VisitDefault(IntermediateNode node) + { + // For any CSharpCodeIntermediateNode children, remove their preceding and trailing whitespace + for (var childIndex = 0; childIndex < node.Children.Count; childIndex++) + { + if (node.Children[childIndex] is CSharpCodeIntermediateNode) + { + childIndex -= RemoveContiguousWhitespace(node.Children, TraversalDirection.Backwards, childIndex - 1); + RemoveContiguousWhitespace(node.Children, TraversalDirection.Forwards, childIndex + 1); + } + } + + base.VisitDefault(node); + } + } } } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DirectiveDescriptorBuilderExtensions.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DirectiveDescriptorBuilderExtensions.cs index e8257bba7f..3e9c14b46f 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DirectiveDescriptorBuilderExtensions.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DirectiveDescriptorBuilderExtensions.cs @@ -117,6 +117,28 @@ namespace Microsoft.AspNetCore.Razor.Language return builder; } + public static IDirectiveDescriptorBuilder AddBooleanToken(this IDirectiveDescriptorBuilder builder) + { + return AddBooleanToken(builder, name: null, description: null); + } + + public static IDirectiveDescriptorBuilder AddBooleanToken(this IDirectiveDescriptorBuilder builder, string name, string description) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.Tokens.Add( + DirectiveTokenDescriptor.CreateToken( + DirectiveTokenKind.Boolean, + optional: false, + name: name, + description: description)); + + return builder; + } + public static IDirectiveDescriptorBuilder AddOptionalMemberToken(this IDirectiveDescriptorBuilder builder) { return AddOptionalMemberToken(builder, name: null, description: null); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DirectiveTokenKind.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DirectiveTokenKind.cs index 916a57c3ca..88b214071c 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DirectiveTokenKind.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DirectiveTokenKind.cs @@ -10,5 +10,6 @@ namespace Microsoft.AspNetCore.Razor.Language Member, String, Attribute, + Boolean, } } \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpCodeParser.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpCodeParser.cs index 9daadf3714..fd94358c15 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpCodeParser.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpCodeParser.cs @@ -1322,7 +1322,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy if (tokenDescriptor.Kind == DirectiveTokenKind.Member || tokenDescriptor.Kind == DirectiveTokenKind.Namespace || tokenDescriptor.Kind == DirectiveTokenKind.Type || - tokenDescriptor.Kind == DirectiveTokenKind.Attribute) + tokenDescriptor.Kind == DirectiveTokenKind.Attribute || + tokenDescriptor.Kind == DirectiveTokenKind.Boolean) { SpanContext.ChunkGenerator = SpanChunkGenerator.Null; SpanContext.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.Whitespace; @@ -1417,6 +1418,22 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return; } break; + + case DirectiveTokenKind.Boolean: + if (AtBooleanLiteral() && !CurrentToken.ContainsDiagnostics) + { + AcceptAndMoveNext(); + } + else + { + Context.ErrorSink.OnError( + RazorDiagnosticFactory.CreateParsing_DirectiveExpectsBooleanLiteral( + new SourceSpan(CurrentStart, CurrentToken.Content.Length), descriptor.Directive)); + builder.Add(BuildDirective()); + return; + } + break; + case DirectiveTokenKind.Attribute: if (At(SyntaxKind.LeftBracket)) { @@ -1699,6 +1716,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy return false; } + private bool AtBooleanLiteral() + { + var result = CSharpTokenizer.GetTokenKeyword(CurrentToken); + return result.HasValue && (result.Value == CSharpKeyword.True || result.Value == CSharpKeyword.False); + } + private void SetupExpressionParsers() { MapExpressionKeyword(ParseAwaitExpression, CSharpKeyword.Await); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorDiagnosticFactory.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorDiagnosticFactory.cs index 1617fc417c..3d1fbb234a 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorDiagnosticFactory.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorDiagnosticFactory.cs @@ -426,6 +426,16 @@ namespace Microsoft.AspNetCore.Razor.Language { return RazorDiagnostic.Create(Parsing_DirectiveExpectsCSharpAttribute, location, directiveName); } + + internal static readonly RazorDiagnosticDescriptor Parsing_DirectiveExpectsBooleanLiteral = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1038", + () => Resources.DirectiveExpectsBooleanLiteral, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_DirectiveExpectsBooleanLiteral(SourceSpan location, string directiveName) + { + return RazorDiagnostic.Create(Parsing_DirectiveExpectsBooleanLiteral, location, directiveName); + } #endregion #region Semantic Errors diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorProjectEngine.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorProjectEngine.cs index 07729dcd25..ac75eac6d1 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorProjectEngine.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorProjectEngine.cs @@ -120,7 +120,7 @@ namespace Microsoft.AspNetCore.Razor.Language NamespaceDirective.Register(builder); AttributeDirective.Register(builder); - AddComponentFeatures(builder); + AddComponentFeatures(builder, configuration.LanguageVersion); } LoadExtensions(builder, configuration.Extensions); @@ -206,7 +206,7 @@ namespace Microsoft.AspNetCore.Razor.Language }); } - private static void AddComponentFeatures(RazorProjectEngineBuilder builder) + private static void AddComponentFeatures(RazorProjectEngineBuilder builder, RazorLanguageVersion razorLanguageVersion) { // Project Engine Features builder.Features.Add(new ComponentImportProjectFeature()); @@ -218,6 +218,11 @@ namespace Microsoft.AspNetCore.Razor.Language ComponentPageDirective.Register(builder); ComponentTypeParamDirective.Register(builder); + if (razorLanguageVersion.CompareTo(RazorLanguageVersion.Version_5_0) >= 0) + { + ComponentPreserveWhitespaceDirective.Register(builder); + } + // Document Classifier builder.Features.Add(new ComponentDocumentClassifierPass()); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Resources.resx b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Resources.resx index 33c63d93c2..65fdf317bb 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Resources.resx +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Resources.resx @@ -559,4 +559,7 @@ Invalid tag helper required directive attribute '{0}'. The directive attribute '{1}' should start with a '@' character. + + The '{0}' directive expects a boolean literal. + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentMarkupBlockPassTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentMarkupBlockPassTest.cs index 365b7909f9..6c00e4f322 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentMarkupBlockPassTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentMarkupBlockPassTest.cs @@ -47,11 +47,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Components "); var expected = NormalizeContent(@" - - + Hello, World! - -"); + "); var documentNode = Lower(document); @@ -163,7 +161,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components "); - var expected = NormalizeContent("
foo
\n "); + var expected = NormalizeContent("
foo
"); var documentNode = Lower(document); @@ -349,11 +347,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Components "); var expected = NormalizeContent(@" - - - - -"); + + "); var documentNode = Lower(document); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentWhitespacePassTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentWhitespacePassTest.cs new file mode 100644 index 0000000000..d2356ace8b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentWhitespacePassTest.cs @@ -0,0 +1,183 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + public class ComponentWhitespacePassTest + { + public ComponentWhitespacePassTest() + { + Pass = new ComponentWhitespacePass(); + ProjectEngine = (DefaultRazorProjectEngine)RazorProjectEngine.Create( + RazorConfiguration.Default, + RazorProjectFileSystem.Create(Environment.CurrentDirectory), + b => + { + if (b.Features.OfType().Any()) + { + b.Features.Remove(b.Features.OfType().Single()); + } + }); + Engine = ProjectEngine.Engine; + + Pass.Engine = Engine; + } + + private DefaultRazorProjectEngine ProjectEngine { get; } + + private RazorEngine Engine { get; } + + private ComponentWhitespacePass Pass { get; } + + [Fact] + public void Execute_RemovesLeadingAndTrailingWhitespace() + { + // Arrange + var document = CreateDocument(@" + +@(""Hello, world"") + +"); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + var method = documentNode.FindPrimaryMethod(); + var child = Assert.IsType(Assert.Single(method.Children)); + Assert.Equal("span", child.TagName); + } + + [Fact] + public void Execute_RemovesLeadingAndTrailingWhitespaceInsideElement() + { + // Arrange + var document = CreateDocument(@" + + Hello, @("" w o r l d "") + +"); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + var parentElement = Assert.IsType(Assert.Single(documentNode.FindPrimaryMethod().Children)); + var childElement = Assert.IsType(Assert.Single(parentElement.Children)); + Assert.Equal("child", childElement.TagName); + Assert.Collection(childElement.Children, + node => + { + var htmlNode = Assert.IsType(node); + Assert.Equal(" Hello, ", GetContent(htmlNode)); + }, + node => + { + var csharpExpressionNode = Assert.IsType(node); + Assert.Equal(@""" w o r l d """, GetContent(csharpExpressionNode)); + }); + } + + [Fact] + public void Execute_LeavesWhitespaceBetweenSiblingElements() + { + // Arrange + var document = CreateDocument(@" "); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + Assert.Collection(documentNode.FindPrimaryMethod().Children, + node => Assert.IsType(node), + node => Assert.IsType(node), + node => Assert.IsType(node)); + } + + [Fact] + public void Execute_RemovesWhitespacePrecedingAndTrailingCSharpCode() + { + // Arrange + var document = CreateDocument(@" + + @val1a @val1b + +@if(someExpression) { /* Do something */ } + + @val2a @val2b + +"); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + var parentElement = Assert.IsType(Assert.Single(documentNode.FindPrimaryMethod().Children)); + Assert.Collection(parentElement.Children, + node => + { + Assert.Equal("child", Assert.IsType(node).TagName); + Assert.Collection(node.Children, + x => Assert.IsType(x), + x => Assert.IsType(x), // We don't remove whitespace before/after C# expressions + x => Assert.IsType(x)); + }, + node => Assert.IsType(node), + node => + { + Assert.Equal("child", Assert.IsType(node).TagName); + Assert.Collection(node.Children, + x => Assert.IsType(x), + x => Assert.IsType(x), // We don't remove whitespace before/after C# expressions + x => Assert.IsType(x)); + }); + } + + private RazorCodeDocument CreateDocument(string content) + { + var source = RazorSourceDocument.Create(content, "test.cshtml"); + return ProjectEngine.CreateCodeDocumentCore(source, FileKinds.Component); + } + + private DocumentIntermediateNode Lower(RazorCodeDocument codeDocument) + { + for (var i = 0; i < Engine.Phases.Count; i++) + { + var phase = Engine.Phases[i]; + if (phase is IRazorCSharpLoweringPhase) + { + break; + } + + phase.Execute(codeDocument); + } + + return codeDocument.GetDocumentIntermediateNode(); + } + + private static string GetContent(IntermediateNode node) + { + var builder = new StringBuilder(); + var tokens = node.Children.OfType(); + foreach (var token in tokens) + { + builder.Append(token.Content); + } + return builder.ToString(); + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index b9fb0e4020..2c01ed31f2 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -2081,6 +2081,69 @@ namespace AnotherTest CompileToAssembly(generated); } + [Fact] + public void Component_WithPreserveWhitespaceDirective_True() + { + // Arrange / Act + var generated = CompileToCSharp(@" +@preservewhitespace true + +
    + @foreach (var item in Enumerable.Range(1, 100)) + { +
  • + @item +
  • + } +
+ +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_WithPreserveWhitespaceDirective_False() + { + // Arrange / Act + var generated = CompileToCSharp(@" +@preservewhitespace false + +
    + @foreach (var item in Enumerable.Range(1, 100)) + { +
  • + @item +
  • + } +
+ +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_WithPreserveWhitespaceDirective_Invalid() + { + // Arrange / Act + var generated = CompileToCSharp(@" +@preservewhitespace someVariable +@code { + bool someVariable = false; +} +", throwOnFailure: false); + + // Assert + Assert.Collection(generated.Diagnostics, d => { Assert.Equal("RZ1038", d.Id); }); + } + #endregion #region EventCallback @@ -4506,13 +4569,17 @@ namespace Test { public class SomeOtherComponent : ComponentBase { + [Parameter] public RenderFragment ChildContent { get; set; } } } ")); // Act var generated = CompileToCSharp(@" - + +

Child content at @DateTime.Now

+

Very @(""good"")

+

Hello

"); @@ -4618,6 +4685,32 @@ namespace Test CompileToAssembly(generated); } + [Fact] + public void WhiteSpace_WithPreserveWhitespace() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +@preservewhitespace true + + + + + + @code { + int Foo = 18; + } + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + #endregion #region Imports @@ -4753,6 +4846,58 @@ namespace New.Test AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); CompileToAssembly(generated); } + + [Fact] + public void Component_PreserveWhitespaceDirective_InImports() + { + // Arrange + var importContent = @" +@preservewhitespace true +"; + var importItem = CreateProjectItem("_Imports.razor", importContent, FileKinds.ComponentImport); + ImportItems.Add(importItem); + + // Act + var generated = CompileToCSharp(@" + + + @DateTime.Now + + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_PreserveWhitespaceDirective_OverrideImports() + { + // Arrange + var importContent = @" +@preservewhitespace true +"; + var importItem = CreateProjectItem("_Imports.razor", importContent, FileKinds.ComponentImport); + ImportItems.Add(importItem); + + // Act + var generated = CompileToCSharp(@" +@preservewhitespace false + + + @DateTime.Now + + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + #endregion #region Misc diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.codegen.cs new file mode 100644 index 0000000000..736d66bd85 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.codegen.cs @@ -0,0 +1,34 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = DateTime.Now; + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.ir.txt new file mode 100644 index 0000000000..7d133754d9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.ir.txt @@ -0,0 +1,31 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (20:0,20 [4] x:\dir\subdir\Test\_Imports.razor) - true + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static System.Object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [55] x:\dir\subdir\Test\TestComponent.cshtml) - parent + HtmlContent - (8:0,8 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (8:0,8 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (14:1,4 [30] x:\dir\subdir\Test\TestComponent.cshtml) - child + HtmlContent - (21:1,11 [1] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (21:1,11 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - + CSharpExpression - (23:1,13 [12] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (23:1,13 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - DateTime.Now + HtmlContent - (35:1,25 [1] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (35:1,25 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - + HtmlContent - (44:1,34 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (44:1,34 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (55:2,9 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (55:2,9 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.mappings.txt new file mode 100644 index 0000000000..a197792aa0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (23:1,13 [12] x:\dir\subdir\Test\TestComponent.cshtml) +|DateTime.Now| +Generated Location: (865:24,13 [12] ) +|DateTime.Now| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.codegen.cs new file mode 100644 index 0000000000..d75d0e63e4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.codegen.cs @@ -0,0 +1,37 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = DateTime.Now; + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.ir.txt new file mode 100644 index 0000000000..94eecda6a9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.ir.txt @@ -0,0 +1,34 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (20:0,20 [4] x:\dir\subdir\Test\_Imports.razor) - true + DirectiveToken - (20:0,20 [5] x:\dir\subdir\Test\TestComponent.cshtml) - false + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static System.Object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + HtmlContent - (27:1,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (27:1,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (29:2,0 [55] x:\dir\subdir\Test\TestComponent.cshtml) - parent + HtmlContent - (37:2,8 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (37:2,8 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (43:3,4 [30] x:\dir\subdir\Test\TestComponent.cshtml) - child + HtmlContent - (50:3,11 [1] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (50:3,11 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - + CSharpExpression - (52:3,13 [12] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (52:3,13 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - DateTime.Now + HtmlContent - (64:3,25 [1] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (64:3,25 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - + HtmlContent - (73:3,34 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (73:3,34 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (84:4,9 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (84:4,9 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.mappings.txt new file mode 100644 index 0000000000..234aca0387 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (52:3,13 [12] x:\dir\subdir\Test\TestComponent.cshtml) +|DateTime.Now| +Generated Location: (925:27,13 [12] ) +|DateTime.Now| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.codegen.cs new file mode 100644 index 0000000000..7b36a7dcc8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.codegen.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + foreach (var item in Enumerable.Range(1, 100)) + { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 7 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = item; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 8 "x:\dir\subdir\Test\TestComponent.cshtml" + + } + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.ir.txt new file mode 100644 index 0000000000..b2b9b58e7e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.ir.txt @@ -0,0 +1,37 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (20:0,20 [5] x:\dir\subdir\Test\TestComponent.cshtml) - false + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static System.Object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + HtmlContent - (27:1,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (27:1,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (29:2,0 [126] x:\dir\subdir\Test\TestComponent.cshtml) - ul + HtmlContent - (33:2,4 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (33:2,4 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (40:3,5 [63] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (40:3,5 [63] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - foreach (var item in Enumerable.Range(1, 100))\n {\n + MarkupElement - (103:5,8 [38] x:\dir\subdir\Test\TestComponent.cshtml) - li + HtmlContent - (107:5,12 [14] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (107:5,12 [14] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpExpression - (122:6,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (122:6,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - item + HtmlContent - (126:6,17 [10] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (126:6,17 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (141:7,13 [7] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (141:7,13 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n } + HtmlContent - (148:8,5 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (148:8,5 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (155:9,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (155:9,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.mappings.txt new file mode 100644 index 0000000000..13d244d11c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.mappings.txt @@ -0,0 +1,21 @@ +Source Location: (40:3,5 [63] x:\dir\subdir\Test\TestComponent.cshtml) +|foreach (var item in Enumerable.Range(1, 100)) + { + | +Generated Location: (917:27,5 [63] ) +|foreach (var item in Enumerable.Range(1, 100)) + { + | + +Source Location: (122:6,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|item| +Generated Location: (1115:36,13 [4] ) +|item| + +Source Location: (141:7,13 [7] x:\dir\subdir\Test\TestComponent.cshtml) +| + }| +Generated Location: (1255:43,13 [7] ) +| + }| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_Invalid/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_Invalid/TestComponent.codegen.cs new file mode 100644 index 0000000000..e5901d1f3a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_Invalid/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = preservewhitespace; + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + bool someVariable = false; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_Invalid/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_Invalid/TestComponent.ir.txt new file mode 100644 index 0000000000..4c2856ab92 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_Invalid/TestComponent.ir.txt @@ -0,0 +1,24 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static System.Object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpExpression - (1:0,1 [18] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (1:0,1 [18] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - preservewhitespace + HtmlContent - (19:0,19 [15] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (19:0,19 [15] x:\dir\subdir\Test\TestComponent.cshtml) - Html - someVariable\n + HtmlContent - (76:3,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (76:3,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (41:1,7 [34] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (41:1,7 [34] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n bool someVariable = false;\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_Invalid/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_Invalid/TestComponent.mappings.txt new file mode 100644 index 0000000000..feab0bd6e8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_Invalid/TestComponent.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (1:0,1 [18] x:\dir\subdir\Test\TestComponent.cshtml) +|preservewhitespace| +Generated Location: (858:24,6 [18] ) +|preservewhitespace| + +Source Location: (41:1,7 [34] x:\dir\subdir\Test\TestComponent.cshtml) +| + bool someVariable = false; +| +Generated Location: (1055:33,7 [34] ) +| + bool someVariable = false; +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.codegen.cs new file mode 100644 index 0000000000..7b36a7dcc8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.codegen.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + foreach (var item in Enumerable.Range(1, 100)) + { + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 7 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = item; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 8 "x:\dir\subdir\Test\TestComponent.cshtml" + + } + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.ir.txt new file mode 100644 index 0000000000..250cb24438 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.ir.txt @@ -0,0 +1,37 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (20:0,20 [4] x:\dir\subdir\Test\TestComponent.cshtml) - true + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static System.Object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + HtmlContent - (26:1,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (26:1,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (28:2,0 [126] x:\dir\subdir\Test\TestComponent.cshtml) - ul + HtmlContent - (32:2,4 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (32:2,4 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (39:3,5 [63] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (39:3,5 [63] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - foreach (var item in Enumerable.Range(1, 100))\n {\n + MarkupElement - (102:5,8 [38] x:\dir\subdir\Test\TestComponent.cshtml) - li + HtmlContent - (106:5,12 [14] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (106:5,12 [14] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpExpression - (121:6,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (121:6,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - item + HtmlContent - (125:6,17 [10] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (125:6,17 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (140:7,13 [7] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (140:7,13 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n } + HtmlContent - (147:8,5 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (147:8,5 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (154:9,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (154:9,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.mappings.txt new file mode 100644 index 0000000000..a78b63be25 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.mappings.txt @@ -0,0 +1,21 @@ +Source Location: (39:3,5 [63] x:\dir\subdir\Test\TestComponent.cshtml) +|foreach (var item in Enumerable.Range(1, 100)) + { + | +Generated Location: (917:27,5 [63] ) +|foreach (var item in Enumerable.Range(1, 100)) + { + | + +Source Location: (121:6,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|item| +Generated Location: (1115:36,13 [4] ) +|item| + +Source Location: (140:7,13 [7] x:\dir\subdir\Test\TestComponent.cshtml) +| + }| +Generated Location: (1255:43,13 [7] ) +| + }| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs index 930aa172c7..f71ec2143d 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs @@ -21,6 +21,20 @@ namespace Test protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = DateTime.Now; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = "good"; + +#line default +#line hidden +#nullable disable } )); #nullable restore diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.ir.txt index 003b347321..e49244d1ba 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.ir.txt @@ -14,9 +14,26 @@ Document - CSharpCode - IntermediateToken - - CSharp - #pragma warning restore 0414 MethodDeclaration - - protected override - void - BuildRenderTree - Component - (0:0,0 [22] x:\dir\subdir\Test\TestComponent.cshtml) - SomeOtherComponent - HtmlContent - (22:0,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (22:0,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n - MarkupElement - (26:2,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1 - HtmlContent - (30:2,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (30:2,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello + Component - (0:0,0 [115] x:\dir\subdir\Test\TestComponent.cshtml) - SomeOtherComponent + ComponentChildContent - - ChildContent - context + HtmlContent - (20:0,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (20:0,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (26:1,4 [39] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (30:1,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (30:1,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Child content at + CSharpExpression - (48:1,26 [12] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (48:1,26 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - DateTime.Now + HtmlContent - (65:1,43 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (65:1,43 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (71:2,4 [21] x:\dir\subdir\Test\TestComponent.cshtml) - p + HtmlContent - (74:2,7 [5] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (74:2,7 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Very + CSharpExpression - (81:2,14 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (81:2,14 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "good" + HtmlContent - (92:2,25 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (92:2,25 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (115:3,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (115:3,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + MarkupElement - (119:5,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (123:5,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (123:5,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.mappings.txt new file mode 100644 index 0000000000..11d74d7703 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (48:1,26 [12] x:\dir\subdir\Test\TestComponent.cshtml) +|DateTime.Now| +Generated Location: (1001:25,26 [12] ) +|DateTime.Now| + +Source Location: (81:2,14 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|"good"| +Generated Location: (1150:32,14 [6] ) +|"good"| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.codegen.cs new file mode 100644 index 0000000000..977f3d0e56 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.codegen.cs @@ -0,0 +1,48 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + Foo + +#line default +#line hidden +#nullable disable + ; + } + #pragma warning restore 1998 +#nullable restore +#line 7 "x:\dir\subdir\Test\TestComponent.cshtml" + + int Foo = 18; + + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.ir.txt new file mode 100644 index 0000000000..a90647f02f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.ir.txt @@ -0,0 +1,34 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (20:0,20 [4] x:\dir\subdir\Test\TestComponent.cshtml) - true + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static System.Object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + HtmlContent - (26:1,0 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (26:1,0 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (32:2,4 [48] x:\dir\subdir\Test\TestComponent.cshtml) - elem + HtmlAttribute - (37:2,9 [10] x:\dir\subdir\Test\TestComponent.cshtml) - attr= - + CSharpExpressionAttributeValue - (43:2,15 [4] x:\dir\subdir\Test\TestComponent.cshtml) - + LazyIntermediateToken - (44:2,16 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Foo + HtmlContent - (48:2,20 [10] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (48:2,20 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (58:3,8 [9] x:\dir\subdir\Test\TestComponent.cshtml) - child + HtmlContent - (67:3,17 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (67:3,17 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (80:4,11 [8] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (80:4,11 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + HtmlContent - (125:8,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (125:8,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + CSharpCode - (95:6,11 [29] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (95:6,11 [29] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n int Foo = 18;\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.mappings.txt new file mode 100644 index 0000000000..6f2c28937b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (44:2,16 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|Foo| +Generated Location: (948:28,16 [3] ) +|Foo| + +Source Location: (95:6,11 [29] x:\dir\subdir\Test\TestComponent.cshtml) +| + int Foo = 18; + | +Generated Location: (1148:38,11 [29] ) +| + int Foo = 18; + | + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithoutCloseTag/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithoutCloseTag/TestComponent.codegen.cs index 5803014b53..3b9d2751e1 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithoutCloseTag/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithoutCloseTag/TestComponent.codegen.cs @@ -14,9 +14,8 @@ namespace Test protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __builder.OpenElement(0, "div"); - __builder.AddMarkupContent(1, "\r\n "); - __builder.OpenElement(2, "input"); - __builder.AddAttribute(3, "@bind", + __builder.OpenElement(1, "input"); + __builder.AddAttribute(2, "@bind", #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" ParentValue @@ -26,7 +25,6 @@ namespace Test #nullable disable ); __builder.CloseElement(); - __builder.AddMarkupContent(4, "\r\n"); __builder.CloseElement(); } #pragma warning restore 1998 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithoutCloseTag/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithoutCloseTag/TestComponent.ir.txt index cdc244dd9b..1f9d6cbb52 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithoutCloseTag/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithoutCloseTag/TestComponent.ir.txt @@ -8,13 +8,9 @@ Document - ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree MarkupElement - (0:0,0 [45] x:\dir\subdir\Test\TestComponent.cshtml) - div - HtmlContent - (5:0,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (5:0,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n MarkupElement - (9:1,2 [28] x:\dir\subdir\Test\TestComponent.cshtml) - input HtmlAttribute - (15:1,8 [21] x:\dir\subdir\Test\TestComponent.cshtml) - @bind=" - " CSharpExpressionAttributeValue - (23:1,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (24:1,17 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - HtmlContent - (37:1,30 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (37:1,30 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (54:3,7 [55] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (54:3,7 [55] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithoutCloseTag/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithoutCloseTag/TestComponent.mappings.txt index c25138f2f9..3bd3f99ff9 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithoutCloseTag/TestComponent.mappings.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithoutCloseTag/TestComponent.mappings.txt @@ -2,7 +2,7 @@ Source Location: (54:3,7 [55] x:\dir\subdir\Test\TestComponent.cshtml) | public string ParentValue { get; set; } = "hi"; | -Generated Location: (1133:34,7 [55] ) +Generated Location: (1027:32,7 [55] ) | public string ParentValue { get; set; } = "hi"; | diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.codegen.cs index dbec07d0cb..2e63ffb34a 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.codegen.cs @@ -24,9 +24,8 @@ namespace Test #nullable disable )); __builder.AddAttribute(2, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((context) => (__builder2) => { - __builder2.AddMarkupContent(3, "\r\n "); - __builder2.OpenElement(4, "div"); - __builder2.AddContent(5, + __builder2.OpenElement(3, "div"); + __builder2.AddContent(4, #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" context.ToLower() @@ -36,7 +35,6 @@ namespace Test #nullable disable ); __builder2.CloseElement(); - __builder2.AddMarkupContent(6, "\r\n"); } )); __builder.CloseComponent(); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.ir.txt index adc85111c5..74d6105b61 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.ir.txt @@ -9,13 +9,9 @@ Document - MethodDeclaration - - protected override - void - BuildRenderTree Component - (0:0,0 [90] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent ComponentChildContent - - ChildContent - context - HtmlContent - (41:0,41 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (41:0,41 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n MarkupElement - (45:1,2 [29] x:\dir\subdir\Test\TestComponent.cshtml) - div CSharpExpression - (51:1,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (51:1,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLower() - HtmlContent - (74:1,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (74:1,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n ComponentTypeArgument - (19:0,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem LazyIntermediateToken - (19:0,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string ComponentAttribute - (32:0,32 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item - AttributeStructure.DoubleQuotes diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.codegen.cs index 22d9a102cb..46d5636adb 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.codegen.cs @@ -22,9 +22,8 @@ namespace Test #line hidden #nullable disable , 2, (context) => (__builder2) => { - __builder2.AddMarkupContent(3, "\r\n "); - __builder2.OpenElement(4, "div"); - __builder2.AddContent(5, + __builder2.OpenElement(3, "div"); + __builder2.AddContent(4, #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" context.ToLower() @@ -34,7 +33,6 @@ namespace Test #nullable disable ); __builder2.CloseElement(); - __builder2.AddMarkupContent(6, "\r\n"); } ); } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.ir.txt index a899c300ed..02d8c7e2f3 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.ir.txt @@ -9,13 +9,9 @@ Document - MethodDeclaration - - protected override - void - BuildRenderTree Component - (0:0,0 [77] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent ComponentChildContent - - ChildContent - context - HtmlContent - (28:0,28 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (28:0,28 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n MarkupElement - (32:1,2 [29] x:\dir\subdir\Test\TestComponent.cshtml) - div CSharpExpression - (38:1,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (38:1,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLower() - HtmlContent - (61:1,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (61:1,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n ComponentAttribute - (19:0,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item - AttributeStructure.DoubleQuotes CSharpExpression - (20:0,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (21:0,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_InLocalFunction/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_InLocalFunction/TestComponent.codegen.cs index 481ebef830..1a167bc537 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_InLocalFunction/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_InLocalFunction/TestComponent.codegen.cs @@ -29,10 +29,8 @@ using Microsoft.AspNetCore.Components.RenderTree; #line default #line hidden #nullable disable - __builder.AddContent(0, " "); - __builder.OpenComponent(1); + __builder.OpenComponent(0); __builder.CloseComponent(); - __builder.AddMarkupContent(2, "\r\n"); #nullable restore #line 6 "x:\dir\subdir\Test\TestComponent.cshtml" } @@ -40,7 +38,6 @@ using Microsoft.AspNetCore.Components.RenderTree; #line default #line hidden #nullable disable - __builder.AddMarkupContent(3, "\r\n"); #nullable restore #line 9 "x:\dir\subdir\Test\TestComponent.cshtml" RenderChildComponent(); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_InLocalFunction/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_InLocalFunction/TestComponent.ir.txt index 930a2aeca7..69e9566787 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_InLocalFunction/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_InLocalFunction/TestComponent.ir.txt @@ -10,14 +10,8 @@ Document - MethodDeclaration - - protected override - void - BuildRenderTree CSharpCode - (54:1,2 [42] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (54:1,2 [42] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n void RenderChildComponent()\n {\n - HtmlContent - (96:4,0 [8] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (96:4,0 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Component - (104:4,8 [15] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - HtmlContent - (119:4,23 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (119:4,23 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (121:5,0 [7] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (121:5,0 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - }\n - HtmlContent - (131:7,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (131:7,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (135:8,2 [25] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (135:8,2 [25] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderChildComponent(); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_InLocalFunction/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_InLocalFunction/TestComponent.mappings.txt index 69488d8b9b..105b799512 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_InLocalFunction/TestComponent.mappings.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_InLocalFunction/TestComponent.mappings.txt @@ -12,12 +12,12 @@ Generated Location: (757:24,2 [42] ) Source Location: (121:5,0 [7] x:\dir\subdir\Test\TestComponent.cshtml) | } | -Generated Location: (1121:37,0 [7] ) +Generated Location: (1019:35,0 [7] ) | } | Source Location: (135:8,2 [25] x:\dir\subdir\Test\TestComponent.cshtml) | RenderChildComponent(); | -Generated Location: (1302:45,2 [25] ) +Generated Location: (1148:42,2 [25] ) | RenderChildComponent(); | diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.codegen.cs index b0d7535388..a0d8581d8f 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.codegen.cs @@ -38,8 +38,7 @@ namespace Test } )); __builder.AddAttribute(5, "AnotherChildContent", (Microsoft.AspNetCore.Components.RenderFragment.Context>)((item) => (__builder2) => { - __builder2.AddMarkupContent(6, "\r\n "); - __builder2.AddContent(7, + __builder2.AddContent(6, #nullable restore #line 4 "x:\dir\subdir\Test\TestComponent.cshtml" System.Math.Max(0, item.Item) @@ -48,7 +47,7 @@ namespace Test #line hidden #nullable disable ); - __builder2.AddMarkupContent(8, ";\r\n"); + __builder2.AddMarkupContent(7, ";\r\n"); } )); __builder.CloseComponent(); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.ir.txt index d3ac4d2440..89a67e7387 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.ir.txt @@ -13,9 +13,6 @@ Document - CSharpExpression - (77:1,22 [17] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (77:1,22 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLower() ComponentChildContent - (117:2,0 [95] x:\dir\subdir\Test\TestComponent.cshtml) - AnotherChildContent - item - HtmlContent - (153:2,36 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (153:2,36 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - LazyIntermediateToken - (155:3,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - CSharpExpression - (158:3,3 [29] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (158:3,3 [29] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - System.Math.Max(0, item.Item) HtmlContent - (187:3,32 [3] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.codegen.cs index 09f1b42acd..0e4bdda7a2 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.codegen.cs @@ -43,8 +43,7 @@ namespace Test __builder2.CloseElement(); } , 6, (item) => (__builder2) => { - __builder2.AddMarkupContent(7, "\r\n "); - __builder2.AddContent(8, + __builder2.AddContent(7, #nullable restore #line 4 "x:\dir\subdir\Test\TestComponent.cshtml" System.Math.Max(0, item.Item) @@ -53,7 +52,7 @@ namespace Test #line hidden #nullable disable ); - __builder2.AddMarkupContent(9, ";\r\n"); + __builder2.AddMarkupContent(8, ";\r\n"); } ); } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.ir.txt index 81ed5115f8..0041a579f2 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.ir.txt @@ -13,9 +13,6 @@ Document - CSharpExpression - (78:1,22 [17] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (78:1,22 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLower() ComponentChildContent - (118:2,0 [95] x:\dir\subdir\Test\TestComponent.cshtml) - AnotherChildContent - item - HtmlContent - (154:2,36 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (154:2,36 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - LazyIntermediateToken - (156:3,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - CSharpExpression - (159:3,3 [29] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (159:3,3 [29] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - System.Math.Max(0, item.Item) HtmlContent - (188:3,32 [3] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.codegen.cs index 7495074ab8..572862ad71 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.codegen.cs @@ -29,7 +29,6 @@ namespace Test #nullable disable ); __builder2.CloseElement(); - __builder2.AddMarkupContent(7, "\r\n "); } )); __builder.CloseComponent(); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.ir.txt index ceaf16b99e..56dc82560d 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.ir.txt @@ -17,8 +17,6 @@ Document - LazyIntermediateToken - (89:2,28 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 1 CSharpExpression - (93:2,32 [23] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (93:2,32 [23] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - item.ToLowerInvariant() - HtmlContent - (129:2,68 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (129:2,68 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n ComponentAttribute - (21:0,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - MyAttr - MyAttr - AttributeStructure.DoubleQuotes HtmlContent - (21:0,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (21:0,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - abc diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.codegen.cs index 7495074ab8..572862ad71 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.codegen.cs @@ -29,7 +29,6 @@ namespace Test #nullable disable ); __builder2.CloseElement(); - __builder2.AddMarkupContent(7, "\r\n "); } )); __builder.CloseComponent(); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.ir.txt index b79b0cb9e0..1dcf38a762 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.ir.txt @@ -17,8 +17,6 @@ Document - LazyIntermediateToken - (89:2,28 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 1 CSharpExpression - (93:2,32 [23] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (93:2,32 [23] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - item.ToLowerInvariant() - HtmlContent - (129:2,68 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (129:2,68 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n ComponentAttribute - (21:0,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - MyAttr - MyAttr - AttributeStructure.DoubleQuotes HtmlContent - (21:0,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (21:0,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - abc diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.codegen.cs index e278e10afa..01fd4ddfba 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.codegen.cs @@ -19,7 +19,7 @@ using Microsoft.AspNetCore.Components; #pragma warning disable 1998 protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { - __builder.AddMarkupContent(0, "

Item1

\r\n"); + __builder.AddMarkupContent(0, "

Item1

"); #nullable restore #line 6 "x:\dir\subdir\Test\TestComponent.cshtml" foreach (var item2 in Items2) @@ -28,10 +28,8 @@ using Microsoft.AspNetCore.Components; #line default #line hidden #nullable disable - __builder.AddContent(1, " "); - __builder.OpenElement(2, "p"); - __builder.AddMarkupContent(3, "\r\n "); - __builder.AddContent(4, + __builder.OpenElement(1, "p"); + __builder.AddContent(2, #nullable restore #line 9 "x:\dir\subdir\Test\TestComponent.cshtml" ChildContent(item2) @@ -40,9 +38,8 @@ using Microsoft.AspNetCore.Components; #line hidden #nullable disable ); - __builder.AddMarkupContent(5, ";\r\n "); + __builder.AddMarkupContent(3, ";\r\n "); __builder.CloseElement(); - __builder.AddMarkupContent(6, "\r\n"); #nullable restore #line 11 "x:\dir\subdir\Test\TestComponent.cshtml" } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.ir.txt index dc03e9a9d6..ebd0a97fae 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.ir.txt @@ -7,21 +7,14 @@ Document - UsingDirective - (1:0,1 [40] x:\dir\subdir\Test\TestComponent.cshtml) - Microsoft.AspNetCore.Components ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - - TItem1, TItem2 MethodDeclaration - - protected override - void - BuildRenderTree - MarkupBlock - -

Item1

\n + MarkupBlock - -

Item1

CSharpCode - (98:5,1 [34] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (98:5,1 [34] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - foreach (var item2 in Items2)\n{\n - HtmlContent - (132:7,0 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (132:7,0 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - MarkupElement - (136:7,4 [40] x:\dir\subdir\Test\TestComponent.cshtml) - p - HtmlContent - (139:7,7 [6] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (139:7,7 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - LazyIntermediateToken - (141:8,0 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - CSharpExpression - (146:8,5 [19] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (146:8,5 [19] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ChildContent(item2) HtmlContent - (165:8,24 [7] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (165:8,24 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Html - ;\n - HtmlContent - (176:9,8 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (176:9,8 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (178:10,0 [3] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (178:10,0 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - }\n CSharpCode - (188:11,7 [185] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.mappings.txt index 830e2d6d1b..f039f8827d 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.mappings.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.mappings.txt @@ -2,7 +2,7 @@ Source Location: (98:5,1 [34] x:\dir\subdir\Test\TestComponent.cshtml) |foreach (var item2 in Items2) { | -Generated Location: (783:26,1 [34] ) +Generated Location: (779:24,1 [34] ) |foreach (var item2 in Items2) { | @@ -10,7 +10,7 @@ Generated Location: (783:26,1 [34] ) Source Location: (178:10,0 [3] x:\dir\subdir\Test\TestComponent.cshtml) |} | -Generated Location: (1432:51,0 [3] ) +Generated Location: (1274:46,0 [3] ) |} | @@ -20,7 +20,7 @@ Source Location: (188:11,7 [185] x:\dir\subdir\Test\TestComponent.cshtml) [Parameter] public List Items2 { get; set; } [Parameter] public RenderFragment ChildContent { get; set; } | -Generated Location: (1612:60,7 [185] ) +Generated Location: (1454:55,7 [185] ) | [Parameter] public TItem1 Item1 { get; set; } [Parameter] public List Items2 { get; set; } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.codegen.cs new file mode 100644 index 0000000000..55984e6f79 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.codegen.cs @@ -0,0 +1,38 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenElement(0, "parent"); + __builder.AddMarkupContent(1, "\r\n "); + __builder.OpenElement(2, "child"); + __builder.AddContent(3, " "); + __builder.AddContent(4, +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + DateTime.Now + +#line default +#line hidden +#nullable disable + ); + __builder.AddContent(5, " "); + __builder.CloseElement(); + __builder.AddMarkupContent(6, "\r\n"); + __builder.CloseElement(); + __builder.AddMarkupContent(7, "\r\n\r\n"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.ir.txt new file mode 100644 index 0000000000..b0c99573e9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_PreserveWhitespaceDirective_InImports/TestComponent.ir.txt @@ -0,0 +1,23 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [55] x:\dir\subdir\Test\TestComponent.cshtml) - parent + HtmlContent - (8:0,8 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (8:0,8 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (14:1,4 [30] x:\dir\subdir\Test\TestComponent.cshtml) - child + HtmlContent - (21:1,11 [1] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (21:1,11 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - + CSharpExpression - (23:1,13 [12] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (23:1,13 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - DateTime.Now + HtmlContent - (35:1,25 [1] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (35:1,25 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - + HtmlContent - (44:1,34 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (44:1,34 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (55:2,9 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (55:2,9 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.codegen.cs new file mode 100644 index 0000000000..d126cfe163 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.codegen.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenElement(0, "parent"); + __builder.OpenElement(1, "child"); + __builder.AddContent(2, +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + DateTime.Now + +#line default +#line hidden +#nullable disable + ); + __builder.CloseElement(); + __builder.CloseElement(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.ir.txt new file mode 100644 index 0000000000..2609421ad6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_PreserveWhitespaceDirective_OverrideImports/TestComponent.ir.txt @@ -0,0 +1,13 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (29:2,0 [55] x:\dir\subdir\Test\TestComponent.cshtml) - parent + MarkupElement - (43:3,4 [30] x:\dir\subdir\Test\TestComponent.cshtml) - child + CSharpExpression - (52:3,13 [12] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (52:3,13 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - DateTime.Now diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_TextTagsAreNotRendered/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_TextTagsAreNotRendered/TestComponent.codegen.cs index 8deff24077..ce02f4d669 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_TextTagsAreNotRendered/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_TextTagsAreNotRendered/TestComponent.codegen.cs @@ -15,7 +15,6 @@ namespace Test { __builder.OpenComponent(0); __builder.CloseComponent(); - __builder.AddMarkupContent(1, "\r\n"); #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" if (true) @@ -25,7 +24,7 @@ namespace Test #line default #line hidden #nullable disable - __builder.AddContent(2, "This text is rendered"); + __builder.AddContent(1, "This text is rendered"); #nullable restore #line 4 "x:\dir\subdir\Test\TestComponent.cshtml" diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_TextTagsAreNotRendered/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_TextTagsAreNotRendered/TestComponent.ir.txt index b1f16b8022..15063495d1 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_TextTagsAreNotRendered/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_TextTagsAreNotRendered/TestComponent.ir.txt @@ -8,8 +8,6 @@ Document - ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree Component - (0:0,0 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Counter - HtmlContent - (11:0,11 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (11:0,11 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (14:1,1 [18] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (14:1,1 [18] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - if (true)\n{\n HtmlContent - (38:3,10 [21] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_TextTagsAreNotRendered/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_TextTagsAreNotRendered/TestComponent.mappings.txt index 82206d510e..5a0f537e81 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_TextTagsAreNotRendered/TestComponent.mappings.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_TextTagsAreNotRendered/TestComponent.mappings.txt @@ -2,7 +2,7 @@ Source Location: (14:1,1 [18] x:\dir\subdir\Test\TestComponent.cshtml) |if (true) { | -Generated Location: (733:20,1 [18] ) +Generated Location: (681:19,1 [18] ) |if (true) { | @@ -11,7 +11,7 @@ Source Location: (66:3,38 [5] x:\dir\subdir\Test\TestComponent.cshtml) | } | -Generated Location: (974:30,38 [5] ) +Generated Location: (922:29,38 [5] ) | } | diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithDocType/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithDocType/TestComponent.codegen.cs index ba7c557a07..4313d7cb1e 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithDocType/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithDocType/TestComponent.codegen.cs @@ -13,8 +13,7 @@ namespace Test #pragma warning disable 1998 protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { - __builder.AddMarkupContent(0, "\r\n"); - __builder.AddMarkupContent(1, "
\r\n
"); + __builder.AddMarkupContent(0, "\r\n
"); } #pragma warning restore 1998 } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithDocType/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithDocType/TestComponent.ir.txt index 7187dffef0..059d6b2fb3 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithDocType/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithDocType/TestComponent.ir.txt @@ -7,6 +7,4 @@ Document - UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree - HtmlContent - (0:0,0 [17] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (0:0,0 [17] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - MarkupBlock - -
\n
+ MarkupBlock - - \n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.codegen.cs new file mode 100644 index 0000000000..9a181f7d60 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.codegen.cs @@ -0,0 +1,48 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenElement(0, "ul"); +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + foreach (var item in Enumerable.Range(1, 100)) + { + +#line default +#line hidden +#nullable disable + __builder.OpenElement(1, "li"); + __builder.AddContent(2, +#nullable restore +#line 7 "x:\dir\subdir\Test\TestComponent.cshtml" + item + +#line default +#line hidden +#nullable disable + ); + __builder.CloseElement(); +#nullable restore +#line 9 "x:\dir\subdir\Test\TestComponent.cshtml" + } + +#line default +#line hidden +#nullable disable + __builder.CloseElement(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.ir.txt new file mode 100644 index 0000000000..606239d583 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.ir.txt @@ -0,0 +1,19 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (29:2,0 [126] x:\dir\subdir\Test\TestComponent.cshtml) - ul + CSharpCode - (35:3,0 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (35:3,0 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - + CSharpCode - (40:3,5 [55] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (40:3,5 [55] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - foreach (var item in Enumerable.Range(1, 100))\n {\n + MarkupElement - (103:5,8 [38] x:\dir\subdir\Test\TestComponent.cshtml) - li + CSharpExpression - (122:6,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (122:6,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - item + CSharpCode - (143:8,0 [7] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (143:8,0 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.mappings.txt new file mode 100644 index 0000000000..e9f9b3f79c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_False/TestComponent.mappings.txt @@ -0,0 +1,16 @@ +Source Location: (40:3,5 [55] x:\dir\subdir\Test\TestComponent.cshtml) +|foreach (var item in Enumerable.Range(1, 100)) + { +| +Generated Location: (634:18,5 [55] ) +|foreach (var item in Enumerable.Range(1, 100)) + { +| + +Source Location: (143:8,0 [7] x:\dir\subdir\Test\TestComponent.cshtml) +| } +| +Generated Location: (1086:37,0 [7] ) +| } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.codegen.cs new file mode 100644 index 0000000000..6bbdab0428 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.codegen.cs @@ -0,0 +1,55 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.AddMarkupContent(0, "\r\n"); + __builder.OpenElement(1, "ul"); + __builder.AddMarkupContent(2, "\r\n"); +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + foreach (var item in Enumerable.Range(1, 100)) + { + +#line default +#line hidden +#nullable disable + __builder.AddContent(3, " "); + __builder.OpenElement(4, "li"); + __builder.AddMarkupContent(5, "\r\n "); + __builder.AddContent(6, +#nullable restore +#line 7 "x:\dir\subdir\Test\TestComponent.cshtml" + item + +#line default +#line hidden +#nullable disable + ); + __builder.AddMarkupContent(7, "\r\n "); + __builder.CloseElement(); + __builder.AddMarkupContent(8, "\r\n"); +#nullable restore +#line 9 "x:\dir\subdir\Test\TestComponent.cshtml" + } + +#line default +#line hidden +#nullable disable + __builder.CloseElement(); + __builder.AddMarkupContent(9, "\r\n\r\n"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.ir.txt new file mode 100644 index 0000000000..ed9ae587ab --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.ir.txt @@ -0,0 +1,34 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + HtmlContent - (26:1,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (26:1,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (28:2,0 [126] x:\dir\subdir\Test\TestComponent.cshtml) - ul + HtmlContent - (32:2,4 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (32:2,4 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (34:3,0 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (34:3,0 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - + CSharpCode - (39:3,5 [55] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (39:3,5 [55] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - foreach (var item in Enumerable.Range(1, 100))\n {\n + HtmlContent - (94:5,0 [8] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (94:5,0 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - + MarkupElement - (102:5,8 [38] x:\dir\subdir\Test\TestComponent.cshtml) - li + HtmlContent - (106:5,12 [14] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (106:5,12 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + LazyIntermediateToken - (108:6,0 [12] x:\dir\subdir\Test\TestComponent.cshtml) - Html - + CSharpExpression - (121:6,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (121:6,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - item + HtmlContent - (125:6,17 [10] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (125:6,17 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (140:7,13 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (140:7,13 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (142:8,0 [7] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (142:8,0 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - }\n + HtmlContent - (154:9,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (154:9,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.mappings.txt new file mode 100644 index 0000000000..d3e86e7e52 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithPreserveWhitespaceDirective_True/TestComponent.mappings.txt @@ -0,0 +1,16 @@ +Source Location: (39:3,5 [55] x:\dir\subdir\Test\TestComponent.cshtml) +|foreach (var item in Enumerable.Range(1, 100)) + { +| +Generated Location: (738:20,5 [55] ) +|foreach (var item in Enumerable.Range(1, 100)) + { +| + +Source Location: (142:8,0 [7] x:\dir\subdir\Test\TestComponent.cshtml) +| } +| +Generated Location: (1416:43,0 [7] ) +| } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs index 8698a027f3..54b8bf2363 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs @@ -21,11 +21,10 @@ using Microsoft.AspNetCore.Components.Web; protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __builder.OpenElement(0, "div"); - __builder.AddMarkupContent(1, "\r\n "); - __builder.OpenElement(2, "input"); - __builder.AddAttribute(3, "type", "text"); - __builder.AddAttribute(4, "Value", "17"); - __builder.AddAttribute(5, "value", Microsoft.AspNetCore.Components.BindConverter.FormatValue( + __builder.OpenElement(1, "input"); + __builder.AddAttribute(2, "type", "text"); + __builder.AddAttribute(3, "Value", "17"); + __builder.AddAttribute(4, "value", Microsoft.AspNetCore.Components.BindConverter.FormatValue( #nullable restore #line 3 "x:\dir\subdir\Test\TestComponent.cshtml" text @@ -34,10 +33,9 @@ using Microsoft.AspNetCore.Components.Web; #line hidden #nullable disable )); - __builder.AddAttribute(6, "onchange", Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text)); + __builder.AddAttribute(5, "onchange", Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text)); __builder.SetUpdatesAttributeName("value"); __builder.CloseElement(); - __builder.AddMarkupContent(7, "\r\n"); __builder.CloseElement(); } #pragma warning restore 1998 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt index 15f4e81c6e..1fbd4bc525 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt @@ -9,8 +9,6 @@ Document - ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree MarkupElement - (44:1,0 [69] x:\dir\subdir\Test\TestComponent.cshtml) - div - HtmlContent - (49:1,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (49:1,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n MarkupElement - (53:2,2 [52] x:\dir\subdir\Test\TestComponent.cshtml) - input HtmlAttribute - - type=" - " HtmlAttributeValue - (66:2,15 [4] x:\dir\subdir\Test\TestComponent.cshtml) - @@ -28,7 +26,5 @@ Document - IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, IntermediateToken - - CSharp - text IntermediateToken - - CSharp - ) - HtmlContent - (105:2,54 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (105:2,54 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (127:4,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (127:4,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private string text = "hi";\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt index f76be5b17e..6b6beae840 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt @@ -2,7 +2,7 @@ Source Location: (127:4,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) | private string text = "hi"; | -Generated Location: (1704:45,12 [35] ) +Generated Location: (1598:43,12 [35] ) | private string text = "hi"; | diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.codegen.cs index 1692b5a96d..af3808fed1 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.codegen.cs @@ -14,15 +14,13 @@ namespace Test protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __builder.OpenElement(0, "div"); - __builder.AddMarkupContent(1, "\r\n "); - __builder.OpenElement(2, "a"); - __builder.AddAttribute(3, "href", "/cool-url"); - __builder.AddAttribute(4, "style", true); - __builder.AddAttribute(5, "disabled", true); - __builder.AddAttribute(6, "href", "/even-cooler-url"); - __builder.AddContent(7, "Learn the ten cool tricks your compiler author will hate!"); + __builder.OpenElement(1, "a"); + __builder.AddAttribute(2, "href", "/cool-url"); + __builder.AddAttribute(3, "style", true); + __builder.AddAttribute(4, "disabled", true); + __builder.AddAttribute(5, "href", "/even-cooler-url"); + __builder.AddContent(6, "Learn the ten cool tricks your compiler author will hate!"); __builder.CloseElement(); - __builder.AddMarkupContent(8, "\r\n"); __builder.CloseElement(); } #pragma warning restore 1998 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.ir.txt index 855ace3024..2a9f025133 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.ir.txt @@ -8,8 +8,6 @@ Document - ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree MarkupElement - (0:0,0 [140] x:\dir\subdir\Test\TestComponent.cshtml) - div - HtmlContent - (5:0,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (5:0,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n MarkupElement - (9:1,2 [123] x:\dir\subdir\Test\TestComponent.cshtml) - a HtmlAttribute - (11:1,4 [17] x:\dir\subdir\Test\TestComponent.cshtml) - href=" - " HtmlAttributeValue - (18:1,11 [9] x:\dir\subdir\Test\TestComponent.cshtml) - @@ -21,5 +19,3 @@ Document - LazyIntermediateToken - (53:1,46 [16] x:\dir\subdir\Test\TestComponent.cshtml) - Html - /even-cooler-url HtmlContent - (71:1,64 [57] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (71:1,64 [57] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Learn the ten cool tricks your compiler author will hate! - HtmlContent - (132:1,125 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (132:1,125 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.codegen.cs index 0d94284032..0258d9ebf9 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.codegen.cs @@ -21,10 +21,9 @@ using Microsoft.AspNetCore.Components.Web; protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __builder.OpenElement(0, "div"); - __builder.AddMarkupContent(1, "\r\n "); - __builder.OpenElement(2, "input"); - __builder.AddAttribute(3, "type", "text"); - __builder.AddAttribute(4, "oninput", Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + __builder.OpenElement(1, "input"); + __builder.AddAttribute(2, "type", "text"); + __builder.AddAttribute(3, "oninput", Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, #nullable restore #line 3 "x:\dir\subdir\Test\TestComponent.cshtml" () => {} @@ -33,7 +32,7 @@ using Microsoft.AspNetCore.Components.Web; #line hidden #nullable disable )); - __builder.AddAttribute(5, "value", Microsoft.AspNetCore.Components.BindConverter.FormatValue( + __builder.AddAttribute(4, "value", Microsoft.AspNetCore.Components.BindConverter.FormatValue( #nullable restore #line 3 "x:\dir\subdir\Test\TestComponent.cshtml" text @@ -42,10 +41,9 @@ using Microsoft.AspNetCore.Components.Web; #line hidden #nullable disable )); - __builder.AddAttribute(6, "oninput", Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text)); + __builder.AddAttribute(5, "oninput", Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text)); __builder.SetUpdatesAttributeName("value"); __builder.CloseElement(); - __builder.AddMarkupContent(7, "\r\n"); __builder.CloseElement(); } #pragma warning restore 1998 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.ir.txt index cbc170c605..8a69783148 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.ir.txt @@ -9,8 +9,6 @@ Document - ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree MarkupElement - (44:1,0 [112] x:\dir\subdir\Test\TestComponent.cshtml) - div - HtmlContent - (49:1,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (49:1,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n MarkupElement - (53:2,2 [95] x:\dir\subdir\Test\TestComponent.cshtml) - input HtmlAttribute - - type=" - " HtmlAttributeValue - (66:2,15 [4] x:\dir\subdir\Test\TestComponent.cshtml) - @@ -30,7 +28,5 @@ Document - IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, IntermediateToken - - CSharp - text IntermediateToken - - CSharp - ) - HtmlContent - (148:2,97 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (148:2,97 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (170:4,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (170:4,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private string text = "hi";\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.mappings.txt index 867fd2df72..b15a594cd2 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.mappings.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.mappings.txt @@ -2,7 +2,7 @@ Source Location: (170:4,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) | private string text = "hi"; | -Generated Location: (2036:53,12 [35] ) +Generated Location: (1930:51,12 [35] ) | private string text = "hi"; | diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs index 5c4151e716..45b501f2e0 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs @@ -21,11 +21,10 @@ using Microsoft.AspNetCore.Components.Web; protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __builder.OpenElement(0, "div"); - __builder.AddMarkupContent(1, "\r\n "); - __builder.OpenElement(2, "input"); - __builder.AddAttribute(3, "type", "text"); - __builder.AddAttribute(4, "value", "17"); - __builder.AddAttribute(5, "value", Microsoft.AspNetCore.Components.BindConverter.FormatValue( + __builder.OpenElement(1, "input"); + __builder.AddAttribute(2, "type", "text"); + __builder.AddAttribute(3, "value", "17"); + __builder.AddAttribute(4, "value", Microsoft.AspNetCore.Components.BindConverter.FormatValue( #nullable restore #line 3 "x:\dir\subdir\Test\TestComponent.cshtml" text @@ -34,10 +33,9 @@ using Microsoft.AspNetCore.Components.Web; #line hidden #nullable disable )); - __builder.AddAttribute(6, "onchange", Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text)); + __builder.AddAttribute(5, "onchange", Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text)); __builder.SetUpdatesAttributeName("value"); __builder.CloseElement(); - __builder.AddMarkupContent(7, "\r\n"); __builder.CloseElement(); } #pragma warning restore 1998 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt index 6ae1973ad2..a4577a9dba 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt @@ -9,8 +9,6 @@ Document - ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree MarkupElement - (44:1,0 [69] x:\dir\subdir\Test\TestComponent.cshtml) - div - HtmlContent - (49:1,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (49:1,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n MarkupElement - (53:2,2 [52] x:\dir\subdir\Test\TestComponent.cshtml) - input HtmlAttribute - - type=" - " HtmlAttributeValue - (66:2,15 [4] x:\dir\subdir\Test\TestComponent.cshtml) - @@ -28,7 +26,5 @@ Document - IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, IntermediateToken - - CSharp - text IntermediateToken - - CSharp - ) - HtmlContent - (105:2,54 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (105:2,54 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (127:4,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (127:4,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private string text = "hi";\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt index f76be5b17e..6b6beae840 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt @@ -2,7 +2,7 @@ Source Location: (127:4,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) | private string text = "hi"; | -Generated Location: (1704:45,12 [35] ) +Generated Location: (1598:43,12 [35] ) | private string text = "hi"; | diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.codegen.cs index f9ca0bdec8..5140f2959a 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.codegen.cs @@ -21,10 +21,9 @@ using Microsoft.AspNetCore.Components.Web; protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __builder.OpenElement(0, "div"); - __builder.AddMarkupContent(1, "\r\n "); - __builder.OpenElement(2, "a"); - __builder.AddAttribute(3, "onclick", "test()"); - __builder.AddAttribute(4, "onclick", Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + __builder.OpenElement(1, "a"); + __builder.AddAttribute(2, "onclick", "test()"); + __builder.AddAttribute(3, "onclick", Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, #nullable restore #line 3 "x:\dir\subdir\Test\TestComponent.cshtml" () => {} @@ -33,9 +32,8 @@ using Microsoft.AspNetCore.Components.Web; #line hidden #nullable disable )); - __builder.AddContent(5, "Learn the ten cool tricks your compiler author will hate!"); + __builder.AddContent(4, "Learn the ten cool tricks your compiler author will hate!"); __builder.CloseElement(); - __builder.AddMarkupContent(6, "\r\n"); __builder.CloseElement(); } #pragma warning restore 1998 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.ir.txt index af5b32da26..0a6e32e41f 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.ir.txt @@ -9,8 +9,6 @@ Document - ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree MarkupElement - (44:1,0 [118] x:\dir\subdir\Test\TestComponent.cshtml) - div - HtmlContent - (49:1,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (49:1,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n MarkupElement - (53:2,2 [101] x:\dir\subdir\Test\TestComponent.cshtml) - a HtmlContent - (93:2,42 [57] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (93:2,42 [57] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Learn the ten cool tricks your compiler author will hate! @@ -22,5 +20,3 @@ Document - IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, LazyIntermediateToken - (83:2,32 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - () => {} IntermediateToken - - CSharp - ) - HtmlContent - (154:2,103 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (154:2,103 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.codegen.cs index 1d52b314c0..4ee5c736c6 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.codegen.cs @@ -14,16 +14,14 @@ namespace Test protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __builder.OpenElement(0, "div"); - __builder.AddMarkupContent(1, "\r\n "); - __builder.OpenElement(2, "a"); - __builder.AddAttribute(3, "href", "/cool-url"); - __builder.AddAttribute(4, "style", true); - __builder.AddAttribute(5, "disabled", true); - __builder.AddAttribute(6, "href", "/even-cooler-url"); - __builder.AddAttribute(7, "href", true); - __builder.AddContent(8, "Learn the ten cool tricks your compiler author will hate!"); + __builder.OpenElement(1, "a"); + __builder.AddAttribute(2, "href", "/cool-url"); + __builder.AddAttribute(3, "style", true); + __builder.AddAttribute(4, "disabled", true); + __builder.AddAttribute(5, "href", "/even-cooler-url"); + __builder.AddAttribute(6, "href", true); + __builder.AddContent(7, "Learn the ten cool tricks your compiler author will hate!"); __builder.CloseElement(); - __builder.AddMarkupContent(9, "\r\n"); __builder.CloseElement(); } #pragma warning restore 1998 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.ir.txt index eab06c4348..00541c63d5 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.ir.txt @@ -8,8 +8,6 @@ Document - ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree MarkupElement - (0:0,0 [145] x:\dir\subdir\Test\TestComponent.cshtml) - div - HtmlContent - (5:0,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (5:0,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n MarkupElement - (9:1,2 [128] x:\dir\subdir\Test\TestComponent.cshtml) - a HtmlAttribute - (11:1,4 [17] x:\dir\subdir\Test\TestComponent.cshtml) - href=" - " HtmlAttributeValue - (18:1,11 [9] x:\dir\subdir\Test\TestComponent.cshtml) - @@ -22,5 +20,3 @@ Document - HtmlAttribute - (70:1,63 [5] x:\dir\subdir\Test\TestComponent.cshtml) - href - HtmlContent - (76:1,69 [57] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (76:1,69 [57] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Learn the ten cool tricks your compiler author will hate! - HtmlContent - (137:1,130 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (137:1,130 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithoutCloseTag/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithoutCloseTag/TestComponent.codegen.cs index a0a824d92b..177ceabaf7 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithoutCloseTag/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithoutCloseTag/TestComponent.codegen.cs @@ -21,9 +21,8 @@ using Microsoft.AspNetCore.Components.Web; protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __builder.OpenElement(0, "div"); - __builder.AddMarkupContent(1, "\r\n "); - __builder.OpenElement(2, "input"); - __builder.AddAttribute(3, "onclick", Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + __builder.OpenElement(1, "input"); + __builder.AddAttribute(2, "onclick", Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, #nullable restore #line 3 "x:\dir\subdir\Test\TestComponent.cshtml" OnClick @@ -33,7 +32,6 @@ using Microsoft.AspNetCore.Components.Web; #nullable disable )); __builder.CloseElement(); - __builder.AddMarkupContent(4, "\r\n"); __builder.CloseElement(); } #pragma warning restore 1998 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithoutCloseTag/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithoutCloseTag/TestComponent.ir.txt index 74a027d012..8349e3075f 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithoutCloseTag/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithoutCloseTag/TestComponent.ir.txt @@ -9,15 +9,11 @@ Document - ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree MarkupElement - (44:1,0 [43] x:\dir\subdir\Test\TestComponent.cshtml) - div - HtmlContent - (49:1,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (49:1,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n MarkupElement - (53:2,2 [26] x:\dir\subdir\Test\TestComponent.cshtml) - input HtmlAttribute - (70:2,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " CSharpExpressionAttributeValue - - IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, LazyIntermediateToken - (70:2,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnClick IntermediateToken - - CSharp - ) - HtmlContent - (79:2,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (79:2,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (96:4,7 [31] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (96:4,7 [31] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n void OnClick() {\n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithoutCloseTag/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithoutCloseTag/TestComponent.mappings.txt index a0d0ac06fa..5080afe9e6 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithoutCloseTag/TestComponent.mappings.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithoutCloseTag/TestComponent.mappings.txt @@ -3,7 +3,7 @@ Source Location: (96:4,7 [31] x:\dir\subdir\Test\TestComponent.cshtml) void OnClick() { } | -Generated Location: (1417:41,7 [31] ) +Generated Location: (1311:39,7 [31] ) | void OnClick() { } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithFullyQualifiedTagName/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithFullyQualifiedTagName/TestComponent.codegen.cs index d8a7967fa3..dcab0dfd43 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithFullyQualifiedTagName/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithFullyQualifiedTagName/TestComponent.codegen.cs @@ -22,9 +22,8 @@ namespace Test #line hidden #nullable disable , 2, (context) => (__builder2) => { - __builder2.AddMarkupContent(3, "\r\n "); - __builder2.OpenElement(4, "div"); - __builder2.AddContent(5, + __builder2.OpenElement(3, "div"); + __builder2.AddContent(4, #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" context.ToLower() @@ -34,7 +33,6 @@ namespace Test #nullable disable ); __builder2.CloseElement(); - __builder2.AddMarkupContent(6, "\r\n"); } ); } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithFullyQualifiedTagName/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithFullyQualifiedTagName/TestComponent.ir.txt index 5067b01f20..5a841a91e9 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithFullyQualifiedTagName/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithFullyQualifiedTagName/TestComponent.ir.txt @@ -9,13 +9,9 @@ Document - MethodDeclaration - - protected override - void - BuildRenderTree Component - (0:0,0 [87] x:\dir\subdir\Test\TestComponent.cshtml) - Test.MyComponent ComponentChildContent - - ChildContent - context - HtmlContent - (33:0,33 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (33:0,33 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n MarkupElement - (37:1,2 [29] x:\dir\subdir\Test\TestComponent.cshtml) - div CSharpExpression - (43:1,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (43:1,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLower() - HtmlContent - (66:1,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (66:1,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n ComponentAttribute - (24:0,24 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item - AttributeStructure.DoubleQuotes CSharpExpression - (25:0,25 [6] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (26:0,26 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs index 324adf9e46..254f087964 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs @@ -14,9 +14,37 @@ namespace Test protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __builder.OpenComponent(0); + __builder.AddAttribute(1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + __builder2.OpenElement(2, "h1"); + __builder2.AddContent(3, "Child content at "); + __builder2.AddContent(4, +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + DateTime.Now + +#line default +#line hidden +#nullable disable + ); + __builder2.CloseElement(); + __builder2.AddMarkupContent(5, "\r\n "); + __builder2.OpenElement(6, "p"); + __builder2.AddContent(7, "Very "); + __builder2.AddContent(8, +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + "good" + +#line default +#line hidden +#nullable disable + ); + __builder2.CloseElement(); + } + )); __builder.CloseComponent(); - __builder.AddMarkupContent(1, "\r\n\r\n"); - __builder.AddMarkupContent(2, "

Hello

"); + __builder.AddMarkupContent(9, "\r\n\r\n"); + __builder.AddMarkupContent(10, "

Hello

"); } #pragma warning restore 1998 } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.ir.txt index c384e3090e..af6b0d3e19 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.ir.txt @@ -7,7 +7,20 @@ Document - UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree - Component - (0:0,0 [22] x:\dir\subdir\Test\TestComponent.cshtml) - SomeOtherComponent - HtmlContent - (22:0,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (22:0,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + Component - (0:0,0 [115] x:\dir\subdir\Test\TestComponent.cshtml) - SomeOtherComponent + ComponentChildContent - - ChildContent - context + MarkupElement - (26:1,4 [39] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (30:1,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (30:1,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Child content at + CSharpExpression - (48:1,26 [12] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (48:1,26 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - DateTime.Now + HtmlContent - (65:1,43 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (65:1,43 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (71:2,4 [21] x:\dir\subdir\Test\TestComponent.cshtml) - p + HtmlContent - (74:2,7 [5] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (74:2,7 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Very + CSharpExpression - (81:2,14 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (81:2,14 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "good" + HtmlContent - (115:3,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (115:3,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n MarkupBlock - -

Hello

diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/MarkupComment_IsNotIncluded/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/MarkupComment_IsNotIncluded/TestComponent.codegen.cs index a1ea2a2c22..f74394ce80 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/MarkupComment_IsNotIncluded/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/MarkupComment_IsNotIncluded/TestComponent.codegen.cs @@ -31,7 +31,6 @@ namespace Test #line hidden #nullable disable ); - __builder.AddMarkupContent(2, " "); __builder.CloseElement(); } #pragma warning restore 1998 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/MarkupComment_IsNotIncluded/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/MarkupComment_IsNotIncluded/TestComponent.ir.txt index fdad6f0a3e..93ebc966c1 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/MarkupComment_IsNotIncluded/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/MarkupComment_IsNotIncluded/TestComponent.ir.txt @@ -12,4 +12,3 @@ Document - MarkupElement - (44:3,0 [38] x:\dir\subdir\Test\TestComponent.cshtml) - div CSharpExpression - (50:3,6 [7] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (50:3,6 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - myValue - MarkupBlock - - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.codegen.cs index 1a54116eb4..552605fd8f 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.codegen.cs @@ -45,8 +45,7 @@ namespace Test #nullable disable __builder.OpenComponent(3); __builder.AddAttribute(4, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { - __builder2.AddMarkupContent(5, "\r\n"); - __builder2.AddContent(6, + __builder2.AddContent(5, #nullable restore #line 5 "x:\dir\subdir\Test\TestComponent.cshtml" "hello, world!" @@ -55,7 +54,6 @@ namespace Test #line hidden #nullable disable ); - __builder2.AddMarkupContent(7, "\r\n"); } )); __builder.CloseComponent(); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.ir.txt index 881808d4ff..4d0759767a 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.ir.txt @@ -19,11 +19,7 @@ Document - LazyIntermediateToken - (93:1,89 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ;\n Component - (99:3,0 [49] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent ComponentChildContent - - ChildContent - context - HtmlContent - (112:3,13 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (112:3,13 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpExpression - (116:4,2 [15] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (116:4,2 [15] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hello, world!" - HtmlContent - (132:4,18 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (132:4,18 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (159:7,7 [76] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (159:7,7 [76] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.mappings.txt index ad61d61350..ed0c4af062 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.mappings.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.mappings.txt @@ -19,7 +19,7 @@ Source Location: (159:7,7 [76] x:\dir\subdir\Test\TestComponent.cshtml) public string Name { get; set; } } | -Generated Location: (2207:65,7 [76] ) +Generated Location: (2093:63,7 [76] ) | class Person { diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.codegen.cs index 11af4cefd1..a4085edb4a 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.codegen.cs @@ -14,13 +14,11 @@ namespace Test protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __builder.OpenElement(0, "div"); - __builder.AddMarkupContent(1, "\r\n "); - __builder.OpenElement(2, "script"); - __builder.AddAttribute(3, "src", "some/url.js"); - __builder.AddAttribute(4, "anotherattribute", true); - __builder.AddMarkupContent(5, "\r\n some text\r\n some more text\r\n "); + __builder.OpenElement(1, "script"); + __builder.AddAttribute(2, "src", "some/url.js"); + __builder.AddAttribute(3, "anotherattribute", true); + __builder.AddMarkupContent(4, "\r\n some text\r\n some more text\r\n "); __builder.CloseElement(); - __builder.AddMarkupContent(6, "\r\n"); __builder.CloseElement(); } #pragma warning restore 1998 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.ir.txt index 8f4611599c..4ba08cf728 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.ir.txt @@ -8,8 +8,6 @@ Document - ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree MarkupElement - (0:0,0 [144] x:\dir\subdir\Test\TestComponent.cshtml) - div - HtmlContent - (5:0,5 [6] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (5:0,5 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n MarkupElement - (11:1,4 [125] x:\dir\subdir\Test\TestComponent.cshtml) - script HtmlAttribute - (18:1,11 [18] x:\dir\subdir\Test\TestComponent.cshtml) - src=' - ' HtmlAttributeValue - (24:1,17 [11] x:\dir\subdir\Test\TestComponent.cshtml) - @@ -17,5 +15,3 @@ Document - HtmlAttribute - (36:1,29 [17] x:\dir\subdir\Test\TestComponent.cshtml) - anotherattribute - HtmlContent - (78:1,71 [49] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (78:1,71 [49] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n some text\n some more text\n - HtmlContent - (136:4,13 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (136:4,13 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.codegen.cs index 16726f5372..5dfe18db34 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.codegen.cs @@ -30,10 +30,9 @@ using Microsoft.AspNetCore.Components.RenderTree; #line default #line hidden #nullable disable - __builder.AddContent(0, " "); - __builder.OpenElement(1, "p"); - __builder.AddContent(2, "Output: "); - __builder.AddContent(3, + __builder.OpenElement(0, "p"); + __builder.AddContent(1, "Output: "); + __builder.AddContent(2, #nullable restore #line 7 "x:\dir\subdir\Test\TestComponent.cshtml" output @@ -43,7 +42,6 @@ using Microsoft.AspNetCore.Components.RenderTree; #nullable disable ); __builder.CloseElement(); - __builder.AddMarkupContent(4, "\r\n"); } #pragma warning restore 1998 } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.ir.txt index 5e1dc16963..1e62832776 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/SingleLineControlFlowStatements_InCodeBlock/TestComponent.ir.txt @@ -10,14 +10,10 @@ Document - MethodDeclaration - - protected override - void - BuildRenderTree CSharpCode - (56:2,2 [134] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (56:2,2 [134] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n var output = string.Empty;\n if (__builder == null) output = "Builder is null!";\n else output = "Builder is not null!";\n - HtmlContent - (190:6,0 [4] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (190:6,0 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - MarkupElement - (194:6,4 [22] x:\dir\subdir\Test\TestComponent.cshtml) - p HtmlContent - (197:6,7 [8] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (197:6,7 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Output: CSharpExpression - (206:6,16 [6] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (206:6,16 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - output - HtmlContent - (216:6,26 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (216:6,26 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (218:7,0 [0] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (218:7,0 [0] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.codegen.cs new file mode 100644 index 0000000000..60146d6047 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.codegen.cs @@ -0,0 +1,43 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.AddMarkupContent(0, "\r\n "); + __builder.OpenElement(1, "elem"); + __builder.AddAttribute(2, "attr", +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + Foo + +#line default +#line hidden +#nullable disable + ); + __builder.AddMarkupContent(3, "\r\n \r\n "); + __builder.CloseElement(); + __builder.AddMarkupContent(4, "\r\n\r\n\r\n"); + } + #pragma warning restore 1998 +#nullable restore +#line 7 "x:\dir\subdir\Test\TestComponent.cshtml" + + int Foo = 18; + + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.ir.txt new file mode 100644 index 0000000000..5a7148821b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.ir.txt @@ -0,0 +1,19 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + HtmlContent - (26:1,0 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (26:1,0 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (32:2,4 [48] x:\dir\subdir\Test\TestComponent.cshtml) - elem + HtmlAttribute - (37:2,9 [10] x:\dir\subdir\Test\TestComponent.cshtml) - attr= - + CSharpExpressionAttributeValue - (43:2,15 [4] x:\dir\subdir\Test\TestComponent.cshtml) - + LazyIntermediateToken - (44:2,16 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Foo + MarkupBlock - - \n \n + MarkupBlock - - \n\n\n + CSharpCode - (95:6,11 [29] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (95:6,11 [29] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n int Foo = 18;\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.mappings.txt new file mode 100644 index 0000000000..8aa5edb3fa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/WhiteSpace_WithPreserveWhitespace/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (95:6,11 [29] x:\dir\subdir\Test\TestComponent.cshtml) +| + int Foo = 18; + | +Generated Location: (1134:35,11 [29] ) +| + int Foo = 18; + | + From 3fe6b07412984035dd69ea6757156dd7c8bd1c93 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 30 Jun 2020 11:38:20 -0700 Subject: [PATCH 2/5] Ensure BlazorWebAssembly.js is present (#23518) --- .../Microsoft.AspNetCore.Components.WebAssembly.props | 5 +++++ .../Microsoft.NET.Sdk.Razor.Components.Wasm.targets | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/Components/WebAssembly/WebAssembly/src/build/net5.0/Microsoft.AspNetCore.Components.WebAssembly.props diff --git a/src/Components/WebAssembly/WebAssembly/src/build/net5.0/Microsoft.AspNetCore.Components.WebAssembly.props b/src/Components/WebAssembly/WebAssembly/src/build/net5.0/Microsoft.AspNetCore.Components.WebAssembly.props new file mode 100644 index 0000000000..41ae67bf35 --- /dev/null +++ b/src/Components/WebAssembly/WebAssembly/src/build/net5.0/Microsoft.AspNetCore.Components.WebAssembly.props @@ -0,0 +1,5 @@ + + + $(MSBuildThisFileDirectory)blazor.webassembly.js + + diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Components.Wasm.targets b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Components.Wasm.targets index fff9969bcb..1d293e3ef4 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Components.Wasm.targets +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Components.Wasm.targets @@ -92,6 +92,7 @@ Copyright (c) .NET Foundation. All rights reserved. + <_BlazorJSFile Include="$(BlazorWebAssemblyJSPath)" /> <_BlazorJSFile Include="$(BlazorWebAssemblyJSMapPath)" Condition="Exists('$(BlazorWebAssemblyJSMapPath)')" /> @@ -140,7 +141,7 @@ Copyright (c) .NET Foundation. All rights reserved. - + <_BlazorOutputWithTargetPath Include="@(_BlazorReadSatelliteAssembly)" @@ -162,6 +163,12 @@ Copyright (c) .NET Foundation. All rights reserved. + + +

Current count:

diff --git a/src/Components/test/testassets/BasicTestApp/CulturePicker.razor b/src/Components/test/testassets/BasicTestApp/CulturePicker.razor index 69cb953b7e..5a32549632 100644 --- a/src/Components/test/testassets/BasicTestApp/CulturePicker.razor +++ b/src/Components/test/testassets/BasicTestApp/CulturePicker.razor @@ -1,4 +1,4 @@ -@inject NavigationManager NavigationManager +@inject NavigationManager NavigationManager

Select your language

diff --git a/src/Components/test/testassets/BasicTestApp/InputEventComponent.razor b/src/Components/test/testassets/BasicTestApp/InputEventComponent.razor index ecbc828390..6082d4647c 100644 --- a/src/Components/test/testassets/BasicTestApp/InputEventComponent.razor +++ b/src/Components/test/testassets/BasicTestApp/InputEventComponent.razor @@ -1,4 +1,4 @@ - +

The text below should update automatically as you type in the text field above

diff --git a/src/Components/test/testassets/BasicTestApp/InteropComponent.razor b/src/Components/test/testassets/BasicTestApp/InteropComponent.razor index 9e2167b4b0..d329d68900 100644 --- a/src/Components/test/testassets/BasicTestApp/InteropComponent.razor +++ b/src/Components/test/testassets/BasicTestApp/InteropComponent.razor @@ -1,4 +1,4 @@ -@using Microsoft.JSInterop +@using Microsoft.JSInterop @using BasicTestApp.InteropTest @using System.Runtime.InteropServices @using System.Text.Json diff --git a/src/Components/test/testassets/BasicTestApp/InteropOnInitializationComponent.razor b/src/Components/test/testassets/BasicTestApp/InteropOnInitializationComponent.razor index ddd4a0ec07..f897b3ae5f 100644 --- a/src/Components/test/testassets/BasicTestApp/InteropOnInitializationComponent.razor +++ b/src/Components/test/testassets/BasicTestApp/InteropOnInitializationComponent.razor @@ -1,4 +1,4 @@ -@page "/prerendered-interop" +@page "/prerendered-interop" @using Microsoft.AspNetCore.Components @using Microsoft.JSInterop @inject IJSRuntime JSRuntime diff --git a/src/Components/test/testassets/BasicTestApp/JsonSerializationCases.razor b/src/Components/test/testassets/BasicTestApp/JsonSerializationCases.razor index 7f1b227f58..31c88eef18 100644 --- a/src/Components/test/testassets/BasicTestApp/JsonSerializationCases.razor +++ b/src/Components/test/testassets/BasicTestApp/JsonSerializationCases.razor @@ -1,4 +1,4 @@ -@using System.Text.Json +@using System.Text.Json @using System.Text.Json.Serialization

JSON serialization cases

diff --git a/src/Components/test/testassets/BasicTestApp/KeyCasesComponent.razor b/src/Components/test/testassets/BasicTestApp/KeyCasesComponent.razor index 582913ae27..168e387123 100644 --- a/src/Components/test/testassets/BasicTestApp/KeyCasesComponent.razor +++ b/src/Components/test/testassets/BasicTestApp/KeyCasesComponent.razor @@ -1,4 +1,4 @@ -@using System.Text.Json +@using System.Text.Json

Model

diff --git a/src/Components/test/testassets/BasicTestApp/KeyCasesTreeNode.razor b/src/Components/test/testassets/BasicTestApp/KeyCasesTreeNode.razor index dcc321eaf6..851e6e91a7 100644 --- a/src/Components/test/testassets/BasicTestApp/KeyCasesTreeNode.razor +++ b/src/Components/test/testassets/BasicTestApp/KeyCasesTreeNode.razor @@ -1,4 +1,4 @@ -
+
@Data.Label   [ Instance: @instanceId; diff --git a/src/Components/test/testassets/BasicTestApp/KeyPressEventComponent.razor b/src/Components/test/testassets/BasicTestApp/KeyPressEventComponent.razor index dd96e41d51..43db51d66b 100644 --- a/src/Components/test/testassets/BasicTestApp/KeyPressEventComponent.razor +++ b/src/Components/test/testassets/BasicTestApp/KeyPressEventComponent.razor @@ -1,4 +1,4 @@ -@using System.Text.Json +@using System.Text.Json Type here:
    diff --git a/src/Components/test/testassets/BasicTestApp/LaggyTypingComponent.razor b/src/Components/test/testassets/BasicTestApp/LaggyTypingComponent.razor index 3d1598d424..5dc47aef04 100644 --- a/src/Components/test/testassets/BasicTestApp/LaggyTypingComponent.razor +++ b/src/Components/test/testassets/BasicTestApp/LaggyTypingComponent.razor @@ -1,4 +1,4 @@ -@using System.Threading +@using System.Threading

    @InputText

    diff --git a/src/Components/test/testassets/BasicTestApp/LimitCounterComponent.razor b/src/Components/test/testassets/BasicTestApp/LimitCounterComponent.razor index bb60eb48cd..1f22e9f3d9 100644 --- a/src/Components/test/testassets/BasicTestApp/LimitCounterComponent.razor +++ b/src/Components/test/testassets/BasicTestApp/LimitCounterComponent.razor @@ -1,4 +1,4 @@ -

    Counter

    +

    Counter

    This counter component is used in the server-side limit tests to showcase that we keep dispatching and processing events when the unacknowledged render batches queue is full and that we produce the update UI once we receive an diff --git a/src/Components/test/testassets/BasicTestApp/LocalizedText.razor b/src/Components/test/testassets/BasicTestApp/LocalizedText.razor index 8423f226dd..a86579e3c9 100644 --- a/src/Components/test/testassets/BasicTestApp/LocalizedText.razor +++ b/src/Components/test/testassets/BasicTestApp/LocalizedText.razor @@ -1,2 +1,2 @@ -

    Culture is: @System.Globalization.CultureInfo.CurrentCulture.Name

    +

    Culture is: @System.Globalization.CultureInfo.CurrentCulture.Name

    @Resources.Message

    diff --git a/src/Components/test/testassets/BasicTestApp/LoggingComponent.razor b/src/Components/test/testassets/BasicTestApp/LoggingComponent.razor index 6ac41d792c..c574def21b 100644 --- a/src/Components/test/testassets/BasicTestApp/LoggingComponent.razor +++ b/src/Components/test/testassets/BasicTestApp/LoggingComponent.razor @@ -1,4 +1,4 @@ -@using Microsoft.Extensions.Logging +@using Microsoft.Extensions.Logging @inject ILoggerFactory LoggerFactory

    Logging buttons

    diff --git a/src/Components/test/testassets/BasicTestApp/LongRunningInterop.razor b/src/Components/test/testassets/BasicTestApp/LongRunningInterop.razor index 81479decd4..1ff1843e4d 100644 --- a/src/Components/test/testassets/BasicTestApp/LongRunningInterop.razor +++ b/src/Components/test/testassets/BasicTestApp/LongRunningInterop.razor @@ -1,4 +1,4 @@ -@using Microsoft.JSInterop +@using Microsoft.JSInterop @using BasicTestApp.InteropTest @using System.Runtime.InteropServices @using System.Text.Json diff --git a/src/Components/test/testassets/BasicTestApp/MarkupBlockComponent.razor b/src/Components/test/testassets/BasicTestApp/MarkupBlockComponent.razor index b0323f5871..73e802fbc4 100644 --- a/src/Components/test/testassets/BasicTestApp/MarkupBlockComponent.razor +++ b/src/Components/test/testassets/BasicTestApp/MarkupBlockComponent.razor @@ -1,4 +1,4 @@ -@using Microsoft.AspNetCore.Components.Rendering +@using Microsoft.AspNetCore.Components.Rendering

    Markup blocks

    diff --git a/src/Components/test/testassets/BasicTestApp/MouseEventComponent.razor b/src/Components/test/testassets/BasicTestApp/MouseEventComponent.razor index a9356c80e0..9b9d05eedc 100644 --- a/src/Components/test/testassets/BasicTestApp/MouseEventComponent.razor +++ b/src/Components/test/testassets/BasicTestApp/MouseEventComponent.razor @@ -1,4 +1,4 @@ -@using System.Collections.Generic +@using System.Collections.Generic @using System.Text.Json

    diff --git a/src/Components/test/testassets/BasicTestApp/MovingCheckboxesComponent.razor b/src/Components/test/testassets/BasicTestApp/MovingCheckboxesComponent.razor index beca5e04d3..481d7aa8fb 100644 --- a/src/Components/test/testassets/BasicTestApp/MovingCheckboxesComponent.razor +++ b/src/Components/test/testassets/BasicTestApp/MovingCheckboxesComponent.razor @@ -1,4 +1,4 @@ -

    +

    This component represents a case that's difficult for the diff algorithm if it doesn't understand how the underlying DOM gets mutated when you check a box.

    diff --git a/src/Components/test/testassets/BasicTestApp/MultipleChildContent.razor b/src/Components/test/testassets/BasicTestApp/MultipleChildContent.razor index 9229fb49ae..fdf7baebc2 100644 --- a/src/Components/test/testassets/BasicTestApp/MultipleChildContent.razor +++ b/src/Components/test/testassets/BasicTestApp/MultipleChildContent.razor @@ -1,4 +1,4 @@ - +
    Col1Col2Col3