diff --git a/src/Mvc/test/WebSites/BasicWebSite/RazorComponents/FetchData.razor b/src/Mvc/test/WebSites/BasicWebSite/RazorComponents/FetchData.razor index d2d7e9ea6629..03c3c8a957b3 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 f1f8cd28b96c..c3df65cf639e 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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 46b8dd5f0645..a1f78b09a342 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 b457a1f9f7f0..cbadc7ee10de 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 000000000000..72f657aac77a --- /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 08eec3ae8025..761e3eb8f4d3 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 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte 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 bool PreserveWhitespaceIsEnabled(DocumentIntermediateNode documentNode) + { + // 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 void RemoveContiguousWhitespace(IntermediateNodeCollection nodes, TraversalDirection direction) + private static int RemoveContiguousWhitespace(IntermediateNodeCollection nodes, TraversalDirection direction, int? startIndex = null) { - var position = direction == TraversalDirection.Forwards ? 0 : nodes.Count - 1; + 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 @@ private static void RemoveContiguousWhitespace(IntermediateNodeCollection nodes, shouldContinueIteration = false; break; - case CSharpCodeIntermediateNode codeIntermediateNode: + case CSharpCodeIntermediateNode _: shouldRemoveNode = false; shouldContinueIteration = false; break; @@ -90,6 +119,7 @@ private static void RemoveContiguousWhitespace(IntermediateNodeCollection nodes, if (shouldRemoveNode) { nodes.RemoveAt(position); + countRemoved++; if (direction == TraversalDirection.Forwards) { position--; @@ -103,6 +133,8 @@ private static void RemoveContiguousWhitespace(IntermediateNodeCollection nodes, break; } } + + return countRemoved; } enum TraversalDirection @@ -110,5 +142,39 @@ enum TraversalDirection 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 e8257bba7fff..3e9c14b46f99 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 @@ public static IDirectiveDescriptorBuilder AddAttributeToken(this IDirectiveDescr 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 916a57c3cae4..88b214071c9e 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 @@ public enum DirectiveTokenKind 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 9daadf371417..fd94358c157e 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 @@ private void ParseExtensibleDirective(in SyntaxListBuilder buil 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 @@ private void ParseExtensibleDirective(in SyntaxListBuilder buil 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 @@ private bool TryParseKeyword(in SyntaxListBuilder builder, IRea 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 1617fc417c67..3d1fbb234a4e 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 @@ public static RazorDiagnostic CreateParsing_DirectiveExpectsCSharpAttribute(Sour { 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 07729dcd2548..ac75eac6d17f 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 @@ public static RazorProjectEngine Create( NamespaceDirective.Register(builder); AttributeDirective.Register(builder); - AddComponentFeatures(builder); + AddComponentFeatures(builder, configuration.LanguageVersion); } LoadExtensions(builder, configuration.Extensions); @@ -206,7 +206,7 @@ private static void AddDefaultFeatures(ICollection features) }); } - 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 @@ private static void AddComponentFeatures(RazorProjectEngineBuilder builder) 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 33c63d93c25f..65fdf317bb17 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 365b7909f924..6c00e4f32227 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 @@ public void Execute_RewritesHtml_Basic() "); var expected = NormalizeContent(@" - - + Hello, World! - -"); + "); var documentNode = Lower(document); @@ -163,7 +161,7 @@ public void Execute_RewritesHtml_CSharpInAttributes() "); - var expected = NormalizeContent("
foo
\n "); + var expected = NormalizeContent("
foo
"); var documentNode = Lower(document); @@ -349,11 +347,8 @@ public void Execute_CanRewriteHtml_OptionWithNoSelectAncestor() "); 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 000000000000..d2356ace8baa --- /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 b9fb0e4020d5..2c01ed31f2ce 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 @@ public void WhiteSpace_InsideAttribute_InMarkupBlock() 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 000000000000..736d66bd85c6 --- /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 000000000000..7d133754d95f --- /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 000000000000..a197792aa0c3 --- /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 000000000000..d75d0e63e463 --- /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 000000000000..94eecda6a9ae --- /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 000000000000..234aca038791 --- /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 000000000000..7b36a7dcc81d --- /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 000000000000..b2b9b58e7e10 --- /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 000000000000..13d244d11c8c --- /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 000000000000..e5901d1f3a58 --- /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 000000000000..4c2856ab92b5 --- /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 000000000000..feab0bd6e818 --- /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 000000000000..7b36a7dcc81d --- /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 000000000000..250cb24438ca --- /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 000000000000..a78b63be25ce --- /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 930aa172c778..f71ec2143dd3 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 @@ private void __RazorDirectiveTokenHelpers__() { 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 003b34732196..e49244d1ba94 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 000000000000..11d74d7703dc --- /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 000000000000..977f3d0e562c --- /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 000000000000..a90647f02fff --- /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 000000000000..6f2c28937b61 --- /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 5803014b53fc..3b9d2751e161 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 @@ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBa 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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 cdc244dd9b15..1f9d6cbb52cf 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 c25138f2f94f..3bd3f99ff99d 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 dbec07d0cb52..2e63ffb34ab7 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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 adc85111c59a..74d6105b61c0 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 22d9a102cbf4..46d5636adb62 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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 a899c300eda7..02d8c7e2f35c 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 481ebef83053..1a167bc53752 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 @@ void RenderChildComponent() #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 @@ void RenderChildComponent() #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 930a2aeca7ab..69e9566787f2 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 69488d8b9b03..105b799512ad 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 b0d753538851..a0d8581d8fe0 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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin } )); __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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 d3ac4d244080..89a67e738733 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 09f1b42acd86..0e4bdda7a207 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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin __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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 81ed5115f8fd..0041a579f27e 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 7495074ab80d..572862ad7113 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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 ceaf16b99e30..56dc82560d10 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 7495074ab80d..572862ad7113 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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 b79b0cb9e057..1dcf38a76206 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 e278e10afa17..01fd4ddfbacf 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 @@ public partial class TestComponent : Microsoft.AspNetCore.Compon #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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 dc03e9a9d627..ebd0a97fae66 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 830e2d6d1b81..f039f8827d03 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 000000000000..55984e6f7922 --- /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 000000000000..b0c99573e9b1 --- /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 000000000000..d126cfe16301 --- /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 000000000000..2609421ad6dd --- /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 8deff2407738..ce02f4d66929 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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin { __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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 b1f16b8022af..15063495d139 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 82206d510efd..5a0f537e819c 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 ba7c557a0790..4313d7cb1e89 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 @@ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBa #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 7187dffef0eb..059d6b2fb3f5 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 000000000000..9a181f7d6085 --- /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 000000000000..606239d5831c --- /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 000000000000..e9f9b3f79cf2 --- /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 000000000000..6bbdab042858 --- /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 000000000000..ed9ae587abaa --- /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 000000000000..d3e86e7e52ca --- /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 8698a027f3e7..54b8bf236323 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 @@ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBa 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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 15f4e81c6e4d..1fbd4bc525ef 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 f76be5b17e5d..6b6beae84076 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 1692b5a96d76..af3808fed175 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 @@ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBa 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 855ace3024f3..2a9f02513397 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 0d942840320a..0258d9ebf940 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 @@ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBa 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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 cbc170c6057c..8a697831487f 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 867fd2df7296..b15a594cd295 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 5c4151e71637..45b501f2e0c1 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 @@ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBa 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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 6ae1973ad27b..a4577a9dbac2 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 f76be5b17e5d..6b6beae84076 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 f9ca0bdec8b6..5140f2959a8a 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 @@ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBa 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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 af5b32da2613..0a6e32e41f5e 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 1d52b314c089..4ee5c736c606 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 @@ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBa 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 eab06c43485e..00541c63d50b 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 a0a824d92beb..177ceabaf7a2 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 @@ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBa 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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 74a027d012de..8349e3075fba 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 a0d0ac06fad3..5080afe9e64a 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 d8a7967fa3be..dcab0dfd430a 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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 5067b01f2033..5a841a91e939 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 324adf9e4657..254f08796496 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 @@ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBa 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 c384e3090e67..af6b0d3e196c 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 a1ea2a2c2283..f74394ce807b 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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 fdad6f0a3e75..93ebc966c1c8 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 1a54116eb48a..552605fd8f46 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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 881808d4ff41..4d0759767a59 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 ad61d6135072..ed0c4af062f3 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 11af4cefd18d..a4085edb4a36 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 @@ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBa 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 8f4611599c91..4ba08cf72898 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 16726f537296..5dfe18db342c 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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #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 5e1dc1696380..1e6283277633 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 000000000000..60146d6047cf --- /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 000000000000..5a7148821bc1 --- /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 000000000000..8aa5edb3fabc --- /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; + | +