From ed7692a585b4b0688cf2d6614e60f1f538912244 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Fri, 4 Feb 2022 05:35:47 -0800 Subject: [PATCH 01/33] Initial support for 'bind:after' in elements --- .../src/ComponentResources.resx | 3 ++ .../Components/ComponentBindLoweringPass.cs | 25 ++++++++++ .../src/TagHelperDescriptor.cs | 7 +++ .../ComponentCodeGenerationTestBase.cs | 35 +++++++++++++ .../TestComponent.codegen.cs | 50 +++++++++++++++++++ .../TestComponent.ir.txt | 34 +++++++++++++ .../TestComponent.mappings.txt | 24 +++++++++ .../TestComponent.codegen.cs | 46 +++++++++++++++++ .../TestComponent.ir.txt | 23 +++++++++ .../TestComponent.mappings.txt | 19 +++++++ .../src/BindTagHelperDescriptorProvider.cs | 19 +++++++ .../RazorBaselineIntegrationTestBase.cs | 2 +- ...ft.AspNetCore.Components.netstandard2.0.cs | 42 ++++++++-------- 13 files changed, 307 insertions(+), 22 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx b/src/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx index 86084bc5b..46084f7c6 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx +++ b/src/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx @@ -129,6 +129,9 @@ Binds the provided expression to the '{0}' property and a change event delegate to the '{1}' property of the component. + + Specifies an action to run after the new value has been set. + Specifies the culture to use for conversions. diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs index fd8060b77..66c360da0 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs @@ -109,6 +109,10 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte { entry.BindCultureNode = node; } + else if(node.BoundAttributeParameter.Name == "after") + { + entry.BindAfterNode = node; + } else { // Unsupported bind attribute parameter. This can only happen if bound attribute descriptor @@ -333,6 +337,14 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE }; } + // Look for an after event. If we find one then we need to pass the event into the + // CreateBinder call we generate. + IntermediateToken after = null; + if (bindEntry.BindAfterNode != null) + { + after = GetAttributeContent(bindEntry.BindAfterNode); + } + var valueExpressionTokens = new List(); var changeExpressionTokens = new List(); @@ -360,6 +372,7 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE original, format, culture, + after, valueExpressionTokens, changeExpressionTokens); } @@ -679,6 +692,7 @@ private void RewriteNodesForElementEventCallbackBind( IntermediateToken original, IntermediateToken format, IntermediateToken culture, + IntermediateToken after, List valueExpressionTokens, List changeExpressionTokens) { @@ -768,6 +782,15 @@ private void RewriteNodesForElementEventCallbackBind( }); } + if (after != null) + { + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $", after: {after.Content}", + Kind = TokenKind.CSharp + }); + } + changeExpressionTokens.Add(new IntermediateToken() { Content = ")", @@ -838,5 +861,7 @@ public BindEntry(IntermediateNodeReference bindNodeReference) public TagHelperDirectiveAttributeParameterIntermediateNode BindFormatNode { get; set; } public TagHelperDirectiveAttributeParameterIntermediateNode BindCultureNode { get; set; } + + public TagHelperDirectiveAttributeParameterIntermediateNode BindAfterNode { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptor.cs b/src/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptor.cs index 43c040dca..01b37550f 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptor.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptor.cs @@ -5,10 +5,12 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; namespace Microsoft.AspNetCore.Razor.Language; +[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] public abstract class TagHelperDescriptor : IEquatable { private IEnumerable _allDiagnostics; @@ -137,4 +139,9 @@ public ParsedTypeInformation(bool success, StringSegment @namespace, StringSegme public StringSegment Namespace { get; } public StringSegment TypeName { get; } } + + private string GetDebuggerDisplay() + { + return $"{DisplayName} - {Kind} - {Name} - {AssemblyName}"; + } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index a4e482452..9b0218e3f 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -1613,6 +1613,41 @@ public static class BindAttributes CompileToAssembly(generated); } + [Fact] + public void BindToElement_WithBindAfter() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", null, ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + + // Act + var generated = CompileToCSharp(@" +
+
+@code { + public string ParentValue { get; set; } = ""hi""; + + Task DoSomething() + { + return Task.CompletedTask; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + [Fact] public void BindToElement_WithStringAttribute_WritesAttributes() { diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs new file mode 100644 index 000000000..60d7a27f7 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs @@ -0,0 +1,50 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, ParentValue, after: DoSomething); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + Task DoSomething() + { + return Task.CompletedTask; + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt new file mode 100644 index 000000000..96f0a98f8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/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 - global::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 + MarkupElement - (0:0,0 [60] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlContent - (52:0,52 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (52:0,52 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (13:0,13 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - ParentValue + IntermediateToken - - CSharp - , after: DoSomething + IntermediateToken - - CSharp - ) + HtmlContent - (60:1,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (60:1,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (69:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (69:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n Task DoSomething()\n {\n return Task.CompletedTask;\n }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt new file mode 100644 index 000000000..2c2cb9da8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt @@ -0,0 +1,24 @@ +Source Location: (13:0,13 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (967:25,13 [11] ) +|ParentValue| + +Source Location: (69:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + Task DoSomething() + { + return Task.CompletedTask; + } +| +Generated Location: (1340:36,7 [131] ) +| + public string ParentValue { get; set; } = "hi"; + + Task DoSomething() + { + return Task.CompletedTask; + } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs new file mode 100644 index 000000000..6cd47a5f2 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs @@ -0,0 +1,46 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenElement(0, "div"); + __builder.AddAttribute(1, "myvalue", global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "myevent", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, ParentValue, after: DoSomething)); + __builder.SetUpdatesAttributeName("myvalue"); + __builder.CloseElement(); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + Task DoSomething() + { + return Task.CompletedTask; + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt new file mode 100644 index 000000000..e8e7b5110 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [60] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (13:0,13 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - ParentValue + IntermediateToken - - CSharp - , after: DoSomething + IntermediateToken - - CSharp - ) + CSharpCode - (69:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (69:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n Task DoSomething()\n {\n return Task.CompletedTask;\n }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt new file mode 100644 index 000000000..1185fa3ad --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (69:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + Task DoSomething() + { + return Task.CompletedTask; + } +| +Generated Location: (1280:32,7 [131] ) +| + public string ParentValue { get; set; } = "hi"; + + Task DoSomething() + { + return Task.CompletedTask; + } +| + diff --git a/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs b/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs index 3af01dd16..bdb8679a6 100644 --- a/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs +++ b/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs @@ -198,6 +198,15 @@ private TagHelperDescriptor CreateFallbackBindTagHelper() parameter.SetPropertyName("Culture"); }); + + attribute.BindAttributeParameter(parameter => + { + parameter.Name = "after"; + parameter.TypeName = typeof(Delegate).FullName; + parameter.Documentation = ComponentResources.BindTagHelper_Element_Culture_Documentation; + + parameter.SetPropertyName("Culture"); + }); }); return builder.Build(); @@ -408,6 +417,15 @@ private List CreateElementBindTagHelpers(List + { + parameter.Name = "after"; + parameter.TypeName = typeof(Delegate).FullName; + parameter.Documentation = ComponentResources.BindTagHelper_Element_Culture_Documentation; + + parameter.SetPropertyName("Culture"); + }); }); // This is no longer supported. This is just here so we can add a diagnostic later on when this matches. @@ -544,6 +562,7 @@ private List CreateComponentBindTagHelpers(ICollection CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, bool existingValue, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTimeOffset existingValue, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTimeOffset existingValue, string format, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTime existingValue, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTime existingValue, string format, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, decimal existingValue, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, double existingValue, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, int existingValue, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, long existingValue, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, bool? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTimeOffset? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTimeOffset? existingValue, string format, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTime? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTime? existingValue, string format, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, decimal? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, double? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, int? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, long? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, float? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, float existingValue, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, string existingValue, System.Globalization.CultureInfo culture = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, T existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTimeOffset existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTimeOffset existingValue, string format, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTime existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTime existingValue, string format, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, decimal existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, double existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, int existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, long existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, bool? existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTimeOffset? existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTimeOffset? existingValue, string format, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTime? existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTime? existingValue, string format, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, decimal? existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, double? existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, int? existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, long? existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, float? existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, float existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, string existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, T existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } } public static partial class EventCallbackFactoryEventArgsExtensions { From d4b1225292e9e42c104e40b113302ffa11f31b4c Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Mon, 7 Feb 2022 03:25:46 -0800 Subject: [PATCH 02/33] Support @bind:get and @bind:set --- ...undAttributeDescriptorBuilderExtensions.cs | 10 ++ .../src/ComponentResources.resx | 6 + .../Components/ComponentBindLoweringPass.cs | 97 ++++++++++++--- .../src/Components/ComponentMetadata.cs | 2 + .../ComponentCodeGenerationTestBase.cs | 35 ++++++ .../src/BindTagHelperDescriptorProvider.cs | 112 ++++++++++++++++-- .../RazorBaselineIntegrationTestBase.cs | 2 +- ...ft.AspNetCore.Components.netstandard2.0.cs | 2 +- 8 files changed, 240 insertions(+), 26 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorBuilderExtensions.cs b/src/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorBuilderExtensions.cs index 658811eaa..27556c9bf 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorBuilderExtensions.cs @@ -82,6 +82,16 @@ public static void SetPropertyName(this BoundAttributeParameterDescriptorBuilder builder.Metadata[TagHelperMetadata.Common.PropertyName] = propertyName; } + public static void SetBindAttributeAlternative(this BoundAttributeParameterDescriptorBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.Metadata[ComponentMetadata.Bind.BindAttributeAlternative] = bool.TrueString; + } + public static string GetPropertyName(this BoundAttributeParameterDescriptorBuilder builder) { if (builder == null) diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx b/src/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx index 46084f7c6..3046d987f 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx +++ b/src/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx @@ -144,6 +144,12 @@ Specifies a format to convert the value specified by the '{0}' attribute. The format string can currently only be used with expressions of type <code>DateTime</code>. + + Specifies the expression to use for binding the value to the attribute. + + + Specifies the expression to use for updating the bound value when a new value is available. + Binds the provided expression to an attribute and a change event, based on the naming of the bind attribute. For example: <code>@bind-value="..."</code> and <code>@bind-value:event="onchange"</code> will assign the current value of the expression to the 'value' attribute, and assign a delegate that attempts to set the value to the 'onchange' attribute. diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs index 66c360da0..f68a6c898 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs @@ -74,6 +74,18 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte } } + // Do a pass to look for (@bind:get, @bind:set) pairs as this alternative form might have been used + // to define the binding. + for (var i = 0; i < parameterReferences.Count; i++) + { + var reference = parameterReferences[i]; + var node = (TagHelperDirectiveAttributeParameterIntermediateNode)reference.Node; + if (node.BoundAttributeParameter.Metadata.ContainsKey(ComponentMetadata.Bind.BindAttributeAlternative)) + { + bindEntries[(reference.Parent, node.AttributeNameWithoutParameter)] = new BindEntry(reference); + } + } + // Now collect all the parameterized attributes and store them along with their corresponding @bind or @bind-* attributes. for (var i = 0; i < parameterReferences.Count; i++) { @@ -113,6 +125,15 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte { entry.BindAfterNode = node; } + else if (node.BoundAttributeParameter.Name == "get") + { + // Avoid removing the reference since it will be processed later on. + continue; + } + else if (node.BoundAttributeParameter.Name == "set") + { + entry.BindSetNode = node; + } else { // Unsupported bind attribute parameter. This can only happen if bound attribute descriptor @@ -276,6 +297,7 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE // multiple passes handle 'special' tag helpers. We have another pass that translates // a tag helper node back into 'regular' element when it doesn't have an associated component var node = bindEntry.BindNode; + var getNode = bindEntry.BindGetNode; if (!TryComputeAttributeNames( parent, bindEntry, @@ -295,7 +317,7 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE return new[] { node }; } - var original = GetAttributeContent(node); + var original = GetAttributeContent((IntermediateNode)node ?? getNode); if (string.IsNullOrEmpty(original.Content)) { // This can happen in error cases, the parser will already have flagged this @@ -310,7 +332,7 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE { format = GetAttributeContent(bindEntry.BindFormatNode); } - else if (node.TagHelper?.GetFormat() != null) + else if (node?.TagHelper?.GetFormat() != null) { // We may have a default format if one is associated with the field type. format = new IntermediateToken() @@ -319,6 +341,15 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE Content = "\"" + node.TagHelper.GetFormat() + "\"", }; } + else if (getNode?.TagHelper?.GetFormat() != null) + { + // We may have a default format if one is associated with the field type. + format = new IntermediateToken() + { + Kind = TokenKind.CSharp, + Content = "\"" + getNode.TagHelper.GetFormat() + "\"", + }; + } // Look for a culture. If we find one then we need to pass the culture into the // two nodes we generate. @@ -327,7 +358,16 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE { culture = GetAttributeContent(bindEntry.BindCultureNode); } - else if (node.TagHelper?.IsInvariantCultureBindTagHelper() == true) + else if (node?.TagHelper?.IsInvariantCultureBindTagHelper() == true) + { + // We may have a default invariant culture if one is associated with the field type. + culture = new IntermediateToken() + { + Kind = TokenKind.CSharp, + Content = $"global::{typeof(CultureInfo).FullName}.{nameof(CultureInfo.InvariantCulture)}", + }; + } + else if (getNode?.TagHelper?.IsInvariantCultureBindTagHelper() == true) { // We may have a default invariant culture if one is associated with the field type. culture = new IntermediateToken() @@ -345,6 +385,12 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE after = GetAttributeContent(bindEntry.BindAfterNode); } + IntermediateToken setter = null; + if (bindEntry.BindSetNode != null) + { + setter = GetAttributeContent(bindEntry.BindSetNode); + } + var valueExpressionTokens = new List(); var changeExpressionTokens = new List(); @@ -372,29 +418,32 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE original, format, culture, + setter, after, valueExpressionTokens, changeExpressionTokens); } + var targetNode = (IntermediateNode)node ?? getNode; + if (parent is MarkupElementIntermediateNode) { var valueNode = new HtmlAttributeIntermediateNode() { Annotations = { - [ComponentMetadata.Common.OriginalAttributeName] = node.OriginalAttributeName, + [ComponentMetadata.Common.OriginalAttributeName] = node?.OriginalAttributeName ?? getNode?.OriginalAttributeName, }, AttributeName = valueAttributeName, - Source = node.Source, + Source = targetNode.Source, Prefix = valueAttributeName + "=\"", Suffix = "\"", }; - for (var i = 0; i < node.Diagnostics.Count; i++) + for (var i = 0; i < targetNode.Diagnostics.Count; i++) { - valueNode.Diagnostics.Add(node.Diagnostics[i]); + valueNode.Diagnostics.Add(targetNode.Diagnostics[i]); } valueNode.Children.Add(new CSharpExpressionAttributeValueIntermediateNode()); @@ -407,11 +456,11 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE { Annotations = { - [ComponentMetadata.Common.OriginalAttributeName] = node.OriginalAttributeName, + [ComponentMetadata.Common.OriginalAttributeName] = node?.OriginalAttributeName ?? getNode?.OriginalAttributeName, }, AttributeName = changeAttributeName, AttributeNameExpression = changeAttributeNode, - Source = node.Source, + Source = targetNode.Source, Prefix = changeAttributeName + "=\"", Suffix = "\"", @@ -504,7 +553,7 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE private bool TryParseBindAttribute(BindEntry bindEntry, out string valueAttributeName) { - var attributeName = bindEntry.BindNode.AttributeName; + var attributeName = bindEntry.BindNode?.AttributeName ?? bindEntry.BindGetNode?.AttributeNameWithoutParameter; valueAttributeName = null; if (attributeName == "bind") @@ -547,7 +596,8 @@ private bool TryComputeAttributeNames( // // We expect 1 bind tag helper per-node. var node = bindEntry.BindNode; - var attributeName = node.AttributeName; + var getNode = bindEntry.BindGetNode; + var attributeName = node?.AttributeName ?? getNode?.AttributeNameWithoutParameter; // Even though some of our 'bind' tag helpers specify the attribute names, they // should still satisfy one of the valid syntaxes. @@ -555,15 +605,15 @@ private bool TryComputeAttributeNames( { return false; } - - valueAttributeName = node.TagHelper.GetValueAttributeName() ?? valueAttributeName; + + valueAttributeName = node?.TagHelper.GetValueAttributeName() ?? getNode?.TagHelper.GetValueAttributeName() ?? valueAttributeName; // If there an attribute that specifies the event like @bind:event="oninput", // that should be preferred. Otherwise, use the one from the tag helper. if (bindEntry.BindEventNode == null) { // @bind:event not specified - changeAttributeName = node.TagHelper.GetChangeAttributeName(); + changeAttributeName = node?.TagHelper.GetChangeAttributeName() ?? getNode?.TagHelper.GetChangeAttributeName(); } else if (TryExtractEventNodeStaticText(bindEntry.BindEventNode, out var text)) { @@ -576,7 +626,7 @@ private bool TryComputeAttributeNames( changeAttributeNode = ExtractEventNodeExpression(bindEntry.BindEventNode); } - expressionAttributeName = node.TagHelper.GetExpressionAttributeName(); + expressionAttributeName = node?.TagHelper.GetExpressionAttributeName() ?? getNode?.TagHelper.GetExpressionAttributeName(); // We expect 0-1 components per-node. var componentTagHelper = (parent as ComponentIntermediateNode)?.Component; @@ -692,6 +742,7 @@ private void RewriteNodesForElementEventCallbackBind( IntermediateToken original, IntermediateToken format, IntermediateToken culture, + IntermediateToken setter, IntermediateToken after, List valueExpressionTokens, List changeExpressionTokens) @@ -782,6 +833,15 @@ private void RewriteNodesForElementEventCallbackBind( }); } + if (setter != null) + { + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $", setter: {setter.Content}", + Kind = TokenKind.CSharp + }); + } + if (after != null) { changeExpressionTokens.Add(new IntermediateToken() @@ -849,7 +909,8 @@ private class BindEntry public BindEntry(IntermediateNodeReference bindNodeReference) { BindNodeReference = bindNodeReference; - BindNode = (TagHelperDirectiveAttributeIntermediateNode)bindNodeReference.Node; + BindNode = bindNodeReference.Node as TagHelperDirectiveAttributeIntermediateNode; + BindGetNode = BindNodeReference.Node as TagHelperDirectiveAttributeParameterIntermediateNode; } public IntermediateNodeReference BindNodeReference { get; } @@ -862,6 +923,10 @@ public BindEntry(IntermediateNodeReference bindNodeReference) public TagHelperDirectiveAttributeParameterIntermediateNode BindCultureNode { get; set; } + public TagHelperDirectiveAttributeParameterIntermediateNode BindGetNode { get; set; } + + public TagHelperDirectiveAttributeParameterIntermediateNode BindSetNode { get; set; } + public TagHelperDirectiveAttributeParameterIntermediateNode BindAfterNode { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMetadata.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMetadata.cs index 2688b1d18..0b3eab0ce 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMetadata.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMetadata.cs @@ -49,6 +49,8 @@ public static class Bind public const string TagHelperKind = "Components.Bind"; + public const string BindAttributeAlternative = "Components.Bind.AlternativeNotation"; + public const string FallbackKey = "Components.Bind.Fallback"; public const string TypeAttribute = "Components.Bind.TypeAttribute"; diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index 9b0218e3f..7a3349082 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -1648,6 +1648,41 @@ Task DoSomething() CompileToAssembly(generated); } + [Fact] + public void BindToElement_WithGetSet() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", null, ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + + // Act + var generated = CompileToCSharp(@" +
+
+@code { + public string ParentValue { get; set; } = ""hi""; + + Task ValueChanged(string value) + { + return Task.CompletedTask; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + [Fact] public void BindToElement_WithStringAttribute_WritesAttributes() { diff --git a/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs b/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs index bdb8679a6..23f351b2f 100644 --- a/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs +++ b/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs @@ -109,7 +109,7 @@ public void Execute(TagHelperDescriptorProviderContext context) return; } - // Tag Helper defintion for case #1. This is the most general case. + // Tag Helper definition for case #1. This is the most general case. context.Results.Add(CreateFallbackBindTagHelper()); // For case #2 & #3 we have a whole bunch of attribute entries on BindMethods that we can use @@ -199,13 +199,33 @@ private TagHelperDescriptor CreateFallbackBindTagHelper() parameter.SetPropertyName("Culture"); }); + attribute.BindAttributeParameter(parameter => + { + parameter.Name = "get"; + parameter.TypeName = typeof(Delegate).FullName; + parameter.Documentation = ComponentResources.BindTagHelper_Element_Get_Documentation; + + parameter.SetPropertyName("Get"); + + parameter.SetBindAttributeAlternative(); + }); + + attribute.BindAttributeParameter(parameter => + { + parameter.Name = "set"; + parameter.TypeName = typeof(Delegate).FullName; + parameter.Documentation = ComponentResources.BindTagHelper_Element_Set_Documentation; + + parameter.SetPropertyName("Set"); + }); + attribute.BindAttributeParameter(parameter => { parameter.Name = "after"; parameter.TypeName = typeof(Delegate).FullName; - parameter.Documentation = ComponentResources.BindTagHelper_Element_Culture_Documentation; + parameter.Documentation = ComponentResources.BindTagHelper_Element_After_Documentation; - parameter.SetPropertyName("Culture"); + parameter.SetPropertyName("After"); }); }); @@ -375,6 +395,35 @@ private List CreateElementBindTagHelpers(List + { + rule.TagName = entry.Element; + if (entry.TypeAttribute != null) + { + rule.Attribute(a => + { + a.Name = "type"; + a.NameComparisonMode = RequiredAttributeDescriptor.NameComparisonMode.FullMatch; + a.Value = entry.TypeAttribute; + a.ValueComparisonMode = RequiredAttributeDescriptor.ValueComparisonMode.FullMatch; + }); + } + + rule.Attribute(a => + { + a.Name = $"{attributeName}:get"; + a.NameComparisonMode = RequiredAttributeDescriptor.NameComparisonMode.FullMatch; + a.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + }); + + rule.Attribute(a => + { + a.Name = $"{attributeName}:set"; + a.NameComparisonMode = RequiredAttributeDescriptor.NameComparisonMode.FullMatch; + a.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + }); + }); + builder.BindAttribute(a => { a.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; @@ -418,13 +467,32 @@ private List CreateElementBindTagHelpers(List + { + parameter.Name = "get"; + parameter.TypeName = typeof(Delegate).FullName; + parameter.Documentation = ComponentResources.BindTagHelper_Element_Get_Documentation; + + parameter.SetPropertyName("Get"); + parameter.SetBindAttributeAlternative(); + }); + + a.BindAttributeParameter(parameter => + { + parameter.Name = "set"; + parameter.TypeName = typeof(Delegate).FullName; + parameter.Documentation = ComponentResources.BindTagHelper_Element_Set_Documentation; + + parameter.SetPropertyName("Set"); + }); + a.BindAttributeParameter(parameter => { parameter.Name = "after"; parameter.TypeName = typeof(Delegate).FullName; - parameter.Documentation = ComponentResources.BindTagHelper_Element_Culture_Documentation; + parameter.Documentation = ComponentResources.BindTagHelper_Element_After_Documentation; - parameter.SetPropertyName("Culture"); + parameter.SetPropertyName("After"); }); }); @@ -557,9 +625,37 @@ private List CreateComponentBindTagHelpers(ICollection + { + parameter.Name = "get"; + parameter.TypeName = typeof(Delegate).FullName; + parameter.Documentation = ComponentResources.BindTagHelper_Element_Get_Documentation; + + parameter.SetPropertyName("Get"); + }); + + attribute.BindAttributeParameter(parameter => + { + parameter.Name = "set"; + parameter.TypeName = typeof(Delegate).FullName; + parameter.Documentation = ComponentResources.BindTagHelper_Element_Set_Documentation; + + parameter.SetPropertyName("Set"); + parameter.SetBindAttributeAlternative(); + }); + + attribute.BindAttributeParameter(parameter => + { + parameter.Name = "after"; + parameter.TypeName = typeof(Delegate).FullName; + parameter.Documentation = ComponentResources.BindTagHelper_Element_After_Documentation; + + parameter.SetPropertyName("After"); + }); }); diff --git a/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs b/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs index 76813c060..2848d64ec 100644 --- a/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs +++ b/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs @@ -38,7 +38,7 @@ public static string DirectoryPath #if GENERATE_BASELINES protected bool GenerateBaselines { get; } = true; #else - protected bool GenerateBaselines { get; } = true; + protected bool GenerateBaselines { get; } = false; #endif protected string TestProjectRoot { get; } diff --git a/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs b/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs index 6ddf0cf0f..1e7655ff0 100644 --- a/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs +++ b/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs @@ -166,7 +166,7 @@ public EventCallbackFactory() { } } public static partial class EventCallbackFactoryBinderExtensions { - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, bool existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, bool existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTimeOffset existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTimeOffset existingValue, string format, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTime existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } From 3fe701189ce3a9e7579e67366c5b6d609a871687 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Mon, 7 Feb 2022 05:31:37 -0800 Subject: [PATCH 03/33] Baselines --- .../TestComponent.codegen.cs | 46 +++++++++++++++++++ .../TestComponent.ir.txt | 23 ++++++++++ .../TestComponent.mappings.txt | 19 ++++++++ 3 files changed, 88 insertions(+) create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs new file mode 100644 index 000000000..44339150f --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs @@ -0,0 +1,46 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenElement(0, "div"); + __builder.AddAttribute(1, "myvalue", global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "myevent", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, ParentValue, setter: ValueChanged)); + __builder.SetUpdatesAttributeName("myvalue"); + __builder.CloseElement(); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + Task ValueChanged(string value) + { + return Task.CompletedTask; + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.ir.txt new file mode 100644 index 000000000..d9826ca4e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [63] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlAttribute - (16:0,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (17:0,17 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (16:0,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - ParentValue + IntermediateToken - - CSharp - , setter: ValueChanged + IntermediateToken - - CSharp - ) + CSharpCode - (72:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (72:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n Task ValueChanged(string value)\n {\n return Task.CompletedTask;\n }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt new file mode 100644 index 000000000..6fed14a28 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (72:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + Task ValueChanged(string value) + { + return Task.CompletedTask; + } +| +Generated Location: (1286:32,7 [144] ) +| + public string ParentValue { get; set; } = "hi"; + + Task ValueChanged(string value) + { + return Task.CompletedTask; + } +| + From 9b5bc10f7814e074e83055fa4e13bd5fb82ab885 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Wed, 9 Feb 2022 08:53:28 -0800 Subject: [PATCH 04/33] Align code generation with runtime --- .../Components/ComponentBindLoweringPass.cs | 69 +++++++++++++------ .../TestComponent.codegen.cs | 2 +- .../TestComponent.ir.txt | 5 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.ir.txt | 5 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 43 ++++++++++++ .../TestComponent.ir.txt | 24 +++++++ .../TestComponent.mappings.txt | 29 ++++++++ .../RazorBaselineIntegrationTestBase.cs | 2 +- ...ft.AspNetCore.Components.netstandard2.0.cs | 68 ++++++++++++------ 12 files changed, 201 insertions(+), 52 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.mappings.txt diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs index f68a6c898..2cb46d686 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs @@ -121,7 +121,7 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte { entry.BindCultureNode = node; } - else if(node.BoundAttributeParameter.Name == "after") + else if (node.BoundAttributeParameter.Name == "after") { entry.BindAfterNode = node; } @@ -605,7 +605,7 @@ private bool TryComputeAttributeNames( { return false; } - + valueAttributeName = node?.TagHelper.GetValueAttributeName() ?? getNode?.TagHelper.GetValueAttributeName() ?? valueAttributeName; // If there an attribute that specifies the event like @bind:event="oninput", @@ -805,7 +805,52 @@ private void RewriteNodesForElementEventCallbackBind( // Note that the linemappings here are applied to the value attribute, not the change attribute. changeExpressionTokens.Add(new IntermediateToken() { - Content = $"global::{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateBinderMethod}(this, __value => {original.Content} = __value, ", + Content = $"global::{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateBinderMethod}(this, ", + Kind = TokenKind.CSharp + }); + + switch ((setter, after)) + { + case (null, null): + // no bind:set nor bind:after, use the same code generation as before + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"__value => {original.Content} = __value", + Kind = TokenKind.CSharp + }); + break; + case (not null, null): + // bind:set only + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: {setter.Content}, value: {original.Content})", + Kind = TokenKind.CSharp + }); + break; + case (null, not null): + // bind:after only + var afterToEventCallback = $"global::{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateMethod}(this, callback: {after.Content})"; + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: __value => {{ {original.Content} = __value; return {afterToEventCallback}.InvokeAsync(); }}, value: {original.Content})", + Kind = TokenKind.CSharp + }); + break; + case (not null, not null): + // bind:set and bind:after create the code even though we disallow this combination through a diagnostic + var setToEventCallback = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: {setter.Content}, value: {original.Content})"; + afterToEventCallback = $"global::{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateMethod}(this, callback: {after.Content})"; + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: async __value => {{ await {setToEventCallback}.InvokeAsync(); await {afterToEventCallback}.InvokeAsync(); }}, value: {original.Content})", + Kind = TokenKind.CSharp + }); + break; + } + + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $", ", Kind = TokenKind.CSharp }); @@ -833,24 +878,6 @@ private void RewriteNodesForElementEventCallbackBind( }); } - if (setter != null) - { - changeExpressionTokens.Add(new IntermediateToken() - { - Content = $", setter: {setter.Content}", - Kind = TokenKind.CSharp - }); - } - - if (after != null) - { - changeExpressionTokens.Add(new IntermediateToken() - { - Content = $", after: {after.Content}", - Kind = TokenKind.CSharp - }); - } - changeExpressionTokens.Add(new IntermediateToken() { Content = ")", diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs index 6cd47a5f2..66d2cc15a 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs @@ -23,7 +23,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line hidden #nullable disable )); - __builder.AddAttribute(2, "myevent", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, ParentValue, after: DoSomething)); + __builder.AddAttribute(2, "myevent", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: DoSomething).InvokeAsync(); }, value: ParentValue), ParentValue)); __builder.SetUpdatesAttributeName("myvalue"); __builder.CloseElement(); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt index e8e7b5110..1ec0f41e2 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt @@ -15,9 +15,10 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: DoSomething).InvokeAsync(); }, value: ParentValue) + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue - IntermediateToken - - CSharp - , after: DoSomething IntermediateToken - - CSharp - ) CSharpCode - (69:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (69:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n Task DoSomething()\n {\n return Task.CompletedTask;\n }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt index 1185fa3ad..5a54fb773 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt @@ -7,7 +7,7 @@ Source Location: (69:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) return Task.CompletedTask; } | -Generated Location: (1280:32,7 [131] ) +Generated Location: (1522:32,7 [131] ) | public string ParentValue { get; set; } = "hi"; diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs index 44339150f..00118c7bf 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs @@ -23,7 +23,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line hidden #nullable disable )); - __builder.AddAttribute(2, "myevent", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, ParentValue, setter: ValueChanged)); + __builder.AddAttribute(2, "myevent", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: ValueChanged, value: ParentValue), ParentValue)); __builder.SetUpdatesAttributeName("myvalue"); __builder.CloseElement(); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.ir.txt index d9826ca4e..659c732c9 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.ir.txt @@ -15,9 +15,10 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (16:0,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: ValueChanged, value: ParentValue) + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue - IntermediateToken - - CSharp - , setter: ValueChanged IntermediateToken - - CSharp - ) CSharpCode - (72:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (72:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n Task ValueChanged(string value)\n {\n return Task.CompletedTask;\n }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt index 6fed14a28..09c174a61 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt @@ -7,7 +7,7 @@ Source Location: (72:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) return Task.CompletedTask; } | -Generated Location: (1286:32,7 [144] ) +Generated Location: (1381:32,7 [144] ) | public string ParentValue { get; set; } = "hi"; diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.codegen.cs new file mode 100644 index 000000000..ad0622448 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenElement(0, "div"); + __builder.AddAttribute(1, "myvalue", global::Microsoft.AspNetCore.Components.BindConverter.FormatValue((() => @ParentValue))); + __builder.AddAttribute(2, "myevent", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => (() => @ParentValue) = __value, (() => @ParentValue), setter: (value => ValueChanged(value)), after: (() => AfterValueChanged()))); + __builder.SetUpdatesAttributeName("myvalue"); + __builder.CloseElement(); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + Task ValueChanged(string value) + { + return Task.CompletedTask; + } + + Task AfterValueChanged() + { + return Task.CompletedTask; + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.ir.txt new file mode 100644 index 000000000..3019f524d --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.ir.txt @@ -0,0 +1,24 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [134] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlAttribute - (16:0,16 [21] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + IntermediateToken - - CSharp - (() => @ParentValue) + IntermediateToken - - CSharp - ) + HtmlAttribute - (16:0,16 [21] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => (() => @ParentValue) = __value, + IntermediateToken - - CSharp - (() => @ParentValue) + IntermediateToken - - CSharp - , setter: (value => ValueChanged(value)) + IntermediateToken - - CSharp - , after: (() => AfterValueChanged()) + IntermediateToken - - CSharp - ) + CSharpCode - (143:2,7 [226] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (143:2,7 [226] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n Task ValueChanged(string value)\n {\n return Task.CompletedTask;\n }\n\n Task AfterValueChanged()\n {\n return Task.CompletedTask;\n }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.mappings.txt new file mode 100644 index 000000000..a685a94bf --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.mappings.txt @@ -0,0 +1,29 @@ +Source Location: (143:2,7 [226] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + Task ValueChanged(string value) + { + return Task.CompletedTask; + } + + Task AfterValueChanged() + { + return Task.CompletedTask; + } +| +Generated Location: (1214:24,7 [226] ) +| + public string ParentValue { get; set; } = "hi"; + + Task ValueChanged(string value) + { + return Task.CompletedTask; + } + + Task AfterValueChanged() + { + return Task.CompletedTask; + } +| + diff --git a/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs b/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs index 2848d64ec..76813c060 100644 --- a/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs +++ b/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs @@ -38,7 +38,7 @@ public static string DirectoryPath #if GENERATE_BASELINES protected bool GenerateBaselines { get; } = true; #else - protected bool GenerateBaselines { get; } = false; + protected bool GenerateBaselines { get; } = true; #endif protected string TestProjectRoot { get; } diff --git a/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs b/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs index 1e7655ff0..a62a87ea2 100644 --- a/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs +++ b/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs @@ -141,6 +141,7 @@ public readonly partial struct EventCallback public EventCallback(Microsoft.AspNetCore.Components.IHandleEvent receiver, System.MulticastDelegate @delegate) { throw null; } public bool HasDelegate { get { throw null; } } public System.Threading.Tasks.Task InvokeAsync(object arg) { throw null; } + public System.Threading.Tasks.Task InvokeAsync() { throw null; } } public sealed partial class EventCallbackFactory { @@ -166,28 +167,50 @@ public EventCallbackFactory() { } } public static partial class EventCallbackFactoryBinderExtensions { - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, bool existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTimeOffset existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTimeOffset existingValue, string format, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTime existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTime existingValue, string format, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, decimal existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, double existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, int existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, long existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, bool? existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTimeOffset? existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTimeOffset? existingValue, string format, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTime? existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTime? existingValue, string format, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, decimal? existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, double? existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, int? existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, long? existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, float? existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, float existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, string existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, T existingValue, System.Globalization.CultureInfo culture = null, System.Delegate after = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, bool existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, bool existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTimeOffset existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, System.DateTimeOffset existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTimeOffset existingValue, string format, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, System.DateTimeOffset existingValue, string format, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTime existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, System.DateTime existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTime existingValue, string format, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, System.DateTime existingValue, string format, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, decimal existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, decimal existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, double existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, double existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, int existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, int existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, long existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, long existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, bool? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, bool? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTimeOffset? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, System.DateTimeOffset? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTimeOffset? existingValue, string format, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, System.DateTimeOffset? existingValue, string format, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTime? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, System.DateTime? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, System.DateTime? existingValue, string format, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, System.DateTime? existingValue, string format, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, decimal? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, decimal? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, double? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, double? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, int? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, int? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, long? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, long? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, float? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, float? existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, float existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, float existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, string existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, string existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, System.Action setter, T existingValue, System.Globalization.CultureInfo culture = null) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateBinder(this Microsoft.AspNetCore.Components.EventCallbackFactory factory, object receiver, Microsoft.AspNetCore.Components.EventCallback setter, T existingValue, System.Globalization.CultureInfo culture = null) { throw null; } } public static partial class EventCallbackFactoryEventArgsExtensions { @@ -390,6 +413,7 @@ namespace Microsoft.AspNetCore.Components.CompilerServices public static partial class RuntimeHelpers { public static Microsoft.AspNetCore.Components.EventCallback CreateInferredEventCallback(object receiver, System.Action callback, T value) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateInferredEventCallback(object receiver, Microsoft.AspNetCore.Components.EventCallback callback, T value) { throw null; } public static Microsoft.AspNetCore.Components.EventCallback CreateInferredEventCallback(object receiver, System.Func callback, T value) { throw null; } public static T TypeCheck(T value) { throw null; } } From d2f775b293deebd8874a6f3f7ba6aa6258a2954d Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Thu, 10 Feb 2022 08:44:33 -0800 Subject: [PATCH 05/33] tmp --- .../src/TagHelperDescriptor.cs | 2 +- .../src/TagMatchingRuleDescriptor.cs | 27 +++ .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.ir.txt | 5 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.codegen.cs | 50 ++++ .../TestComponent.ir.txt | 35 +++ .../TestComponent.mappings.txt | 24 ++ .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.codegen.cs | 10 - .../TestComponent.diagnostics.txt | 4 +- .../TestComponent.ir.txt | 10 - .../TestComponent.mappings.txt | 7 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.codegen.cs | 10 - .../TestComponent.diagnostics.txt | 4 +- .../TestComponent.ir.txt | 10 - .../TestComponent.mappings.txt | 7 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.codegen.cs | 11 - .../TestComponent.diagnostics.txt | 4 +- .../TestComponent.ir.txt | 10 - .../TestComponent.mappings.txt | 2 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.codegen.cs | 11 - .../TestComponent.diagnostics.txt | 4 +- .../TestComponent.ir.txt | 10 - .../TestComponent.mappings.txt | 2 +- .../src/BindTagHelperDescriptorProvider.cs | 7 + .../BindTagHelperDescriptorProviderTest.cs | 213 +++++++++++------- 66 files changed, 412 insertions(+), 231 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptor.cs b/src/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptor.cs index 01b37550f..7f1d983c1 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptor.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptor.cs @@ -142,6 +142,6 @@ public ParsedTypeInformation(bool success, StringSegment @namespace, StringSegme private string GetDebuggerDisplay() { - return $"{DisplayName} - {Kind} - {Name} - {AssemblyName}"; + return $"{DisplayName} - {string.Join(" | ", TagMatchingRules.Select(r => r.GetDebuggerDisplay()))}"; } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/TagMatchingRuleDescriptor.cs b/src/Microsoft.AspNetCore.Razor.Language/src/TagMatchingRuleDescriptor.cs index 0ae02029d..15b20f9af 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/TagMatchingRuleDescriptor.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/TagMatchingRuleDescriptor.cs @@ -5,10 +5,12 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; namespace Microsoft.AspNetCore.Razor.Language; +[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] public abstract class TagMatchingRuleDescriptor : IEquatable { private int? _hashCode; @@ -65,4 +67,29 @@ public override int GetHashCode() _hashCode ??= TagMatchingRuleDescriptorComparer.Default.GetHashCode(this); return _hashCode.Value; } + + internal string GetDebuggerDisplay() + { + var tagName = TagName ?? "*"; + tagName += TagStructure == TagStructure.WithoutEndTag ? "/" : ""; + return $"{TagName ?? "*"}[{string.Join(", ", Attributes.Select(a => DescribeAttribute(a)))}]"; + static string DescribeAttribute(RequiredAttributeDescriptor attribute) + { + var name = attribute.Name switch + { + null => "*", + var prefix when attribute.NameComparison == RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch => $"^{prefix}", + var full => $"{full}", + }; + + var value = attribute.Value switch + { + null => "", + var prefix when attribute.ValueComparison == RequiredAttributeDescriptor.ValueComparisonMode.PrefixMatch => $"^={prefix}", + var suffix when attribute.ValueComparison == RequiredAttributeDescriptor.ValueComparisonMode.SuffixMatch => $"$={suffix}", + var full => $"={full}", + }; + return name + value; + } + } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WithCulture/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WithCulture/TestComponent.ir.txt index f07545a68..a53b29f50 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WithCulture/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WithCulture/TestComponent.ir.txt @@ -27,7 +27,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (47:1,18 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - , culture: CultureInfo.InvariantCulture IntermediateToken - - CSharp - ) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.ir.txt index a8f77c4c9..538938c11 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.ir.txt @@ -27,7 +27,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (32:0,32 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => CurrentDate = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - CurrentDate IntermediateToken - - CSharp - , format: "MM/dd" IntermediateToken - - CSharp - ) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.ir.txt index 5b4792da0..110d1d5d1 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.ir.txt @@ -25,7 +25,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (32:0,32 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - ) HtmlContent - (77:0,77 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithCulture/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithCulture/TestComponent.ir.txt index 299fe67b0..40bf9b02a 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithCulture/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithCulture/TestComponent.ir.txt @@ -27,7 +27,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (47:1,18 [12] x:\dir\subdir\Test\TestComponent.cshtml) - anotherevent=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - , culture: CultureInfo.InvariantCulture IntermediateToken - - CSharp - ) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithSuffix_OverridesEvent/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithSuffix_OverridesEvent/TestComponent.ir.txt index 1c39e7c11..ae0d2970b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithSuffix_OverridesEvent/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithSuffix_OverridesEvent/TestComponent.ir.txt @@ -22,7 +22,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (18:0,18 [12] x:\dir\subdir\Test\TestComponent.cshtml) - anotherevent=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - ) HtmlContent - (67:0,67 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.ir.txt index 73f6a4cc7..4c696a2ac 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.ir.txt @@ -22,7 +22,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (18:0,18 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - ) HtmlContent - (34:0,34 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs index 60d7a27f7..30eeb978a 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs @@ -29,7 +29,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line hidden #nullable disable ); - __o = global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, ParentValue, after: DoSomething); + __o = global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: DoSomething).InvokeAsync(); }, value: ParentValue), ParentValue); } #pragma warning restore 1998 #nullable restore diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt index 96f0a98f8..9d49fb7de 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt @@ -24,9 +24,10 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: DoSomething).InvokeAsync(); }, value: ParentValue) + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue - IntermediateToken - - CSharp - , after: DoSomething IntermediateToken - - CSharp - ) HtmlContent - (60:1,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (60:1,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt index 2c2cb9da8..50c3c70f9 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt @@ -12,7 +12,7 @@ Source Location: (69:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) return Task.CompletedTask; } | -Generated Location: (1340:36,7 [131] ) +Generated Location: (1582:36,7 [131] ) | public string ParentValue { get; set; } = "hi"; diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithEventAsExplicitExpression/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithEventAsExplicitExpression/TestComponent.ir.txt index cf68d913a..74f0ee504 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithEventAsExplicitExpression/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithEventAsExplicitExpression/TestComponent.ir.txt @@ -24,7 +24,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (48:1,18 [12] x:\dir\subdir\Test\TestComponent.cshtml) - =" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - ) HtmlContent - (100:1,70 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithEventAsExpression/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithEventAsExpression/TestComponent.ir.txt index fce90b29a..bc2141f61 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithEventAsExpression/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithEventAsExpression/TestComponent.ir.txt @@ -24,7 +24,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (48:1,18 [12] x:\dir\subdir\Test\TestComponent.cshtml) - =" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - ) HtmlContent - (87:1,57 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs new file mode 100644 index 000000000..5c8a431ea --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs @@ -0,0 +1,50 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: ValueChanged, value: ParentValue), ParentValue); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + Task ValueChanged(string value) + { + return Task.CompletedTask; + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.ir.txt new file mode 100644 index 000000000..7851a2d99 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.ir.txt @@ -0,0 +1,35 @@ +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 - global::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 + MarkupElement - (0:0,0 [63] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlContent - (55:0,55 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (55:0,55 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlAttribute - (16:0,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (17:0,17 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (16:0,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: ValueChanged, value: ParentValue) + IntermediateToken - - CSharp - , + IntermediateToken - - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlContent - (63:1,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (63:1,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (72:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (72:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n Task ValueChanged(string value)\n {\n return Task.CompletedTask;\n }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt new file mode 100644 index 000000000..21c6fb556 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt @@ -0,0 +1,24 @@ +Source Location: (17:0,17 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (971:25,17 [11] ) +|ParentValue| + +Source Location: (72:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + Task ValueChanged(string value) + { + return Task.CompletedTask; + } +| +Generated Location: (1441:36,7 [144] ) +| + public string ParentValue { get; set; } = "hi"; + + Task ValueChanged(string value) + { + return Task.CompletedTask; + } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithStringAttribute_WritesAttributes/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithStringAttribute_WritesAttributes/TestComponent.ir.txt index 9a4b310c4..74850727a 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithStringAttribute_WritesAttributes/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithStringAttribute_WritesAttributes/TestComponent.ir.txt @@ -22,7 +22,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (18:0,18 [11] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - ) HtmlContent - (33:0,33 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.ir.txt index 59b0be0a0..16eb2fe23 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.ir.txt @@ -22,7 +22,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - ) HtmlContent - (28:0,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToInputElementWithDefaultCulture/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToInputElementWithDefaultCulture/TestComponent.ir.txt index 06989ddc4..d22873d24 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToInputElementWithDefaultCulture/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToInputElementWithDefaultCulture/TestComponent.ir.txt @@ -28,7 +28,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (63:1,34 [12] x:\dir\subdir\Test\TestComponent.cshtml) - anotherevent=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - ) HtmlContent - (112:1,83 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToInputElementWithDefaultCulture_Override/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToInputElementWithDefaultCulture_Override/TestComponent.ir.txt index 1f698de1c..14dc57fa6 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToInputElementWithDefaultCulture_Override/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToInputElementWithDefaultCulture_Override/TestComponent.ir.txt @@ -30,7 +30,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (63:1,34 [12] x:\dir\subdir\Test\TestComponent.cshtml) - anotherevent=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - , culture: CultureInfo.CurrentCulture IntermediateToken - - CSharp - ) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_CanOverrideEvent/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_CanOverrideEvent/TestComponent.ir.txt index 3e04cf944..a99100add 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_CanOverrideEvent/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_CanOverrideEvent/TestComponent.ir.txt @@ -27,7 +27,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (58:1,14 [12] x:\dir\subdir\Test\TestComponent.cshtml) - oninput=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => CurrentDate = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - CurrentDate IntermediateToken - - CSharp - , format: "MM/dd" IntermediateToken - - CSharp - ) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultCultureAndDefaultFormat_Override/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultCultureAndDefaultFormat_Override/TestComponent.ir.txt index a312a4ebb..6d2dd19f5 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultCultureAndDefaultFormat_Override/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultCultureAndDefaultFormat_Override/TestComponent.ir.txt @@ -29,7 +29,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (28:0,28 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => CurrentDate = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - CurrentDate IntermediateToken - - CSharp - , format: "MM/dd/yyyy" IntermediateToken - - CSharp - , culture: global::System.Globalization.CultureInfo.InvariantCulture diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.ir.txt index 16bc17b8d..69413be93 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.ir.txt @@ -27,7 +27,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (28:0,28 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => CurrentDate = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - CurrentDate IntermediateToken - - CSharp - , format: "MM/dd" IntermediateToken - - CSharp - ) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.ir.txt index b5fc94060..7d10d90af 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.ir.txt @@ -27,7 +27,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (28:0,28 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => CurrentDate = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - CurrentDate IntermediateToken - - CSharp - , format: "MM/dd/yyyy" IntermediateToken - - CSharp - ) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithSuffix/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithSuffix/TestComponent.ir.txt index 16e99042b..d9c9bc1bf 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithSuffix/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithSuffix/TestComponent.ir.txt @@ -27,7 +27,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (64:1,20 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => CurrentDate = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - CurrentDate IntermediateToken - - CSharp - , format: "MM/dd" IntermediateToken - - CSharp - ) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithSuffix_CanOverrideEvent/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithSuffix_CanOverrideEvent/TestComponent.ir.txt index 3937d7999..20f887fea 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithSuffix_CanOverrideEvent/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithSuffix_CanOverrideEvent/TestComponent.ir.txt @@ -24,7 +24,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (20:0,20 [12] x:\dir\subdir\Test\TestComponent.cshtml) - oninput=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => CurrentDate = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - CurrentDate IntermediateToken - - CSharp - , format: "MM/dd" IntermediateToken - - CSharp - ) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithCssScope/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithCssScope/TestComponent.ir.txt index be3ed6136..2be0850e6 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithCssScope/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithCssScope/TestComponent.ir.txt @@ -91,7 +91,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (589:13,30 [10] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => myVariable = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => myVariable = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - myVariable IntermediateToken - - CSharp - ) CSharpCode - (637:13,78 [3] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs index b08d22306..c5666a1be 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs @@ -27,16 +27,6 @@ private void __RazorDirectiveTokenHelpers__() { #pragma warning disable 1998 protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { - __o = global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( -#nullable restore -#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" - text - -#line default -#line hidden -#nullable disable - ); - __o = global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text); } #pragma warning restore 1998 #nullable restore diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt index 1a102a545..4efa2d013 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt @@ -1 +1,3 @@ -x:\dir\subdir\Test\TestComponent.cshtml(3,3): Error RZ10008: The attribute 'Value' is used two or more times for this element. Attributes must be unique (case-insensitive). The attribute 'Value' is used by the '@bind' directive attribute. +x:\dir\subdir\Test\TestComponent.cshtml(3,3): Error RZ9989: The attribute '@bind' was matched by multiple bind attributes. Duplicates: +Microsoft.AspNetCore.Components.Web.BindAttributes +Microsoft.AspNetCore.Components.Web.BindAttributes diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt index 19278677c..f7209a0c1 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt @@ -27,16 +27,6 @@ Document - HtmlAttribute - - Value=" - " HtmlAttributeValue - (79:2,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (79:2,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 17 - HtmlAttribute - (90:2,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " - CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( - LazyIntermediateToken - (91:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - text - IntermediateToken - - CSharp - ) - HtmlAttribute - (90:2,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " - CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::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 HtmlContent - (113:3,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt index 305be5ea9..779bdbe9b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt @@ -3,16 +3,11 @@ Source Location: (1:0,1 [41] x:\dir\subdir\Test\TestComponent.cshtml) Generated Location: (320:12,0 [41] ) |using Microsoft.AspNetCore.Components.Web| -Source Location: (91:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) -|text| -Generated Location: (1158:32,40 [4] ) -|text| - Source Location: (127:4,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) | private string text = "hi"; | -Generated Location: (1495:43,12 [35] ) +Generated Location: (1093:33,12 [35] ) | private string text = "hi"; | diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.ir.txt index 546f5fbed..6e245411e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.ir.txt @@ -36,7 +36,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (85:2,34 [5] x:\dir\subdir\Test\TestComponent.cshtml) - oninput=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => text = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - text IntermediateToken - - CSharp - ) HtmlContent - (148:2,97 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs index b08d22306..c5666a1be 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs @@ -27,16 +27,6 @@ private void __RazorDirectiveTokenHelpers__() { #pragma warning disable 1998 protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { - __o = global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( -#nullable restore -#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" - text - -#line default -#line hidden -#nullable disable - ); - __o = global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text); } #pragma warning restore 1998 #nullable restore diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt index 360fcb1f9..4efa2d013 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt @@ -1 +1,3 @@ -x:\dir\subdir\Test\TestComponent.cshtml(3,3): Error RZ10008: The attribute 'value' is used two or more times for this element. Attributes must be unique (case-insensitive). The attribute 'value' is used by the '@bind' directive attribute. +x:\dir\subdir\Test\TestComponent.cshtml(3,3): Error RZ9989: The attribute '@bind' was matched by multiple bind attributes. Duplicates: +Microsoft.AspNetCore.Components.Web.BindAttributes +Microsoft.AspNetCore.Components.Web.BindAttributes diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt index 7df8a7965..97c942ad3 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt @@ -27,16 +27,6 @@ Document - HtmlAttribute - - value=" - " HtmlAttributeValue - (79:2,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (79:2,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 17 - HtmlAttribute - (90:2,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " - CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( - LazyIntermediateToken - (91:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - text - IntermediateToken - - CSharp - ) - HtmlAttribute - (90:2,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " - CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::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 HtmlContent - (113:3,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt index 305be5ea9..779bdbe9b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt @@ -3,16 +3,11 @@ Source Location: (1:0,1 [41] x:\dir\subdir\Test\TestComponent.cshtml) Generated Location: (320:12,0 [41] ) |using Microsoft.AspNetCore.Components.Web| -Source Location: (91:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) -|text| -Generated Location: (1158:32,40 [4] ) -|text| - Source Location: (127:4,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) | private string text = "hi"; | -Generated Location: (1495:43,12 [35] ) +Generated Location: (1093:33,12 [35] ) | private string text = "hi"; | diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WithCulture/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WithCulture/TestComponent.ir.txt index 111837dcd..b818ce55c 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WithCulture/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WithCulture/TestComponent.ir.txt @@ -18,7 +18,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (47:1,18 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - , culture: CultureInfo.InvariantCulture IntermediateToken - - CSharp - ) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.ir.txt index be8083f1c..197aca5a6 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.ir.txt @@ -20,7 +20,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (32:0,32 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => CurrentDate = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - CurrentDate IntermediateToken - - CSharp - , format: "MM/dd" IntermediateToken - - CSharp - ) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.ir.txt index 22d37a669..6c7f7c991 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.ir.txt @@ -18,7 +18,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (32:0,32 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - ) CSharpCode - (86:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithCulture/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithCulture/TestComponent.ir.txt index be36f3585..37d707216 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithCulture/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithCulture/TestComponent.ir.txt @@ -18,7 +18,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (47:1,18 [12] x:\dir\subdir\Test\TestComponent.cshtml) - anotherevent=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - , culture: CultureInfo.InvariantCulture IntermediateToken - - CSharp - ) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithSuffix_OverridesEvent/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithSuffix_OverridesEvent/TestComponent.ir.txt index 001abce27..42fee1611 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithSuffix_OverridesEvent/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithSuffix_OverridesEvent/TestComponent.ir.txt @@ -15,7 +15,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (18:0,18 [12] x:\dir\subdir\Test\TestComponent.cshtml) - anotherevent=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - ) CSharpCode - (76:1,7 [55] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.ir.txt index 1c3afc063..954d3ac59 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.ir.txt @@ -15,7 +15,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (18:0,18 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - ) CSharpCode - (43:1,7 [55] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithEventAsExplicitExpression/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithEventAsExplicitExpression/TestComponent.ir.txt index 0bd40bac9..353cebbf0 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithEventAsExplicitExpression/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithEventAsExplicitExpression/TestComponent.ir.txt @@ -17,7 +17,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (48:1,18 [12] x:\dir\subdir\Test\TestComponent.cshtml) - =" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - ) CSharpCode - (109:2,7 [55] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithEventAsExpression/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithEventAsExpression/TestComponent.ir.txt index ca784e306..5780379e3 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithEventAsExpression/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithEventAsExpression/TestComponent.ir.txt @@ -17,7 +17,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (48:1,18 [12] x:\dir\subdir\Test\TestComponent.cshtml) - =" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - ) CSharpCode - (96:2,7 [55] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithStringAttribute_WritesAttributes/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithStringAttribute_WritesAttributes/TestComponent.ir.txt index 4944584b0..42d4cb08d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithStringAttribute_WritesAttributes/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithStringAttribute_WritesAttributes/TestComponent.ir.txt @@ -15,7 +15,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (18:0,18 [11] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - ) CSharpCode - (42:1,7 [55] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.ir.txt index 74751a555..8a1debd24 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.ir.txt @@ -15,7 +15,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - ) CSharpCode - (37:1,7 [55] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToInputElementWithDefaultCulture/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToInputElementWithDefaultCulture/TestComponent.ir.txt index 332f5d09e..4a6580537 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToInputElementWithDefaultCulture/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToInputElementWithDefaultCulture/TestComponent.ir.txt @@ -19,7 +19,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (63:1,34 [12] x:\dir\subdir\Test\TestComponent.cshtml) - anotherevent=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - ) CSharpCode - (121:2,7 [44] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToInputElementWithDefaultCulture_Override/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToInputElementWithDefaultCulture_Override/TestComponent.ir.txt index 41209c989..b72916186 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToInputElementWithDefaultCulture_Override/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToInputElementWithDefaultCulture_Override/TestComponent.ir.txt @@ -21,7 +21,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (63:1,34 [12] x:\dir\subdir\Test\TestComponent.cshtml) - anotherevent=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - ParentValue IntermediateToken - - CSharp - , culture: CultureInfo.CurrentCulture IntermediateToken - - CSharp - ) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_CanOverrideEvent/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_CanOverrideEvent/TestComponent.ir.txt index 493504cd6..c59f56929 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_CanOverrideEvent/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_CanOverrideEvent/TestComponent.ir.txt @@ -18,7 +18,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (58:1,14 [12] x:\dir\subdir\Test\TestComponent.cshtml) - oninput=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => CurrentDate = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - CurrentDate IntermediateToken - - CSharp - , format: "MM/dd" IntermediateToken - - CSharp - ) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultCultureAndDefaultFormat_Override/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultCultureAndDefaultFormat_Override/TestComponent.ir.txt index 138ab3f68..b4c6f36b6 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultCultureAndDefaultFormat_Override/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultCultureAndDefaultFormat_Override/TestComponent.ir.txt @@ -22,7 +22,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (28:0,28 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => CurrentDate = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - CurrentDate IntermediateToken - - CSharp - , format: "MM/dd/yyyy" IntermediateToken - - CSharp - , culture: global::System.Globalization.CultureInfo.InvariantCulture diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.ir.txt index da99767ad..efe33321d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.ir.txt @@ -20,7 +20,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (28:0,28 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => CurrentDate = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - CurrentDate IntermediateToken - - CSharp - , format: "MM/dd" IntermediateToken - - CSharp - ) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.ir.txt index 2f237e863..455668136 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.ir.txt @@ -20,7 +20,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (28:0,28 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => CurrentDate = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - CurrentDate IntermediateToken - - CSharp - , format: "MM/dd/yyyy" IntermediateToken - - CSharp - ) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithSuffix/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithSuffix/TestComponent.ir.txt index 3326d1424..d25cdd864 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithSuffix/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithSuffix/TestComponent.ir.txt @@ -18,7 +18,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (64:1,20 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => CurrentDate = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - CurrentDate IntermediateToken - - CSharp - , format: "MM/dd" IntermediateToken - - CSharp - ) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithSuffix_CanOverrideEvent/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithSuffix_CanOverrideEvent/TestComponent.ir.txt index 882c91a05..1017f5af1 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithSuffix_CanOverrideEvent/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithSuffix_CanOverrideEvent/TestComponent.ir.txt @@ -17,7 +17,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (20:0,20 [12] x:\dir\subdir\Test\TestComponent.cshtml) - oninput=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => CurrentDate = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - CurrentDate IntermediateToken - - CSharp - , format: "MM/dd" IntermediateToken - - CSharp - ) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithCssScope/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithCssScope/TestComponent.ir.txt index dc6f5578b..e6eda3f6c 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithCssScope/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithCssScope/TestComponent.ir.txt @@ -49,7 +49,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (589:13,30 [10] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => myVariable = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => myVariable = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - myVariable IntermediateToken - - CSharp - ) HtmlAttribute - - TestCssScope - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs index e7c2b8c81..3c7dd7e81 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs @@ -24,17 +24,6 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. __builder.OpenElement(1, "input"); __builder.AddAttribute(2, "type", "text"); __builder.AddAttribute(3, "Value", "17"); - __builder.AddAttribute(4, "value", global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( -#nullable restore -#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" - text - -#line default -#line hidden -#nullable disable - )); - __builder.AddAttribute(5, "onchange", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text)); - __builder.SetUpdatesAttributeName("value"); __builder.CloseElement(); __builder.CloseElement(); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt index 1a102a545..4efa2d013 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt @@ -1 +1,3 @@ -x:\dir\subdir\Test\TestComponent.cshtml(3,3): Error RZ10008: The attribute 'Value' is used two or more times for this element. Attributes must be unique (case-insensitive). The attribute 'Value' is used by the '@bind' directive attribute. +x:\dir\subdir\Test\TestComponent.cshtml(3,3): Error RZ9989: The attribute '@bind' was matched by multiple bind attributes. Duplicates: +Microsoft.AspNetCore.Components.Web.BindAttributes +Microsoft.AspNetCore.Components.Web.BindAttributes diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt index d664170d7..0cea35260 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt @@ -16,15 +16,5 @@ Document - HtmlAttribute - - Value=" - " HtmlAttributeValue - (79:2,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (79:2,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 17 - HtmlAttribute - (90:2,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " - CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( - LazyIntermediateToken - (91:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - text - IntermediateToken - - CSharp - ) - HtmlAttribute - (90:2,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " - CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, - IntermediateToken - - CSharp - text - IntermediateToken - - CSharp - ) 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/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt index 3d997cbf5..8794264ff 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt +++ b/src/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: (1630:43,12 [35] ) +Generated Location: (1108:32,12 [35] ) | private string text = "hi"; | diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.ir.txt index 7600964cf..7894be672 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.ir.txt @@ -25,7 +25,9 @@ Document - IntermediateToken - - CSharp - ) HtmlAttribute - (85:2,34 [5] x:\dir\subdir\Test\TestComponent.cshtml) - oninput=" - " CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => text = __value + IntermediateToken - - CSharp - , IntermediateToken - - CSharp - text IntermediateToken - - CSharp - ) CSharpCode - (170:4,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs index a9cfd2559..51f37af88 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs @@ -24,17 +24,6 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. __builder.OpenElement(1, "input"); __builder.AddAttribute(2, "type", "text"); __builder.AddAttribute(3, "value", "17"); - __builder.AddAttribute(4, "value", global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( -#nullable restore -#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" - text - -#line default -#line hidden -#nullable disable - )); - __builder.AddAttribute(5, "onchange", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text)); - __builder.SetUpdatesAttributeName("value"); __builder.CloseElement(); __builder.CloseElement(); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt index 360fcb1f9..4efa2d013 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt @@ -1 +1,3 @@ -x:\dir\subdir\Test\TestComponent.cshtml(3,3): Error RZ10008: The attribute 'value' is used two or more times for this element. Attributes must be unique (case-insensitive). The attribute 'value' is used by the '@bind' directive attribute. +x:\dir\subdir\Test\TestComponent.cshtml(3,3): Error RZ9989: The attribute '@bind' was matched by multiple bind attributes. Duplicates: +Microsoft.AspNetCore.Components.Web.BindAttributes +Microsoft.AspNetCore.Components.Web.BindAttributes diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt index fd41b818e..9dc9c1d03 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt @@ -16,15 +16,5 @@ Document - HtmlAttribute - - value=" - " HtmlAttributeValue - (79:2,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (79:2,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 17 - HtmlAttribute - (90:2,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " - CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( - LazyIntermediateToken - (91:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - text - IntermediateToken - - CSharp - ) - HtmlAttribute - (90:2,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " - CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, - IntermediateToken - - CSharp - text - IntermediateToken - - CSharp - ) 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/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt index 3d997cbf5..8794264ff 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt +++ b/src/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: (1630:43,12 [35] ) +Generated Location: (1108:32,12 [35] ) | private string text = "hi"; | diff --git a/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs b/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs index 23f351b2f..2e6c4633f 100644 --- a/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs +++ b/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Globalization; using System.Linq; using Microsoft.AspNetCore.Razor.Language; @@ -671,6 +672,7 @@ private List CreateComponentBindTagHelpers(ICollection a.Name.StartsWith("@bind", StringComparison.Ordinal)); - - // Invariants - Assert.Empty(attribute.Diagnostics); - Assert.False(attribute.HasErrors); - Assert.Equal(ComponentMetadata.Bind.TagHelperKind, attribute.Kind); - Assert.False(attribute.IsDefaultKind()); - Assert.False(attribute.HasIndexer); - Assert.Null(attribute.IndexerNamePrefix); - Assert.Null(attribute.IndexerTypeName); - Assert.False(attribute.IsIndexerBooleanProperty); - Assert.False(attribute.IsIndexerStringProperty); - - Assert.Equal( - "Binds the provided expression to the 'myprop' attribute and a change event " + - "delegate to the 'myevent' attribute.", - attribute.Documentation); - - Assert.Equal("@bind", attribute.Name); - Assert.Equal("Bind", attribute.GetPropertyName()); - Assert.Equal("object Test.BindAttributes.Bind", attribute.DisplayName); - - // Defined from the property type - Assert.Equal("System.Object", attribute.TypeName); - Assert.False(attribute.IsStringProperty); - Assert.False(attribute.IsBooleanProperty); - Assert.False(attribute.IsEnum); - - var parameter = Assert.Single(attribute.BoundAttributeParameters, a => a.Name.Equals("format")); - - // Invariants - Assert.Empty(parameter.Diagnostics); - Assert.False(parameter.HasErrors); - Assert.Equal(ComponentMetadata.Bind.TagHelperKind, parameter.Kind); - Assert.False(parameter.IsDefaultKind()); - - Assert.Equal( - "Specifies a format to convert the value specified by the '@bind' attribute. " + - "The format string can currently only be used with expressions of type DateTime.", - parameter.Documentation); - - Assert.Equal("format", parameter.Name); - Assert.Equal("Format_myprop", parameter.GetPropertyName()); - Assert.Equal(":format", parameter.DisplayName); - - // Defined from the property type - Assert.Equal("System.String", parameter.TypeName); - Assert.True(parameter.IsStringProperty); - Assert.False(parameter.IsBooleanProperty); - Assert.False(parameter.IsEnum); - - parameter = Assert.Single(attribute.BoundAttributeParameters, a => a.Name.Equals("culture")); - - // Invariants - Assert.Empty(parameter.Diagnostics); - Assert.False(parameter.HasErrors); - Assert.Equal(ComponentMetadata.Bind.TagHelperKind, parameter.Kind); - Assert.False(parameter.IsDefaultKind()); - - Assert.Equal( - "Specifies the culture to use for conversions.", - parameter.Documentation); - - Assert.Equal("culture", parameter.Name); - Assert.Equal("Culture", parameter.GetPropertyName()); - Assert.Equal(":culture", parameter.DisplayName); + Assert.Collection(bind.TagMatchingRules.OrderBy(o => o.Attributes.Count), + rule => + { + Assert.Empty(rule.Diagnostics); + Assert.False(rule.HasErrors); + Assert.Null(rule.ParentTag); + Assert.Equal("div", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + var requiredAttribute = Assert.Single(rule.Attributes); + Assert.Empty(requiredAttribute.Diagnostics); + Assert.Equal("@bind", requiredAttribute.DisplayName); + Assert.Equal("@bind", requiredAttribute.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, requiredAttribute.NameComparison); + Assert.Null(requiredAttribute.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.None, requiredAttribute.ValueComparison); + + var attribute = Assert.Single(bind.BoundAttributes, a => a.Name.StartsWith("@bind", StringComparison.Ordinal)); + AssertAttribute(attribute); + }, + rule => + { + Assert.Empty(rule.Diagnostics); + Assert.False(rule.HasErrors); + Assert.Null(rule.ParentTag); + Assert.Equal("div", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + Assert.Collection(rule.Attributes.OrderBy(a => a.Name), + requiredAttribute => + { + Assert.Empty(requiredAttribute.Diagnostics); + Assert.Equal("@bind:get", requiredAttribute.DisplayName); + Assert.Equal("@bind:get", requiredAttribute.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, requiredAttribute.NameComparison); + Assert.Null(requiredAttribute.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.None, requiredAttribute.ValueComparison); + + var attribute = Assert.Single(bind.BoundAttributes, a => a.Name.StartsWith("@bind", StringComparison.Ordinal)); + AssertAttribute(attribute); + }, + requiredAttribute => + { + Assert.Empty(requiredAttribute.Diagnostics); + Assert.Equal("@bind:set", requiredAttribute.DisplayName); + Assert.Equal("@bind:set", requiredAttribute.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, requiredAttribute.NameComparison); + Assert.Null(requiredAttribute.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.None, requiredAttribute.ValueComparison); + + var attribute = Assert.Single(bind.BoundAttributes, a => a.Name.StartsWith("@bind", StringComparison.Ordinal)); + AssertAttribute(attribute); + }); + }); - // Defined from the property type - Assert.Equal("System.Globalization.CultureInfo", parameter.TypeName); - Assert.False(parameter.IsStringProperty); - Assert.False(parameter.IsBooleanProperty); - Assert.False(parameter.IsEnum); + static void AssertAttribute(BoundAttributeDescriptor attribute) + { + // Invariants + Assert.Empty(attribute.Diagnostics); + Assert.False(attribute.HasErrors); + Assert.Equal(ComponentMetadata.Bind.TagHelperKind, attribute.Kind); + Assert.False(attribute.IsDefaultKind()); + Assert.False(attribute.HasIndexer); + Assert.Null(attribute.IndexerNamePrefix); + Assert.Null(attribute.IndexerTypeName); + Assert.False(attribute.IsIndexerBooleanProperty); + Assert.False(attribute.IsIndexerStringProperty); + + Assert.Equal( + "Binds the provided expression to the 'myprop' attribute and a change event " + + "delegate to the 'myevent' attribute.", + attribute.Documentation); + + Assert.Equal("@bind", attribute.Name); + Assert.Equal("Bind", attribute.GetPropertyName()); + Assert.Equal("object Test.BindAttributes.Bind", attribute.DisplayName); + + // Defined from the property type + Assert.Equal("System.Object", attribute.TypeName); + Assert.False(attribute.IsStringProperty); + Assert.False(attribute.IsBooleanProperty); + Assert.False(attribute.IsEnum); + + var parameter = Assert.Single(attribute.BoundAttributeParameters, a => a.Name.Equals("format")); + + // Invariants + Assert.Empty(parameter.Diagnostics); + Assert.False(parameter.HasErrors); + Assert.Equal(ComponentMetadata.Bind.TagHelperKind, parameter.Kind); + Assert.False(parameter.IsDefaultKind()); + + Assert.Equal( + "Specifies a format to convert the value specified by the '@bind' attribute. " + + "The format string can currently only be used with expressions of type DateTime.", + parameter.Documentation); + + Assert.Equal("format", parameter.Name); + Assert.Equal("Format_myprop", parameter.GetPropertyName()); + Assert.Equal(":format", parameter.DisplayName); + + // Defined from the property type + Assert.Equal("System.String", parameter.TypeName); + Assert.True(parameter.IsStringProperty); + Assert.False(parameter.IsBooleanProperty); + Assert.False(parameter.IsEnum); + + parameter = Assert.Single(attribute.BoundAttributeParameters, a => a.Name.Equals("culture")); + + // Invariants + Assert.Empty(parameter.Diagnostics); + Assert.False(parameter.HasErrors); + Assert.Equal(ComponentMetadata.Bind.TagHelperKind, parameter.Kind); + Assert.False(parameter.IsDefaultKind()); + + Assert.Equal( + "Specifies the culture to use for conversions.", + parameter.Documentation); + + Assert.Equal("culture", parameter.Name); + Assert.Equal("Culture", parameter.GetPropertyName()); + Assert.Equal(":culture", parameter.DisplayName); + + // Defined from the property type + Assert.Equal("System.Globalization.CultureInfo", parameter.TypeName); + Assert.False(parameter.IsStringProperty); + Assert.False(parameter.IsBooleanProperty); + Assert.False(parameter.IsEnum); + } } [Fact] From 61d078e0f5345c6eec4d1207008ee0691bbb4cec Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Thu, 10 Feb 2022 10:13:20 -0800 Subject: [PATCH 06/33] Fix tests and update baselines --- .../TagHelperDescriptorExtensions.cs | 2 +- .../TestComponent.codegen.cs | 10 + .../TestComponent.diagnostics.txt | 4 +- .../TestComponent.ir.txt | 12 ++ .../TestComponent.mappings.txt | 7 +- .../TestComponent.codegen.cs | 10 + .../TestComponent.diagnostics.txt | 4 +- .../TestComponent.ir.txt | 12 ++ .../TestComponent.mappings.txt | 7 +- .../TestComponent.codegen.cs | 11 + .../TestComponent.diagnostics.txt | 4 +- .../TestComponent.ir.txt | 12 ++ .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 11 + .../TestComponent.diagnostics.txt | 4 +- .../TestComponent.ir.txt | 12 ++ .../TestComponent.mappings.txt | 2 +- .../BindTagHelperDescriptorProviderTest.cs | 192 ++++++++++++++---- .../RazorBaselineIntegrationTestBase.cs | 2 +- 19 files changed, 260 insertions(+), 60 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/TagHelperDescriptorExtensions.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/TagHelperDescriptorExtensions.cs index 885d38395..13935efb8 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/TagHelperDescriptorExtensions.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/TagHelperDescriptorExtensions.cs @@ -44,7 +44,7 @@ public static bool IsInputElementBindTagHelper(this TagHelperDescriptor tagHelpe { return tagHelper.IsBindTagHelper() && - tagHelper.TagMatchingRules.Count == 1 && + tagHelper.TagMatchingRules.Count == 2 && string.Equals("input", tagHelper.TagMatchingRules[0].TagName); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs index c5666a1be..b08d22306 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs @@ -27,6 +27,16 @@ private void __RazorDirectiveTokenHelpers__() { #pragma warning disable 1998 protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { + __o = global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + text + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text); } #pragma warning restore 1998 #nullable restore diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt index 4efa2d013..1a102a545 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt @@ -1,3 +1 @@ -x:\dir\subdir\Test\TestComponent.cshtml(3,3): Error RZ9989: The attribute '@bind' was matched by multiple bind attributes. Duplicates: -Microsoft.AspNetCore.Components.Web.BindAttributes -Microsoft.AspNetCore.Components.Web.BindAttributes +x:\dir\subdir\Test\TestComponent.cshtml(3,3): Error RZ10008: The attribute 'Value' is used two or more times for this element. Attributes must be unique (case-insensitive). The attribute 'Value' is used by the '@bind' directive attribute. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt index f7209a0c1..27ad7d517 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt @@ -27,6 +27,18 @@ Document - HtmlAttribute - - Value=" - " HtmlAttributeValue - (79:2,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (79:2,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 17 + HtmlAttribute - (90:2,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (91:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - text + IntermediateToken - - CSharp - ) + HtmlAttribute - (90:2,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => text = __value + IntermediateToken - - CSharp - , + 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 HtmlContent - (113:3,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt index 779bdbe9b..305be5ea9 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt @@ -3,11 +3,16 @@ Source Location: (1:0,1 [41] x:\dir\subdir\Test\TestComponent.cshtml) Generated Location: (320:12,0 [41] ) |using Microsoft.AspNetCore.Components.Web| +Source Location: (91:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|text| +Generated Location: (1158:32,40 [4] ) +|text| + Source Location: (127:4,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) | private string text = "hi"; | -Generated Location: (1093:33,12 [35] ) +Generated Location: (1495:43,12 [35] ) | private string text = "hi"; | diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs index c5666a1be..b08d22306 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs @@ -27,6 +27,16 @@ private void __RazorDirectiveTokenHelpers__() { #pragma warning disable 1998 protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { + __o = global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + text + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text); } #pragma warning restore 1998 #nullable restore diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt index 4efa2d013..360fcb1f9 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt @@ -1,3 +1 @@ -x:\dir\subdir\Test\TestComponent.cshtml(3,3): Error RZ9989: The attribute '@bind' was matched by multiple bind attributes. Duplicates: -Microsoft.AspNetCore.Components.Web.BindAttributes -Microsoft.AspNetCore.Components.Web.BindAttributes +x:\dir\subdir\Test\TestComponent.cshtml(3,3): Error RZ10008: The attribute 'value' is used two or more times for this element. Attributes must be unique (case-insensitive). The attribute 'value' is used by the '@bind' directive attribute. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt index 97c942ad3..dd7af8971 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt @@ -27,6 +27,18 @@ Document - HtmlAttribute - - value=" - " HtmlAttributeValue - (79:2,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (79:2,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 17 + HtmlAttribute - (90:2,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (91:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - text + IntermediateToken - - CSharp - ) + HtmlAttribute - (90:2,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => text = __value + IntermediateToken - - CSharp - , + 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 HtmlContent - (113:3,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt index 779bdbe9b..305be5ea9 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt @@ -3,11 +3,16 @@ Source Location: (1:0,1 [41] x:\dir\subdir\Test\TestComponent.cshtml) Generated Location: (320:12,0 [41] ) |using Microsoft.AspNetCore.Components.Web| +Source Location: (91:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|text| +Generated Location: (1158:32,40 [4] ) +|text| + Source Location: (127:4,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) | private string text = "hi"; | -Generated Location: (1093:33,12 [35] ) +Generated Location: (1495:43,12 [35] ) | private string text = "hi"; | diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs index 3c7dd7e81..e7c2b8c81 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs @@ -24,6 +24,17 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. __builder.OpenElement(1, "input"); __builder.AddAttribute(2, "type", "text"); __builder.AddAttribute(3, "Value", "17"); + __builder.AddAttribute(4, "value", global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + text + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(5, "onchange", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text)); + __builder.SetUpdatesAttributeName("value"); __builder.CloseElement(); __builder.CloseElement(); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt index 4efa2d013..1a102a545 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt @@ -1,3 +1 @@ -x:\dir\subdir\Test\TestComponent.cshtml(3,3): Error RZ9989: The attribute '@bind' was matched by multiple bind attributes. Duplicates: -Microsoft.AspNetCore.Components.Web.BindAttributes -Microsoft.AspNetCore.Components.Web.BindAttributes +x:\dir\subdir\Test\TestComponent.cshtml(3,3): Error RZ10008: The attribute 'Value' is used two or more times for this element. Attributes must be unique (case-insensitive). The attribute 'Value' is used by the '@bind' directive attribute. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt index 0cea35260..758de1b45 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt @@ -16,5 +16,17 @@ Document - HtmlAttribute - - Value=" - " HtmlAttributeValue - (79:2,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (79:2,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 17 + HtmlAttribute - (90:2,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (91:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - text + IntermediateToken - - CSharp - ) + HtmlAttribute - (90:2,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => text = __value + IntermediateToken - - CSharp - , + IntermediateToken - - CSharp - text + IntermediateToken - - CSharp - ) 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/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt index 8794264ff..3d997cbf5 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt +++ b/src/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: (1108:32,12 [35] ) +Generated Location: (1630:43,12 [35] ) | private string text = "hi"; | diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs index 51f37af88..a9cfd2559 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs @@ -24,6 +24,17 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. __builder.OpenElement(1, "input"); __builder.AddAttribute(2, "type", "text"); __builder.AddAttribute(3, "value", "17"); + __builder.AddAttribute(4, "value", global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + text + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(5, "onchange", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text)); + __builder.SetUpdatesAttributeName("value"); __builder.CloseElement(); __builder.CloseElement(); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt index 4efa2d013..360fcb1f9 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt @@ -1,3 +1 @@ -x:\dir\subdir\Test\TestComponent.cshtml(3,3): Error RZ9989: The attribute '@bind' was matched by multiple bind attributes. Duplicates: -Microsoft.AspNetCore.Components.Web.BindAttributes -Microsoft.AspNetCore.Components.Web.BindAttributes +x:\dir\subdir\Test\TestComponent.cshtml(3,3): Error RZ10008: The attribute 'value' is used two or more times for this element. Attributes must be unique (case-insensitive). The attribute 'value' is used by the '@bind' directive attribute. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt index 9dc9c1d03..4a4e36c47 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt @@ -16,5 +16,17 @@ Document - HtmlAttribute - - value=" - " HtmlAttributeValue - (79:2,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (79:2,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 17 + HtmlAttribute - (90:2,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (91:2,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - text + IntermediateToken - - CSharp - ) + HtmlAttribute - (90:2,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => text = __value + IntermediateToken - - CSharp - , + IntermediateToken - - CSharp - text + IntermediateToken - - CSharp - ) 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/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt index 8794264ff..3d997cbf5 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt +++ b/src/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: (1108:32,12 [35] ) +Generated Location: (1630:43,12 [35] ) | private string text = "hi"; | diff --git a/src/Microsoft.CodeAnalysis.Razor/test/BindTagHelperDescriptorProviderTest.cs b/src/Microsoft.CodeAnalysis.Razor/test/BindTagHelperDescriptorProviderTest.cs index 55733c2c4..cd92559cc 100644 --- a/src/Microsoft.CodeAnalysis.Razor/test/BindTagHelperDescriptorProviderTest.cs +++ b/src/Microsoft.CodeAnalysis.Razor/test/BindTagHelperDescriptorProviderTest.cs @@ -540,13 +540,43 @@ public class BindAttributes Assert.False(bind.IsInputElementBindTagHelper()); Assert.False(bind.IsInputElementFallbackBindTagHelper()); - var rule = Assert.Single(bind.TagMatchingRules); - Assert.Equal("div", rule.TagName); - Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + Assert.Collection(bind.TagMatchingRules.OrderBy(o => o.Attributes.Count), + rule => + { + Assert.Equal("div", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); - var requiredAttribute = Assert.Single(rule.Attributes); - Assert.Equal("@bind-myprop", requiredAttribute.DisplayName); - Assert.Equal("@bind-myprop", requiredAttribute.Name); + var requiredAttribute = Assert.Single(rule.Attributes); + Assert.Equal("@bind-myprop", requiredAttribute.DisplayName); + Assert.Equal("@bind-myprop", requiredAttribute.Name); + + var attribute = Assert.Single(bind.BoundAttributes, a => a.Name.StartsWith("@bind", StringComparison.Ordinal)); + Assert.Equal("@bind-myprop", attribute.Name); + Assert.Equal("Bind_myprop", attribute.GetPropertyName()); + Assert.Equal("object Test.BindAttributes.Bind_myprop", attribute.DisplayName); + + attribute = Assert.Single(bind.BoundAttributes, a => a.Name.StartsWith("format", StringComparison.Ordinal)); + Assert.Equal("format-myprop", attribute.Name); + Assert.Equal("Format_myprop", attribute.GetPropertyName()); + Assert.Equal("string Test.BindAttributes.Format_myprop", attribute.DisplayName); + }, + rule => + { + Assert.Equal("div", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + Assert.Collection(rule.Attributes.OrderBy(a => a.Name), + requiredAttribute => + { + Assert.Equal("@bind-myprop:get", requiredAttribute.DisplayName); + Assert.Equal("@bind-myprop:get", requiredAttribute.Name); + }, + requiredAttribute => + { + Assert.Equal("@bind-myprop:set", requiredAttribute.DisplayName); + Assert.Equal("@bind-myprop:set", requiredAttribute.Name); + }); + }); var attribute = Assert.Single(bind.BoundAttributes, a => a.Name.StartsWith("@bind", StringComparison.Ordinal)); Assert.Equal("@bind-myprop", attribute.Name); @@ -596,13 +626,33 @@ public class BindAttributes Assert.True(bind.IsInputElementBindTagHelper()); Assert.True(bind.IsInputElementFallbackBindTagHelper()); - var rule = Assert.Single(bind.TagMatchingRules); - Assert.Equal("input", rule.TagName); - Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + Assert.Collection(bind.TagMatchingRules.OrderBy(r => r.Attributes.Count), + rule => + { + Assert.Equal("input", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); - var requiredAttribute = Assert.Single(rule.Attributes); - Assert.Equal("@bind", requiredAttribute.DisplayName); - Assert.Equal("@bind", requiredAttribute.Name); + var requiredAttribute = Assert.Single(rule.Attributes); + Assert.Equal("@bind", requiredAttribute.DisplayName); + Assert.Equal("@bind", requiredAttribute.Name); + }, + rule => + { + Assert.Equal("input", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + Assert.Collection(rule.Attributes.OrderBy(o => o.Name), + requiredAttribute => + { + Assert.Equal("@bind:get", requiredAttribute.DisplayName); + Assert.Equal("@bind:get", requiredAttribute.Name); + }, + requiredAttribute => + { + Assert.Equal("@bind:set", requiredAttribute.DisplayName); + Assert.Equal("@bind:set", requiredAttribute.Name); + }); + }); var attribute = Assert.Single(bind.BoundAttributes, a => a.Name.StartsWith("@bind", StringComparison.Ordinal)); Assert.Equal("@bind", attribute.Name); @@ -652,24 +702,53 @@ public class BindAttributes Assert.True(bind.IsInputElementBindTagHelper()); Assert.False(bind.IsInputElementFallbackBindTagHelper()); - var rule = Assert.Single(bind.TagMatchingRules); - Assert.Equal("input", rule.TagName); - Assert.Equal(TagStructure.Unspecified, rule.TagStructure); - - Assert.Collection( - rule.Attributes, - a => + Assert.Collection(bind.TagMatchingRules.OrderBy(r => r.Attributes.Count), + rule => { - Assert.Equal("type", a.DisplayName); - Assert.Equal("type", a.Name); - Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, a.NameComparison); - Assert.Equal("checkbox", a.Value); - Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch, a.ValueComparison); + Assert.Equal("input", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + Assert.Collection( + rule.Attributes, + a => + { + Assert.Equal("type", a.DisplayName); + Assert.Equal("type", a.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, a.NameComparison); + Assert.Equal("checkbox", a.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch, a.ValueComparison); + }, + a => + { + Assert.Equal("@bind", a.DisplayName); + Assert.Equal("@bind", a.Name); + }); }, - a => + rule => { - Assert.Equal("@bind", a.DisplayName); - Assert.Equal("@bind", a.Name); + Assert.Equal("input", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + Assert.Collection( + rule.Attributes, + a => + { + Assert.Equal("type", a.DisplayName); + Assert.Equal("type", a.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, a.NameComparison); + Assert.Equal("checkbox", a.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch, a.ValueComparison); + }, + a => + { + Assert.Equal("@bind:get", a.DisplayName); + Assert.Equal("@bind:get", a.Name); + }, + a => + { + Assert.Equal("@bind:set", a.DisplayName); + Assert.Equal("@bind:set", a.Name); + }); }); var attribute = Assert.Single(bind.BoundAttributes, a => a.Name.StartsWith("@bind", StringComparison.Ordinal)); @@ -722,24 +801,53 @@ public class BindAttributes Assert.False(bind.IsInvariantCultureBindTagHelper()); Assert.Null(bind.GetFormat()); - var rule = Assert.Single(bind.TagMatchingRules); - Assert.Equal("input", rule.TagName); - Assert.Equal(TagStructure.Unspecified, rule.TagStructure); - - Assert.Collection( - rule.Attributes, - a => + Assert.Collection(bind.TagMatchingRules.OrderBy(o => o.Attributes.Count), + rule => { - Assert.Equal("type", a.DisplayName); - Assert.Equal("type", a.Name); - Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, a.NameComparison); - Assert.Equal("checkbox", a.Value); - Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch, a.ValueComparison); + Assert.Equal("input", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + Assert.Collection( + rule.Attributes, + a => + { + Assert.Equal("type", a.DisplayName); + Assert.Equal("type", a.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, a.NameComparison); + Assert.Equal("checkbox", a.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch, a.ValueComparison); + }, + a => + { + Assert.Equal("@bind-somevalue", a.DisplayName); + Assert.Equal("@bind-somevalue", a.Name); + }); }, - a => + rule => { - Assert.Equal("@bind-somevalue", a.DisplayName); - Assert.Equal("@bind-somevalue", a.Name); + Assert.Equal("input", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + Assert.Collection( + rule.Attributes, + a => + { + Assert.Equal("type", a.DisplayName); + Assert.Equal("type", a.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, a.NameComparison); + Assert.Equal("checkbox", a.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch, a.ValueComparison); + }, + a => + { + Assert.Equal("@bind-somevalue:get", a.DisplayName); + Assert.Equal("@bind-somevalue:get", a.Name); + }, + a => + { + Assert.Equal("@bind-somevalue:set", a.DisplayName); + Assert.Equal("@bind-somevalue:set", a.Name); + }); }); var attribute = Assert.Single(bind.BoundAttributes, a => a.Name.StartsWith("@bind", StringComparison.Ordinal)); diff --git a/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs b/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs index 76813c060..2848d64ec 100644 --- a/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs +++ b/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs @@ -38,7 +38,7 @@ public static string DirectoryPath #if GENERATE_BASELINES protected bool GenerateBaselines { get; } = true; #else - protected bool GenerateBaselines { get; } = true; + protected bool GenerateBaselines { get; } = false; #endif protected string TestProjectRoot { get; } From addd707b4046a3eb13bc777eb0fd85a3849469f4 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Thu, 10 Feb 2022 14:14:18 -0800 Subject: [PATCH 07/33] Code generation for component bindings --- .../Components/ComponentBindLoweringPass.cs | 119 +++++++++++++++++- .../src/Components/ComponentMetadata.cs | 2 + .../src/Components/ComponentsApi.cs | 2 + ...elperBoundAttributeDescriptorExtensions.cs | 8 ++ .../ComponentCodeGenerationTestBase.cs | 35 ++++++ .../src/BindTagHelperDescriptorProvider.cs | 17 +++ .../ComponentTagHelperDescriptorProvider.cs | 57 ++++++++- 7 files changed, 233 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs index 2cb46d686..704b903b1 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs @@ -402,6 +402,9 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE { RewriteNodesForComponentDelegateBind( original, + setter, + after, + changeAttribute.IsAwaitableDelegateResult(), valueExpressionTokens, changeExpressionTokens); } @@ -409,6 +412,8 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE { RewriteNodesForComponentEventCallbackBind( original, + setter, + after, valueExpressionTokens, changeExpressionTokens); } @@ -702,6 +707,9 @@ static CSharpExpressionIntermediateNode ExtractEventNodeExpression(TagHelperDire private void RewriteNodesForComponentDelegateBind( IntermediateToken original, + IntermediateToken setter, + IntermediateToken after, + bool awaitable, List valueExpressionTokens, List changeExpressionTokens) { @@ -710,19 +718,74 @@ private void RewriteNodesForComponentDelegateBind( // - create a delegate to handle changes valueExpressionTokens.Add(original); + // Since we have to support setters and after, there are a few things to consider: + // If we are provided with a setter, we can cast it to the change attribute type, like + // (Action)(value => { }) or (Func)(value => Task.CompletedTask) and use that. + // If we are provided with an 'after' we'll need to generate a callback where we invoke the 'after' expression + // after the regular setter. In this case, unfortunately we can't rely on EventCallbackFactory to normalize things + // since the target attribute type is a delegate and not an EventCallback. + // For that reason, we at least captured whether the attribute has an awaitable result, and we'll use that information + // during code generation. + // For example, with a synchronous 'after' method we will generate code as follows: + // (TargetAttributeType)(__value => = __value; RuntimeHelpers.InferSynchronousDelegate(after)(); } + // With an asynchronous 'after' method we will generate code as follows: + // (TargetAttributeType)(__value => = __value; return RuntimeHelpers.InferAsynchronousDelegate(after)(); } + // Now rewrite the content of the change-handler node. Since it's a component attribute, // we don't use the 'BindMethods' wrapper. We expect component attributes to always 'match' on type. // // __value => = __value - changeExpressionTokens.Add(new IntermediateToken() + + switch (setter, after, awaitable) { - Content = $"__value => {original.Content} = __value", - Kind = TokenKind.CSharp, - }); + case (null, null, _): + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"__value => {original.Content} = __value", + Kind = TokenKind.CSharp, + }); + break; + case (not null, null, _): + changeExpressionTokens.Add(new IntermediateToken() + { + // Figure out the type check + Content = setter.Content, + Kind = TokenKind.CSharp, + }); + break; + case (null, not null, false): + var syncAfterExpression = $"{ComponentsApi.RuntimeHelpers.InvokeSynchronousDelegate}({after})()"; + changeExpressionTokens.Add(new IntermediateToken() + { + // Figure out the type check + Content = $"__value => {original.Content} = __value; {syncAfterExpression}", + Kind = TokenKind.CSharp, + }); + break; + case (null, not null, true): + var asyncAfterExpression = $"{ComponentsApi.RuntimeHelpers.InvokeAsynchronousDelegate}({after})()"; + changeExpressionTokens.Add(new IntermediateToken() + { + // Figure out the type check + Content = $"async __value => {original.Content} = __value; await {asyncAfterExpression}", + Kind = TokenKind.CSharp, + }); + break; + default: + // Treat this as the original case, since we don't support bind:set and bind:after simultaneously, we will produce an error. + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"__value => {original.Content} = __value", + Kind = TokenKind.CSharp, + }); + break; + } } private void RewriteNodesForComponentEventCallbackBind( IntermediateToken original, + IntermediateToken setter, + IntermediateToken after, List valueExpressionTokens, List changeExpressionTokens) { @@ -731,9 +794,55 @@ private void RewriteNodesForComponentEventCallbackBind( // - create a delegate to handle changes valueExpressionTokens.Add(original); + // This is largely the same as the one for elements as we can invoke CreateInferredCallback all the way to victory + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, ", + Kind = TokenKind.CSharp + }); + + switch ((setter, after)) + { + case (null, null): + // no bind:set nor bind:after, use the same code generation as before + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"__value => {original.Content} = __value", + Kind = TokenKind.CSharp + }); + break; + case (not null, null): + // bind:set only + changeExpressionTokens.Add(new IntermediateToken() + { + Content = setter.Content, + Kind = TokenKind.CSharp + }); + break; + case (null, not null): + // bind:after only + var afterToEventCallback = $"global::{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateMethod}(this, callback: {after.Content})"; + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: __value => {{ {original.Content} = __value; return {afterToEventCallback}.InvokeAsync(); }}, value: {original.Content})", + Kind = TokenKind.CSharp + }); + break; + case (not null, not null): + // bind:set and bind:after create the code even though we disallow this combination through a diagnostic + var setToEventCallback = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: {setter.Content}, value: {original.Content})"; + afterToEventCallback = $"global::{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateMethod}(this, callback: {after.Content})"; + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: async __value => {{ await {setToEventCallback}.InvokeAsync(); await {afterToEventCallback}.InvokeAsync(); }}, value: {original.Content})", + Kind = TokenKind.CSharp + }); + break; + } + changeExpressionTokens.Add(new IntermediateToken() { - Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, __value => {original.Content} = __value, {original.Content})", + Content = $", {original.Content})", Kind = TokenKind.CSharp }); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMetadata.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMetadata.cs index 0b3eab0ce..8c3595f87 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMetadata.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMetadata.cs @@ -93,6 +93,8 @@ public static class Component public const string DelegateSignatureKey = "Components.DelegateSignature"; + public const string DelegateAwaitableResultKey = "Components.DelegateAwaitableResult"; + public const string EventCallbackKey = "Components.EventCallback"; public const string WeaklyTypedKey = "Components.IsWeaklyTyped"; diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentsApi.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentsApi.cs index 001d81210..ba139148b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentsApi.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentsApi.cs @@ -109,6 +109,8 @@ public static class RuntimeHelpers { public const string TypeCheck = "global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck"; public const string CreateInferredEventCallback = "global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback"; + public const string InvokeSynchronousDelegate = "global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate"; + public const string InvokeAsynchronousDelegate = "global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate"; } public static class RouteAttribute diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/TagHelperBoundAttributeDescriptorExtensions.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/TagHelperBoundAttributeDescriptorExtensions.cs index 54fefbbb7..c67345627 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/TagHelperBoundAttributeDescriptorExtensions.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/TagHelperBoundAttributeDescriptorExtensions.cs @@ -17,6 +17,14 @@ public static bool IsDelegateProperty(this BoundAttributeDescriptor attribute) string.Equals(value, bool.TrueString); } + public static bool IsAwaitableDelegateResult(this BoundAttributeDescriptor attribute) + { + var key = ComponentMetadata.Component.DelegateAwaitableResultKey; + return + attribute.Metadata.TryGetValue(key, out var value) && + string.Equals(value, bool.TrueString); + } + /// /// Gets a value indicating whether the attribute is of type EventCallback or /// EventCallback{T} diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index 7a3349082..707fa5235 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -1683,6 +1683,41 @@ Task ValueChanged(string value) CompileToAssembly(generated); } + [Fact] + public void BindToComponent_SpecifiesValue_WithGetSet() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public Func ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; + + public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + [Fact] public void BindToElement_WithStringAttribute_WritesAttributes() { diff --git a/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs b/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs index 2e6c4633f..efb0256c7 100644 --- a/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs +++ b/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs @@ -613,6 +613,23 @@ private List CreateComponentBindTagHelpers(ICollection + { + rule.TagName = tagHelper.TagMatchingRules.Single().TagName; + rule.Attribute(attribute => + { + attribute.Name = "@bind-" + valueAttribute.Name + ":get"; + attribute.NameComparisonMode = RequiredAttributeDescriptor.NameComparisonMode.FullMatch; + attribute.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + }); + rule.Attribute(attribute => + { + attribute.Name = "@bind-" + valueAttribute.Name + ":set"; + attribute.NameComparisonMode = RequiredAttributeDescriptor.NameComparisonMode.FullMatch; + attribute.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; + }); + }); + builder.BindAttribute(attribute => { attribute.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString; diff --git a/src/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs b/src/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs index 221c181fc..23e6dbd22 100644 --- a/src/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs +++ b/src/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs @@ -10,6 +10,7 @@ using System.Linq; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Components; +using System.Runtime.CompilerServices; namespace Microsoft.CodeAnalysis.Razor; @@ -160,7 +161,7 @@ private TagHelperDescriptorBuilder CreateDescriptorBuilder(ComponentSymbols symb continue; } - CreateProperty(builder, property.property, property.kind); + CreateProperty(builder, property.property, property.kind, symbols); } if (builder.BoundAttributes.Any(a => a.IsParameterizedChildContentProperty()) && @@ -175,7 +176,7 @@ private TagHelperDescriptorBuilder CreateDescriptorBuilder(ComponentSymbols symb return builder; } - private void CreateProperty(TagHelperDescriptorBuilder builder, IPropertySymbol property, PropertyKind kind) + private void CreateProperty(TagHelperDescriptorBuilder builder, IPropertySymbol property, PropertyKind kind, ComponentSymbols symbols) { builder.BindAttribute(pb => { @@ -202,6 +203,7 @@ private void CreateProperty(TagHelperDescriptorBuilder builder, IPropertySymbol if (kind == PropertyKind.Delegate) { pb.Metadata.Add(ComponentMetadata.Component.DelegateSignatureKey, bool.TrueString); + pb.Metadata.Add(ComponentMetadata.Component.DelegateAwaitableResultKey, IsAwaitable(property)); } if (HasTypeParameter(property.Type)) @@ -263,6 +265,57 @@ bool HasTypeParameter(ITypeSymbol type) } } + private static string IsAwaitable(IPropertySymbol prop) + { + var methodSymbol = ((INamedTypeSymbol)prop.Type).DelegateInvokeMethod; + if (methodSymbol.ReturnsVoid) + { + return bool.FalseString; + } + else + { + var members = methodSymbol.ReturnType.GetMembers(); + for (var i = 0; i < members.Length; i++) + { + var candidate = members[i]; + if (candidate is not IMethodSymbol method || !string.Equals(candidate.Name, "GetAwaiter", StringComparison.Ordinal)) + { + continue; + } + if (!VerifyGetAwaiter(method)) + { + continue; + } + + return bool.TrueString; + } + return methodSymbol.IsAsync ? bool.TrueString : bool.FalseString; + + static bool VerifyGetAwaiter(IMethodSymbol getAwaiter) + { + var returnType = getAwaiter.ReturnType; + if (returnType == null) + { + return false; + } + + if (!returnType.GetMembers().OfType().Any(p => p.Name == WellKnownMemberNames.IsCompleted && p.Type.SpecialType == SpecialType.System_Boolean && p.GetMethod != null)) + { + return false; + } + + var methods = returnType.GetMembers().OfType(); + + if (!methods.Any(x => x.Name == WellKnownMemberNames.OnCompleted && x.ReturnsVoid && x.Parameters.Length == 1 && x.Parameters.First().Type.TypeKind == TypeKind.Delegate)) + { + return false; + } + + return methods.Any(m => m.Name == WellKnownMemberNames.GetResult && !m.Parameters.Any()); + } + } + } + private void CreateTypeParameterProperty(TagHelperDescriptorBuilder builder, ITypeParameterSymbol typeParameter, bool cascade) { builder.BindAttribute(pb => From f88b09c113759efd4c504d9d4af05b661e26f8c4 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Fri, 11 Feb 2022 02:43:24 -0800 Subject: [PATCH 08/33] Fixes --- .../Components/ComponentBindLoweringPass.cs | 172 ++++++++++++------ .../ComponentAttributeIntermediateNode.cs | 6 +- .../src/Intermediate/IntermediateNode.cs | 4 +- .../Intermediate/IntermediateNodeReference.cs | 9 +- .../ComponentCodeGenerationTestBase.cs | 2 +- .../src/BindTagHelperDescriptorProvider.cs | 2 +- .../IntegrationTests/IntegrationTestBase.cs | 2 +- .../RazorBaselineIntegrationTestBase.cs | 2 +- ...ft.AspNetCore.Components.netstandard2.0.cs | 3 + 9 files changed, 134 insertions(+), 68 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs index 704b903b1..efa4fab5e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs @@ -55,7 +55,7 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte // The dict key is a tuple of (parent, attributeName) to differentiate attributes with the same name in two different elements. // We don't have to worry about duplicate bound attributes in the same element // like, , because IR lowering takes care of that. - var bindEntries = new Dictionary<(IntermediateNode, string), BindEntry>(); + var bindEntries = new Dictionary<(IntermediateNode, IntermediateNode), BindEntry>(); for (var i = 0; i < references.Count; i++) { var reference = references[i]; @@ -70,7 +70,7 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte if (node.TagHelper.IsBindTagHelper()) { - bindEntries[(parent, node.AttributeName)] = new BindEntry(reference); + bindEntries[(parent, node)] = new BindEntry(reference); } } @@ -82,7 +82,7 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte var node = (TagHelperDirectiveAttributeParameterIntermediateNode)reference.Node; if (node.BoundAttributeParameter.Metadata.ContainsKey(ComponentMetadata.Bind.BindAttributeAlternative)) { - bindEntries[(reference.Parent, node.AttributeNameWithoutParameter)] = new BindEntry(reference); + bindEntries[(reference.Parent, node)] = new BindEntry(reference); } } @@ -96,13 +96,14 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte if (!parent.Children.Contains(node)) { // This node was removed as a duplicate, skip it. + bindEntries.Remove((parent, node)); continue; } if (node.TagHelper.IsBindTagHelper()) { // Check if this tag contains a corresponding non-parameterized bind node. - if (!bindEntries.TryGetValue((parent, node.AttributeNameWithoutParameter), out var entry)) + if (!bindEntries.TryGetValue((parent, node), out var entry)) { // There is no corresponding bind node. Add a diagnostic and move on. parameterReference.Parent.Diagnostics.Add(ComponentDiagnosticFactory.CreateBindAttributeParameter_MissingBind( @@ -483,18 +484,37 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE } else { - var valueNode = new ComponentAttributeIntermediateNode(node) + ComponentAttributeIntermediateNode valueNode; + if (node != null) { - Annotations = - { - [ComponentMetadata.Common.OriginalAttributeName] = node.OriginalAttributeName, - }, - AttributeName = valueAttributeName, - BoundAttribute = valueAttribute, // Might be null if it doesn't match a component attribute - PropertyName = valueAttribute?.GetPropertyName(), - TagHelper = valueAttribute == null ? null : node.TagHelper, - TypeName = valueAttribute?.IsWeaklyTyped() == false ? valueAttribute.TypeName : null, - }; + valueNode = new ComponentAttributeIntermediateNode(node) + { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = node.OriginalAttributeName, + }, + AttributeName = valueAttributeName, + BoundAttribute = valueAttribute, // Might be null if it doesn't match a component attribute + PropertyName = valueAttribute?.GetPropertyName(), + TagHelper = valueAttribute == null ? null : node.TagHelper, + TypeName = valueAttribute?.IsWeaklyTyped() == false ? valueAttribute.TypeName : null, + }; + } + else + { + valueNode = new ComponentAttributeIntermediateNode(getNode) + { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = getNode.OriginalAttributeName, + }, + AttributeName = valueAttributeName, + BoundAttribute = valueAttribute, // Might be null if it doesn't match a component attribute + PropertyName = valueAttribute?.GetPropertyName(), + TagHelper = valueAttribute == null ? null : getNode.TagHelper, + TypeName = valueAttribute?.IsWeaklyTyped() == false ? valueAttribute.TypeName : null, + }; + } valueNode.Children.Clear(); valueNode.Children.Add(new CSharpExpressionIntermediateNode()); @@ -503,18 +523,37 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE valueNode.Children[0].Children.Add(valueExpressionTokens[i]); } - var changeNode = new ComponentAttributeIntermediateNode(node) + ComponentAttributeIntermediateNode changeNode = null; + if (node != null) { - Annotations = + changeNode = new ComponentAttributeIntermediateNode(node) + { + Annotations = { - [ComponentMetadata.Common.OriginalAttributeName] = node.OriginalAttributeName, + [ComponentMetadata.Common.OriginalAttributeName] = node.OriginalAttributeName, }, - AttributeName = changeAttributeName, - BoundAttribute = changeAttribute, // Might be null if it doesn't match a component attribute - PropertyName = changeAttribute?.GetPropertyName(), - TagHelper = changeAttribute == null ? null : node.TagHelper, - TypeName = changeAttribute?.IsWeaklyTyped() == false ? changeAttribute.TypeName : null, - }; + AttributeName = changeAttributeName, + BoundAttribute = changeAttribute, // Might be null if it doesn't match a component attribute + PropertyName = changeAttribute?.GetPropertyName(), + TagHelper = changeAttribute == null ? null : node.TagHelper, + TypeName = changeAttribute?.IsWeaklyTyped() == false ? changeAttribute.TypeName : null, + }; + } + else + { + changeNode = new ComponentAttributeIntermediateNode(getNode) + { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = getNode.OriginalAttributeName, + }, + AttributeName = changeAttributeName, + BoundAttribute = changeAttribute, // Might be null if it doesn't match a component attribute + PropertyName = changeAttribute?.GetPropertyName(), + TagHelper = changeAttribute == null ? null : getNode.TagHelper, + TypeName = changeAttribute?.IsWeaklyTyped() == false ? changeAttribute.TypeName : null, + }; + } changeNode.Children.Clear(); changeNode.Children.Add(new CSharpExpressionIntermediateNode()); @@ -528,19 +567,36 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE ComponentAttributeIntermediateNode expressionNode = null; if (expressionAttribute != null) { - expressionNode = new ComponentAttributeIntermediateNode(node) + if(node != null) { - Annotations = - { - [ComponentMetadata.Common.OriginalAttributeName] = node.OriginalAttributeName, - }, - AttributeName = expressionAttributeName, - BoundAttribute = expressionAttribute, - PropertyName = expressionAttribute.GetPropertyName(), - TagHelper = node.TagHelper, - TypeName = expressionAttribute.IsWeaklyTyped() ? null : expressionAttribute.TypeName, - }; - + expressionNode = new ComponentAttributeIntermediateNode(node) + { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = node.OriginalAttributeName, + }, + AttributeName = expressionAttributeName, + BoundAttribute = expressionAttribute, + PropertyName = expressionAttribute.GetPropertyName(), + TagHelper = node.TagHelper, + TypeName = expressionAttribute.IsWeaklyTyped() ? null : expressionAttribute.TypeName, + }; + } + else + { + expressionNode = new ComponentAttributeIntermediateNode(getNode) + { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = getNode.OriginalAttributeName, + }, + AttributeName = expressionAttributeName, + BoundAttribute = expressionAttribute, + PropertyName = expressionAttribute.GetPropertyName(), + TagHelper = getNode.TagHelper, + TypeName = expressionAttribute.IsWeaklyTyped() ? null : expressionAttribute.TypeName, + }; + } expressionNode.Children.Clear(); expressionNode.Children.Add(new CSharpExpressionIntermediateNode()); expressionNode.Children[0].Children.Add(new IntermediateToken() @@ -739,29 +795,29 @@ private void RewriteNodesForComponentDelegateBind( switch (setter, after, awaitable) { case (null, null, _): - changeExpressionTokens.Add(new IntermediateToken() - { - Content = $"__value => {original.Content} = __value", - Kind = TokenKind.CSharp, - }); - break; + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"__value => {original.Content} = __value", + Kind = TokenKind.CSharp, + }); + break; case (not null, null, _): - changeExpressionTokens.Add(new IntermediateToken() - { - // Figure out the type check - Content = setter.Content, - Kind = TokenKind.CSharp, - }); - break; + changeExpressionTokens.Add(new IntermediateToken() + { + // Figure out the type check + Content = setter.Content, + Kind = TokenKind.CSharp, + }); + break; case (null, not null, false): - var syncAfterExpression = $"{ComponentsApi.RuntimeHelpers.InvokeSynchronousDelegate}({after})()"; - changeExpressionTokens.Add(new IntermediateToken() - { - // Figure out the type check - Content = $"__value => {original.Content} = __value; {syncAfterExpression}", - Kind = TokenKind.CSharp, - }); - break; + var syncAfterExpression = $"{ComponentsApi.RuntimeHelpers.InvokeSynchronousDelegate}({after})()"; + changeExpressionTokens.Add(new IntermediateToken() + { + // Figure out the type check + Content = $"__value => {original.Content} = __value; {syncAfterExpression}", + Kind = TokenKind.CSharp, + }); + break; case (null, not null, true): var asyncAfterExpression = $"{ComponentsApi.RuntimeHelpers.InvokeAsynchronousDelegate}({after})()"; changeExpressionTokens.Add(new IntermediateToken() @@ -770,7 +826,7 @@ private void RewriteNodesForComponentDelegateBind( Content = $"async __value => {original.Content} = __value; await {asyncAfterExpression}", Kind = TokenKind.CSharp, }); - break; + break; default: // Treat this as the original case, since we don't support bind:set and bind:after simultaneously, we will produce an error. changeExpressionTokens.Add(new IntermediateToken() diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ComponentAttributeIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ComponentAttributeIntermediateNode.cs index 7eb2fc598..8042285e6 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ComponentAttributeIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ComponentAttributeIntermediateNode.cs @@ -97,13 +97,13 @@ public ComponentAttributeIntermediateNode(TagHelperDirectiveAttributeParameterIn throw new ArgumentNullException(nameof(directiveAttributeParameterNode)); } - AttributeName = directiveAttributeParameterNode.AttributeNameWithoutParameter; + AttributeName = directiveAttributeParameterNode.AttributeName; AttributeStructure = directiveAttributeParameterNode.AttributeStructure; BoundAttribute = directiveAttributeParameterNode.BoundAttribute; - PropertyName = directiveAttributeParameterNode.BoundAttributeParameter.GetPropertyName(); + PropertyName = directiveAttributeParameterNode.BoundAttribute.GetPropertyName(); Source = directiveAttributeParameterNode.Source; TagHelper = directiveAttributeParameterNode.TagHelper; - TypeName = directiveAttributeParameterNode.BoundAttributeParameter.TypeName; + TypeName = directiveAttributeParameterNode.BoundAttribute.IsWeaklyTyped() ? null : directiveAttributeParameterNode.BoundAttribute.TypeName; for (var i = 0; i < directiveAttributeParameterNode.Children.Count; i++) { diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/IntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/IntermediateNode.cs index 7d2c57d01..45542ecf9 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/IntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/IntermediateNode.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #nullable disable @@ -58,7 +58,7 @@ private string Tree } } - private string DebuggerToString() + internal string DebuggerToString() { var formatter = new DebuggerDisplayFormatter(); formatter.FormatNode(this); diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/IntermediateNodeReference.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/IntermediateNodeReference.cs index 390d14941..0760212fa 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/IntermediateNodeReference.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/IntermediateNodeReference.cs @@ -1,13 +1,15 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #nullable disable using System; using System.Collections.Generic; +using System.Diagnostics; namespace Microsoft.AspNetCore.Razor.Language.Intermediate; +[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] public struct IntermediateNodeReference { public IntermediateNodeReference(IntermediateNode parent, IntermediateNode node) @@ -207,4 +209,9 @@ public IntermediateNodeReference Replace(IntermediateNode node) Parent.Children[index] = node; return new IntermediateNodeReference(Parent, node); } + + private string GetDebuggerDisplay() + { + return $"ref: {Parent.DebuggerToString()} - {Node.DebuggerToString()}"; + } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index 707fa5235..d1f728aec 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -1684,7 +1684,7 @@ Task ValueChanged(string value) } [Fact] - public void BindToComponent_SpecifiesValue_WithGetSet() + public void BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate() { // Arrange AdditionalSyntaxTrees.Add(Parse(@" diff --git a/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs b/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs index efb0256c7..f22b102e0 100644 --- a/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs +++ b/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs @@ -654,6 +654,7 @@ private List CreateComponentBindTagHelpers(ICollection @@ -663,7 +664,6 @@ private List CreateComponentBindTagHelpers(ICollection diff --git a/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs b/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs index 9f04fd8ed..09d956290 100644 --- a/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs +++ b/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs @@ -99,7 +99,7 @@ protected IntegrationTestBase(bool? generateBaselines = null, string? projectDir #if GENERATE_BASELINES protected bool GenerateBaselines { get; } = true; #else - protected bool GenerateBaselines { get; } = false; + protected bool GenerateBaselines { get; } = true; #endif protected string TestProjectRoot { get; } diff --git a/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs b/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs index 2848d64ec..76813c060 100644 --- a/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs +++ b/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs @@ -38,7 +38,7 @@ public static string DirectoryPath #if GENERATE_BASELINES protected bool GenerateBaselines { get; } = true; #else - protected bool GenerateBaselines { get; } = false; + protected bool GenerateBaselines { get; } = true; #endif protected string TestProjectRoot { get; } diff --git a/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs b/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs index a62a87ea2..e72550793 100644 --- a/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs +++ b/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs @@ -412,7 +412,10 @@ namespace Microsoft.AspNetCore.Components.CompilerServices { public static partial class RuntimeHelpers { + public static System.Action CreateInferredEventCallback(System.Action callback, T value) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateInferredEventCallback(object receiver, System.Action callback, T value) { throw null; } + public static Microsoft.AspNetCore.Components.EventCallback CreateInferredEventCallback(object receiver, Microsoft.AspNetCore.Components.EventCallback callback, T value) { throw null; } public static Microsoft.AspNetCore.Components.EventCallback CreateInferredEventCallback(object receiver, System.Func callback, T value) { throw null; } public static T TypeCheck(T value) { throw null; } From beefae620077895327c2bf219fa61a108757f997 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Fri, 11 Feb 2022 02:52:17 -0800 Subject: [PATCH 09/33] Make component bindings work --- .../Components/ComponentBindLoweringPass.cs | 17 +++++--- .../TestComponent.codegen.cs | 42 +++++++++++++++++++ .../TestComponent.ir.txt | 18 ++++++++ .../TestComponent.mappings.txt | 13 ++++++ 4 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs index efa4fab5e..6b9a9a248 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs @@ -55,7 +55,7 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte // The dict key is a tuple of (parent, attributeName) to differentiate attributes with the same name in two different elements. // We don't have to worry about duplicate bound attributes in the same element // like, , because IR lowering takes care of that. - var bindEntries = new Dictionary<(IntermediateNode, IntermediateNode), BindEntry>(); + var bindEntries = new Dictionary<(IntermediateNode, string), BindEntry>(); for (var i = 0; i < references.Count; i++) { var reference = references[i]; @@ -70,7 +70,7 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte if (node.TagHelper.IsBindTagHelper()) { - bindEntries[(parent, node)] = new BindEntry(reference); + bindEntries[(parent, node.AttributeName)] = new BindEntry(reference); } } @@ -79,10 +79,18 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte for (var i = 0; i < parameterReferences.Count; i++) { var reference = parameterReferences[i]; + var parent = reference.Parent; var node = (TagHelperDirectiveAttributeParameterIntermediateNode)reference.Node; + + if (!parent.Children.Contains(node)) + { + // This node was removed as a duplicate, skip it. + continue; + } + if (node.BoundAttributeParameter.Metadata.ContainsKey(ComponentMetadata.Bind.BindAttributeAlternative)) { - bindEntries[(reference.Parent, node)] = new BindEntry(reference); + bindEntries[(reference.Parent, node.AttributeNameWithoutParameter)] = new BindEntry(reference); } } @@ -96,14 +104,13 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte if (!parent.Children.Contains(node)) { // This node was removed as a duplicate, skip it. - bindEntries.Remove((parent, node)); continue; } if (node.TagHelper.IsBindTagHelper()) { // Check if this tag contains a corresponding non-parameterized bind node. - if (!bindEntries.TryGetValue((parent, node), out var entry)) + if (!bindEntries.TryGetValue((parent, node.AttributeNameWithoutParameter), out var entry)) { // There is no corresponding bind node. Add a diagnostic and move on. parameterReference.Parent.Diagnostics.Add(ComponentDiagnosticFactory.CreateBindAttributeParameter_MissingBind( diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs new file mode 100644 index 000000000..665a822a9 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", (global::System.Func)(UpdateValue)); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.ir.txt new file mode 100644 index 000000000..5d14f2a99 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - UpdateValue + CSharpCode - (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt new file mode 100644 index 000000000..d8fc489a8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } +| +Generated Location: (1232:31,7 [144] ) +| + public int ParentValue { get; set; } = 42; + + public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } +| + From 3d42627d15befc9dd1adae9b49b4f79522e4bbc2 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Fri, 11 Feb 2022 05:16:00 -0800 Subject: [PATCH 10/33] Code generation fixes --- .../src/Components/ComponentBindLoweringPass.cs | 8 ++++---- .../Microsoft.AspNetCore.Components.netstandard2.0.cs | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs index 6b9a9a248..703460e98 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs @@ -817,20 +817,20 @@ private void RewriteNodesForComponentDelegateBind( }); break; case (null, not null, false): - var syncAfterExpression = $"{ComponentsApi.RuntimeHelpers.InvokeSynchronousDelegate}({after})()"; + var syncAfterExpression = $"{ComponentsApi.RuntimeHelpers.InvokeSynchronousDelegate}({after.Content})();"; changeExpressionTokens.Add(new IntermediateToken() { // Figure out the type check - Content = $"__value => {original.Content} = __value; {syncAfterExpression}", + Content = $"__value => {{ {original.Content} = __value; {syncAfterExpression} }}", Kind = TokenKind.CSharp, }); break; case (null, not null, true): - var asyncAfterExpression = $"{ComponentsApi.RuntimeHelpers.InvokeAsynchronousDelegate}({after})()"; + var asyncAfterExpression = $"{ComponentsApi.RuntimeHelpers.InvokeAsynchronousDelegate}({after.Content})();"; changeExpressionTokens.Add(new IntermediateToken() { // Figure out the type check - Content = $"async __value => {original.Content} = __value; await {asyncAfterExpression}", + Content = $"async __value => {{ {original.Content} = __value; await {asyncAfterExpression} }}", Kind = TokenKind.CSharp, }); break; diff --git a/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs b/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs index e72550793..afd5b43d2 100644 --- a/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs +++ b/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs @@ -412,7 +412,10 @@ namespace Microsoft.AspNetCore.Components.CompilerServices { public static partial class RuntimeHelpers { - public static System.Action CreateInferredEventCallback(System.Action callback, T value) { throw null; } + + public static System.Func InvokeSynchronousDelegate(System.Action callback) { throw null; } + public static System.Func InvokeAsynchronousDelegate(System.Action callback) { throw null; } + public static System.Func InvokeAsynchronousDelegate(System.Func callback) { throw null; } public static Microsoft.AspNetCore.Components.EventCallback CreateInferredEventCallback(object receiver, System.Action callback, T value) { throw null; } From ad8d8368441a4b2e1e1579bc291777803701786d Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Fri, 11 Feb 2022 05:43:44 -0800 Subject: [PATCH 11/33] Get set after baselines --- .../TestComponent.codegen.cs | 58 +++++++++++++++++++ .../TestComponent.ir.txt | 27 +++++++++ .../TestComponent.mappings.txt | 18 ++++++ .../TestComponent.codegen.cs | 56 ++++++++++++++++++ .../TestComponent.ir.txt | 27 +++++++++ .../TestComponent.mappings.txt | 14 +++++ .../TestComponent.codegen.cs | 58 +++++++++++++++++++ .../TestComponent.ir.txt | 29 ++++++++++ .../TestComponent.mappings.txt | 18 ++++++ .../TestComponent.codegen.cs | 56 ++++++++++++++++++ .../TestComponent.ir.txt | 29 ++++++++++ .../TestComponent.mappings.txt | 14 +++++ .../TestComponent.codegen.cs | 58 +++++++++++++++++++ .../TestComponent.ir.txt | 29 ++++++++++ .../TestComponent.mappings.txt | 18 ++++++ .../TestComponent.codegen.cs | 58 +++++++++++++++++++ .../TestComponent.ir.txt | 27 +++++++++ .../TestComponent.mappings.txt | 18 ++++++ .../TestComponent.codegen.cs | 56 ++++++++++++++++++ .../TestComponent.ir.txt | 27 +++++++++ .../TestComponent.mappings.txt | 14 +++++ .../TestComponent.codegen.cs | 58 +++++++++++++++++++ .../TestComponent.ir.txt | 27 +++++++++ .../TestComponent.mappings.txt | 18 ++++++ .../TestComponent.codegen.cs | 56 ++++++++++++++++++ .../TestComponent.ir.txt | 27 +++++++++ .../TestComponent.mappings.txt | 14 +++++ .../TestComponent.codegen.cs | 58 +++++++++++++++++++ .../TestComponent.ir.txt | 29 ++++++++++ .../TestComponent.mappings.txt | 18 ++++++ .../TestComponent.codegen.cs | 56 ++++++++++++++++++ .../TestComponent.ir.txt | 29 ++++++++++ .../TestComponent.mappings.txt | 14 +++++ .../TestComponent.codegen.cs | 58 +++++++++++++++++++ .../TestComponent.ir.txt | 29 ++++++++++ .../TestComponent.mappings.txt | 18 ++++++ .../TestComponent.codegen.cs | 58 +++++++++++++++++++ .../TestComponent.ir.txt | 27 +++++++++ .../TestComponent.mappings.txt | 18 ++++++ .../TestComponent.codegen.cs | 56 ++++++++++++++++++ .../TestComponent.ir.txt | 27 +++++++++ .../TestComponent.mappings.txt | 14 +++++ .../TestComponent.codegen.cs | 42 ++++++++++++++ .../TestComponent.ir.txt | 18 ++++++ .../TestComponent.mappings.txt | 13 +++++ .../TestComponent.codegen.cs | 40 +++++++++++++ .../TestComponent.ir.txt | 18 ++++++ .../TestComponent.mappings.txt | 9 +++ .../TestComponent.codegen.cs | 42 ++++++++++++++ .../TestComponent.ir.txt | 20 +++++++ .../TestComponent.mappings.txt | 13 +++++ .../TestComponent.codegen.cs | 40 +++++++++++++ .../TestComponent.ir.txt | 20 +++++++ .../TestComponent.mappings.txt | 9 +++ .../TestComponent.codegen.cs | 42 ++++++++++++++ .../TestComponent.ir.txt | 20 +++++++ .../TestComponent.mappings.txt | 13 +++++ .../TestComponent.codegen.cs | 42 ++++++++++++++ .../TestComponent.ir.txt | 18 ++++++ .../TestComponent.mappings.txt | 13 +++++ .../TestComponent.codegen.cs | 40 +++++++++++++ .../TestComponent.ir.txt | 18 ++++++ .../TestComponent.mappings.txt | 9 +++ .../TestComponent.codegen.cs | 42 ++++++++++++++ .../TestComponent.ir.txt | 18 ++++++ .../TestComponent.mappings.txt | 13 +++++ .../TestComponent.codegen.cs | 40 +++++++++++++ .../TestComponent.ir.txt | 18 ++++++ .../TestComponent.mappings.txt | 9 +++ .../TestComponent.codegen.cs | 42 ++++++++++++++ .../TestComponent.ir.txt | 20 +++++++ .../TestComponent.mappings.txt | 13 +++++ .../TestComponent.codegen.cs | 40 +++++++++++++ .../TestComponent.ir.txt | 20 +++++++ .../TestComponent.mappings.txt | 9 +++ .../TestComponent.codegen.cs | 42 ++++++++++++++ .../TestComponent.ir.txt | 20 +++++++ .../TestComponent.mappings.txt | 13 +++++ .../TestComponent.codegen.cs | 42 ++++++++++++++ .../TestComponent.ir.txt | 18 ++++++ .../TestComponent.mappings.txt | 13 +++++ .../TestComponent.codegen.cs | 40 +++++++++++++ .../TestComponent.ir.txt | 18 ++++++ .../TestComponent.mappings.txt | 9 +++ 84 files changed, 2416 insertions(+) create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.mappings.txt diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs new file mode 100644 index 000000000..489e052bf --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs @@ -0,0 +1,58 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = new global::System.Action( + __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update)(); }); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public void Update() { } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.ir.txt new file mode 100644 index 000000000..2a68cebe1 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.ir.txt @@ -0,0 +1,27 @@ +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 - global::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 + Component - (0:0,0 [72] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update)(); } + HtmlContent - (72:0,72 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (72:0,72 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public void Update() { }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt new file mode 100644 index 000000000..e0dceb3f3 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1022:25,30 [11] ) +|ParentValue| + +Source Location: (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public void Update() { } +| +Generated Location: (1773:47,7 [82] ) +| + public int ParentValue { get; set; } = 42; + + public void Update() { } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs new file mode 100644 index 000000000..31e3a764e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs @@ -0,0 +1,56 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = new global::System.Action( + __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(() => { })(); }); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.ir.txt new file mode 100644 index 000000000..ac2f1a7e8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.ir.txt @@ -0,0 +1,27 @@ +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 - global::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 + Component - (0:0,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(() => { })(); } + HtmlContent - (75:0,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (75:0,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (84:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (84:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt new file mode 100644 index 000000000..e387ab031 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1022:25,30 [11] ) +|ParentValue| + +Source Location: (84:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1776:47,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.codegen.cs new file mode 100644 index 000000000..53932078b --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.codegen.cs @@ -0,0 +1,58 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: UpdateValue).InvokeAsync(); }, value: ParentValue), ParentValue))); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public EventCallback UpdateValue { get; set; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.ir.txt new file mode 100644 index 000000000..f424f87ce --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.ir.txt @@ -0,0 +1,29 @@ +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 - global::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 + Component - (0:0,0 [77] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: UpdateValue).InvokeAsync(); }, value: ParentValue) + IntermediateToken - - CSharp - , ParentValue) + HtmlContent - (77:0,77 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (77:0,77 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (86:1,7 [104] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (86:1,7 [104] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public EventCallback UpdateValue { get; set; }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.mappings.txt new file mode 100644 index 000000000..260a23e98 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1022:25,30 [11] ) +|ParentValue| + +Source Location: (86:1,7 [104] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public EventCallback UpdateValue { get; set; } +| +Generated Location: (2258:47,7 [104] ) +| + public int ParentValue { get; set; } = 42; + + public EventCallback UpdateValue { get; set; } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.codegen.cs new file mode 100644 index 000000000..97cb480e8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.codegen.cs @@ -0,0 +1,56 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: () => { }).InvokeAsync(); }, value: ParentValue), ParentValue))); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.ir.txt new file mode 100644 index 000000000..c071da3ae --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.ir.txt @@ -0,0 +1,29 @@ +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 - global::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 + Component - (0:0,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: () => { }).InvokeAsync(); }, value: ParentValue) + IntermediateToken - - CSharp - , ParentValue) + HtmlContent - (75:0,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (75:0,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (84:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (84:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.mappings.txt new file mode 100644 index 000000000..56e31e228 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1022:25,30 [11] ) +|ParentValue| + +Source Location: (84:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (2256:47,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.codegen.cs new file mode 100644 index 000000000..fd6cec9e9 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.codegen.cs @@ -0,0 +1,58 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: UpdateValue).InvokeAsync(); }, value: ParentValue), ParentValue))); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public Task UpdateValue() => Task.CompletedTask; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.ir.txt new file mode 100644 index 000000000..a2a7f400c --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.ir.txt @@ -0,0 +1,29 @@ +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 - global::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 + Component - (0:0,0 [77] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: UpdateValue).InvokeAsync(); }, value: ParentValue) + IntermediateToken - - CSharp - , ParentValue) + HtmlContent - (77:0,77 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (77:0,77 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (86:1,7 [106] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (86:1,7 [106] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public Task UpdateValue() => Task.CompletedTask;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.mappings.txt new file mode 100644 index 000000000..a9594edf5 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1022:25,30 [11] ) +|ParentValue| + +Source Location: (86:1,7 [106] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public Task UpdateValue() => Task.CompletedTask; +| +Generated Location: (2258:47,7 [106] ) +| + public int ParentValue { get; set; } = 42; + + public Task UpdateValue() => Task.CompletedTask; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs new file mode 100644 index 000000000..2083cdf5e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs @@ -0,0 +1,58 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = new global::System.Func( + async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(Update)(); }); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public Task Update() => Task.CompletedTask; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.ir.txt new file mode 100644 index 000000000..104cee492 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.ir.txt @@ -0,0 +1,27 @@ +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 - global::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 + Component - (0:0,0 [72] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(Update)(); } + HtmlContent - (72:0,72 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (72:0,72 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (81:1,7 [101] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (81:1,7 [101] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public Task Update() => Task.CompletedTask;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt new file mode 100644 index 000000000..e7a4eb46b --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1022:25,30 [11] ) +|ParentValue| + +Source Location: (81:1,7 [101] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public Task Update() => Task.CompletedTask; +| +Generated Location: (1813:47,7 [101] ) +| + public int ParentValue { get; set; } = 42; + + public Task Update() => Task.CompletedTask; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs new file mode 100644 index 000000000..bf25d3f4b --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs @@ -0,0 +1,56 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = new global::System.Func( + async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(() => { return Task.CompletedTask; })(); }); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.ir.txt new file mode 100644 index 000000000..6c128a32a --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.ir.txt @@ -0,0 +1,27 @@ +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 - global::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 + Component - (0:0,0 [102] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(() => { return Task.CompletedTask; })(); } + HtmlContent - (102:0,102 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (102:0,102 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (111:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (111:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt new file mode 100644 index 000000000..8be3ed8b3 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1022:25,30 [11] ) +|ParentValue| + +Source Location: (111:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1843:47,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.codegen.cs new file mode 100644 index 000000000..dfb767b60 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.codegen.cs @@ -0,0 +1,58 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = new global::System.Action( + UpdateValue); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public void UpdateValue(int value) => ParentValue = value; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.ir.txt new file mode 100644 index 000000000..073dd9baa --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.ir.txt @@ -0,0 +1,27 @@ +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 - global::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 + Component - (0:0,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - UpdateValue + HtmlContent - (75:0,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (75:0,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public void UpdateValue(int value) => ParentValue = value;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.mappings.txt new file mode 100644 index 000000000..fe537597e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1022:25,30 [11] ) +|ParentValue| + +Source Location: (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public void UpdateValue(int value) => ParentValue = value; +| +Generated Location: (1638:47,7 [116] ) +| + public int ParentValue { get; set; } = 42; + + public void UpdateValue(int value) => ParentValue = value; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.codegen.cs new file mode 100644 index 000000000..3d9df4195 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.codegen.cs @@ -0,0 +1,56 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = new global::System.Action( + value => ParentValue = value); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.ir.txt new file mode 100644 index 000000000..b8f2eb661 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.ir.txt @@ -0,0 +1,27 @@ +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 - global::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 + Component - (0:0,0 [92] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - value => ParentValue = value + HtmlContent - (92:0,92 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (92:0,92 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (101:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (101:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.mappings.txt new file mode 100644 index 000000000..bd269df90 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1022:25,30 [11] ) +|ParentValue| + +Source Location: (101:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1655:47,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.codegen.cs new file mode 100644 index 000000000..cd399bc92 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.codegen.cs @@ -0,0 +1,58 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, UpdateValue, ParentValue))); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public EventCallback UpdateValue { get; set; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.ir.txt new file mode 100644 index 000000000..3a9543d1d --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.ir.txt @@ -0,0 +1,29 @@ +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 - global::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 + Component - (0:0,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - UpdateValue + IntermediateToken - - CSharp - , ParentValue) + HtmlContent - (75:0,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (75:0,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (84:1,7 [109] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (84:1,7 [109] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public EventCallback UpdateValue { get; set; }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.mappings.txt new file mode 100644 index 000000000..20a9e8fce --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1022:25,30 [11] ) +|ParentValue| + +Source Location: (84:1,7 [109] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public EventCallback UpdateValue { get; set; } +| +Generated Location: (1975:47,7 [109] ) +| + public int ParentValue { get; set; } = 42; + + public EventCallback UpdateValue { get; set; } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.codegen.cs new file mode 100644 index 000000000..f8f5bad6f --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.codegen.cs @@ -0,0 +1,56 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, value => ParentValue = value, ParentValue))); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.ir.txt new file mode 100644 index 000000000..738d496c1 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.ir.txt @@ -0,0 +1,29 @@ +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 - global::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 + Component - (0:0,0 [92] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - value => ParentValue = value + IntermediateToken - - CSharp - , ParentValue) + HtmlContent - (92:0,92 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (92:0,92 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (101:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (101:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.mappings.txt new file mode 100644 index 000000000..8cd6e5680 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1022:25,30 [11] ) +|ParentValue| + +Source Location: (101:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1992:47,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.codegen.cs new file mode 100644 index 000000000..f75214ce7 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.codegen.cs @@ -0,0 +1,58 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, UpdateValue, ParentValue))); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.ir.txt new file mode 100644 index 000000000..bb5d897a9 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.ir.txt @@ -0,0 +1,29 @@ +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 - global::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 + Component - (0:0,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - UpdateValue + IntermediateToken - - CSharp - , ParentValue) + HtmlContent - (75:0,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (75:0,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.mappings.txt new file mode 100644 index 000000000..77e0d1319 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1022:25,30 [11] ) +|ParentValue| + +Source Location: (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } +| +Generated Location: (1975:47,7 [144] ) +| + public int ParentValue { get; set; } = 42; + + public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs new file mode 100644 index 000000000..ec733b332 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs @@ -0,0 +1,58 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = new global::System.Func( + UpdateValue); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.ir.txt new file mode 100644 index 000000000..41d475b56 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.ir.txt @@ -0,0 +1,27 @@ +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 - global::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 + Component - (0:0,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - UpdateValue + HtmlContent - (75:0,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (75:0,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt new file mode 100644 index 000000000..ba8a97169 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1022:25,30 [11] ) +|ParentValue| + +Source Location: (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } +| +Generated Location: (1665:47,7 [144] ) +| + public int ParentValue { get; set; } = 42; + + public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.codegen.cs new file mode 100644 index 000000000..787f89ba6 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.codegen.cs @@ -0,0 +1,56 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = new global::System.Func( + value => { ParentValue = value; return Task.CompletedTask; }); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.ir.txt new file mode 100644 index 000000000..37a51274c --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.ir.txt @@ -0,0 +1,27 @@ +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 - global::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 + Component - (0:0,0 [124] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - value => { ParentValue = value; return Task.CompletedTask; } + HtmlContent - (124:0,124 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (124:0,124 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (133:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (133:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.mappings.txt new file mode 100644 index 000000000..1fa7b3068 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1022:25,30 [11] ) +|ParentValue| + +Source Location: (133:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1714:47,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs new file mode 100644 index 000000000..0419136ce --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", (global::System.Action)(__value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update)(); })); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public void Update() { } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.ir.txt new file mode 100644 index 000000000..4257d1469 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [72] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update)(); } + CSharpCode - (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public void Update() { }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt new file mode 100644 index 000000000..aa27b9b68 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public void Update() { } +| +Generated Location: (1340:31,7 [82] ) +| + public int ParentValue { get; set; } = 42; + + public void Update() { } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs new file mode 100644 index 000000000..eda535d1f --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", (global::System.Action)(__value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(() => { })(); })); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.ir.txt new file mode 100644 index 000000000..49e620b40 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(() => { })(); } + CSharpCode - (84:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (84:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt new file mode 100644 index 000000000..c18edbf19 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (84:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1343:31,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.codegen.cs new file mode 100644 index 000000000..177efc27b --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: UpdateValue).InvokeAsync(); }, value: ParentValue), ParentValue)))); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public EventCallback UpdateValue { get; set; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.ir.txt new file mode 100644 index 000000000..d08ff8458 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [77] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: UpdateValue).InvokeAsync(); }, value: ParentValue) + IntermediateToken - - CSharp - , ParentValue) + CSharpCode - (86:1,7 [104] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (86:1,7 [104] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public EventCallback UpdateValue { get; set; }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.mappings.txt new file mode 100644 index 000000000..a9f99d1f9 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (86:1,7 [104] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public EventCallback UpdateValue { get; set; } +| +Generated Location: (1827:31,7 [104] ) +| + public int ParentValue { get; set; } = 42; + + public EventCallback UpdateValue { get; set; } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.codegen.cs new file mode 100644 index 000000000..b4df1c8eb --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: () => { }).InvokeAsync(); }, value: ParentValue), ParentValue)))); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.ir.txt new file mode 100644 index 000000000..8ef052b4b --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: () => { }).InvokeAsync(); }, value: ParentValue) + IntermediateToken - - CSharp - , ParentValue) + CSharpCode - (84:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (84:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.mappings.txt new file mode 100644 index 000000000..4af886e41 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesAction/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (84:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1825:31,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.codegen.cs new file mode 100644 index 000000000..97526fe14 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: UpdateValue).InvokeAsync(); }, value: ParentValue), ParentValue)))); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public Task UpdateValue() => Task.CompletedTask; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.ir.txt new file mode 100644 index 000000000..18ff54c41 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [77] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: UpdateValue).InvokeAsync(); }, value: ParentValue) + IntermediateToken - - CSharp - , ParentValue) + CSharpCode - (86:1,7 [106] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (86:1,7 [106] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public Task UpdateValue() => Task.CompletedTask;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.mappings.txt new file mode 100644 index 000000000..6f73b7dc1 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_EventCallback_ReceivesFunction/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (86:1,7 [106] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public Task UpdateValue() => Task.CompletedTask; +| +Generated Location: (1827:31,7 [106] ) +| + public int ParentValue { get; set; } = 42; + + public Task UpdateValue() => Task.CompletedTask; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs new file mode 100644 index 000000000..560f70a9d --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", (global::System.Func)(async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(Update)(); })); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public Task Update() => Task.CompletedTask; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.ir.txt new file mode 100644 index 000000000..877e36565 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [72] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(Update)(); } + CSharpCode - (81:1,7 [101] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (81:1,7 [101] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public Task Update() => Task.CompletedTask;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt new file mode 100644 index 000000000..66c79168c --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (81:1,7 [101] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public Task Update() => Task.CompletedTask; +| +Generated Location: (1380:31,7 [101] ) +| + public int ParentValue { get; set; } = 42; + + public Task Update() => Task.CompletedTask; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs new file mode 100644 index 000000000..ecbdffe0a --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", (global::System.Func)(async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(() => { return Task.CompletedTask; })(); })); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.ir.txt new file mode 100644 index 000000000..df338385e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [102] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(() => { return Task.CompletedTask; })(); } + CSharpCode - (111:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (111:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt new file mode 100644 index 000000000..08490524b --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (111:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1410:31,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.codegen.cs new file mode 100644 index 000000000..8b4cd7490 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", (global::System.Action)(UpdateValue)); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public void UpdateValue(int value) => ParentValue = value; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.ir.txt new file mode 100644 index 000000000..11abda08c --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - UpdateValue + CSharpCode - (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public void UpdateValue(int value) => ParentValue = value;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.mappings.txt new file mode 100644 index 000000000..25810998e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_Action/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public void UpdateValue(int value) => ParentValue = value; +| +Generated Location: (1205:31,7 [116] ) +| + public int ParentValue { get; set; } = 42; + + public void UpdateValue(int value) => ParentValue = value; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.codegen.cs new file mode 100644 index 000000000..63e0971b1 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", (global::System.Action)(value => ParentValue = value)); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.ir.txt new file mode 100644 index 000000000..66284cced --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [92] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - value => ParentValue = value + CSharpCode - (101:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (101:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.mappings.txt new file mode 100644 index 000000000..89a142c61 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ActionLambda/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (101:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1222:31,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.codegen.cs new file mode 100644 index 000000000..84fb66772 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, UpdateValue, ParentValue)))); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public EventCallback UpdateValue { get; set; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.ir.txt new file mode 100644 index 000000000..f0ad6a1c2 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - UpdateValue + IntermediateToken - - CSharp - , ParentValue) + CSharpCode - (84:1,7 [109] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (84:1,7 [109] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public EventCallback UpdateValue { get; set; }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.mappings.txt new file mode 100644 index 000000000..b5f0f6c8d --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (84:1,7 [109] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public EventCallback UpdateValue { get; set; } +| +Generated Location: (1544:31,7 [109] ) +| + public int ParentValue { get; set; } = 42; + + public EventCallback UpdateValue { get; set; } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.codegen.cs new file mode 100644 index 000000000..c6a2f0191 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, value => ParentValue = value, ParentValue)))); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.ir.txt new file mode 100644 index 000000000..159c6c183 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [92] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - value => ParentValue = value + IntermediateToken - - CSharp - , ParentValue) + CSharpCode - (101:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (101:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.mappings.txt new file mode 100644 index 000000000..514906b92 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesAction/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (101:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1561:31,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.codegen.cs new file mode 100644 index 000000000..867d317bc --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, UpdateValue, ParentValue)))); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.ir.txt new file mode 100644 index 000000000..c3aaf5e0d --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - UpdateValue + IntermediateToken - - CSharp - , ParentValue) + CSharpCode - (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.mappings.txt new file mode 100644 index 000000000..472b7d18b --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_EventCallback_ReceivesFunction/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } +| +Generated Location: (1544:31,7 [144] ) +| + public int ParentValue { get; set; } = 42; + + public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs new file mode 100644 index 000000000..665a822a9 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", (global::System.Func)(UpdateValue)); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.ir.txt new file mode 100644 index 000000000..5d14f2a99 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - UpdateValue + CSharpCode - (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt new file mode 100644 index 000000000..d8fc489a8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } +| +Generated Location: (1232:31,7 [144] ) +| + public int ParentValue { get; set; } = 42; + + public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.codegen.cs new file mode 100644 index 000000000..b4b19ac0c --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", (global::System.Func)(value => { ParentValue = value; return Task.CompletedTask; })); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.ir.txt new file mode 100644 index 000000000..42840198e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [124] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - value => { ParentValue = value; return Task.CompletedTask; } + CSharpCode - (133:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (133:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.mappings.txt new file mode 100644 index 000000000..21addfc02 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_TaskReturningLambda/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (133:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1281:31,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + From 0713ea4ee157e27191f8c0d3e8d6fc5968fb14b9 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Fri, 11 Feb 2022 05:44:25 -0800 Subject: [PATCH 12/33] Update other baselines --- .../ComponentCodeGenerationTestBase.cs | 498 +++++++++++++++++- .../TestComponent.codegen.cs | 56 ++ .../TestComponent.ir.txt | 27 + .../TestComponent.mappings.txt | 14 + .../TestComponent.codegen.cs | 55 ++ .../TestComponent.ir.txt | 29 + .../TestComponent.mappings.txt | 14 + .../TestComponent.codegen.cs | 57 ++ .../TestComponent.ir.txt | 30 ++ .../TestComponent.mappings.txt | 14 + .../TestComponent.codegen.cs | 67 +++ .../TestComponent.ir.txt | 33 ++ .../TestComponent.mappings.txt | 14 + .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.codegen.cs | 56 ++ .../TestComponent.ir.txt | 27 + .../TestComponent.mappings.txt | 14 + .../TestComponent.codegen.cs | 55 ++ .../TestComponent.ir.txt | 29 + .../TestComponent.mappings.txt | 14 + .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.codegen.cs | 4 +- .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 12 +- .../TestComponent.ir.txt | 6 +- .../TestComponent.mappings.txt | 8 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.codegen.cs | 4 +- .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 4 +- .../Regression_597/TestComponent.ir.txt | 4 +- .../Regression_609/TestComponent.ir.txt | 8 +- .../TestComponent.codegen.cs | 40 ++ .../TestComponent.ir.txt | 18 + .../TestComponent.mappings.txt | 9 + .../TestComponent.codegen.cs | 40 ++ .../TestComponent.ir.txt | 20 + .../TestComponent.mappings.txt | 9 + .../TestComponent.codegen.cs | 41 ++ .../TestComponent.ir.txt | 21 + .../TestComponent.mappings.txt | 9 + .../TestComponent.codegen.cs | 52 ++ .../TestComponent.ir.txt | 24 + .../TestComponent.mappings.txt | 9 + .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.codegen.cs | 40 ++ .../TestComponent.ir.txt | 18 + .../TestComponent.mappings.txt | 9 + .../TestComponent.codegen.cs | 40 ++ .../TestComponent.ir.txt | 20 + .../TestComponent.mappings.txt | 9 + .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.ir.txt | 2 +- .../TestComponent.codegen.cs | 6 +- .../TestComponent.ir.txt | 6 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 2 +- .../Regression_597/TestComponent.ir.txt | 4 +- .../Regression_609/TestComponent.ir.txt | 8 +- .../BindTagHelperDescriptorProviderTest.cs | 114 +++- .../IntegrationTests/IntegrationTestBase.cs | 2 +- .../RazorBaselineIntegrationTestBase.cs | 2 +- 82 files changed, 1724 insertions(+), 101 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.mappings.txt diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index d1f728aec..fb70c41d0 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -1051,7 +1051,7 @@ public class ComponentWithEditorRequiredChildContent : ComponentBase #region Bind [Fact] - public void BindToComponent_SpecifiesValue_WithMatchingProperties() + public void BindToComponent_WithMatchingProperties() { // Arrange AdditionalSyntaxTrees.Add(Parse(@" @@ -1242,7 +1242,7 @@ public class MyComponent : ComponentBase } [Fact] - public void BindToComponent_SpecifiesValue_WithoutMatchingProperties() + public void BindToComponent_WithoutMatchingProperties() { // Arrange AdditionalSyntaxTrees.Add(Parse(@" @@ -1270,7 +1270,7 @@ public class MyComponent : ComponentBase } [Fact] - public void BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties() + public void BindToComponentAndChangeEvent_WithMatchingProperties() { // Arrange AdditionalSyntaxTrees.Add(Parse(@" @@ -1302,7 +1302,7 @@ public class MyComponent : ComponentBase } [Fact] - public void BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties() + public void BindToComponentAndChangeEvent_WithoutMatchingProperties() { // Arrange AdditionalSyntaxTrees.Add(Parse(@" @@ -1329,7 +1329,7 @@ public class MyComponent : ComponentBase } [Fact] - public void BindToComponent_SpecifiesValueAndExpression() + public void BindToComponentAndExpression() { // Arrange AdditionalSyntaxTrees.Add(Parse(@" @@ -1403,7 +1403,7 @@ public class MyComponent : ComponentBase } [Fact] - public void BindToComponent_SpecifiesValueAndExpression_TypeChecked() + public void BindToComponentAndExpression_TypeChecked() { // Arrange AdditionalSyntaxTrees.Add(Parse(@" @@ -1442,7 +1442,7 @@ public class MyComponent : ComponentBase } [Fact] - public void BindToComponent_SpecifiesValueAndExpression_Generic() + public void BindToComponentAndExpression_Generic() { // Arrange AdditionalSyntaxTrees.Add(Parse(@" @@ -1684,11 +1684,12 @@ Task ValueChanged(string value) } [Fact] - public void BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate() + public void BindToComponent_WithGetSet_TaskReturningDelegate() { // Arrange AdditionalSyntaxTrees.Add(Parse(@" using System; +using System.Threading.Tasks; using Microsoft.AspNetCore.Components; namespace Test @@ -1699,7 +1700,7 @@ public class MyComponent : ComponentBase public int Value { get; set; } [Parameter] - public Func ValueChanged { get; set; } + public Func ValueChanged { get; set; } } }")); @@ -1718,6 +1719,485 @@ public class MyComponent : ComponentBase CompileToAssembly(generated); } + [Fact] + public void BindToComponent_WithGetSet_TaskReturningLambda() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public Func ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + { ParentValue = value; return Task.CompletedTask; }"" /> +@code { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_WithGetSet_Action() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public Action ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; + + public void UpdateValue(int value) => ParentValue = value; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_WithGetSet_ActionLambda() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public Action ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + ParentValue = value"" /> +@code { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_WithGetSet_EventCallback() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public EventCallback ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; + + public EventCallback UpdateValue { get; set; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_WithGetSet_EventCallback_ReceivesAction() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public EventCallback ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + ParentValue = value"" /> +@code { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_WithGetSet_EventCallback_ReceivesFunction() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public EventCallback ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; + + public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_WithAfter_TaskReturningDelegate() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public Func ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; + + public Task Update() => Task.CompletedTask; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_WithAfter_TaskReturningLambda() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public Func ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + { return Task.CompletedTask; }"" /> +@code { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_WithAfter_Action() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public Action ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; + + public void Update() { } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_WithAfter_ActionLambda() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public Action ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + { }"" /> +@code { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_WithAfter_EventCallback() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public EventCallback ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; + + public EventCallback UpdateValue { get; set; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_WithAfter_EventCallback_ReceivesAction() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public EventCallback ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + { }"" /> +@code { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToComponent_WithAfter_EventCallback_ReceivesFunction() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public EventCallback ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; + + public Task UpdateValue() => Task.CompletedTask; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "tmp")] + public void BindToComponent_WithAfter_AsyncLambdaProducesError() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public Action ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + { ParentValue = value; return Task.CompletedTask; }"" /> +@code { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + [Fact] public void BindToElement_WithStringAttribute_WritesAttributes() { diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs new file mode 100644 index 000000000..52d5bf35e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs @@ -0,0 +1,56 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = new global::System.Action( + __value => ParentValue = __value); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt new file mode 100644 index 000000000..5c709a8e2 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt @@ -0,0 +1,27 @@ +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 - global::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 + Component - (0:0,0 [71] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - OnChanged - OnChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => ParentValue = __value + HtmlContent - (71:0,71 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (71:0,71 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt new file mode 100644 index 000000000..5208407a4 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1018:25,26 [11] ) +|ParentValue| + +Source Location: (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1655:47,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs new file mode 100644 index 000000000..ed3118fdf --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ; + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt new file mode 100644 index 000000000..f9795bb61 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt @@ -0,0 +1,29 @@ +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 - global::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 + Component - (0:0,0 [71] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - OnChanged - - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , ParentValue) + HtmlContent - (71:0,71 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (71:0,71 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt new file mode 100644 index 000000000..710f8fe2b --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (914:25,26 [11] ) +|ParentValue| + +Source Location: (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1615:46,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.codegen.cs new file mode 100644 index 000000000..703d98997 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.codegen.cs @@ -0,0 +1,57 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = new global::System.Action( + __value => ParentValue = __value); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.ir.txt new file mode 100644 index 000000000..b6fa4be64 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.ir.txt @@ -0,0 +1,30 @@ +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 - global::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 + Component - (0:0,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => ParentValue = __value + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueExpression - ValueExpression - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - () => ParentValue + HtmlContent - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.mappings.txt new file mode 100644 index 000000000..640c8fb20 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1018:25,26 [11] ) +|ParentValue| + +Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1847:48,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.codegen.cs new file mode 100644 index 000000000..fac8e0b08 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.codegen.cs @@ -0,0 +1,67 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + global::__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(__builder, -1, -1, +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + , -1, + __value => ParentValue = __value, -1, () => ParentValue); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent<>); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public DateTime ParentValue { get; set; } = DateTime.Now; + +#line default +#line hidden +#nullable disable + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, T __arg0, int __seq1, global::System.Action __arg1, int __seq2, global::System.Linq.Expressions.Expression> __arg2) + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "SomeParam", __arg0); + __builder.AddAttribute(__seq1, "SomeParamChanged", __arg1); + __builder.AddAttribute(__seq2, "SomeParamExpression", __arg2); + __builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.ir.txt new file mode 100644 index 000000000..af9805417 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.ir.txt @@ -0,0 +1,33 @@ +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 - global::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 + Component - (0:0,0 [45] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParam - SomeParam - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParamChanged - SomeParamChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => ParentValue = __value + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParamExpression - SomeParamExpression - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - () => ParentValue + HtmlContent - (45:0,45 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (45:0,45 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (54:1,7 [65] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (54:1,7 [65] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public DateTime ParentValue { get; set; } = DateTime.Now;\n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.mappings.txt new file mode 100644 index 000000000..332ceba9c --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1001:25,30 [11] ) +|ParentValue| + +Source Location: (54:1,7 [65] x:\dir\subdir\Test\TestComponent.cshtml) +| + public DateTime ParentValue { get; set; } = DateTime.Now; +| +Generated Location: (1444:43,7 [65] ) +| + public DateTime ParentValue { get; set; } = DateTime.Now; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.ir.txt index ccbea200e..bfe510c64 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.ir.txt @@ -20,7 +20,9 @@ Document - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , ParentValue) ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueExpression - ValueExpression - AttributeStructure.DoubleQuotes CSharpExpression - IntermediateToken - - CSharp - () => ParentValue diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression_Generic/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression_Generic/TestComponent.ir.txt index 6b2d5134b..55e09dc4c 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression_Generic/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression_Generic/TestComponent.ir.txt @@ -20,7 +20,9 @@ Document - LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParamChanged - SomeParamChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , ParentValue) ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParamExpression - SomeParamExpression - AttributeStructure.DoubleQuotes CSharpExpression - IntermediateToken - - CSharp - () => ParentValue diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValue_WithMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValue_WithMatchingProperties/TestComponent.ir.txt index cb80fb4de..aa747e021 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValue_WithMatchingProperties/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValue_WithMatchingProperties/TestComponent.ir.txt @@ -20,7 +20,9 @@ Document - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , ParentValue) HtmlContent - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_TypeChecked_WithMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_TypeChecked_WithMatchingProperties/TestComponent.ir.txt index 30a067c1b..7a3e38f4d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_TypeChecked_WithMatchingProperties/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_TypeChecked_WithMatchingProperties/TestComponent.ir.txt @@ -20,7 +20,9 @@ Document - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , ParentValue) HtmlContent - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (50:1,7 [55] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.codegen.cs new file mode 100644 index 000000000..52d5bf35e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.codegen.cs @@ -0,0 +1,56 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = new global::System.Action( + __value => ParentValue = __value); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.ir.txt new file mode 100644 index 000000000..fc3de77ba --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.ir.txt @@ -0,0 +1,27 @@ +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 - global::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 + Component - (0:0,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => ParentValue = __value + HtmlContent - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.mappings.txt new file mode 100644 index 000000000..0a1a4873d --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1018:25,26 [11] ) +|ParentValue| + +Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1655:47,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.codegen.cs new file mode 100644 index 000000000..ed3118fdf --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ; + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.ir.txt new file mode 100644 index 000000000..9068e3bc8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.ir.txt @@ -0,0 +1,29 @@ +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 - global::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 + Component - (0:0,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , ParentValue) + HtmlContent - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.mappings.txt new file mode 100644 index 000000000..885673b5e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (914:25,26 [11] ) +|ParentValue| + +Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1615:46,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.ir.txt index f6aa894a2..143bf2960 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.ir.txt @@ -22,7 +22,9 @@ Document - LazyIntermediateToken - (37:0,37 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value ComponentAttribute - (37:0,37 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged - - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => Value = __value, Value) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => Value = __value + IntermediateToken - - CSharp - , Value) HtmlContent - (44:0,44 [2] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (44:0,44 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (53:1,7 [21] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.ir.txt index b6e627df3..876e2df76 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.ir.txt @@ -23,7 +23,9 @@ Document - LazyIntermediateToken - (24:0,24 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value ComponentAttribute - (24:0,24 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged - - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => Value = __value, Value) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => Value = __value + IntermediateToken - - CSharp - , Value) HtmlContent - (43:0,43 [2] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (43:0,43 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (52:1,7 [21] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.ir.txt index a7fa31e2f..3f258ab61 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.ir.txt @@ -23,7 +23,9 @@ Document - LazyIntermediateToken - (48:0,48 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - message ComponentAttribute - (47:0,47 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageChanged - MessageChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => message = __value, message) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => message = __value + IntermediateToken - - CSharp - , message) ComponentAttribute - (47:0,47 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageExpression - MessageExpression - AttributeStructure.DoubleQuotes CSharpExpression - IntermediateToken - - CSharp - () => message diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.ir.txt index 4dccc4373..3aa80022f 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.ir.txt @@ -23,7 +23,9 @@ Document - LazyIntermediateToken - (59:0,59 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - message ComponentAttribute - (58:0,58 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageChanged - MessageChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => message = __value, message) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => message = __value + IntermediateToken - - CSharp - , message) ComponentAttribute - (58:0,58 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageExpression - MessageExpression - AttributeStructure.DoubleQuotes CSharpExpression - IntermediateToken - - CSharp - () => message diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.ir.txt index f4d88a67f..c22f7d11e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.ir.txt @@ -23,7 +23,9 @@ Document - LazyIntermediateToken - (29:0,29 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - message ComponentAttribute - (28:0,28 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageChanged - MessageChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => message = __value, message) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => message = __value + IntermediateToken - - CSharp - , message) ComponentAttribute - (28:0,28 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageExpression - MessageExpression - AttributeStructure.DoubleQuotes CSharpExpression - IntermediateToken - - CSharp - () => message diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs index 4a484575b..6e639b6be 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs @@ -27,7 +27,7 @@ private void __RazorDirectiveTokenHelpers__() { #pragma warning disable 1998 protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { - __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( + __o = #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" true @@ -35,7 +35,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line default #line hidden #nullable disable - ); + ; } #pragma warning restore 1998 } diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt index b3f45338d..b04c3f7eb 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt @@ -18,7 +18,7 @@ Document - HtmlContent - (42:0,42 [2] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (42:0,42 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n MarkupElement - (44:1,0 [64] x:\dir\subdir\Test\TestComponent.cshtml) - input - ComponentAttribute - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - PreventDefault - AttributeStructure.DoubleQuotes + ComponentAttribute - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onclick:preventDefault - onclick - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true HtmlAttribute - - @onclick:preventDefault - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.mappings.txt index 7e5e9c17d..ed40a1ee9 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.mappings.txt @@ -5,6 +5,6 @@ Generated Location: (320:12,0 [41] ) Source Location: (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) |true| -Generated Location: (1190:32,32 [4] ) +Generated Location: (1084:32,32 [4] ) |true| diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs index cecfacc01..5ebec5122 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs @@ -36,7 +36,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line hidden #nullable disable ); - __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( + __o = #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" true @@ -44,8 +44,8 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line default #line hidden #nullable disable - ); - __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( + ; + __o = #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" Foo @@ -53,8 +53,8 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line default #line hidden #nullable disable - ); - __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( + ; + __o = #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" false @@ -62,7 +62,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line default #line hidden #nullable disable - ); + ; } #pragma warning restore 1998 #nullable restore diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt index 4f9bc31b5..dd3b7a90d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt @@ -25,13 +25,13 @@ Document - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, LazyIntermediateToken - (62:1,18 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - () => Foo = false IntermediateToken - - CSharp - ) - ComponentAttribute - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - PreventDefault - AttributeStructure.DoubleQuotes + ComponentAttribute - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus:preventDefault - onfocus - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true - ComponentAttribute - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - StopPropagation - AttributeStructure.DoubleQuotes + ComponentAttribute - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - onclick:stopPropagation - onclick - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Foo - ComponentAttribute - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - StopPropagation - AttributeStructure.DoubleQuotes + ComponentAttribute - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus:stopPropagation - onfocus - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - false HtmlContent - (193:1,149 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt index f9563b1fa..09788dee5 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt @@ -10,24 +10,24 @@ Generated Location: (1205:32,18 [17] ) Source Location: (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) |true| -Generated Location: (1548:41,62 [4] ) +Generated Location: (1442:41,62 [4] ) |true| Source Location: (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) |Foo| -Generated Location: (1910:50,94 [3] ) +Generated Location: (1697:50,94 [3] ) |Foo| Source Location: (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) |false| -Generated Location: (2302:59,125 [5] ) +Generated Location: (1982:59,125 [5] ) |false| Source Location: (202:2,7 [30] x:\dir\subdir\Test\TestComponent.cshtml) | bool Foo { get; set; } | -Generated Location: (2501:69,7 [30] ) +Generated Location: (2180:69,7 [30] ) | bool Foo { get; set; } | diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt index 8cad10932..750792ef0 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt @@ -20,5 +20,5 @@ Document - MarkupElement - (44:1,0 [74] x:\dir\subdir\Test\TestComponent.cshtml) - button HtmlContent - (101:1,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (101:1,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Click Me - ComponentAttribute - - onclick - PreventDefault - AttributeStructure.Minimized - ComponentAttribute - - onclick - StopPropagation - AttributeStructure.Minimized + ComponentAttribute - - onclick:preventDefault - onclick - AttributeStructure.Minimized + ComponentAttribute - - onclick:stopPropagation - onclick - AttributeStructure.Minimized diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.codegen.cs index 2d1c1bf3d..425590cc6 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.codegen.cs @@ -36,7 +36,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line hidden #nullable disable ); - __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( + __o = #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" ShouldPreventDefault() @@ -44,7 +44,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line default #line hidden #nullable disable - ); + ; } #pragma warning restore 1998 #nullable restore diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt index 0ed0d31e3..e25d823c9 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt @@ -23,7 +23,7 @@ Document - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, LazyIntermediateToken - (61:1,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnFocus IntermediateToken - - CSharp - ) - ComponentAttribute - (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - PreventDefault - AttributeStructure.DoubleQuotes + ComponentAttribute - (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus:preventDefault - onfocus - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ShouldPreventDefault() HtmlContent - (121:1,77 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.mappings.txt index db5044541..37cc2f888 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.mappings.txt @@ -10,7 +10,7 @@ Generated Location: (1204:32,17 [7] ) Source Location: (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) |ShouldPreventDefault()| -Generated Location: (1526:41,51 [22] ) +Generated Location: (1420:41,51 [22] ) |ShouldPreventDefault()| Source Location: (130:2,7 [95] x:\dir\subdir\Test\TestComponent.cshtml) @@ -19,7 +19,7 @@ Source Location: (130:2,7 [95] x:\dir\subdir\Test\TestComponent.cshtml) bool ShouldPreventDefault() { return false; } | -Generated Location: (1742:51,7 [95] ) +Generated Location: (1635:51,7 [95] ) | void OnFocus(FocusEventArgs e) { } diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_597/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_597/TestComponent.ir.txt index 12d8110f3..ec9b4b0a4 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_597/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_597/TestComponent.ir.txt @@ -20,7 +20,9 @@ Document - LazyIntermediateToken - (18:0,18 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - y ComponentAttribute - (18:0,18 [1] x:\dir\subdir\Test\TestComponent.cshtml) - vChanged - - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => y = __value, y) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => y = __value + IntermediateToken - - CSharp - , y) HtmlContent - (23:0,23 [2] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (23:0,23 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n HtmlContent - (57:3,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_609/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_609/TestComponent.ir.txt index a0c578fc0..05908cc6e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_609/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_609/TestComponent.ir.txt @@ -20,13 +20,17 @@ Document - LazyIntermediateToken - (19:0,19 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - UserName ComponentAttribute - (18:0,18 [9] x:\dir\subdir\Test\TestComponent.cshtml) - NameChanged - - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => UserName = __value, UserName) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => UserName = __value + IntermediateToken - - CSharp - , UserName) ComponentAttribute - (45:0,45 [13] x:\dir\subdir\Test\TestComponent.cshtml) - IsActive - - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (46:0,46 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - UserIsActive ComponentAttribute - (45:0,45 [13] x:\dir\subdir\Test\TestComponent.cshtml) - IsActiveChanged - - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => UserIsActive = __value, UserIsActive) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => UserIsActive = __value + IntermediateToken - - CSharp - , UserIsActive) HtmlContent - (62:0,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (62:0,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n HtmlContent - (162:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs new file mode 100644 index 000000000..23de622f8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "OnChanged", (global::System.Action)(__value => ParentValue = __value)); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt new file mode 100644 index 000000000..8f47d724a --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [71] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - OnChanged - OnChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => ParentValue = __value + CSharpCode - (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt new file mode 100644 index 000000000..95daba29a --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1219:31,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs new file mode 100644 index 000000000..8decdb4f8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __builder.AddAttribute(2, "OnChanged", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue)); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt new file mode 100644 index 000000000..010d4c247 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [71] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - OnChanged - - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , ParentValue) + CSharpCode - (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt new file mode 100644 index 000000000..bf244e6cc --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1195:31,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.codegen.cs new file mode 100644 index 000000000..d04161bb6 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.codegen.cs @@ -0,0 +1,41 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", (global::System.Action)(__value => ParentValue = __value)); + __builder.AddAttribute(3, "ValueExpression", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue)); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.ir.txt new file mode 100644 index 000000000..8a718dd19 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.ir.txt @@ -0,0 +1,21 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => ParentValue = __value + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueExpression - ValueExpression - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - () => ParentValue + CSharpCode - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.mappings.txt new file mode 100644 index 000000000..2e37b7cba --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1454:32,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.codegen.cs new file mode 100644 index 000000000..9dd49e3b6 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.codegen.cs @@ -0,0 +1,52 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + global::__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(__builder, 0, 1, +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + , 2, __value => ParentValue = __value, 3, () => ParentValue); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public DateTime ParentValue { get; set; } = DateTime.Now; + +#line default +#line hidden +#nullable disable + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, T __arg0, int __seq1, global::System.Action __arg1, int __seq2, global::System.Linq.Expressions.Expression> __arg2) + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "SomeParam", __arg0); + __builder.AddAttribute(__seq1, "SomeParamChanged", __arg1); + __builder.AddAttribute(__seq2, "SomeParamExpression", __arg2); + __builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.ir.txt new file mode 100644 index 000000000..e3d19b421 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.ir.txt @@ -0,0 +1,24 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [45] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParam - SomeParam - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParamChanged - SomeParamChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => ParentValue = __value + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParamExpression - SomeParamExpression - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - () => ParentValue + CSharpCode - (54:1,7 [65] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (54:1,7 [65] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public DateTime ParentValue { get; set; } = DateTime.Now;\n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.mappings.txt new file mode 100644 index 000000000..fae712528 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (54:1,7 [65] x:\dir\subdir\Test\TestComponent.cshtml) +| + public DateTime ParentValue { get; set; } = DateTime.Now; +| +Generated Location: (995:28,7 [65] ) +| + public DateTime ParentValue { get; set; } = DateTime.Now; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.ir.txt index c015eaa27..af01968d8 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression/TestComponent.ir.txt @@ -13,7 +13,9 @@ Document - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , ParentValue) ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueExpression - ValueExpression - AttributeStructure.DoubleQuotes CSharpExpression - IntermediateToken - - CSharp - () => ParentValue diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression_Generic/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression_Generic/TestComponent.ir.txt index c4ed3a8b9..45e62c5a0 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression_Generic/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression_Generic/TestComponent.ir.txt @@ -13,7 +13,9 @@ Document - LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParamChanged - SomeParamChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , ParentValue) ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParamExpression - SomeParamExpression - AttributeStructure.DoubleQuotes CSharpExpression - IntermediateToken - - CSharp - () => ParentValue diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValue_WithMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValue_WithMatchingProperties/TestComponent.ir.txt index 79fdeabc6..b75ec7eed 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValue_WithMatchingProperties/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValue_WithMatchingProperties/TestComponent.ir.txt @@ -13,6 +13,8 @@ Document - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , ParentValue) CSharpCode - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_TypeChecked_WithMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_TypeChecked_WithMatchingProperties/TestComponent.ir.txt index dd8e73e84..aec6490ed 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_TypeChecked_WithMatchingProperties/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_TypeChecked_WithMatchingProperties/TestComponent.ir.txt @@ -13,6 +13,8 @@ Document - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , ParentValue) CSharpCode - (50:1,7 [55] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (50:1,7 [55] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "42";\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.codegen.cs new file mode 100644 index 000000000..84497a267 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", (global::System.Action)(__value => ParentValue = __value)); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.ir.txt new file mode 100644 index 000000000..f5ab4fe32 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => ParentValue = __value + CSharpCode - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.mappings.txt new file mode 100644 index 000000000..5f9a9a2d9 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1222:31,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.codegen.cs new file mode 100644 index 000000000..636be4b0a --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __builder.AddAttribute(2, "ValueChanged", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue)); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.ir.txt new file mode 100644 index 000000000..2b7fb6405 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , ParentValue) + CSharpCode - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.mappings.txt new file mode 100644 index 000000000..d19b561ec --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1198:31,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.ir.txt index bdb3d3b59..c00a617cb 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.ir.txt @@ -15,6 +15,8 @@ Document - LazyIntermediateToken - (37:0,37 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value ComponentAttribute - (37:0,37 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged - - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => Value = __value, Value) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => Value = __value + IntermediateToken - - CSharp - , Value) CSharpCode - (53:1,7 [21] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (53:1,7 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string Value;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.ir.txt index 3b774af48..ede98a79d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.ir.txt @@ -16,7 +16,9 @@ Document - LazyIntermediateToken - (24:0,24 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value ComponentAttribute - (24:0,24 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged - - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => Value = __value, Value) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => Value = __value + IntermediateToken - - CSharp - , Value) CSharpCode - (52:1,7 [21] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (52:1,7 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string Value;\n NamespaceDeclaration - - __Blazor.Test.TestComponent diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.ir.txt index 17b0ba586..cca299c05 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.ir.txt @@ -16,7 +16,9 @@ Document - LazyIntermediateToken - (48:0,48 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - message ComponentAttribute - (47:0,47 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageChanged - MessageChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => message = __value, message) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => message = __value + IntermediateToken - - CSharp - , message) ComponentAttribute - (47:0,47 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageExpression - MessageExpression - AttributeStructure.DoubleQuotes CSharpExpression - IntermediateToken - - CSharp - () => message diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.ir.txt index a515250cf..9218e903b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.ir.txt @@ -16,7 +16,9 @@ Document - LazyIntermediateToken - (59:0,59 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - message ComponentAttribute - (58:0,58 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageChanged - MessageChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => message = __value, message) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => message = __value + IntermediateToken - - CSharp - , message) ComponentAttribute - (58:0,58 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageExpression - MessageExpression - AttributeStructure.DoubleQuotes CSharpExpression - IntermediateToken - - CSharp - () => message diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.ir.txt index 21c25b2da..cfcec4f31 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.ir.txt @@ -16,7 +16,9 @@ Document - LazyIntermediateToken - (29:0,29 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - message ComponentAttribute - (28:0,28 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageChanged - MessageChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => message = __value, message) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => message = __value + IntermediateToken - - CSharp - , message) ComponentAttribute - (28:0,28 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageExpression - MessageExpression - AttributeStructure.DoubleQuotes CSharpExpression - IntermediateToken - - CSharp - () => message diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs index 32084f8b0..19c9d4481 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs @@ -21,7 +21,7 @@ public partial class TestComponent : global::Microsoft.AspNetCore.Components.Com protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __builder.OpenElement(0, "input"); - __builder.AddEventPreventDefaultAttribute(1, "onclick", + __builder.AddEventPreventDefaultAttribute(1, "onclick:preventDefault", #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" true diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt index f8fbaca93..3f792f273 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt @@ -9,7 +9,7 @@ Document - ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree MarkupElement - (44:1,0 [64] x:\dir\subdir\Test\TestComponent.cshtml) - input - ComponentAttribute - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - PreventDefault - AttributeStructure.DoubleQuotes + ComponentAttribute - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onclick:preventDefault - onclick - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true HtmlAttribute - - @onclick:preventDefault - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs index 0f689e9f3..c5ecb1c13 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs @@ -30,7 +30,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line hidden #nullable disable )); - __builder.AddEventPreventDefaultAttribute(2, "onfocus", + __builder.AddEventPreventDefaultAttribute(2, "onfocus:preventDefault", #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" true @@ -39,7 +39,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line hidden #nullable disable ); - __builder.AddEventStopPropagationAttribute(3, "onclick", + __builder.AddEventStopPropagationAttribute(3, "onclick:stopPropagation", #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" Foo @@ -48,7 +48,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line hidden #nullable disable ); - __builder.AddEventStopPropagationAttribute(4, "onfocus", + __builder.AddEventStopPropagationAttribute(4, "onfocus:stopPropagation", #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" false diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt index bcf8439c2..516039b84 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt @@ -16,13 +16,13 @@ Document - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, LazyIntermediateToken - (62:1,18 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - () => Foo = false IntermediateToken - - CSharp - ) - ComponentAttribute - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - PreventDefault - AttributeStructure.DoubleQuotes + ComponentAttribute - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus:preventDefault - onfocus - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true - ComponentAttribute - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - StopPropagation - AttributeStructure.DoubleQuotes + ComponentAttribute - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - onclick:stopPropagation - onclick - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Foo - ComponentAttribute - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - StopPropagation - AttributeStructure.DoubleQuotes + ComponentAttribute - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus:stopPropagation - onfocus - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - false CSharpCode - (202:2,7 [30] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt index 72ae01501..cbcc1d351 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt @@ -2,7 +2,7 @@ Source Location: (202:2,7 [30] x:\dir\subdir\Test\TestComponent.cshtml) | bool Foo { get; set; } | -Generated Location: (2237:65,7 [30] ) +Generated Location: (2284:65,7 [30] ) | bool Foo { get; set; } | diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.codegen.cs index 5b3af0457..91cf00e25 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.codegen.cs @@ -21,8 +21,8 @@ public partial class TestComponent : global::Microsoft.AspNetCore.Components.Com protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __builder.OpenElement(0, "button"); - __builder.AddEventPreventDefaultAttribute(1, "onclick", true); - __builder.AddEventStopPropagationAttribute(2, "onclick", true); + __builder.AddEventPreventDefaultAttribute(1, "onclick:preventDefault", true); + __builder.AddEventStopPropagationAttribute(2, "onclick:stopPropagation", true); __builder.AddContent(3, "Click Me"); __builder.CloseElement(); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt index 7b4919bb9..54e49dea3 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt @@ -11,5 +11,5 @@ Document - MarkupElement - (44:1,0 [74] x:\dir\subdir\Test\TestComponent.cshtml) - button HtmlContent - (101:1,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (101:1,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Click Me - ComponentAttribute - - onclick - PreventDefault - AttributeStructure.Minimized - ComponentAttribute - - onclick - StopPropagation - AttributeStructure.Minimized + ComponentAttribute - - onclick:preventDefault - onclick - AttributeStructure.Minimized + ComponentAttribute - - onclick:stopPropagation - onclick - AttributeStructure.Minimized diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.codegen.cs index f0ab67e1a..262a11ef3 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.codegen.cs @@ -30,7 +30,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line hidden #nullable disable )); - __builder.AddEventPreventDefaultAttribute(2, "onfocus", + __builder.AddEventPreventDefaultAttribute(2, "onfocus:preventDefault", #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" ShouldPreventDefault() diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt index 6acdd8a2e..3785cfdf5 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt @@ -14,7 +14,7 @@ Document - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, LazyIntermediateToken - (61:1,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnFocus IntermediateToken - - CSharp - ) - ComponentAttribute - (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - PreventDefault - AttributeStructure.DoubleQuotes + ComponentAttribute - (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus:preventDefault - onfocus - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ShouldPreventDefault() CSharpCode - (130:2,7 [95] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.mappings.txt index 9f974409b..4028e0b27 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.mappings.txt @@ -4,7 +4,7 @@ Source Location: (130:2,7 [95] x:\dir\subdir\Test\TestComponent.cshtml) bool ShouldPreventDefault() { return false; } | -Generated Location: (1537:46,7 [95] ) +Generated Location: (1552:46,7 [95] ) | void OnFocus(FocusEventArgs e) { } diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_597/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_597/TestComponent.ir.txt index 76e1eafdc..f074fa5c9 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_597/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_597/TestComponent.ir.txt @@ -13,6 +13,8 @@ Document - LazyIntermediateToken - (18:0,18 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - y ComponentAttribute - (18:0,18 [1] x:\dir\subdir\Test\TestComponent.cshtml) - vChanged - - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => y = __value, y) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => y = __value + IntermediateToken - - CSharp - , y) CSharpCode - (32:1,7 [24] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (32:1,7 [24] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string y = null;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_609/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_609/TestComponent.ir.txt index d540e3cc9..7a0083580 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_609/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_609/TestComponent.ir.txt @@ -13,12 +13,16 @@ Document - LazyIntermediateToken - (19:0,19 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - UserName ComponentAttribute - (18:0,18 [9] x:\dir\subdir\Test\TestComponent.cshtml) - NameChanged - - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => UserName = __value, UserName) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => UserName = __value + IntermediateToken - - CSharp - , UserName) ComponentAttribute - (45:0,45 [13] x:\dir\subdir\Test\TestComponent.cshtml) - IsActive - - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (46:0,46 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - UserIsActive ComponentAttribute - (45:0,45 [13] x:\dir\subdir\Test\TestComponent.cshtml) - IsActiveChanged - - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => UserIsActive = __value, UserIsActive) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => UserIsActive = __value + IntermediateToken - - CSharp - , UserIsActive) CSharpCode - (73:2,7 [88] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (73:2,7 [88] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string UserName { get; set; }\n public bool UserIsActive { get; set; }\n diff --git a/src/Microsoft.CodeAnalysis.Razor/test/BindTagHelperDescriptorProviderTest.cs b/src/Microsoft.CodeAnalysis.Razor/test/BindTagHelperDescriptorProviderTest.cs index cd92559cc..d4cadd66e 100644 --- a/src/Microsoft.CodeAnalysis.Razor/test/BindTagHelperDescriptorProviderTest.cs +++ b/src/Microsoft.CodeAnalysis.Razor/test/BindTagHelperDescriptorProviderTest.cs @@ -97,20 +97,51 @@ public Task SetParametersAsync(ParameterView parameters) Assert.Equal("Test.MyComponent", bind.DisplayName); Assert.Equal("Test.MyComponent", bind.GetTypeName()); - var rule = Assert.Single(bind.TagMatchingRules); - Assert.Empty(rule.Diagnostics); - Assert.False(rule.HasErrors); - Assert.Null(rule.ParentTag); - Assert.Equal("MyComponent", rule.TagName); - Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + Assert.Collection(bind.TagMatchingRules.OrderBy(r => r.Attributes.Count), + rule => + { + Assert.Empty(rule.Diagnostics); + Assert.False(rule.HasErrors); + Assert.Null(rule.ParentTag); + Assert.Equal("MyComponent", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); - var requiredAttribute = Assert.Single(rule.Attributes); - Assert.Empty(requiredAttribute.Diagnostics); - Assert.Equal("@bind-MyProperty", requiredAttribute.DisplayName); - Assert.Equal("@bind-MyProperty", requiredAttribute.Name); - Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, requiredAttribute.NameComparison); - Assert.Null(requiredAttribute.Value); - Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.None, requiredAttribute.ValueComparison); + var requiredAttribute = Assert.Single(rule.Attributes); + Assert.Empty(requiredAttribute.Diagnostics); + Assert.Equal("@bind-MyProperty", requiredAttribute.DisplayName); + Assert.Equal("@bind-MyProperty", requiredAttribute.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, requiredAttribute.NameComparison); + Assert.Null(requiredAttribute.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.None, requiredAttribute.ValueComparison); + }, + rule => + { + Assert.Empty(rule.Diagnostics); + Assert.False(rule.HasErrors); + Assert.Null(rule.ParentTag); + Assert.Equal("MyComponent", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + Assert.Collection(rule.Attributes.OrderBy(a => a.Name), + requiredAttribute => + { + Assert.Empty(requiredAttribute.Diagnostics); + Assert.Equal("@bind-MyProperty:get", requiredAttribute.DisplayName); + Assert.Equal("@bind-MyProperty:get", requiredAttribute.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, requiredAttribute.NameComparison); + Assert.Null(requiredAttribute.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.None, requiredAttribute.ValueComparison); + }, + requiredAttribute => + { + Assert.Empty(requiredAttribute.Diagnostics); + Assert.Equal("@bind-MyProperty:set", requiredAttribute.DisplayName); + Assert.Equal("@bind-MyProperty:set", requiredAttribute.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, requiredAttribute.NameComparison); + Assert.Null(requiredAttribute.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.None, requiredAttribute.ValueComparison); + }); + }); var attribute = Assert.Single(bind.BoundAttributes); @@ -218,20 +249,51 @@ public Task SetParametersAsync(ParameterView parameters) Assert.Equal("Test.MyComponent", bind.DisplayName); Assert.Equal("Test.MyComponent", bind.GetTypeName()); - var rule = Assert.Single(bind.TagMatchingRules); - Assert.Empty(rule.Diagnostics); - Assert.False(rule.HasErrors); - Assert.Null(rule.ParentTag); - Assert.Equal("MyComponent", rule.TagName); - Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + Assert.Collection(bind.TagMatchingRules.OrderBy(o => o.Attributes.Count), + rule => + { + Assert.Empty(rule.Diagnostics); + Assert.False(rule.HasErrors); + Assert.Null(rule.ParentTag); + Assert.Equal("MyComponent", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); - var requiredAttribute = Assert.Single(rule.Attributes); - Assert.Empty(requiredAttribute.Diagnostics); - Assert.Equal("@bind-MyProperty", requiredAttribute.DisplayName); - Assert.Equal("@bind-MyProperty", requiredAttribute.Name); - Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, requiredAttribute.NameComparison); - Assert.Null(requiredAttribute.Value); - Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.None, requiredAttribute.ValueComparison); + var requiredAttribute = Assert.Single(rule.Attributes); + Assert.Empty(requiredAttribute.Diagnostics); + Assert.Equal("@bind-MyProperty", requiredAttribute.DisplayName); + Assert.Equal("@bind-MyProperty", requiredAttribute.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, requiredAttribute.NameComparison); + Assert.Null(requiredAttribute.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.None, requiredAttribute.ValueComparison); + }, + rule => + { + Assert.Empty(rule.Diagnostics); + Assert.False(rule.HasErrors); + Assert.Null(rule.ParentTag); + Assert.Equal("MyComponent", rule.TagName); + Assert.Equal(TagStructure.Unspecified, rule.TagStructure); + + Assert.Collection(rule.Attributes.OrderBy(a => a.Name), + requiredAttribute => + { + Assert.Empty(requiredAttribute.Diagnostics); + Assert.Equal("@bind-MyProperty:get", requiredAttribute.DisplayName); + Assert.Equal("@bind-MyProperty:get", requiredAttribute.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, requiredAttribute.NameComparison); + Assert.Null(requiredAttribute.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.None, requiredAttribute.ValueComparison); + }, + requiredAttribute => + { + Assert.Empty(requiredAttribute.Diagnostics); + Assert.Equal("@bind-MyProperty:set", requiredAttribute.DisplayName); + Assert.Equal("@bind-MyProperty:set", requiredAttribute.Name); + Assert.Equal(RequiredAttributeDescriptor.NameComparisonMode.FullMatch, requiredAttribute.NameComparison); + Assert.Null(requiredAttribute.Value); + Assert.Equal(RequiredAttributeDescriptor.ValueComparisonMode.None, requiredAttribute.ValueComparison); + }); + }); var attribute = Assert.Single(bind.BoundAttributes); diff --git a/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs b/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs index 09d956290..9f04fd8ed 100644 --- a/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs +++ b/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs @@ -99,7 +99,7 @@ protected IntegrationTestBase(bool? generateBaselines = null, string? projectDir #if GENERATE_BASELINES protected bool GenerateBaselines { get; } = true; #else - protected bool GenerateBaselines { get; } = true; + protected bool GenerateBaselines { get; } = false; #endif protected string TestProjectRoot { get; } diff --git a/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs b/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs index 76813c060..2848d64ec 100644 --- a/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs +++ b/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorBaselineIntegrationTestBase.cs @@ -38,7 +38,7 @@ public static string DirectoryPath #if GENERATE_BASELINES protected bool GenerateBaselines { get; } = true; #else - protected bool GenerateBaselines { get; } = true; + protected bool GenerateBaselines { get; } = false; #endif protected string TestProjectRoot { get; } From 48530b16eb61a17be4265dd409403815561bccbf Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Fri, 11 Feb 2022 06:35:46 -0800 Subject: [PATCH 13/33] Update runtime helpers and update code gen --- .../src/Components/ComponentBindLoweringPass.cs | 6 ++---- .../Microsoft.AspNetCore.Components.netstandard2.0.cs | 9 +++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs index 703460e98..7ec91be49 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs @@ -811,22 +811,20 @@ private void RewriteNodesForComponentDelegateBind( case (not null, null, _): changeExpressionTokens.Add(new IntermediateToken() { - // Figure out the type check Content = setter.Content, Kind = TokenKind.CSharp, }); break; case (null, not null, false): - var syncAfterExpression = $"{ComponentsApi.RuntimeHelpers.InvokeSynchronousDelegate}({after.Content})();"; + var syncAfterExpression = $"{ComponentsApi.RuntimeHelpers.InvokeSynchronousDelegate}({after.Content});"; changeExpressionTokens.Add(new IntermediateToken() { - // Figure out the type check Content = $"__value => {{ {original.Content} = __value; {syncAfterExpression} }}", Kind = TokenKind.CSharp, }); break; case (null, not null, true): - var asyncAfterExpression = $"{ComponentsApi.RuntimeHelpers.InvokeAsynchronousDelegate}({after.Content})();"; + var asyncAfterExpression = $"{ComponentsApi.RuntimeHelpers.InvokeAsynchronousDelegate}({after.Content});"; changeExpressionTokens.Add(new IntermediateToken() { // Figure out the type check diff --git a/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs b/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs index afd5b43d2..493dca1af 100644 --- a/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs +++ b/src/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs @@ -412,13 +412,10 @@ namespace Microsoft.AspNetCore.Components.CompilerServices { public static partial class RuntimeHelpers { - - public static System.Func InvokeSynchronousDelegate(System.Action callback) { throw null; } - public static System.Func InvokeAsynchronousDelegate(System.Action callback) { throw null; } - public static System.Func InvokeAsynchronousDelegate(System.Func callback) { throw null; } - + public static void InvokeSynchronousDelegate(System.Action callback) { throw null; } + public static System.Threading.Tasks.Task InvokeAsynchronousDelegate(System.Action callback) { throw null; } + public static System.Threading.Tasks.Task InvokeAsynchronousDelegate(System.Func callback) { throw null; } public static Microsoft.AspNetCore.Components.EventCallback CreateInferredEventCallback(object receiver, System.Action callback, T value) { throw null; } - public static Microsoft.AspNetCore.Components.EventCallback CreateInferredEventCallback(object receiver, Microsoft.AspNetCore.Components.EventCallback callback, T value) { throw null; } public static Microsoft.AspNetCore.Components.EventCallback CreateInferredEventCallback(object receiver, System.Func callback, T value) { throw null; } public static T TypeCheck(T value) { throw null; } From 770c516dd323c5f4d229a5cc830d63ee01e104f0 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Fri, 11 Feb 2022 06:47:44 -0800 Subject: [PATCH 14/33] update baselines --- .../BindToComponent_WithAfter_Action/TestComponent.codegen.cs | 2 +- .../BindToComponent_WithAfter_Action/TestComponent.ir.txt | 2 +- .../BindToComponent_WithAfter_Action/TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../BindToComponent_WithAfter_ActionLambda/TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 2 +- .../BindToComponent_WithAfter_Action/TestComponent.codegen.cs | 2 +- .../BindToComponent_WithAfter_Action/TestComponent.ir.txt | 2 +- .../BindToComponent_WithAfter_Action/TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../BindToComponent_WithAfter_ActionLambda/TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs index 489e052bf..f6e47b085 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs @@ -30,7 +30,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #nullable disable ); __o = new global::System.Action( - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update)(); }); + __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); }); __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { } )); diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.ir.txt index 2a68cebe1..663e62244 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.ir.txt @@ -20,7 +20,7 @@ Document - LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update)(); } + IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); } HtmlContent - (72:0,72 [2] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (72:0,72 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt index e0dceb3f3..52d7b1a9f 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt @@ -9,7 +9,7 @@ Source Location: (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) public void Update() { } | -Generated Location: (1773:47,7 [82] ) +Generated Location: (1771:47,7 [82] ) | public int ParentValue { get; set; } = 42; diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs index 31e3a764e..c3b17feb8 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs @@ -30,7 +30,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #nullable disable ); __o = new global::System.Action( - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(() => { })(); }); + __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(() => { }); }); __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { } )); diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.ir.txt index ac2f1a7e8..6caa4f6c7 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.ir.txt @@ -20,7 +20,7 @@ Document - LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(() => { })(); } + IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(() => { }); } HtmlContent - (75:0,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (75:0,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (84:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt index e387ab031..d2a2e09ce 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt @@ -7,7 +7,7 @@ Source Location: (84:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (1776:47,7 [50] ) +Generated Location: (1774:47,7 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs index 2083cdf5e..759245ab9 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs @@ -30,7 +30,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #nullable disable ); __o = new global::System.Func( - async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(Update)(); }); + async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(Update); }); __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { } )); diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.ir.txt index 104cee492..a7b468fe2 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.ir.txt @@ -20,7 +20,7 @@ Document - LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(Update)(); } + IntermediateToken - - CSharp - async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(Update); } HtmlContent - (72:0,72 [2] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (72:0,72 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (81:1,7 [101] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt index e7a4eb46b..6a6e993e2 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt @@ -9,7 +9,7 @@ Source Location: (81:1,7 [101] x:\dir\subdir\Test\TestComponent.cshtml) public Task Update() => Task.CompletedTask; | -Generated Location: (1813:47,7 [101] ) +Generated Location: (1811:47,7 [101] ) | public int ParentValue { get; set; } = 42; diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs index bf25d3f4b..d4903a54a 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs @@ -30,7 +30,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #nullable disable ); __o = new global::System.Func( - async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(() => { return Task.CompletedTask; })(); }); + async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(() => { return Task.CompletedTask; }); }); __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { } )); diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.ir.txt index 6c128a32a..061b5eb56 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.ir.txt @@ -20,7 +20,7 @@ Document - LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(() => { return Task.CompletedTask; })(); } + IntermediateToken - - CSharp - async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(() => { return Task.CompletedTask; }); } HtmlContent - (102:0,102 [2] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (102:0,102 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (111:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt index 8be3ed8b3..e3a41e7fc 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt @@ -7,7 +7,7 @@ Source Location: (111:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (1843:47,7 [50] ) +Generated Location: (1841:47,7 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs index 0419136ce..f3b492d17 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.codegen.cs @@ -23,7 +23,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line hidden #nullable disable )); - __builder.AddAttribute(2, "ValueChanged", (global::System.Action)(__value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update)(); })); + __builder.AddAttribute(2, "ValueChanged", (global::System.Action)(__value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); })); __builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.ir.txt index 4257d1469..5654e78b1 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.ir.txt @@ -13,6 +13,6 @@ Document - LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update)(); } + IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); } CSharpCode - (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public void Update() { }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt index aa27b9b68..8135f3040 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_Action/TestComponent.mappings.txt @@ -4,7 +4,7 @@ Source Location: (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) public void Update() { } | -Generated Location: (1340:31,7 [82] ) +Generated Location: (1338:31,7 [82] ) | public int ParentValue { get; set; } = 42; diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs index eda535d1f..63c1343c4 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.codegen.cs @@ -23,7 +23,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line hidden #nullable disable )); - __builder.AddAttribute(2, "ValueChanged", (global::System.Action)(__value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(() => { })(); })); + __builder.AddAttribute(2, "ValueChanged", (global::System.Action)(__value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(() => { }); })); __builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.ir.txt index 49e620b40..878d9ea11 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.ir.txt @@ -13,6 +13,6 @@ Document - LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(() => { })(); } + IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(() => { }); } CSharpCode - (84:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (84:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt index c18edbf19..704c75161 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_ActionLambda/TestComponent.mappings.txt @@ -2,7 +2,7 @@ Source Location: (84:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (1343:31,7 [50] ) +Generated Location: (1341:31,7 [50] ) | public int ParentValue { get; set; } = 42; | diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs index 560f70a9d..47e51c471 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.codegen.cs @@ -23,7 +23,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line hidden #nullable disable )); - __builder.AddAttribute(2, "ValueChanged", (global::System.Func)(async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(Update)(); })); + __builder.AddAttribute(2, "ValueChanged", (global::System.Func)(async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(Update); })); __builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.ir.txt index 877e36565..2095a9f65 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.ir.txt @@ -13,6 +13,6 @@ Document - LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(Update)(); } + IntermediateToken - - CSharp - async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(Update); } CSharpCode - (81:1,7 [101] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (81:1,7 [101] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public Task Update() => Task.CompletedTask;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt index 66c79168c..5b61d456e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningDelegate/TestComponent.mappings.txt @@ -4,7 +4,7 @@ Source Location: (81:1,7 [101] x:\dir\subdir\Test\TestComponent.cshtml) public Task Update() => Task.CompletedTask; | -Generated Location: (1380:31,7 [101] ) +Generated Location: (1378:31,7 [101] ) | public int ParentValue { get; set; } = 42; diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs index ecbdffe0a..bc68a0b7d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.codegen.cs @@ -23,7 +23,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line hidden #nullable disable )); - __builder.AddAttribute(2, "ValueChanged", (global::System.Func)(async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(() => { return Task.CompletedTask; })(); })); + __builder.AddAttribute(2, "ValueChanged", (global::System.Func)(async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(() => { return Task.CompletedTask; }); })); __builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.ir.txt index df338385e..4d6587422 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.ir.txt @@ -13,6 +13,6 @@ Document - LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(() => { return Task.CompletedTask; })(); } + IntermediateToken - - CSharp - async __value => { ParentValue = __value; await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeAsynchronousDelegate(() => { return Task.CompletedTask; }); } CSharpCode - (111:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (111:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt index 08490524b..82696bec9 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_TaskReturningLambda/TestComponent.mappings.txt @@ -2,7 +2,7 @@ Source Location: (111:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) | public int ParentValue { get; set; } = 42; | -Generated Location: (1410:31,7 [50] ) +Generated Location: (1408:31,7 [50] ) | public int ParentValue { get; set; } = 42; | From 2214496575d8a0a9ab70f2fea0aef5ed43d72744 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Wed, 16 Feb 2022 08:28:33 -0800 Subject: [PATCH 15/33] Add additional tests for checking errors --- .../Components/ComponentBindLoweringPass.cs | 61 +++++- .../Components/ComponentDiagnosticFactory.cs | 82 ++++++- .../src/TagMatchingRuleDescriptor.cs | 2 +- .../ComponentCodeGenerationTestBase.cs | 205 +++++++++++++++++- 4 files changed, 333 insertions(+), 17 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs index 7ec91be49..ed1cc6d98 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs @@ -90,7 +90,16 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte if (node.BoundAttributeParameter.Metadata.ContainsKey(ComponentMetadata.Bind.BindAttributeAlternative)) { - bindEntries[(reference.Parent, node.AttributeNameWithoutParameter)] = new BindEntry(reference); + if (!bindEntries.TryGetValue((reference.Parent, node.AttributeNameWithoutParameter), out var existingEntry)) + { + bindEntries[(reference.Parent, node.AttributeNameWithoutParameter)] = new BindEntry(reference); + } + else + { + existingEntry.BindNode.Diagnostics.Add(ComponentDiagnosticFactory.CreateBindAttributeParameter_InvalidSyntaxBindAndBindGet( + node.Source, + existingEntry.BindNode.AttributeName)); + } } } @@ -112,10 +121,20 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte // Check if this tag contains a corresponding non-parameterized bind node. if (!bindEntries.TryGetValue((parent, node.AttributeNameWithoutParameter), out var entry)) { - // There is no corresponding bind node. Add a diagnostic and move on. - parameterReference.Parent.Diagnostics.Add(ComponentDiagnosticFactory.CreateBindAttributeParameter_MissingBind( - node.Source, - node.AttributeName)); + if (node.BoundAttributeParameter.Name != "set") + { + // There is no corresponding bind node. Add a diagnostic and move on. + parameterReference.Parent.Diagnostics.Add(ComponentDiagnosticFactory.CreateBindAttributeParameter_MissingBind( + node.Source, + node.AttributeName)); + } + else + { + // There is no corresponding bind node. Add a diagnostic and move on. + parameterReference.Parent.Diagnostics.Add(ComponentDiagnosticFactory.CreateBindAttributeParameter_MissingBindGet( + node.Source, + node.AttributeNameWithoutParameter)); + } } else if (node.BoundAttributeParameter.Name == "event") { @@ -140,6 +159,12 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte } else if (node.BoundAttributeParameter.Name == "set") { + if (entry.BindNode != null) + { + parameterReference.Parent.Diagnostics.Add(ComponentDiagnosticFactory.CreateBindAttributeParameter_UseBindGet( + node.Source, + node.BoundAttribute.Name)); + } entry.BindSetNode = node; } else @@ -157,6 +182,13 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte foreach (var entry in bindEntries) { var reference = entry.Value.BindNodeReference; + if (entry.Value.BindSetNode != null && entry.Value.BindAfterNode != null) + { + var afterNode = entry.Value.BindAfterNode; + entry.Key.Item1.Diagnostics.Add(ComponentDiagnosticFactory.CreateBindAttributeParameter_InvalidSyntaxBindSetAfter( + afterNode.Source, + afterNode.AttributeNameWithoutParameter)); + } var rewritten = RewriteUsage(reference.Parent, entry.Value); reference.Remove(); @@ -319,10 +351,21 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE { // Skip anything we can't understand. It's important that we don't crash, that will bring down // the build. - node.Diagnostics.Add(ComponentDiagnosticFactory.CreateBindAttribute_InvalidSyntax( - node.Source, - node.AttributeName)); - return new[] { node }; + if (node != null) + { + node.Diagnostics.Add(ComponentDiagnosticFactory.CreateBindAttribute_InvalidSyntax( + node.Source, + node.AttributeName)); + return new[] { node }; + } + else + { + getNode.Diagnostics.Add(ComponentDiagnosticFactory.CreateBindAttribute_MissingBindSet( + getNode.Source, + getNode.AttributeName, + $"{getNode.AttributeNameWithoutParameter}:set")); + return new[] { getNode }; + } } var original = GetAttributeContent((IntermediateNode)node ?? getNode); diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs index 990dd1f5c..200a224f3 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #nullable disable @@ -456,4 +456,84 @@ public static RazorDiagnostic CreateEventHandlerParameter_Duplicates(SourceSpan? Environment.NewLine + string.Join(Environment.NewLine, attributes.Select(p => p.TagHelper.DisplayName))); return diagnostic; } + + public static readonly RazorDiagnosticDescriptor BindAttributeParameter_UseBindGet = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10015", + () => "Attribute '{0}:get' must be used with attribute '{0}:set'.", + RazorDiagnosticSeverity.Error); + + + public static RazorDiagnostic CreateBindAttributeParameter_UseBindGet(SourceSpan? source, string attribute) + { + var diagnostic = RazorDiagnostic.Create( + BindAttributeParameter_UseBindGet, + source ?? SourceSpan.Undefined, + attribute); + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor BindAttributeParameter_MissingBindGet = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10016", + () => "Attribute '{0}:set' was used but no attribute '{0}:get' was found.", + RazorDiagnosticSeverity.Error); + + + public static RazorDiagnostic CreateBindAttributeParameter_MissingBindGet(SourceSpan? source, string attribute) + { + var diagnostic = RazorDiagnostic.Create( + BindAttributeParameter_MissingBindGet, + source ?? SourceSpan.Undefined, + attribute); + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor BindAttribute_MissingBindSet = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10017", + () => "The attribute '{0}' must have a companion '{1}' attribute.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreateBindAttribute_MissingBindSet(SourceSpan? source, string attributeGet, string attributeSet) + { + var diagnostic = RazorDiagnostic.Create( + BindAttribute_MissingBindSet, + source ?? SourceSpan.Undefined, + attributeGet, + attributeSet); + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor BindAttributeParameter_InvalidSyntaxBindAndBindGet = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10018", + () => "Attribute '{0}' can't be used in conjunction with '{0}:get'.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreateBindAttributeParameter_InvalidSyntaxBindAndBindGet(SourceSpan? source, string attribute) + { + var diagnostic = RazorDiagnostic.Create( + BindAttributeParameter_InvalidSyntaxBindAndBindGet, + source ?? SourceSpan.Undefined, + attribute); + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor BindAttributeParameter_InvalidSyntaxBindSetAfter = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10019", + () => "Attribute '{0}:after' can not be used with '{0}:set'. Invoke the code in '{0}:after' inside '{0}:set' instead.", + RazorDiagnosticSeverity.Error); + + + public static RazorDiagnostic CreateBindAttributeParameter_InvalidSyntaxBindSetAfter(SourceSpan? source, string attribute) + { + var diagnostic = RazorDiagnostic.Create( + BindAttributeParameter_InvalidSyntaxBindSetAfter, + source ?? SourceSpan.Undefined, + attribute); + return diagnostic; + } + } diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/TagMatchingRuleDescriptor.cs b/src/Microsoft.AspNetCore.Razor.Language/src/TagMatchingRuleDescriptor.cs index 15b20f9af..1535d9185 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/TagMatchingRuleDescriptor.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/TagMatchingRuleDescriptor.cs @@ -79,7 +79,7 @@ static string DescribeAttribute(RequiredAttributeDescriptor attribute) { null => "*", var prefix when attribute.NameComparison == RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch => $"^{prefix}", - var full => $"{full}", + var full => full, }; var value = attribute.Value switch diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index fb70c41d0..542d04267 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -1614,7 +1614,7 @@ public static class BindAttributes } [Fact] - public void BindToElement_WithBindAfter() + public void BindToElement_WithBindAfterAndSuffix() { // Arrange AdditionalSyntaxTrees.Add(Parse(@" @@ -1623,7 +1623,7 @@ public void BindToElement_WithBindAfter() namespace Test { - [BindElement(""div"", null, ""myvalue"", ""myevent"")] + [BindElement(""div"", ""myvalue"", ""myvalue"", ""myevent"")] public static class BindAttributes { } @@ -1631,7 +1631,7 @@ public static class BindAttributes // Act var generated = CompileToCSharp(@" -
+
@code { public string ParentValue { get; set; } = ""hi""; @@ -1649,7 +1649,7 @@ Task DoSomething() } [Fact] - public void BindToElement_WithGetSet() + public void BindToElement_WithGetSetAndSuffix() { // Arrange AdditionalSyntaxTrees.Add(Parse(@" @@ -1658,7 +1658,7 @@ public void BindToElement_WithGetSet() namespace Test { - [BindElement(""div"", null, ""myvalue"", ""myevent"")] + [BindElement(""div"", ""myvalue"", ""myvalue"", ""myevent"")] public static class BindAttributes { } @@ -1666,7 +1666,7 @@ public static class BindAttributes // Act var generated = CompileToCSharp(@" -
+
@code { public string ParentValue { get; set; } = ""hi""; @@ -2594,6 +2594,199 @@ @using System.Globalization CompileToAssembly(generated); } + [Fact] + public void BindToElement_MixingBindAndParamBindSet() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", ""value"", ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + // Act + var generated = CompileToCSharp(@" +
+@code { + public string ParentValue { get; set; } = ""hi""; + + public void UpdateValue(string value) => ParentValue = value; +}", throwOnFailure: false); + + // Assert + Assert.Collection(generated.Diagnostics, + diagnostic => Assert.Equal("RZ10015", diagnostic.Id)); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + } + + [Fact] + public void BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", null, ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + // Act + var generated = CompileToCSharp(@" +
+@code { + public string ParentValue { get; set; } = ""hi""; + + public void UpdateValue(string value) => ParentValue = value; +}", throwOnFailure: false); + + // Assert + Assert.Collection(generated.Diagnostics, + diagnostic => Assert.Equal("RZ10016", diagnostic.Id)); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + } + + [Fact] + public void BindToElement_MixingBindValueWithGetSet() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", null, ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + // Act + var generated = CompileToCSharp(@" +
+@code { + public string ParentValue { get; set; } = ""hi""; + + public void UpdateValue(string value) => ParentValue = value; +}", throwOnFailure: false); + + // Assert + Assert.Collection(generated.Diagnostics, + diagnostic => Assert.Equal("RZ10018", diagnostic.Id), + diagnostic => Assert.Equal("RZ10015", diagnostic.Id)); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + } + + [Fact] + public void BindToElement_MixingSetWithAfter() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", null, ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + // Act + var generated = CompileToCSharp(@" +
+@code { + public string ParentValue { get; set; } = ""hi""; + + public void UpdateValue(string value) => ParentValue = value; + public void AfterUpdate() { } +}", throwOnFailure: false); + + // Assert + Assert.Collection(generated.Diagnostics, + diagnostic => Assert.Equal("RZ10019", diagnostic.Id)); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + } + + [Fact] + public void BindToElement_MissingBindGet() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", ""value"", ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + // Act + var generated = CompileToCSharp(@" +
+@code { + public string ParentValue { get; set; } = ""hi""; + + public void UpdateValue(string value) => ParentValue = value; +}", throwOnFailure: false); + + // Assert + Assert.Collection(generated.Diagnostics, + diagnostic => Assert.Equal("RZ10016", diagnostic.Id)); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + } + + [Fact] + public void BindToElement_MissingBindSet() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", ""value"", ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + // Act + var generated = CompileToCSharp(@" +
+@code { + public string ParentValue { get; set; } = ""hi""; + + public void UpdateValue(string value) => ParentValue = value; +}", throwOnFailure: false); + + // Assert + Assert.Collection(generated.Diagnostics, + diagnostic => Assert.Equal("RZ10017", diagnostic.Id)); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + } [Fact] public void BuiltIn_BindToInputText_CanOverrideEvent() From c44cb602891734e55f685cead7385c336cffde9c Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Wed, 16 Feb 2022 08:28:58 -0800 Subject: [PATCH 16/33] Add baselines for error cases --- .../TestComponent.codegen.cs | 37 +++++++++++++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 21 ++++++++ .../TestComponent.mappings.txt | 13 +++++ .../TestComponent.codegen.cs | 37 +++++++++++++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 23 ++++++++ .../TestComponent.mappings.txt | 13 +++++ .../TestComponent.codegen.cs | 47 ++++++++++++++++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 33 ++++++++++++ .../TestComponent.mappings.txt | 18 +++++++ .../TestComponent.codegen.cs | 54 +++++++++++++++++++ .../TestComponent.diagnostics.txt | 2 + .../TestComponent.ir.txt | 36 +++++++++++++ .../TestComponent.mappings.txt | 23 ++++++++ .../TestComponent.codegen.cs | 47 ++++++++++++++++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 33 ++++++++++++ .../TestComponent.mappings.txt | 18 +++++++ .../TestComponent.codegen.cs | 48 +++++++++++++++++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 33 ++++++++++++ .../TestComponent.mappings.txt | 20 +++++++ .../TestComponent.codegen.cs | 50 +++++++++++++++++ .../TestComponent.ir.txt | 35 ++++++++++++ .../TestComponent.mappings.txt | 24 +++++++++ .../TestComponent.codegen.cs | 50 +++++++++++++++++ .../TestComponent.ir.txt | 35 ++++++++++++ .../TestComponent.mappings.txt | 24 +++++++++ .../TestComponent.codegen.cs | 32 +++++++++++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 12 +++++ .../TestComponent.mappings.txt | 13 +++++ .../TestComponent.codegen.cs | 32 +++++++++++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 14 +++++ .../TestComponent.mappings.txt | 13 +++++ .../TestComponent.codegen.cs | 43 +++++++++++++++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 24 +++++++++ .../TestComponent.mappings.txt | 13 +++++ .../TestComponent.codegen.cs | 50 +++++++++++++++++ .../TestComponent.diagnostics.txt | 2 + .../TestComponent.ir.txt | 27 ++++++++++ .../TestComponent.mappings.txt | 13 +++++ .../TestComponent.codegen.cs | 43 +++++++++++++++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 24 +++++++++ .../TestComponent.mappings.txt | 13 +++++ .../TestComponent.codegen.cs | 44 +++++++++++++++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 24 +++++++++ .../TestComponent.mappings.txt | 15 ++++++ .../TestComponent.codegen.cs | 46 ++++++++++++++++ .../TestComponent.ir.txt | 24 +++++++++ .../TestComponent.mappings.txt | 19 +++++++ .../TestComponent.codegen.cs | 46 ++++++++++++++++ .../TestComponent.ir.txt | 24 +++++++++ .../TestComponent.mappings.txt | 19 +++++++ 60 files changed, 1413 insertions(+) create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.diagnostics.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.diagnostics.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.diagnostics.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.diagnostics.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.diagnostics.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.diagnostics.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.diagnostics.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.diagnostics.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.diagnostics.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.diagnostics.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.diagnostics.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.diagnostics.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.mappings.txt diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.codegen.cs new file mode 100644 index 000000000..81831fbed --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.diagnostics.txt new file mode 100644 index 000000000..8cf39c3ec --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,23): Error RZ10016: Attribute 'bind-value:set' was used but no attribute 'bind-value:get' was found. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.ir.txt new file mode 100644 index 000000000..4478df68e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.ir.txt @@ -0,0 +1,21 @@ +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 - global::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 + MarkupElement - (0:0,0 [37] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlContent - (37:0,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (37:0,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n public void UpdateValue(string value) => ParentValue = value;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.mappings.txt new file mode 100644 index 000000000..570939ff8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| +Generated Location: (924:26,7 [124] ) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.codegen.cs new file mode 100644 index 000000000..81831fbed --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.diagnostics.txt new file mode 100644 index 000000000..db0d277a0 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,23): Error RZ10017: The attribute 'bind-value:get' must have a companion 'bind-value:set' attribute. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.ir.txt new file mode 100644 index 000000000..3fb0eb060 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.ir.txt @@ -0,0 +1,23 @@ +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 - global::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 + MarkupElement - (0:0,0 [37] x:\dir\subdir\Test\TestComponent.cshtml) - div + TagHelperDirectiveAttributeParameter - (22:0,22 [11] x:\dir\subdir\Test\TestComponent.cshtml) - bind-value:get - HtmlAttributeValueStyle.DoubleQuotes + LazyIntermediateToken - (22:0,22 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + HtmlContent - (37:0,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (37:0,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n public void UpdateValue(string value) => ParentValue = value;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.mappings.txt new file mode 100644 index 000000000..570939ff8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| +Generated Location: (924:26,7 [124] ) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.codegen.cs new file mode 100644 index 000000000..c3e96e6ea --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.codegen.cs @@ -0,0 +1,47 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: UpdateValue, value: ParentValue), ParentValue); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.diagnostics.txt new file mode 100644 index 000000000..33089ffaa --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,50): Error RZ10015: Attribute '@bind-value:get' must be used with attribute '@bind-value:set'. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.ir.txt new file mode 100644 index 000000000..dc9345adc --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.ir.txt @@ -0,0 +1,33 @@ +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 - global::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 + MarkupElement - (0:0,0 [64] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlAttribute - (18:0,18 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (19:0,19 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (18:0,18 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: UpdateValue, value: ParentValue) + IntermediateToken - - CSharp - , + IntermediateToken - - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlContent - (64:0,64 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (64:0,64 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (73:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (73:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n public void UpdateValue(string value) => ParentValue = value;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.mappings.txt new file mode 100644 index 000000000..2f591a81c --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (19:0,19 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (973:25,19 [11] ) +|ParentValue| + +Source Location: (73:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| +Generated Location: (1442:36,7 [124] ) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.codegen.cs new file mode 100644 index 000000000..ae0050a47 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = ParentValue; + +#line default +#line hidden +#nullable disable + __o = global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: UpdateValue, value: ParentValue), ParentValue); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.diagnostics.txt new file mode 100644 index 000000000..d5b6177cf --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,38): Error RZ10018: Attribute 'bind' can't be used in conjunction with 'bind:get'. +x:\dir\subdir\Test\TestComponent.cshtml(1,63): Error RZ10015: Attribute '@bind:get' must be used with attribute '@bind:set'. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.ir.txt new file mode 100644 index 000000000..31c170b4c --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.ir.txt @@ -0,0 +1,36 @@ +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 - global::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 + MarkupElement - (0:0,0 [77] x:\dir\subdir\Test\TestComponent.cshtml) - div + TagHelperDirectiveAttributeParameter - (37:0,37 [12] x:\dir\subdir\Test\TestComponent.cshtml) - bind:get - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (38:0,38 [11] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (38:0,38 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (13:0,13 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: UpdateValue, value: ParentValue) + IntermediateToken - - CSharp - , + IntermediateToken - - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlContent - (77:0,77 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (77:0,77 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (86:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (86:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n public void UpdateValue(string value) => ParentValue = value;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.mappings.txt new file mode 100644 index 000000000..93de31d63 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.mappings.txt @@ -0,0 +1,23 @@ +Source Location: (38:0,38 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (906:24,38 [11] ) +|ParentValue| + +Source Location: (13:0,13 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1139:32,13 [11] ) +|ParentValue| + +Source Location: (86:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| +Generated Location: (1608:43,7 [124] ) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.codegen.cs new file mode 100644 index 000000000..5cfd50ab3 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.codegen.cs @@ -0,0 +1,47 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, ParentValue); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.diagnostics.txt new file mode 100644 index 000000000..0afd0a4e0 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,44): Error RZ10016: Attribute 'bind-value:set' was used but no attribute 'bind-value:get' was found. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.ir.txt new file mode 100644 index 000000000..0c8b63d10 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.ir.txt @@ -0,0 +1,33 @@ +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 - global::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 + MarkupElement - (0:0,0 [58] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (13:0,13 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , + IntermediateToken - - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlContent - (58:0,58 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (58:0,58 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (67:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (67:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n public void UpdateValue(string value) => ParentValue = value;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.mappings.txt new file mode 100644 index 000000000..a43ef8b40 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (13:0,13 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (967:25,13 [11] ) +|ParentValue| + +Source Location: (67:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| +Generated Location: (1320:36,7 [124] ) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.codegen.cs new file mode 100644 index 000000000..d72073724 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingSetWithAfter/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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: async __value => { await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: UpdateValue, value: ParentValue).InvokeAsync(); await global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: AfterUpdate).InvokeAsync(); }, value: ParentValue), ParentValue); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; + public void AfterUpdate() { } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.diagnostics.txt new file mode 100644 index 000000000..90d2bf3bc --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,68): Error RZ10019: Attribute 'bind:after' can not be used with 'bind:set'. Invoke the code in 'bind:after' inside 'bind:set' instead. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.ir.txt new file mode 100644 index 000000000..07024aaa7 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.ir.txt @@ -0,0 +1,33 @@ +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 - global::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 + MarkupElement - (0:0,0 [82] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlAttribute - (16:0,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (17:0,17 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (16:0,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: async __value => { await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: UpdateValue, value: ParentValue).InvokeAsync(); await global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: AfterUpdate).InvokeAsync(); }, value: ParentValue) + IntermediateToken - - CSharp - , + IntermediateToken - - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlContent - (82:0,82 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (82:0,82 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (91:1,7 [159] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (91:1,7 [159] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n public void UpdateValue(string value) => ParentValue = value;\n public void AfterUpdate() { }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.mappings.txt new file mode 100644 index 000000000..617b1b7c3 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (17:0,17 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (971:25,17 [11] ) +|ParentValue| + +Source Location: (91:1,7 [159] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; + public void AfterUpdate() { } +| +Generated Location: (1738:36,7 [159] ) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; + public void AfterUpdate() { } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.codegen.cs new file mode 100644 index 000000000..d3daef859 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.codegen.cs @@ -0,0 +1,50 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: DoSomething).InvokeAsync(); }, value: ParentValue), ParentValue); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + Task DoSomething() + { + return Task.CompletedTask; + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.ir.txt new file mode 100644 index 000000000..1078a7b86 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.ir.txt @@ -0,0 +1,35 @@ +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 - global::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 + MarkupElement - (0:0,0 [76] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlContent - (68:0,68 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (68:0,68 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlAttribute - (20:0,20 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (21:0,21 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (20:0,20 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: DoSomething).InvokeAsync(); }, value: ParentValue) + IntermediateToken - - CSharp - , + IntermediateToken - - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlContent - (76:1,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (76:1,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (85:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (85:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n Task DoSomething()\n {\n return Task.CompletedTask;\n }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.mappings.txt new file mode 100644 index 000000000..6d6041ab7 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.mappings.txt @@ -0,0 +1,24 @@ +Source Location: (21:0,21 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (975:25,21 [11] ) +|ParentValue| + +Source Location: (85:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + Task DoSomething() + { + return Task.CompletedTask; + } +| +Generated Location: (1590:36,7 [131] ) +| + public string ParentValue { get; set; } = "hi"; + + Task DoSomething() + { + return Task.CompletedTask; + } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.codegen.cs new file mode 100644 index 000000000..abdf3d431 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.codegen.cs @@ -0,0 +1,50 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: ValueChanged, value: ParentValue), ParentValue); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + Task ValueChanged(string value) + { + return Task.CompletedTask; + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.ir.txt new file mode 100644 index 000000000..cb53a16d9 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.ir.txt @@ -0,0 +1,35 @@ +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 - global::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 + MarkupElement - (0:0,0 [79] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlContent - (71:0,71 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (71:0,71 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlAttribute - (24:0,24 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (25:0,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (24:0,24 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: ValueChanged, value: ParentValue) + IntermediateToken - - CSharp - , + IntermediateToken - - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlContent - (79:1,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (79:1,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (88:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (88:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n Task ValueChanged(string value)\n {\n return Task.CompletedTask;\n }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.mappings.txt new file mode 100644 index 000000000..dcb360bcd --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.mappings.txt @@ -0,0 +1,24 @@ +Source Location: (25:0,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (979:25,25 [11] ) +|ParentValue| + +Source Location: (88:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + Task ValueChanged(string value) + { + return Task.CompletedTask; + } +| +Generated Location: (1449:36,7 [144] ) +| + public string ParentValue { get; set; } = "hi"; + + Task ValueChanged(string value) + { + return Task.CompletedTask; + } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.codegen.cs new file mode 100644 index 000000000..ff12c4cd1 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.codegen.cs @@ -0,0 +1,32 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenElement(0, "div"); + __builder.CloseElement(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.diagnostics.txt new file mode 100644 index 000000000..8cf39c3ec --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,23): Error RZ10016: Attribute 'bind-value:set' was used but no attribute 'bind-value:get' was found. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.ir.txt new file mode 100644 index 000000000..b783b3899 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.ir.txt @@ -0,0 +1,12 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [37] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpCode - (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n public void UpdateValue(string value) => ParentValue = value;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.mappings.txt new file mode 100644 index 000000000..29688fb09 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| +Generated Location: (741:21,7 [124] ) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.codegen.cs new file mode 100644 index 000000000..ff12c4cd1 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.codegen.cs @@ -0,0 +1,32 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenElement(0, "div"); + __builder.CloseElement(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.diagnostics.txt new file mode 100644 index 000000000..db0d277a0 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,23): Error RZ10017: The attribute 'bind-value:get' must have a companion 'bind-value:set' attribute. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.ir.txt new file mode 100644 index 000000000..6aa44473d --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.ir.txt @@ -0,0 +1,14 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [37] x:\dir\subdir\Test\TestComponent.cshtml) - div + TagHelperDirectiveAttributeParameter - (22:0,22 [11] x:\dir\subdir\Test\TestComponent.cshtml) - bind-value:get - HtmlAttributeValueStyle.DoubleQuotes + LazyIntermediateToken - (22:0,22 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + CSharpCode - (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n public void UpdateValue(string value) => ParentValue = value;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.mappings.txt new file mode 100644 index 000000000..29688fb09 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| +Generated Location: (741:21,7 [124] ) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.codegen.cs new file mode 100644 index 000000000..8ad953adf --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenElement(0, "div"); + __builder.AddAttribute(1, "myvalue", global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "myevent", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: UpdateValue, value: ParentValue), ParentValue)); + __builder.SetUpdatesAttributeName("myvalue"); + __builder.CloseElement(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.diagnostics.txt new file mode 100644 index 000000000..33089ffaa --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,50): Error RZ10015: Attribute '@bind-value:get' must be used with attribute '@bind-value:set'. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.ir.txt new file mode 100644 index 000000000..c34e4887d --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.ir.txt @@ -0,0 +1,24 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [64] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlAttribute - (18:0,18 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (19:0,19 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (18:0,18 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: UpdateValue, value: ParentValue) + IntermediateToken - - CSharp - , + IntermediateToken - - CSharp - ParentValue + IntermediateToken - - CSharp - ) + CSharpCode - (73:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (73:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n public void UpdateValue(string value) => ParentValue = value;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.mappings.txt new file mode 100644 index 000000000..bcdcdec4f --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindAndParamBindSet/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (73:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| +Generated Location: (1382:32,7 [124] ) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.codegen.cs new file mode 100644 index 000000000..baff0c05d --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.codegen.cs @@ -0,0 +1,50 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenElement(0, "div"); + __builder.AddAttribute(1, "myvalue", global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "myevent", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: UpdateValue, value: ParentValue), ParentValue)); + __builder.SetUpdatesAttributeName("myvalue"); +#nullable restore +#line (1,39)-(1,50) 24 "x:\dir\subdir\Test\TestComponent.cshtml" +__builder.AddContent(3, ParentValue); + +#line default +#line hidden +#nullable disable + __builder.CloseElement(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.diagnostics.txt new file mode 100644 index 000000000..d5b6177cf --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,38): Error RZ10018: Attribute 'bind' can't be used in conjunction with 'bind:get'. +x:\dir\subdir\Test\TestComponent.cshtml(1,63): Error RZ10015: Attribute '@bind:get' must be used with attribute '@bind:set'. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.ir.txt new file mode 100644 index 000000000..e647ba231 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.ir.txt @@ -0,0 +1,27 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [77] x:\dir\subdir\Test\TestComponent.cshtml) - div + TagHelperDirectiveAttributeParameter - (37:0,37 [12] x:\dir\subdir\Test\TestComponent.cshtml) - bind:get - HtmlAttributeValueStyle.DoubleQuotes + CSharpExpression - (38:0,38 [11] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (38:0,38 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (13:0,13 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: UpdateValue, value: ParentValue) + IntermediateToken - - CSharp - , + IntermediateToken - - CSharp - ParentValue + IntermediateToken - - CSharp - ) + CSharpCode - (86:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (86:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n public void UpdateValue(string value) => ParentValue = value;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.mappings.txt new file mode 100644 index 000000000..9fae1fac0 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindValueWithGetSet/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (86:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| +Generated Location: (1550:39,7 [124] ) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.codegen.cs new file mode 100644 index 000000000..a7b078b5b --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenElement(0, "div"); + __builder.AddAttribute(1, "myvalue", global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "myevent", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => ParentValue = __value, ParentValue)); + __builder.SetUpdatesAttributeName("myvalue"); + __builder.CloseElement(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.diagnostics.txt new file mode 100644 index 000000000..0afd0a4e0 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,44): Error RZ10016: Attribute 'bind-value:set' was used but no attribute 'bind-value:get' was found. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.ir.txt new file mode 100644 index 000000000..e6c11d0c8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.ir.txt @@ -0,0 +1,24 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [58] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (13:0,13 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , + IntermediateToken - - CSharp - ParentValue + IntermediateToken - - CSharp - ) + CSharpCode - (67:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (67:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n public void UpdateValue(string value) => ParentValue = value;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.mappings.txt new file mode 100644 index 000000000..08f055fc6 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingBindWithoutSuffixAndParamBindSetWithSuffix/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (67:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| +Generated Location: (1260:32,7 [124] ) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.codegen.cs new file mode 100644 index 000000000..1acaefc38 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.codegen.cs @@ -0,0 +1,44 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenElement(0, "div"); + __builder.AddAttribute(1, "myvalue", global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "myevent", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: async __value => { await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: UpdateValue, value: ParentValue).InvokeAsync(); await global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: AfterUpdate).InvokeAsync(); }, value: ParentValue), ParentValue)); + __builder.SetUpdatesAttributeName("myvalue"); + __builder.CloseElement(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; + public void AfterUpdate() { } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.diagnostics.txt new file mode 100644 index 000000000..90d2bf3bc --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,68): Error RZ10019: Attribute 'bind:after' can not be used with 'bind:set'. Invoke the code in 'bind:after' inside 'bind:set' instead. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.ir.txt new file mode 100644 index 000000000..ab5cbb159 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.ir.txt @@ -0,0 +1,24 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [82] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlAttribute - (16:0,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (17:0,17 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (16:0,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: async __value => { await global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: UpdateValue, value: ParentValue).InvokeAsync(); await global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: AfterUpdate).InvokeAsync(); }, value: ParentValue) + IntermediateToken - - CSharp - , + IntermediateToken - - CSharp - ParentValue + IntermediateToken - - CSharp - ) + CSharpCode - (91:1,7 [159] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (91:1,7 [159] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n public void UpdateValue(string value) => ParentValue = value;\n public void AfterUpdate() { }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.mappings.txt new file mode 100644 index 000000000..8d6028113 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MixingSetWithAfter/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (91:1,7 [159] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; + public void AfterUpdate() { } +| +Generated Location: (1678:32,7 [159] ) +| + public string ParentValue { get; set; } = "hi"; + + public void UpdateValue(string value) => ParentValue = value; + public void AfterUpdate() { } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.codegen.cs new file mode 100644 index 000000000..827d8a220 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.codegen.cs @@ -0,0 +1,46 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenElement(0, "div"); + __builder.AddAttribute(1, "myvalue", global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "myevent", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: DoSomething).InvokeAsync(); }, value: ParentValue), ParentValue)); + __builder.SetUpdatesAttributeName("myvalue"); + __builder.CloseElement(); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + Task DoSomething() + { + return Task.CompletedTask; + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.ir.txt new file mode 100644 index 000000000..a0fd4e682 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.ir.txt @@ -0,0 +1,24 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [76] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlAttribute - (20:0,20 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (21:0,21 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (20:0,20 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: DoSomething).InvokeAsync(); }, value: ParentValue) + IntermediateToken - - CSharp - , + IntermediateToken - - CSharp - ParentValue + IntermediateToken - - CSharp - ) + CSharpCode - (85:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (85:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n Task DoSomething()\n {\n return Task.CompletedTask;\n }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.mappings.txt new file mode 100644 index 000000000..be455fc79 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfterAndSuffix/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (85:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + Task DoSomething() + { + return Task.CompletedTask; + } +| +Generated Location: (1530:32,7 [131] ) +| + public string ParentValue { get; set; } = "hi"; + + Task DoSomething() + { + return Task.CompletedTask; + } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.codegen.cs new file mode 100644 index 000000000..53e1f4a82 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.codegen.cs @@ -0,0 +1,46 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenElement(0, "div"); + __builder.AddAttribute(1, "myvalue", global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "myevent", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: ValueChanged, value: ParentValue), ParentValue)); + __builder.SetUpdatesAttributeName("myvalue"); + __builder.CloseElement(); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + + Task ValueChanged(string value) + { + return Task.CompletedTask; + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.ir.txt new file mode 100644 index 000000000..bbbedfe59 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.ir.txt @@ -0,0 +1,24 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [79] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlAttribute - (24:0,24 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( + LazyIntermediateToken - (25:0,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (24:0,24 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: ValueChanged, value: ParentValue) + IntermediateToken - - CSharp - , + IntermediateToken - - CSharp - ParentValue + IntermediateToken - - CSharp - ) + CSharpCode - (88:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (88:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n Task ValueChanged(string value)\n {\n return Task.CompletedTask;\n }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.mappings.txt new file mode 100644 index 000000000..fed5b9609 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndSuffix/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (88:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; + + Task ValueChanged(string value) + { + return Task.CompletedTask; + } +| +Generated Location: (1389:32,7 [144] ) +| + public string ParentValue { get; set; } = "hi"; + + Task ValueChanged(string value) + { + return Task.CompletedTask; + } +| + From 9da42b2fea02abe6488fe1e00508514fbdbe17ae Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Thu, 17 Feb 2022 10:06:16 -0800 Subject: [PATCH 17/33] renames and test fixes --- .../src/BoundAttributeDescriptorBuilderExtensions.cs | 4 ++-- .../src/Components/ComponentBindLoweringPass.cs | 4 ++-- .../src/Components/ComponentMetadata.cs | 4 ++-- .../TagHelperBoundAttributeDescriptorExtensions.cs | 4 ++-- .../ComponentCodeGenerationTestBase.cs | 6 ------ .../src/BindTagHelperDescriptorProvider.cs | 12 ++++++------ .../src/ComponentTagHelperDescriptorProvider.cs | 2 +- 7 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorBuilderExtensions.cs b/src/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorBuilderExtensions.cs index 27556c9bf..a4efdd39d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorBuilderExtensions.cs @@ -82,14 +82,14 @@ public static void SetPropertyName(this BoundAttributeParameterDescriptorBuilder builder.Metadata[TagHelperMetadata.Common.PropertyName] = propertyName; } - public static void SetBindAttributeAlternative(this BoundAttributeParameterDescriptorBuilder builder) + public static void SetBindAttributeGetSet(this BoundAttributeParameterDescriptorBuilder builder) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } - builder.Metadata[ComponentMetadata.Bind.BindAttributeAlternative] = bool.TrueString; + builder.Metadata[ComponentMetadata.Bind.BindAttributeGetSet] = bool.TrueString; } public static string GetPropertyName(this BoundAttributeParameterDescriptorBuilder builder) diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs index ed1cc6d98..eccb642d5 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs @@ -88,7 +88,7 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte continue; } - if (node.BoundAttributeParameter.Metadata.ContainsKey(ComponentMetadata.Bind.BindAttributeAlternative)) + if (node.BoundAttributeParameter.Metadata.ContainsKey(ComponentMetadata.Bind.BindAttributeGetSet)) { if (!bindEntries.TryGetValue((reference.Parent, node.AttributeNameWithoutParameter), out var existingEntry)) { @@ -455,7 +455,7 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE original, setter, after, - changeAttribute.IsAwaitableDelegateResult(), + changeAttribute.IsDelegateWithAwaitableResult(), valueExpressionTokens, changeExpressionTokens); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMetadata.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMetadata.cs index 8c3595f87..564c9c516 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMetadata.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMetadata.cs @@ -49,7 +49,7 @@ public static class Bind public const string TagHelperKind = "Components.Bind"; - public const string BindAttributeAlternative = "Components.Bind.AlternativeNotation"; + public const string BindAttributeGetSet = "Components.Bind.AlternativeNotation"; public const string FallbackKey = "Components.Bind.Fallback"; @@ -93,7 +93,7 @@ public static class Component public const string DelegateSignatureKey = "Components.DelegateSignature"; - public const string DelegateAwaitableResultKey = "Components.DelegateAwaitableResult"; + public const string DelegateWithAwaitableResultKey = "Components.IsDelegateAwaitableResult"; public const string EventCallbackKey = "Components.EventCallback"; diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/TagHelperBoundAttributeDescriptorExtensions.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/TagHelperBoundAttributeDescriptorExtensions.cs index c67345627..9ca7feaab 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/TagHelperBoundAttributeDescriptorExtensions.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/TagHelperBoundAttributeDescriptorExtensions.cs @@ -17,9 +17,9 @@ public static bool IsDelegateProperty(this BoundAttributeDescriptor attribute) string.Equals(value, bool.TrueString); } - public static bool IsAwaitableDelegateResult(this BoundAttributeDescriptor attribute) + public static bool IsDelegateWithAwaitableResult(this BoundAttributeDescriptor attribute) { - var key = ComponentMetadata.Component.DelegateAwaitableResultKey; + var key = ComponentMetadata.Component.DelegateWithAwaitableResultKey; return attribute.Metadata.TryGetValue(key, out var value) && string.Equals(value, bool.TrueString); diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index 542d04267..c9a461062 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -2751,9 +2751,6 @@ public static class BindAttributes // Assert Assert.Collection(generated.Diagnostics, diagnostic => Assert.Equal("RZ10016", diagnostic.Id)); - - AssertDocumentNodeMatchesBaseline(generated.CodeDocument); - AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); } [Fact] @@ -2783,9 +2780,6 @@ public static class BindAttributes // Assert Assert.Collection(generated.Diagnostics, diagnostic => Assert.Equal("RZ10017", diagnostic.Id)); - - AssertDocumentNodeMatchesBaseline(generated.CodeDocument); - AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); } [Fact] diff --git a/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs b/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs index f22b102e0..d0efb3cde 100644 --- a/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs +++ b/src/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs @@ -203,12 +203,12 @@ private TagHelperDescriptor CreateFallbackBindTagHelper() attribute.BindAttributeParameter(parameter => { parameter.Name = "get"; - parameter.TypeName = typeof(Delegate).FullName; + parameter.TypeName = typeof(object).FullName; parameter.Documentation = ComponentResources.BindTagHelper_Element_Get_Documentation; parameter.SetPropertyName("Get"); - parameter.SetBindAttributeAlternative(); + parameter.SetBindAttributeGetSet(); }); attribute.BindAttributeParameter(parameter => @@ -471,11 +471,11 @@ private List CreateElementBindTagHelpers(List { parameter.Name = "get"; - parameter.TypeName = typeof(Delegate).FullName; + parameter.TypeName = typeof(object).FullName; parameter.Documentation = ComponentResources.BindTagHelper_Element_Get_Documentation; parameter.SetPropertyName("Get"); - parameter.SetBindAttributeAlternative(); + parameter.SetBindAttributeGetSet(); }); a.BindAttributeParameter(parameter => @@ -650,11 +650,11 @@ private List CreateComponentBindTagHelpers(ICollection { parameter.Name = "get"; - parameter.TypeName = typeof(Delegate).FullName; + parameter.TypeName = typeof(object).FullName; parameter.Documentation = ComponentResources.BindTagHelper_Element_Get_Documentation; parameter.SetPropertyName("Get"); - parameter.SetBindAttributeAlternative(); + parameter.SetBindAttributeGetSet(); }); attribute.BindAttributeParameter(parameter => diff --git a/src/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs b/src/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs index 23e6dbd22..cb7d39059 100644 --- a/src/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs +++ b/src/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs @@ -203,7 +203,7 @@ private void CreateProperty(TagHelperDescriptorBuilder builder, IPropertySymbol if (kind == PropertyKind.Delegate) { pb.Metadata.Add(ComponentMetadata.Component.DelegateSignatureKey, bool.TrueString); - pb.Metadata.Add(ComponentMetadata.Component.DelegateAwaitableResultKey, IsAwaitable(property)); + pb.Metadata.Add(ComponentMetadata.Component.DelegateWithAwaitableResultKey, IsAwaitable(property)); } if (HasTypeParameter(property.Type)) From 72f199f4178968fd009253ec651a47939404ff86 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Fri, 11 Mar 2022 17:43:08 +0100 Subject: [PATCH 18/33] Cleanups --- .../Components/ComponentBindLoweringPass.cs | 207 +++++++++--------- 1 file changed, 107 insertions(+), 100 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs index eccb642d5..8b6dbccce 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs @@ -811,7 +811,7 @@ static CSharpExpressionIntermediateNode ExtractEventNodeExpression(TagHelperDire } } - private void RewriteNodesForComponentDelegateBind( + private async void RewriteNodesForComponentDelegateBind( IntermediateToken original, IntermediateToken setter, IntermediateToken after, @@ -842,31 +842,35 @@ private void RewriteNodesForComponentDelegateBind( // // __value => = __value - switch (setter, after, awaitable) + if (setter == null && after == null) { - case (null, null, _): - changeExpressionTokens.Add(new IntermediateToken() - { - Content = $"__value => {original.Content} = __value", - Kind = TokenKind.CSharp, - }); - break; - case (not null, null, _): - changeExpressionTokens.Add(new IntermediateToken() - { - Content = setter.Content, - Kind = TokenKind.CSharp, - }); - break; - case (null, not null, false): + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"__value => {original.Content} = __value", + Kind = TokenKind.CSharp, + }); + } + else if (setter != null && after == null) + { + changeExpressionTokens.Add(new IntermediateToken() + { + Content = setter.Content, + Kind = TokenKind.CSharp, + }); + } + else if (after != null && setter == null) + { + if(!awaitable) + { var syncAfterExpression = $"{ComponentsApi.RuntimeHelpers.InvokeSynchronousDelegate}({after.Content});"; changeExpressionTokens.Add(new IntermediateToken() { Content = $"__value => {{ {original.Content} = __value; {syncAfterExpression} }}", Kind = TokenKind.CSharp, }); - break; - case (null, not null, true): + } + else + { var asyncAfterExpression = $"{ComponentsApi.RuntimeHelpers.InvokeAsynchronousDelegate}({after.Content});"; changeExpressionTokens.Add(new IntermediateToken() { @@ -874,15 +878,16 @@ private void RewriteNodesForComponentDelegateBind( Content = $"async __value => {{ {original.Content} = __value; await {asyncAfterExpression} }}", Kind = TokenKind.CSharp, }); - break; - default: - // Treat this as the original case, since we don't support bind:set and bind:after simultaneously, we will produce an error. - changeExpressionTokens.Add(new IntermediateToken() - { - Content = $"__value => {original.Content} = __value", - Kind = TokenKind.CSharp, - }); - break; + } + } + else + { + // Treat this as the original case, since we don't support bind:set and bind:after simultaneously, we will produce an error. + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"__value => {original.Content} = __value", + Kind = TokenKind.CSharp, + }); } } @@ -905,43 +910,44 @@ private void RewriteNodesForComponentEventCallbackBind( Kind = TokenKind.CSharp }); - switch ((setter, after)) + if (setter == null && after == null) { - case (null, null): - // no bind:set nor bind:after, use the same code generation as before - changeExpressionTokens.Add(new IntermediateToken() - { - Content = $"__value => {original.Content} = __value", - Kind = TokenKind.CSharp - }); - break; - case (not null, null): - // bind:set only - changeExpressionTokens.Add(new IntermediateToken() - { - Content = setter.Content, - Kind = TokenKind.CSharp - }); - break; - case (null, not null): - // bind:after only - var afterToEventCallback = $"global::{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateMethod}(this, callback: {after.Content})"; - changeExpressionTokens.Add(new IntermediateToken() - { - Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: __value => {{ {original.Content} = __value; return {afterToEventCallback}.InvokeAsync(); }}, value: {original.Content})", - Kind = TokenKind.CSharp - }); - break; - case (not null, not null): - // bind:set and bind:after create the code even though we disallow this combination through a diagnostic - var setToEventCallback = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: {setter.Content}, value: {original.Content})"; - afterToEventCallback = $"global::{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateMethod}(this, callback: {after.Content})"; - changeExpressionTokens.Add(new IntermediateToken() - { - Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: async __value => {{ await {setToEventCallback}.InvokeAsync(); await {afterToEventCallback}.InvokeAsync(); }}, value: {original.Content})", - Kind = TokenKind.CSharp - }); - break; + // no bind:set nor bind:after, assign to the bound expression + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"__value => {original.Content} = __value", + Kind = TokenKind.CSharp + }); + + }else if(setter != null && after == null) + { + // bind:set only + changeExpressionTokens.Add(new IntermediateToken() + { + Content = setter.Content, + Kind = TokenKind.CSharp + }); + } + else if (setter == null && after != null) + { + // bind:after only + var afterToEventCallback = $"global::{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateMethod}(this, callback: {after.Content})"; + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: __value => {{ {original.Content} = __value; return {afterToEventCallback}.InvokeAsync(); }}, value: {original.Content})", + Kind = TokenKind.CSharp + }); + } + else + { + // bind:set and bind:after create the code even though we disallow this combination through a diagnostic + var setToEventCallback = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: {setter.Content}, value: {original.Content})"; + var afterToEventCallback = $"global::{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateMethod}(this, callback: {after.Content})"; + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: async __value => {{ await {setToEventCallback}.InvokeAsync(); await {afterToEventCallback}.InvokeAsync(); }}, value: {original.Content})", + Kind = TokenKind.CSharp + }); } changeExpressionTokens.Add(new IntermediateToken() @@ -1022,43 +1028,44 @@ private void RewriteNodesForElementEventCallbackBind( Kind = TokenKind.CSharp }); - switch ((setter, after)) + if(setter == null && after == null) { - case (null, null): - // no bind:set nor bind:after, use the same code generation as before - changeExpressionTokens.Add(new IntermediateToken() - { - Content = $"__value => {original.Content} = __value", - Kind = TokenKind.CSharp - }); - break; - case (not null, null): - // bind:set only - changeExpressionTokens.Add(new IntermediateToken() - { - Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: {setter.Content}, value: {original.Content})", - Kind = TokenKind.CSharp - }); - break; - case (null, not null): - // bind:after only - var afterToEventCallback = $"global::{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateMethod}(this, callback: {after.Content})"; - changeExpressionTokens.Add(new IntermediateToken() - { - Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: __value => {{ {original.Content} = __value; return {afterToEventCallback}.InvokeAsync(); }}, value: {original.Content})", - Kind = TokenKind.CSharp - }); - break; - case (not null, not null): - // bind:set and bind:after create the code even though we disallow this combination through a diagnostic - var setToEventCallback = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: {setter.Content}, value: {original.Content})"; - afterToEventCallback = $"global::{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateMethod}(this, callback: {after.Content})"; - changeExpressionTokens.Add(new IntermediateToken() - { - Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: async __value => {{ await {setToEventCallback}.InvokeAsync(); await {afterToEventCallback}.InvokeAsync(); }}, value: {original.Content})", - Kind = TokenKind.CSharp - }); - break; + // no bind:set nor bind:after, , assign to the bound expression + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"__value => {original.Content} = __value", + Kind = TokenKind.CSharp + }); + } + else if (setter != null && after == null) + { + // bind:set only + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: {setter.Content}, value: {original.Content})", + Kind = TokenKind.CSharp + }); + } + else if(setter == null && after != null) + { + // bind:after only + var afterToEventCallback = $"global::{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateMethod}(this, callback: {after.Content})"; + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: __value => {{ {original.Content} = __value; return {afterToEventCallback}.InvokeAsync(); }}, value: {original.Content})", + Kind = TokenKind.CSharp + }); + } + else + { + // bind:set and bind:after create the code even though we disallow this combination through a diagnostic + var setToEventCallback = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: {setter.Content}, value: {original.Content})"; + var afterToEventCallback = $"global::{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateMethod}(this, callback: {after.Content})"; + changeExpressionTokens.Add(new IntermediateToken() + { + Content = $"{ComponentsApi.RuntimeHelpers.CreateInferredEventCallback}(this, callback: async __value => {{ await {setToEventCallback}.InvokeAsync(); await {afterToEventCallback}.InvokeAsync(); }}, value: {original.Content})", + Kind = TokenKind.CSharp + }); } changeExpressionTokens.Add(new IntermediateToken() From 2dffd556e4c9a9e0ab74acc152226107bdf1ab71 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Fri, 11 Mar 2022 18:00:41 +0100 Subject: [PATCH 19/33] Add additional test asserts for the new parameters --- .../BindTagHelperDescriptorProviderTest.cs | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/src/Microsoft.CodeAnalysis.Razor/test/BindTagHelperDescriptorProviderTest.cs b/src/Microsoft.CodeAnalysis.Razor/test/BindTagHelperDescriptorProviderTest.cs index d4cadd66e..aa58a273f 100644 --- a/src/Microsoft.CodeAnalysis.Razor/test/BindTagHelperDescriptorProviderTest.cs +++ b/src/Microsoft.CodeAnalysis.Razor/test/BindTagHelperDescriptorProviderTest.cs @@ -563,6 +563,72 @@ static void AssertAttribute(BoundAttributeDescriptor attribute) Assert.False(parameter.IsStringProperty); Assert.False(parameter.IsBooleanProperty); Assert.False(parameter.IsEnum); + + parameter = Assert.Single(attribute.BoundAttributeParameters, a => a.Name.Equals("get")); + + // Invariants + Assert.Empty(parameter.Diagnostics); + Assert.False(parameter.HasErrors); + Assert.Equal(ComponentMetadata.Bind.TagHelperKind, parameter.Kind); + Assert.False(parameter.IsDefaultKind()); + + Assert.Equal( + "Specifies the expression to use for binding the value to the attribute.", + parameter.Documentation); + + Assert.Equal("get", parameter.Name); + Assert.Equal("Get", parameter.GetPropertyName()); + Assert.Equal(":get", parameter.DisplayName); + + // Defined from the property type + Assert.Equal("System.Object", parameter.TypeName); + Assert.False(parameter.IsStringProperty); + Assert.False(parameter.IsBooleanProperty); + Assert.False(parameter.IsEnum); + + parameter = Assert.Single(attribute.BoundAttributeParameters, a => a.Name.Equals("set")); + + // Invariants + Assert.Empty(parameter.Diagnostics); + Assert.False(parameter.HasErrors); + Assert.Equal(ComponentMetadata.Bind.TagHelperKind, parameter.Kind); + Assert.False(parameter.IsDefaultKind()); + + Assert.Equal( + "Specifies the expression to use for updating the bound value when a new value is available.", + parameter.Documentation); + + Assert.Equal("set", parameter.Name); + Assert.Equal("Set", parameter.GetPropertyName()); + Assert.Equal(":set", parameter.DisplayName); + + // Defined from the property type + Assert.Equal("System.Delegate", parameter.TypeName); + Assert.False(parameter.IsStringProperty); + Assert.False(parameter.IsBooleanProperty); + Assert.False(parameter.IsEnum); + + parameter = Assert.Single(attribute.BoundAttributeParameters, a => a.Name.Equals("after")); + + // Invariants + Assert.Empty(parameter.Diagnostics); + Assert.False(parameter.HasErrors); + Assert.Equal(ComponentMetadata.Bind.TagHelperKind, parameter.Kind); + Assert.False(parameter.IsDefaultKind()); + + Assert.Equal( + "Specifies an action to run after the new value has been set.", + parameter.Documentation); + + Assert.Equal("after", parameter.Name); + Assert.Equal("After", parameter.GetPropertyName()); + Assert.Equal(":after", parameter.DisplayName); + + // Defined from the property type + Assert.Equal("System.Delegate", parameter.TypeName); + Assert.False(parameter.IsStringProperty); + Assert.False(parameter.IsBooleanProperty); + Assert.False(parameter.IsEnum); } } From d2d4b4d73ab6bb64467469a687b02f280106df52 Mon Sep 17 00:00:00 2001 From: jacalvar Date: Fri, 11 Mar 2022 18:24:45 +0100 Subject: [PATCH 20/33] Remove unnecessary change to ComponentAttributeIntermediateNode and update baselines --- .../src/Intermediate/ComponentAttributeIntermediateNode.cs | 2 +- .../TestComponent.ir.txt | 2 +- .../TestComponent.ir.txt | 6 +++--- .../TestComponent.ir.txt | 4 ++-- .../TestComponent.ir.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.ir.txt | 2 +- .../TestComponent.codegen.cs | 6 +++--- .../TestComponent.ir.txt | 6 +++--- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 4 ++-- .../TestComponent.ir.txt | 4 ++-- .../TestComponent.codegen.cs | 2 +- .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 2 +- 15 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ComponentAttributeIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ComponentAttributeIntermediateNode.cs index 8042285e6..d160623c6 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ComponentAttributeIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ComponentAttributeIntermediateNode.cs @@ -97,7 +97,7 @@ public ComponentAttributeIntermediateNode(TagHelperDirectiveAttributeParameterIn throw new ArgumentNullException(nameof(directiveAttributeParameterNode)); } - AttributeName = directiveAttributeParameterNode.AttributeName; + AttributeName = directiveAttributeParameterNode.AttributeNameWithoutParameter; AttributeStructure = directiveAttributeParameterNode.AttributeStructure; BoundAttribute = directiveAttributeParameterNode.BoundAttribute; PropertyName = directiveAttributeParameterNode.BoundAttribute.GetPropertyName(); diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt index b04c3f7eb..d6aeeca39 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt @@ -18,7 +18,7 @@ Document - HtmlContent - (42:0,42 [2] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (42:0,42 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n MarkupElement - (44:1,0 [64] x:\dir\subdir\Test\TestComponent.cshtml) - input - ComponentAttribute - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onclick:preventDefault - onclick - AttributeStructure.DoubleQuotes + ComponentAttribute - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - onclick - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true HtmlAttribute - - @onclick:preventDefault - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt index dd3b7a90d..659a6ce5c 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt @@ -25,13 +25,13 @@ Document - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, LazyIntermediateToken - (62:1,18 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - () => Foo = false IntermediateToken - - CSharp - ) - ComponentAttribute - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus:preventDefault - onfocus - AttributeStructure.DoubleQuotes + ComponentAttribute - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - onfocus - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true - ComponentAttribute - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - onclick:stopPropagation - onclick - AttributeStructure.DoubleQuotes + ComponentAttribute - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - onclick - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Foo - ComponentAttribute - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus:stopPropagation - onfocus - AttributeStructure.DoubleQuotes + ComponentAttribute - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - onfocus - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - false HtmlContent - (193:1,149 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt index 750792ef0..514314786 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt @@ -20,5 +20,5 @@ Document - MarkupElement - (44:1,0 [74] x:\dir\subdir\Test\TestComponent.cshtml) - button HtmlContent - (101:1,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (101:1,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Click Me - ComponentAttribute - - onclick:preventDefault - onclick - AttributeStructure.Minimized - ComponentAttribute - - onclick:stopPropagation - onclick - AttributeStructure.Minimized + ComponentAttribute - - onclick - onclick - AttributeStructure.Minimized + ComponentAttribute - - onclick - onclick - AttributeStructure.Minimized diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt index e25d823c9..ee6d0d2be 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt @@ -23,7 +23,7 @@ Document - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, LazyIntermediateToken - (61:1,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnFocus IntermediateToken - - CSharp - ) - ComponentAttribute - (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus:preventDefault - onfocus - AttributeStructure.DoubleQuotes + ComponentAttribute - (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - onfocus - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ShouldPreventDefault() HtmlContent - (121:1,77 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs index 19c9d4481..32084f8b0 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs @@ -21,7 +21,7 @@ public partial class TestComponent : global::Microsoft.AspNetCore.Components.Com protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __builder.OpenElement(0, "input"); - __builder.AddEventPreventDefaultAttribute(1, "onclick:preventDefault", + __builder.AddEventPreventDefaultAttribute(1, "onclick", #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" true diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt index 3f792f273..08cc6d946 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt @@ -9,7 +9,7 @@ Document - ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree MarkupElement - (44:1,0 [64] x:\dir\subdir\Test\TestComponent.cshtml) - input - ComponentAttribute - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onclick:preventDefault - onclick - AttributeStructure.DoubleQuotes + ComponentAttribute - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - onclick - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true HtmlAttribute - - @onclick:preventDefault - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs index c5ecb1c13..0f689e9f3 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs @@ -30,7 +30,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line hidden #nullable disable )); - __builder.AddEventPreventDefaultAttribute(2, "onfocus:preventDefault", + __builder.AddEventPreventDefaultAttribute(2, "onfocus", #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" true @@ -39,7 +39,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line hidden #nullable disable ); - __builder.AddEventStopPropagationAttribute(3, "onclick:stopPropagation", + __builder.AddEventStopPropagationAttribute(3, "onclick", #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" Foo @@ -48,7 +48,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line hidden #nullable disable ); - __builder.AddEventStopPropagationAttribute(4, "onfocus:stopPropagation", + __builder.AddEventStopPropagationAttribute(4, "onfocus", #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" false diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt index 516039b84..234e4d8f8 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt @@ -16,13 +16,13 @@ Document - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, LazyIntermediateToken - (62:1,18 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - () => Foo = false IntermediateToken - - CSharp - ) - ComponentAttribute - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus:preventDefault - onfocus - AttributeStructure.DoubleQuotes + ComponentAttribute - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - onfocus - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true - ComponentAttribute - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - onclick:stopPropagation - onclick - AttributeStructure.DoubleQuotes + ComponentAttribute - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - onclick - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Foo - ComponentAttribute - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus:stopPropagation - onfocus - AttributeStructure.DoubleQuotes + ComponentAttribute - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - onfocus - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - false CSharpCode - (202:2,7 [30] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt index cbcc1d351..72ae01501 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt @@ -2,7 +2,7 @@ Source Location: (202:2,7 [30] x:\dir\subdir\Test\TestComponent.cshtml) | bool Foo { get; set; } | -Generated Location: (2284:65,7 [30] ) +Generated Location: (2237:65,7 [30] ) | bool Foo { get; set; } | diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.codegen.cs index 91cf00e25..5b3af0457 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.codegen.cs @@ -21,8 +21,8 @@ public partial class TestComponent : global::Microsoft.AspNetCore.Components.Com protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __builder.OpenElement(0, "button"); - __builder.AddEventPreventDefaultAttribute(1, "onclick:preventDefault", true); - __builder.AddEventStopPropagationAttribute(2, "onclick:stopPropagation", true); + __builder.AddEventPreventDefaultAttribute(1, "onclick", true); + __builder.AddEventStopPropagationAttribute(2, "onclick", true); __builder.AddContent(3, "Click Me"); __builder.CloseElement(); } diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt index 54e49dea3..8d0efc3f0 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt @@ -11,5 +11,5 @@ Document - MarkupElement - (44:1,0 [74] x:\dir\subdir\Test\TestComponent.cshtml) - button HtmlContent - (101:1,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (101:1,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Click Me - ComponentAttribute - - onclick:preventDefault - onclick - AttributeStructure.Minimized - ComponentAttribute - - onclick:stopPropagation - onclick - AttributeStructure.Minimized + ComponentAttribute - - onclick - onclick - AttributeStructure.Minimized + ComponentAttribute - - onclick - onclick - AttributeStructure.Minimized diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.codegen.cs index 262a11ef3..f0ab67e1a 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.codegen.cs @@ -30,7 +30,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line hidden #nullable disable )); - __builder.AddEventPreventDefaultAttribute(2, "onfocus:preventDefault", + __builder.AddEventPreventDefaultAttribute(2, "onfocus", #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" ShouldPreventDefault() diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt index 3785cfdf5..366872695 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt @@ -14,7 +14,7 @@ Document - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, LazyIntermediateToken - (61:1,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnFocus IntermediateToken - - CSharp - ) - ComponentAttribute - (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus:preventDefault - onfocus - AttributeStructure.DoubleQuotes + ComponentAttribute - (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - onfocus - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ShouldPreventDefault() CSharpCode - (130:2,7 [95] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.mappings.txt index 4028e0b27..9f974409b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.mappings.txt @@ -4,7 +4,7 @@ Source Location: (130:2,7 [95] x:\dir\subdir\Test\TestComponent.cshtml) bool ShouldPreventDefault() { return false; } | -Generated Location: (1552:46,7 [95] ) +Generated Location: (1537:46,7 [95] ) | void OnFocus(FocusEventArgs e) { } From ac025036e740c4808d575a5df4abbf07932b2b3b Mon Sep 17 00:00:00 2001 From: jacalvar Date: Mon, 14 Mar 2022 17:05:24 +0100 Subject: [PATCH 21/33] Fix bad refactoring --- .../Components/ComponentBindLoweringPass.cs | 181 +++++------------- 1 file changed, 52 insertions(+), 129 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs index 8b6dbccce..5409d84b8 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs @@ -368,12 +368,12 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE } } - var original = GetAttributeContent((IntermediateNode)node ?? getNode); + var original = GetAttributeContent(bindEntry.GetEffectiveBindNode()); if (string.IsNullOrEmpty(original.Content)) { // This can happen in error cases, the parser will already have flagged this // as an error, so ignore it. - return new[] { node }; + return new[] { bindEntry.GetEffectiveBindNode() }; } // Look for a format. If we find one then we need to pass the format into the @@ -383,22 +383,13 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE { format = GetAttributeContent(bindEntry.BindFormatNode); } - else if (node?.TagHelper?.GetFormat() != null) + else if (bindEntry.GetEffectiveNodeTagHelperDescriptor()?.GetFormat() != null) { // We may have a default format if one is associated with the field type. format = new IntermediateToken() { Kind = TokenKind.CSharp, - Content = "\"" + node.TagHelper.GetFormat() + "\"", - }; - } - else if (getNode?.TagHelper?.GetFormat() != null) - { - // We may have a default format if one is associated with the field type. - format = new IntermediateToken() - { - Kind = TokenKind.CSharp, - Content = "\"" + getNode.TagHelper.GetFormat() + "\"", + Content = "\"" + bindEntry.GetEffectiveNodeTagHelperDescriptor().GetFormat() + "\"", }; } @@ -409,16 +400,7 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE { culture = GetAttributeContent(bindEntry.BindCultureNode); } - else if (node?.TagHelper?.IsInvariantCultureBindTagHelper() == true) - { - // We may have a default invariant culture if one is associated with the field type. - culture = new IntermediateToken() - { - Kind = TokenKind.CSharp, - Content = $"global::{typeof(CultureInfo).FullName}.{nameof(CultureInfo.InvariantCulture)}", - }; - } - else if (getNode?.TagHelper?.IsInvariantCultureBindTagHelper() == true) + else if (bindEntry.GetEffectiveNodeTagHelperDescriptor()?.IsInvariantCultureBindTagHelper() == true) { // We may have a default invariant culture if one is associated with the field type. culture = new IntermediateToken() @@ -480,7 +462,7 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE changeExpressionTokens); } - var targetNode = (IntermediateNode)node ?? getNode; + var targetNode = bindEntry.GetEffectiveBindNode(); if (parent is MarkupElementIntermediateNode) { @@ -488,7 +470,7 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE { Annotations = { - [ComponentMetadata.Common.OriginalAttributeName] = node?.OriginalAttributeName ?? getNode?.OriginalAttributeName, + [ComponentMetadata.Common.OriginalAttributeName] = bindEntry.GetOriginalAttributeName(), }, AttributeName = valueAttributeName, Source = targetNode.Source, @@ -512,7 +494,7 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE { Annotations = { - [ComponentMetadata.Common.OriginalAttributeName] = node?.OriginalAttributeName ?? getNode?.OriginalAttributeName, + [ComponentMetadata.Common.OriginalAttributeName] = bindEntry.GetOriginalAttributeName(), }, AttributeName = changeAttributeName, AttributeNameExpression = changeAttributeNode, @@ -534,37 +516,13 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE } else { - ComponentAttributeIntermediateNode valueNode; - if (node != null) - { - valueNode = new ComponentAttributeIntermediateNode(node) - { - Annotations = - { - [ComponentMetadata.Common.OriginalAttributeName] = node.OriginalAttributeName, - }, - AttributeName = valueAttributeName, - BoundAttribute = valueAttribute, // Might be null if it doesn't match a component attribute - PropertyName = valueAttribute?.GetPropertyName(), - TagHelper = valueAttribute == null ? null : node.TagHelper, - TypeName = valueAttribute?.IsWeaklyTyped() == false ? valueAttribute.TypeName : null, - }; - } - else - { - valueNode = new ComponentAttributeIntermediateNode(getNode) - { - Annotations = - { - [ComponentMetadata.Common.OriginalAttributeName] = getNode.OriginalAttributeName, - }, - AttributeName = valueAttributeName, - BoundAttribute = valueAttribute, // Might be null if it doesn't match a component attribute - PropertyName = valueAttribute?.GetPropertyName(), - TagHelper = valueAttribute == null ? null : getNode.TagHelper, - TypeName = valueAttribute?.IsWeaklyTyped() == false ? valueAttribute.TypeName : null, - }; - } + ComponentAttributeIntermediateNode valueNode = node != null ? new ComponentAttributeIntermediateNode(node) : new ComponentAttributeIntermediateNode(getNode); + valueNode.Annotations[ComponentMetadata.Common.OriginalAttributeName] = bindEntry.GetOriginalAttributeName(); + valueNode.AttributeName = valueAttributeName; + valueNode.BoundAttribute = valueAttribute; // Might be null if it doesn't match a component attribute + valueNode.PropertyName = valueAttribute?.GetPropertyName(); + valueNode.TagHelper = valueAttribute == null ? null : bindEntry.GetEffectiveNodeTagHelperDescriptor(); + valueNode.TypeName = valueAttribute?.IsWeaklyTyped() == false ? valueAttribute.TypeName : null; valueNode.Children.Clear(); valueNode.Children.Add(new CSharpExpressionIntermediateNode()); @@ -573,37 +531,13 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE valueNode.Children[0].Children.Add(valueExpressionTokens[i]); } - ComponentAttributeIntermediateNode changeNode = null; - if (node != null) - { - changeNode = new ComponentAttributeIntermediateNode(node) - { - Annotations = - { - [ComponentMetadata.Common.OriginalAttributeName] = node.OriginalAttributeName, - }, - AttributeName = changeAttributeName, - BoundAttribute = changeAttribute, // Might be null if it doesn't match a component attribute - PropertyName = changeAttribute?.GetPropertyName(), - TagHelper = changeAttribute == null ? null : node.TagHelper, - TypeName = changeAttribute?.IsWeaklyTyped() == false ? changeAttribute.TypeName : null, - }; - } - else - { - changeNode = new ComponentAttributeIntermediateNode(getNode) - { - Annotations = - { - [ComponentMetadata.Common.OriginalAttributeName] = getNode.OriginalAttributeName, - }, - AttributeName = changeAttributeName, - BoundAttribute = changeAttribute, // Might be null if it doesn't match a component attribute - PropertyName = changeAttribute?.GetPropertyName(), - TagHelper = changeAttribute == null ? null : getNode.TagHelper, - TypeName = changeAttribute?.IsWeaklyTyped() == false ? changeAttribute.TypeName : null, - }; - } + var changeNode = node != null ? new ComponentAttributeIntermediateNode(node) : new ComponentAttributeIntermediateNode(getNode); + changeNode.Annotations[ComponentMetadata.Common.OriginalAttributeName] = bindEntry.GetOriginalAttributeName(); + changeNode.AttributeName = changeAttributeName; + changeNode.BoundAttribute = changeAttribute; // Might be null if it doesn't match a component attribute + changeNode.PropertyName = changeAttribute?.GetPropertyName(); + changeNode.TagHelper = changeAttribute == null ? null : bindEntry.GetEffectiveNodeTagHelperDescriptor(); + changeNode.TypeName = changeAttribute?.IsWeaklyTyped() == false ? changeAttribute.TypeName : null; changeNode.Children.Clear(); changeNode.Children.Add(new CSharpExpressionIntermediateNode()); @@ -617,36 +551,14 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE ComponentAttributeIntermediateNode expressionNode = null; if (expressionAttribute != null) { - if(node != null) - { - expressionNode = new ComponentAttributeIntermediateNode(node) - { - Annotations = - { - [ComponentMetadata.Common.OriginalAttributeName] = node.OriginalAttributeName, - }, - AttributeName = expressionAttributeName, - BoundAttribute = expressionAttribute, - PropertyName = expressionAttribute.GetPropertyName(), - TagHelper = node.TagHelper, - TypeName = expressionAttribute.IsWeaklyTyped() ? null : expressionAttribute.TypeName, - }; - } - else - { - expressionNode = new ComponentAttributeIntermediateNode(getNode) - { - Annotations = - { - [ComponentMetadata.Common.OriginalAttributeName] = getNode.OriginalAttributeName, - }, - AttributeName = expressionAttributeName, - BoundAttribute = expressionAttribute, - PropertyName = expressionAttribute.GetPropertyName(), - TagHelper = getNode.TagHelper, - TypeName = expressionAttribute.IsWeaklyTyped() ? null : expressionAttribute.TypeName, - }; - } + expressionNode = node != null ? new ComponentAttributeIntermediateNode(node) : new ComponentAttributeIntermediateNode(getNode); + expressionNode.Annotations[ComponentMetadata.Common.OriginalAttributeName] = bindEntry.GetOriginalAttributeName(); + expressionNode.AttributeName = expressionAttributeName; + expressionNode.BoundAttribute = expressionAttribute; + expressionNode.PropertyName = expressionAttribute.GetPropertyName(); + expressionNode.TagHelper = bindEntry.GetEffectiveNodeTagHelperDescriptor(); + expressionNode.TypeName = expressionAttribute.IsWeaklyTyped() ? null : expressionAttribute.TypeName; + expressionNode.Children.Clear(); expressionNode.Children.Add(new CSharpExpressionIntermediateNode()); expressionNode.Children[0].Children.Add(new IntermediateToken() @@ -664,7 +576,7 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE private bool TryParseBindAttribute(BindEntry bindEntry, out string valueAttributeName) { - var attributeName = bindEntry.BindNode?.AttributeName ?? bindEntry.BindGetNode?.AttributeNameWithoutParameter; + var attributeName = bindEntry.GetEffectiveBindNodeAttributeName(); valueAttributeName = null; if (attributeName == "bind") @@ -706,9 +618,7 @@ private bool TryComputeAttributeNames( // generated to match a specific tag and has metadata that identify the attributes. // // We expect 1 bind tag helper per-node. - var node = bindEntry.BindNode; - var getNode = bindEntry.BindGetNode; - var attributeName = node?.AttributeName ?? getNode?.AttributeNameWithoutParameter; + var attributeName = bindEntry.GetEffectiveBindNodeAttributeName(); // Even though some of our 'bind' tag helpers specify the attribute names, they // should still satisfy one of the valid syntaxes. @@ -717,14 +627,14 @@ private bool TryComputeAttributeNames( return false; } - valueAttributeName = node?.TagHelper.GetValueAttributeName() ?? getNode?.TagHelper.GetValueAttributeName() ?? valueAttributeName; + valueAttributeName = bindEntry.GetEffectiveNodeTagHelperDescriptor()?.GetValueAttributeName() ?? valueAttributeName; // If there an attribute that specifies the event like @bind:event="oninput", // that should be preferred. Otherwise, use the one from the tag helper. if (bindEntry.BindEventNode == null) { // @bind:event not specified - changeAttributeName = node?.TagHelper.GetChangeAttributeName() ?? getNode?.TagHelper.GetChangeAttributeName(); + changeAttributeName = bindEntry.GetEffectiveBindNodeChangeAttributeName(); } else if (TryExtractEventNodeStaticText(bindEntry.BindEventNode, out var text)) { @@ -737,7 +647,7 @@ private bool TryComputeAttributeNames( changeAttributeNode = ExtractEventNodeExpression(bindEntry.BindEventNode); } - expressionAttributeName = node?.TagHelper.GetExpressionAttributeName() ?? getNode?.TagHelper.GetExpressionAttributeName(); + expressionAttributeName = bindEntry.GetEffectiveBindNodeExpressionAttributeName(); // We expect 0-1 components per-node. var componentTagHelper = (parent as ComponentIntermediateNode)?.Component; @@ -860,7 +770,7 @@ private async void RewriteNodesForComponentDelegateBind( } else if (after != null && setter == null) { - if(!awaitable) + if (!awaitable) { var syncAfterExpression = $"{ComponentsApi.RuntimeHelpers.InvokeSynchronousDelegate}({after.Content});"; changeExpressionTokens.Add(new IntermediateToken() @@ -919,7 +829,8 @@ private void RewriteNodesForComponentEventCallbackBind( Kind = TokenKind.CSharp }); - }else if(setter != null && after == null) + } + else if (setter != null && after == null) { // bind:set only changeExpressionTokens.Add(new IntermediateToken() @@ -1028,7 +939,7 @@ private void RewriteNodesForElementEventCallbackBind( Kind = TokenKind.CSharp }); - if(setter == null && after == null) + if (setter == null && after == null) { // no bind:set nor bind:after, , assign to the bound expression changeExpressionTokens.Add(new IntermediateToken() @@ -1046,7 +957,7 @@ private void RewriteNodesForElementEventCallbackBind( Kind = TokenKind.CSharp }); } - else if(setter == null && after != null) + else if (setter == null && after != null) { // bind:after only var afterToEventCallback = $"global::{ComponentsApi.EventCallback.FactoryAccessor}.{ComponentsApi.EventCallbackFactory.CreateMethod}(this, callback: {after.Content})"; @@ -1175,5 +1086,17 @@ public BindEntry(IntermediateNodeReference bindNodeReference) public TagHelperDirectiveAttributeParameterIntermediateNode BindSetNode { get; set; } public TagHelperDirectiveAttributeParameterIntermediateNode BindAfterNode { get; set; } + + public IntermediateNode GetEffectiveBindNode() => (IntermediateNode)BindNode ?? BindGetNode; + + public TagHelperDescriptor GetEffectiveNodeTagHelperDescriptor() => BindNode?.TagHelper ?? BindGetNode?.TagHelper; + + public string GetOriginalAttributeName() => BindNode?.OriginalAttributeName ?? BindGetNode?.OriginalAttributeName; + + public string GetEffectiveBindNodeAttributeName() => BindNode?.AttributeName ?? BindGetNode?.AttributeNameWithoutParameter; + + public string GetEffectiveBindNodeChangeAttributeName() => BindNode?.TagHelper.GetChangeAttributeName() ?? BindGetNode?.TagHelper.GetChangeAttributeName(); + + internal string GetEffectiveBindNodeExpressionAttributeName() => BindNode?.TagHelper.GetExpressionAttributeName() ?? BindGetNode?.TagHelper.GetExpressionAttributeName(); } } From 39483c80f35754a131c504207d26ce7cc9825724 Mon Sep 17 00:00:00 2001 From: jacalvar Date: Mon, 14 Mar 2022 18:18:03 +0100 Subject: [PATCH 22/33] Undo accidental test renames --- .../ComponentCodeGenerationTestBase.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index c9a461062..3a640a175 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -1051,7 +1051,7 @@ public class ComponentWithEditorRequiredChildContent : ComponentBase #region Bind [Fact] - public void BindToComponent_WithMatchingProperties() + public void BindToComponent_SpecifiesValue_WithMatchingProperties() { // Arrange AdditionalSyntaxTrees.Add(Parse(@" @@ -1242,7 +1242,7 @@ public class MyComponent : ComponentBase } [Fact] - public void BindToComponent_WithoutMatchingProperties() + public void BindToComponent_SpecifiesValue_WithoutMatchingProperties() { // Arrange AdditionalSyntaxTrees.Add(Parse(@" @@ -1270,7 +1270,7 @@ public class MyComponent : ComponentBase } [Fact] - public void BindToComponentAndChangeEvent_WithMatchingProperties() + public void BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties() { // Arrange AdditionalSyntaxTrees.Add(Parse(@" @@ -1302,7 +1302,7 @@ public class MyComponent : ComponentBase } [Fact] - public void BindToComponentAndChangeEvent_WithoutMatchingProperties() + public void BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties() { // Arrange AdditionalSyntaxTrees.Add(Parse(@" @@ -1329,7 +1329,7 @@ public class MyComponent : ComponentBase } [Fact] - public void BindToComponentAndExpression() + public void BindToComponent_SpecifiesValueAndExpression() { // Arrange AdditionalSyntaxTrees.Add(Parse(@" @@ -1403,7 +1403,7 @@ public class MyComponent : ComponentBase } [Fact] - public void BindToComponentAndExpression_TypeChecked() + public void BindToComponent_SpecifiesValueAndExpression_TypeChecked() { // Arrange AdditionalSyntaxTrees.Add(Parse(@" @@ -1442,7 +1442,7 @@ public class MyComponent : ComponentBase } [Fact] - public void BindToComponentAndExpression_Generic() + public void BindToComponent_SpecifiesValueAndExpression_Generic() { // Arrange AdditionalSyntaxTrees.Add(Parse(@" From fab5b4ef52fa20c55eeebaaac7a2f1b5ea8b3db8 Mon Sep 17 00:00:00 2001 From: jacalvar Date: Mon, 14 Mar 2022 18:41:49 +0100 Subject: [PATCH 23/33] Fix baselines --- .../TestComponent.codegen.cs | 56 ---------------- .../TestComponent.ir.txt | 27 -------- .../TestComponent.mappings.txt | 14 ---- .../TestComponent.codegen.cs | 55 --------------- .../TestComponent.ir.txt | 29 -------- .../TestComponent.mappings.txt | 14 ---- .../TestComponent.codegen.cs | 57 ---------------- .../TestComponent.ir.txt | 30 --------- .../TestComponent.mappings.txt | 14 ---- .../TestComponent.codegen.cs | 67 ------------------- .../TestComponent.ir.txt | 33 --------- .../TestComponent.mappings.txt | 14 ---- .../TestComponent.ir.txt | 4 +- .../TestComponent.ir.txt | 4 +- .../TestComponent.codegen.cs | 56 ---------------- .../TestComponent.ir.txt | 27 -------- .../TestComponent.mappings.txt | 14 ---- .../TestComponent.codegen.cs | 55 --------------- .../TestComponent.ir.txt | 29 -------- .../TestComponent.mappings.txt | 14 ---- .../TestComponent.codegen.cs | 37 ---------- .../TestComponent.diagnostics.txt | 1 - .../TestComponent.ir.txt | 21 ------ .../TestComponent.mappings.txt | 13 ---- .../TestComponent.codegen.cs | 37 ---------- .../TestComponent.diagnostics.txt | 1 - .../TestComponent.ir.txt | 23 ------- .../TestComponent.mappings.txt | 13 ---- .../TestComponent.codegen.cs | 50 -------------- .../TestComponent.ir.txt | 35 ---------- .../TestComponent.mappings.txt | 24 ------- .../TestComponent.codegen.cs | 50 -------------- .../TestComponent.ir.txt | 35 ---------- .../TestComponent.mappings.txt | 24 ------- .../TestComponent.codegen.cs | 53 --------------- .../TestComponent.ir.txt | 34 ---------- .../TestComponent.mappings.txt | 19 ------ .../TestComponent.codegen.cs | 40 ----------- .../TestComponent.ir.txt | 18 ----- .../TestComponent.mappings.txt | 9 --- .../TestComponent.codegen.cs | 40 ----------- .../TestComponent.ir.txt | 20 ------ .../TestComponent.mappings.txt | 9 --- .../TestComponent.codegen.cs | 41 ------------ .../TestComponent.ir.txt | 21 ------ .../TestComponent.mappings.txt | 9 --- .../TestComponent.codegen.cs | 52 -------------- .../TestComponent.ir.txt | 24 ------- .../TestComponent.mappings.txt | 9 --- .../TestComponent.ir.txt | 4 +- .../TestComponent.codegen.cs | 42 ------------ .../TestComponent.ir.txt | 18 ----- .../TestComponent.mappings.txt | 13 ---- .../TestComponent.ir.txt | 4 +- .../TestComponent.codegen.cs | 40 ----------- .../TestComponent.ir.txt | 18 ----- .../TestComponent.mappings.txt | 9 --- .../TestComponent.codegen.cs | 40 ----------- .../TestComponent.ir.txt | 20 ------ .../TestComponent.mappings.txt | 9 --- .../TestComponent.codegen.cs | 32 --------- .../TestComponent.diagnostics.txt | 1 - .../TestComponent.ir.txt | 12 ---- .../TestComponent.mappings.txt | 13 ---- .../TestComponent.codegen.cs | 32 --------- .../TestComponent.diagnostics.txt | 1 - .../TestComponent.ir.txt | 14 ---- .../TestComponent.mappings.txt | 13 ---- .../TestComponent.mappings.txt | 9 --- .../TestComponent.codegen.cs | 46 ------------- .../TestComponent.ir.txt | 24 ------- .../TestComponent.mappings.txt | 19 ------ .../TestComponent.codegen.cs | 46 ------------- .../TestComponent.ir.txt | 24 ------- .../TestComponent.mappings.txt | 19 ------ .../TestComponent.codegen.cs | 43 ------------ .../TestComponent.ir.txt | 24 ------- .../TestComponent.mappings.txt | 29 -------- 78 files changed, 12 insertions(+), 1981 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.diagnostics.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.diagnostics.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplatImplictExpression/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplatImplictExpression/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplatImplictExpression/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.diagnostics.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.diagnostics.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_StartEndTag/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.codegen.cs delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.ir.txt delete mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.mappings.txt diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs deleted file mode 100644 index 52d5bf35e..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs +++ /dev/null @@ -1,56 +0,0 @@ -// -#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - ParentValue - -#line default -#line hidden -#nullable disable - ); - __o = new global::System.Action( - __value => ParentValue = __value); - __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { - } - )); -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" -__o = typeof(global::Test.MyComponent); - -#line default -#line hidden -#nullable disable - } - #pragma warning restore 1998 -#nullable restore -#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - - public int ParentValue { get; set; } = 42; - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt deleted file mode 100644 index 5c709a8e2..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt +++ /dev/null @@ -1,27 +0,0 @@ -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 - global::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 - Component - (0:0,0 [71] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes - CSharpExpression - - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - OnChanged - OnChanged - AttributeStructure.DoubleQuotes - CSharpExpression - - IntermediateToken - - CSharp - __value => ParentValue = __value - HtmlContent - (71:0,71 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (71:0,71 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - CSharpCode - (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt deleted file mode 100644 index 5208407a4..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt +++ /dev/null @@ -1,14 +0,0 @@ -Source Location: (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) -|ParentValue| -Generated Location: (1018:25,26 [11] ) -|ParentValue| - -Source Location: (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) -| - public int ParentValue { get; set; } = 42; -| -Generated Location: (1655:47,7 [50] ) -| - public int ParentValue { get; set; } = 42; -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs deleted file mode 100644 index ed3118fdf..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs +++ /dev/null @@ -1,55 +0,0 @@ -// -#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - __o = -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - ParentValue - -#line default -#line hidden -#nullable disable - ; - __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue); - __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { - } - )); -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" -__o = typeof(global::Test.MyComponent); - -#line default -#line hidden -#nullable disable - } - #pragma warning restore 1998 -#nullable restore -#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - - public int ParentValue { get; set; } = 42; - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt deleted file mode 100644 index f9795bb61..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt +++ /dev/null @@ -1,29 +0,0 @@ -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 - global::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 - Component - (0:0,0 [71] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - - AttributeStructure.DoubleQuotes - CSharpExpression - - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - OnChanged - - AttributeStructure.DoubleQuotes - CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, - IntermediateToken - - CSharp - __value => ParentValue = __value - IntermediateToken - - CSharp - , ParentValue) - HtmlContent - (71:0,71 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (71:0,71 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - CSharpCode - (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt deleted file mode 100644 index 710f8fe2b..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt +++ /dev/null @@ -1,14 +0,0 @@ -Source Location: (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) -|ParentValue| -Generated Location: (914:25,26 [11] ) -|ParentValue| - -Source Location: (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) -| - public int ParentValue { get; set; } = 42; -| -Generated Location: (1615:46,7 [50] ) -| - public int ParentValue { get; set; } = 42; -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.codegen.cs deleted file mode 100644 index 703d98997..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.codegen.cs +++ /dev/null @@ -1,57 +0,0 @@ -// -#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - ParentValue - -#line default -#line hidden -#nullable disable - ); - __o = new global::System.Action( - __value => ParentValue = __value); - __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue); - __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { - } - )); -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" -__o = typeof(global::Test.MyComponent); - -#line default -#line hidden -#nullable disable - } - #pragma warning restore 1998 -#nullable restore -#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - - public int ParentValue { get; set; } = 42; - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.ir.txt deleted file mode 100644 index b6fa4be64..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.ir.txt +++ /dev/null @@ -1,30 +0,0 @@ -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 - global::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 - Component - (0:0,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes - CSharpExpression - - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes - CSharpExpression - - IntermediateToken - - CSharp - __value => ParentValue = __value - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueExpression - ValueExpression - AttributeStructure.DoubleQuotes - CSharpExpression - - IntermediateToken - - CSharp - () => ParentValue - HtmlContent - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - CSharpCode - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.mappings.txt deleted file mode 100644 index 640c8fb20..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.mappings.txt +++ /dev/null @@ -1,14 +0,0 @@ -Source Location: (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) -|ParentValue| -Generated Location: (1018:25,26 [11] ) -|ParentValue| - -Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) -| - public int ParentValue { get; set; } = 42; -| -Generated Location: (1847:48,7 [50] ) -| - public int ParentValue { get; set; } = 42; -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.codegen.cs deleted file mode 100644 index fac8e0b08..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.codegen.cs +++ /dev/null @@ -1,67 +0,0 @@ -// -#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - global::__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(__builder, -1, -1, -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - ParentValue - -#line default -#line hidden -#nullable disable - , -1, - __value => ParentValue = __value, -1, () => ParentValue); -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" -__o = typeof(global::Test.MyComponent<>); - -#line default -#line hidden -#nullable disable - } - #pragma warning restore 1998 -#nullable restore -#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - - public DateTime ParentValue { get; set; } = DateTime.Now; - -#line default -#line hidden -#nullable disable - } -} -namespace __Blazor.Test.TestComponent -{ - #line hidden - internal static class TypeInference - { - public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, T __arg0, int __seq1, global::System.Action __arg1, int __seq2, global::System.Linq.Expressions.Expression> __arg2) - { - __builder.OpenComponent>(seq); - __builder.AddAttribute(__seq0, "SomeParam", __arg0); - __builder.AddAttribute(__seq1, "SomeParamChanged", __arg1); - __builder.AddAttribute(__seq2, "SomeParamExpression", __arg2); - __builder.CloseComponent(); - } - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.ir.txt deleted file mode 100644 index af9805417..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.ir.txt +++ /dev/null @@ -1,33 +0,0 @@ -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 - global::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 - Component - (0:0,0 [45] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParam - SomeParam - AttributeStructure.DoubleQuotes - CSharpExpression - - LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParamChanged - SomeParamChanged - AttributeStructure.DoubleQuotes - CSharpExpression - - IntermediateToken - - CSharp - __value => ParentValue = __value - ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParamExpression - SomeParamExpression - AttributeStructure.DoubleQuotes - CSharpExpression - - IntermediateToken - - CSharp - () => ParentValue - HtmlContent - (45:0,45 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (45:0,45 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - CSharpCode - (54:1,7 [65] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (54:1,7 [65] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public DateTime ParentValue { get; set; } = DateTime.Now;\n - NamespaceDeclaration - - __Blazor.Test.TestComponent - ClassDeclaration - - internal static - TypeInference - - - ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.mappings.txt deleted file mode 100644 index 332ceba9c..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.mappings.txt +++ /dev/null @@ -1,14 +0,0 @@ -Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) -|ParentValue| -Generated Location: (1001:25,30 [11] ) -|ParentValue| - -Source Location: (54:1,7 [65] x:\dir\subdir\Test\TestComponent.cshtml) -| - public DateTime ParentValue { get; set; } = DateTime.Now; -| -Generated Location: (1444:43,7 [65] ) -| - public DateTime ParentValue { get; set; } = DateTime.Now; -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt index c08cd6a1a..f9795bb61 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt @@ -20,7 +20,9 @@ Document - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - OnChanged - - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , ParentValue) HtmlContent - (71:0,71 [2] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (71:0,71 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.ir.txt index 2a38c699b..9068e3bc8 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.ir.txt @@ -20,7 +20,9 @@ Document - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , ParentValue) HtmlContent - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n CSharpCode - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.codegen.cs deleted file mode 100644 index 52d5bf35e..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.codegen.cs +++ /dev/null @@ -1,56 +0,0 @@ -// -#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - ParentValue - -#line default -#line hidden -#nullable disable - ); - __o = new global::System.Action( - __value => ParentValue = __value); - __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { - } - )); -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" -__o = typeof(global::Test.MyComponent); - -#line default -#line hidden -#nullable disable - } - #pragma warning restore 1998 -#nullable restore -#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - - public int ParentValue { get; set; } = 42; - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.ir.txt deleted file mode 100644 index fc3de77ba..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.ir.txt +++ /dev/null @@ -1,27 +0,0 @@ -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 - global::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 - Component - (0:0,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes - CSharpExpression - - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes - CSharpExpression - - IntermediateToken - - CSharp - __value => ParentValue = __value - HtmlContent - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - CSharpCode - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.mappings.txt deleted file mode 100644 index 0a1a4873d..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.mappings.txt +++ /dev/null @@ -1,14 +0,0 @@ -Source Location: (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) -|ParentValue| -Generated Location: (1018:25,26 [11] ) -|ParentValue| - -Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) -| - public int ParentValue { get; set; } = 42; -| -Generated Location: (1655:47,7 [50] ) -| - public int ParentValue { get; set; } = 42; -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.codegen.cs deleted file mode 100644 index ed3118fdf..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.codegen.cs +++ /dev/null @@ -1,55 +0,0 @@ -// -#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - __o = -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - ParentValue - -#line default -#line hidden -#nullable disable - ; - __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue); - __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { - } - )); -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" -__o = typeof(global::Test.MyComponent); - -#line default -#line hidden -#nullable disable - } - #pragma warning restore 1998 -#nullable restore -#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - - public int ParentValue { get; set; } = 42; - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.ir.txt deleted file mode 100644 index 9068e3bc8..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.ir.txt +++ /dev/null @@ -1,29 +0,0 @@ -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 - global::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 - Component - (0:0,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - - AttributeStructure.DoubleQuotes - CSharpExpression - - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - - AttributeStructure.DoubleQuotes - CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, - IntermediateToken - - CSharp - __value => ParentValue = __value - IntermediateToken - - CSharp - , ParentValue) - HtmlContent - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - CSharpCode - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.mappings.txt deleted file mode 100644 index 885673b5e..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.mappings.txt +++ /dev/null @@ -1,14 +0,0 @@ -Source Location: (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) -|ParentValue| -Generated Location: (914:25,26 [11] ) -|ParentValue| - -Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) -| - public int ParentValue { get; set; } = 42; -| -Generated Location: (1615:46,7 [50] ) -| - public int ParentValue { get; set; } = 42; -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.codegen.cs deleted file mode 100644 index 81831fbed..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.codegen.cs +++ /dev/null @@ -1,37 +0,0 @@ -// -#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - } - #pragma warning restore 1998 -#nullable restore -#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - - public string ParentValue { get; set; } = "hi"; - - public void UpdateValue(string value) => ParentValue = value; - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.diagnostics.txt deleted file mode 100644 index 8cf39c3ec..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.diagnostics.txt +++ /dev/null @@ -1 +0,0 @@ -x:\dir\subdir\Test\TestComponent.cshtml(1,23): Error RZ10016: Attribute 'bind-value:set' was used but no attribute 'bind-value:get' was found. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.ir.txt deleted file mode 100644 index 4478df68e..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.ir.txt +++ /dev/null @@ -1,21 +0,0 @@ -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 - global::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 - MarkupElement - (0:0,0 [37] x:\dir\subdir\Test\TestComponent.cshtml) - div - HtmlContent - (37:0,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (37:0,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - CSharpCode - (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n public void UpdateValue(string value) => ParentValue = value;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.mappings.txt deleted file mode 100644 index 570939ff8..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.mappings.txt +++ /dev/null @@ -1,13 +0,0 @@ -Source Location: (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) -| - public string ParentValue { get; set; } = "hi"; - - public void UpdateValue(string value) => ParentValue = value; -| -Generated Location: (924:26,7 [124] ) -| - public string ParentValue { get; set; } = "hi"; - - public void UpdateValue(string value) => ParentValue = value; -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.codegen.cs deleted file mode 100644 index 81831fbed..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.codegen.cs +++ /dev/null @@ -1,37 +0,0 @@ -// -#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - } - #pragma warning restore 1998 -#nullable restore -#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - - public string ParentValue { get; set; } = "hi"; - - public void UpdateValue(string value) => ParentValue = value; - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.diagnostics.txt deleted file mode 100644 index db0d277a0..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.diagnostics.txt +++ /dev/null @@ -1 +0,0 @@ -x:\dir\subdir\Test\TestComponent.cshtml(1,23): Error RZ10017: The attribute 'bind-value:get' must have a companion 'bind-value:set' attribute. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.ir.txt deleted file mode 100644 index 3fb0eb060..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.ir.txt +++ /dev/null @@ -1,23 +0,0 @@ -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 - global::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 - MarkupElement - (0:0,0 [37] x:\dir\subdir\Test\TestComponent.cshtml) - div - TagHelperDirectiveAttributeParameter - (22:0,22 [11] x:\dir\subdir\Test\TestComponent.cshtml) - bind-value:get - HtmlAttributeValueStyle.DoubleQuotes - LazyIntermediateToken - (22:0,22 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - HtmlContent - (37:0,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (37:0,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - CSharpCode - (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n public void UpdateValue(string value) => ParentValue = value;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.mappings.txt deleted file mode 100644 index 570939ff8..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.mappings.txt +++ /dev/null @@ -1,13 +0,0 @@ -Source Location: (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) -| - public string ParentValue { get; set; } = "hi"; - - public void UpdateValue(string value) => ParentValue = value; -| -Generated Location: (924:26,7 [124] ) -| - public string ParentValue { get; set; } = "hi"; - - public void UpdateValue(string value) => ParentValue = value; -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs deleted file mode 100644 index 30eeb978a..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs +++ /dev/null @@ -1,50 +0,0 @@ -// -#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - __o = global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - ParentValue - -#line default -#line hidden -#nullable disable - ); - __o = global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: DoSomething).InvokeAsync(); }, value: ParentValue), ParentValue); - } - #pragma warning restore 1998 -#nullable restore -#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" - - public string ParentValue { get; set; } = "hi"; - - Task DoSomething() - { - return Task.CompletedTask; - } - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt deleted file mode 100644 index 9d49fb7de..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt +++ /dev/null @@ -1,35 +0,0 @@ -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 - global::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 - MarkupElement - (0:0,0 [60] x:\dir\subdir\Test\TestComponent.cshtml) - div - HtmlContent - (52:0,52 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (52:0,52 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " - CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( - LazyIntermediateToken - (13:0,13 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - IntermediateToken - - CSharp - ) - HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " - CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: DoSomething).InvokeAsync(); }, value: ParentValue) - IntermediateToken - - CSharp - , - IntermediateToken - - CSharp - ParentValue - IntermediateToken - - CSharp - ) - HtmlContent - (60:1,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (60:1,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - CSharpCode - (69:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (69:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n Task DoSomething()\n {\n return Task.CompletedTask;\n }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt deleted file mode 100644 index 50c3c70f9..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt +++ /dev/null @@ -1,24 +0,0 @@ -Source Location: (13:0,13 [11] x:\dir\subdir\Test\TestComponent.cshtml) -|ParentValue| -Generated Location: (967:25,13 [11] ) -|ParentValue| - -Source Location: (69:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) -| - public string ParentValue { get; set; } = "hi"; - - Task DoSomething() - { - return Task.CompletedTask; - } -| -Generated Location: (1582:36,7 [131] ) -| - public string ParentValue { get; set; } = "hi"; - - Task DoSomething() - { - return Task.CompletedTask; - } -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs deleted file mode 100644 index 5c8a431ea..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs +++ /dev/null @@ -1,50 +0,0 @@ -// -#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - __o = global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - ParentValue - -#line default -#line hidden -#nullable disable - ); - __o = global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: ValueChanged, value: ParentValue), ParentValue); - } - #pragma warning restore 1998 -#nullable restore -#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" - - public string ParentValue { get; set; } = "hi"; - - Task ValueChanged(string value) - { - return Task.CompletedTask; - } - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.ir.txt deleted file mode 100644 index 7851a2d99..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.ir.txt +++ /dev/null @@ -1,35 +0,0 @@ -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 - global::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 - MarkupElement - (0:0,0 [63] x:\dir\subdir\Test\TestComponent.cshtml) - div - HtmlContent - (55:0,55 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (55:0,55 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - HtmlAttribute - (16:0,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " - CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( - LazyIntermediateToken - (17:0,17 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - IntermediateToken - - CSharp - ) - HtmlAttribute - (16:0,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " - CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: ValueChanged, value: ParentValue) - IntermediateToken - - CSharp - , - IntermediateToken - - CSharp - ParentValue - IntermediateToken - - CSharp - ) - HtmlContent - (63:1,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (63:1,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - CSharpCode - (72:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (72:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n Task ValueChanged(string value)\n {\n return Task.CompletedTask;\n }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt deleted file mode 100644 index 21c6fb556..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt +++ /dev/null @@ -1,24 +0,0 @@ -Source Location: (17:0,17 [11] x:\dir\subdir\Test\TestComponent.cshtml) -|ParentValue| -Generated Location: (971:25,17 [11] ) -|ParentValue| - -Source Location: (72:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) -| - public string ParentValue { get; set; } = "hi"; - - Task ValueChanged(string value) - { - return Task.CompletedTask; - } -| -Generated Location: (1441:36,7 [144] ) -| - public string ParentValue { get; set; } = "hi"; - - Task ValueChanged(string value) - { - return Task.CompletedTask; - } -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplatImplictExpression/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplatImplictExpression/TestComponent.codegen.cs deleted file mode 100644 index 412b7925a..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplatImplictExpression/TestComponent.codegen.cs +++ /dev/null @@ -1,53 +0,0 @@ -// -#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 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.RenderTree.RenderTreeBuilder builder) - { - __o = -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - someAttributes - -#line default -#line hidden -#nullable disable - ; - __o = -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - "after" - -#line default -#line hidden -#nullable disable - ; - } - #pragma warning restore 1998 -#nullable restore -#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" - - private Dictionary someAttributes = new Dictionary(); - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplatImplictExpression/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplatImplictExpression/TestComponent.ir.txt deleted file mode 100644 index 9102ec0b5..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplatImplictExpression/TestComponent.ir.txt +++ /dev/null @@ -1,34 +0,0 @@ -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 - 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 - MarkupElement - (0:0,0 [101] x:\dir\subdir\Test\TestComponent.cshtml) - elem - HtmlContent - (89:0,89 [5] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - (89:0,89 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello - HtmlAttribute - - attributebefore=" - " - HtmlAttributeValue - (23:0,23 [6] x:\dir\subdir\Test\TestComponent.cshtml) - - IntermediateToken - (23:0,23 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - before - HtmlAttribute - (44:0,44 [15] x:\dir\subdir\Test\TestComponent.cshtml) - - - CSharpExpressionAttributeValue - - - IntermediateToken - (45:0,45 [14] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - someAttributes - HtmlAttribute - - attributeafter=" - " - CSharpExpressionAttributeValue - (77:0,77 [10] x:\dir\subdir\Test\TestComponent.cshtml) - - IntermediateToken - (79:0,79 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "after" - HtmlContent - (101:0,101 [4] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - (101:0,101 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n - HtmlContent - (206:4,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - (206:4,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - CSharpCode - (112:2,7 [93] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - (112:2,7 [93] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private Dictionary someAttributes = new Dictionary();\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplatImplictExpression/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplatImplictExpression/TestComponent.mappings.txt deleted file mode 100644 index 50bff7758..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplatImplictExpression/TestComponent.mappings.txt +++ /dev/null @@ -1,19 +0,0 @@ -Source Location: (45:0,45 [14] x:\dir\subdir\Test\TestComponent.cshtml) -|someAttributes| -Generated Location: (908:25,45 [14] ) -|someAttributes| - -Source Location: (79:0,79 [7] x:\dir\subdir\Test\TestComponent.cshtml) -|"after"| -Generated Location: (1158:34,79 [7] ) -|"after"| - -Source Location: (112:2,7 [93] x:\dir\subdir\Test\TestComponent.cshtml) -| - private Dictionary someAttributes = new Dictionary(); -| -Generated Location: (1358:44,7 [93] ) -| - private Dictionary someAttributes = new Dictionary(); -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs deleted file mode 100644 index 23de622f8..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -#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 : global::Microsoft.AspNetCore.Components.ComponentBase - { - #pragma warning disable 1998 - protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - __builder.OpenComponent(0); - __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - ParentValue - -#line default -#line hidden -#nullable disable - )); - __builder.AddAttribute(2, "OnChanged", (global::System.Action)(__value => ParentValue = __value)); - __builder.CloseComponent(); - } - #pragma warning restore 1998 -#nullable restore -#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - - public int ParentValue { get; set; } = 42; - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt deleted file mode 100644 index 8f47d724a..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt +++ /dev/null @@ -1,18 +0,0 @@ -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 - global::Microsoft.AspNetCore.Components.ComponentBase - - MethodDeclaration - - protected override - void - BuildRenderTree - Component - (0:0,0 [71] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes - CSharpExpression - - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - OnChanged - OnChanged - AttributeStructure.DoubleQuotes - CSharpExpression - - IntermediateToken - - CSharp - __value => ParentValue = __value - CSharpCode - (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt deleted file mode 100644 index 95daba29a..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt +++ /dev/null @@ -1,9 +0,0 @@ -Source Location: (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) -| - public int ParentValue { get; set; } = 42; -| -Generated Location: (1219:31,7 [50] ) -| - public int ParentValue { get; set; } = 42; -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs deleted file mode 100644 index 8decdb4f8..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -#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 : global::Microsoft.AspNetCore.Components.ComponentBase - { - #pragma warning disable 1998 - protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - __builder.OpenComponent(0); - __builder.AddAttribute(1, "Value", -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - ParentValue - -#line default -#line hidden -#nullable disable - ); - __builder.AddAttribute(2, "OnChanged", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue)); - __builder.CloseComponent(); - } - #pragma warning restore 1998 -#nullable restore -#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - - public int ParentValue { get; set; } = 42; - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt deleted file mode 100644 index 010d4c247..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt +++ /dev/null @@ -1,20 +0,0 @@ -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 - global::Microsoft.AspNetCore.Components.ComponentBase - - MethodDeclaration - - protected override - void - BuildRenderTree - Component - (0:0,0 [71] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - - AttributeStructure.DoubleQuotes - CSharpExpression - - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - OnChanged - - AttributeStructure.DoubleQuotes - CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, - IntermediateToken - - CSharp - __value => ParentValue = __value - IntermediateToken - - CSharp - , ParentValue) - CSharpCode - (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt deleted file mode 100644 index bf244e6cc..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt +++ /dev/null @@ -1,9 +0,0 @@ -Source Location: (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) -| - public int ParentValue { get; set; } = 42; -| -Generated Location: (1195:31,7 [50] ) -| - public int ParentValue { get; set; } = 42; -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.codegen.cs deleted file mode 100644 index d04161bb6..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.codegen.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -#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 : global::Microsoft.AspNetCore.Components.ComponentBase - { - #pragma warning disable 1998 - protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - __builder.OpenComponent(0); - __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - ParentValue - -#line default -#line hidden -#nullable disable - )); - __builder.AddAttribute(2, "ValueChanged", (global::System.Action)(__value => ParentValue = __value)); - __builder.AddAttribute(3, "ValueExpression", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>(() => ParentValue)); - __builder.CloseComponent(); - } - #pragma warning restore 1998 -#nullable restore -#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - - public int ParentValue { get; set; } = 42; - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.ir.txt deleted file mode 100644 index 8a718dd19..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.ir.txt +++ /dev/null @@ -1,21 +0,0 @@ -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 - global::Microsoft.AspNetCore.Components.ComponentBase - - MethodDeclaration - - protected override - void - BuildRenderTree - Component - (0:0,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes - CSharpExpression - - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes - CSharpExpression - - IntermediateToken - - CSharp - __value => ParentValue = __value - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueExpression - ValueExpression - AttributeStructure.DoubleQuotes - CSharpExpression - - IntermediateToken - - CSharp - () => ParentValue - CSharpCode - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.mappings.txt deleted file mode 100644 index 2e37b7cba..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression/TestComponent.mappings.txt +++ /dev/null @@ -1,9 +0,0 @@ -Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) -| - public int ParentValue { get; set; } = 42; -| -Generated Location: (1454:32,7 [50] ) -| - public int ParentValue { get; set; } = 42; -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.codegen.cs deleted file mode 100644 index 9dd49e3b6..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.codegen.cs +++ /dev/null @@ -1,52 +0,0 @@ -// -#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 : global::Microsoft.AspNetCore.Components.ComponentBase - { - #pragma warning disable 1998 - protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - global::__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(__builder, 0, 1, -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - ParentValue - -#line default -#line hidden -#nullable disable - , 2, __value => ParentValue = __value, 3, () => ParentValue); - } - #pragma warning restore 1998 -#nullable restore -#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - - public DateTime ParentValue { get; set; } = DateTime.Now; - -#line default -#line hidden -#nullable disable - } -} -namespace __Blazor.Test.TestComponent -{ - #line hidden - internal static class TypeInference - { - public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, T __arg0, int __seq1, global::System.Action __arg1, int __seq2, global::System.Linq.Expressions.Expression> __arg2) - { - __builder.OpenComponent>(seq); - __builder.AddAttribute(__seq0, "SomeParam", __arg0); - __builder.AddAttribute(__seq1, "SomeParamChanged", __arg1); - __builder.AddAttribute(__seq2, "SomeParamExpression", __arg2); - __builder.CloseComponent(); - } - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.ir.txt deleted file mode 100644 index e3d19b421..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.ir.txt +++ /dev/null @@ -1,24 +0,0 @@ -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 - global::Microsoft.AspNetCore.Components.ComponentBase - - MethodDeclaration - - protected override - void - BuildRenderTree - Component - (0:0,0 [45] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParam - SomeParam - AttributeStructure.DoubleQuotes - CSharpExpression - - LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParamChanged - SomeParamChanged - AttributeStructure.DoubleQuotes - CSharpExpression - - IntermediateToken - - CSharp - __value => ParentValue = __value - ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParamExpression - SomeParamExpression - AttributeStructure.DoubleQuotes - CSharpExpression - - IntermediateToken - - CSharp - () => ParentValue - CSharpCode - (54:1,7 [65] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (54:1,7 [65] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public DateTime ParentValue { get; set; } = DateTime.Now;\n - NamespaceDeclaration - - __Blazor.Test.TestComponent - ClassDeclaration - - internal static - TypeInference - - - ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.mappings.txt deleted file mode 100644 index fae712528..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponentAndExpression_Generic/TestComponent.mappings.txt +++ /dev/null @@ -1,9 +0,0 @@ -Source Location: (54:1,7 [65] x:\dir\subdir\Test\TestComponent.cshtml) -| - public DateTime ParentValue { get; set; } = DateTime.Now; -| -Generated Location: (995:28,7 [65] ) -| - public DateTime ParentValue { get; set; } = DateTime.Now; -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt index c5205de2b..010d4c247 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt @@ -13,6 +13,8 @@ Document - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - OnChanged - - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , ParentValue) CSharpCode - (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (80:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs deleted file mode 100644 index 665a822a9..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.codegen.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -#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 : global::Microsoft.AspNetCore.Components.ComponentBase - { - #pragma warning disable 1998 - protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - __builder.OpenComponent(0); - __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - ParentValue - -#line default -#line hidden -#nullable disable - )); - __builder.AddAttribute(2, "ValueChanged", (global::System.Func)(UpdateValue)); - __builder.CloseComponent(); - } - #pragma warning restore 1998 -#nullable restore -#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - - public int ParentValue { get; set; } = 42; - - public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.ir.txt deleted file mode 100644 index 5d14f2a99..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.ir.txt +++ /dev/null @@ -1,18 +0,0 @@ -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 - global::Microsoft.AspNetCore.Components.ComponentBase - - MethodDeclaration - - protected override - void - BuildRenderTree - Component - (0:0,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes - CSharpExpression - - LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes - CSharpExpression - - IntermediateToken - - CSharp - UpdateValue - CSharpCode - (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt deleted file mode 100644 index d8fc489a8..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithGetSet_TaskReturningDelegate/TestComponent.mappings.txt +++ /dev/null @@ -1,13 +0,0 @@ -Source Location: (84:1,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) -| - public int ParentValue { get; set; } = 42; - - public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } -| -Generated Location: (1232:31,7 [144] ) -| - public int ParentValue { get; set; } = 42; - - public Task UpdateValue(int value) { ParentValue = value; return Task.CompletedTask; } -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.ir.txt index 2045e2f59..2b7fb6405 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.ir.txt @@ -13,6 +13,8 @@ Document - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , ParentValue) CSharpCode - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.codegen.cs deleted file mode 100644 index 84497a267..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.codegen.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -#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 : global::Microsoft.AspNetCore.Components.ComponentBase - { - #pragma warning disable 1998 - protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - __builder.OpenComponent(0); - __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - ParentValue - -#line default -#line hidden -#nullable disable - )); - __builder.AddAttribute(2, "ValueChanged", (global::System.Action)(__value => ParentValue = __value)); - __builder.CloseComponent(); - } - #pragma warning restore 1998 -#nullable restore -#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - - public int ParentValue { get; set; } = 42; - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.ir.txt deleted file mode 100644 index f5ab4fe32..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.ir.txt +++ /dev/null @@ -1,18 +0,0 @@ -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 - global::Microsoft.AspNetCore.Components.ComponentBase - - MethodDeclaration - - protected override - void - BuildRenderTree - Component - (0:0,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes - CSharpExpression - - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes - CSharpExpression - - IntermediateToken - - CSharp - __value => ParentValue = __value - CSharpCode - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.mappings.txt deleted file mode 100644 index 5f9a9a2d9..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithMatchingProperties/TestComponent.mappings.txt +++ /dev/null @@ -1,9 +0,0 @@ -Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) -| - public int ParentValue { get; set; } = 42; -| -Generated Location: (1222:31,7 [50] ) -| - public int ParentValue { get; set; } = 42; -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.codegen.cs deleted file mode 100644 index 636be4b0a..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.codegen.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -#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 : global::Microsoft.AspNetCore.Components.ComponentBase - { - #pragma warning disable 1998 - protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - __builder.OpenComponent(0); - __builder.AddAttribute(1, "Value", -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - ParentValue - -#line default -#line hidden -#nullable disable - ); - __builder.AddAttribute(2, "ValueChanged", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue)); - __builder.CloseComponent(); - } - #pragma warning restore 1998 -#nullable restore -#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - - public int ParentValue { get; set; } = 42; - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.ir.txt deleted file mode 100644 index 2b7fb6405..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.ir.txt +++ /dev/null @@ -1,20 +0,0 @@ -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 - global::Microsoft.AspNetCore.Components.ComponentBase - - MethodDeclaration - - protected override - void - BuildRenderTree - Component - (0:0,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - - AttributeStructure.DoubleQuotes - CSharpExpression - - LazyIntermediateToken - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - ComponentAttribute - (26:0,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - - AttributeStructure.DoubleQuotes - CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, - IntermediateToken - - CSharp - __value => ParentValue = __value - IntermediateToken - - CSharp - , ParentValue) - CSharpCode - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.mappings.txt deleted file mode 100644 index d19b561ec..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithoutMatchingProperties/TestComponent.mappings.txt +++ /dev/null @@ -1,9 +0,0 @@ -Source Location: (50:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) -| - public int ParentValue { get; set; } = 42; -| -Generated Location: (1198:31,7 [50] ) -| - public int ParentValue { get; set; } = 42; -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.codegen.cs deleted file mode 100644 index ff12c4cd1..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.codegen.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -#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 : global::Microsoft.AspNetCore.Components.ComponentBase - { - #pragma warning disable 1998 - protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - __builder.OpenElement(0, "div"); - __builder.CloseElement(); - } - #pragma warning restore 1998 -#nullable restore -#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - - public string ParentValue { get; set; } = "hi"; - - public void UpdateValue(string value) => ParentValue = value; - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.diagnostics.txt deleted file mode 100644 index 8cf39c3ec..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.diagnostics.txt +++ /dev/null @@ -1 +0,0 @@ -x:\dir\subdir\Test\TestComponent.cshtml(1,23): Error RZ10016: Attribute 'bind-value:set' was used but no attribute 'bind-value:get' was found. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.ir.txt deleted file mode 100644 index b783b3899..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.ir.txt +++ /dev/null @@ -1,12 +0,0 @@ -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 - global::Microsoft.AspNetCore.Components.ComponentBase - - MethodDeclaration - - protected override - void - BuildRenderTree - MarkupElement - (0:0,0 [37] x:\dir\subdir\Test\TestComponent.cshtml) - div - CSharpCode - (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n public void UpdateValue(string value) => ParentValue = value;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.mappings.txt deleted file mode 100644 index 29688fb09..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindGet/TestComponent.mappings.txt +++ /dev/null @@ -1,13 +0,0 @@ -Source Location: (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) -| - public string ParentValue { get; set; } = "hi"; - - public void UpdateValue(string value) => ParentValue = value; -| -Generated Location: (741:21,7 [124] ) -| - public string ParentValue { get; set; } = "hi"; - - public void UpdateValue(string value) => ParentValue = value; -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.codegen.cs deleted file mode 100644 index ff12c4cd1..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.codegen.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -#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 : global::Microsoft.AspNetCore.Components.ComponentBase - { - #pragma warning disable 1998 - protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - __builder.OpenElement(0, "div"); - __builder.CloseElement(); - } - #pragma warning restore 1998 -#nullable restore -#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - - public string ParentValue { get; set; } = "hi"; - - public void UpdateValue(string value) => ParentValue = value; - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.diagnostics.txt deleted file mode 100644 index db0d277a0..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.diagnostics.txt +++ /dev/null @@ -1 +0,0 @@ -x:\dir\subdir\Test\TestComponent.cshtml(1,23): Error RZ10017: The attribute 'bind-value:get' must have a companion 'bind-value:set' attribute. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.ir.txt deleted file mode 100644 index 6aa44473d..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.ir.txt +++ /dev/null @@ -1,14 +0,0 @@ -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 - global::Microsoft.AspNetCore.Components.ComponentBase - - MethodDeclaration - - protected override - void - BuildRenderTree - MarkupElement - (0:0,0 [37] x:\dir\subdir\Test\TestComponent.cshtml) - div - TagHelperDirectiveAttributeParameter - (22:0,22 [11] x:\dir\subdir\Test\TestComponent.cshtml) - bind-value:get - HtmlAttributeValueStyle.DoubleQuotes - LazyIntermediateToken - (22:0,22 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - CSharpCode - (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n public void UpdateValue(string value) => ParentValue = value;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.mappings.txt deleted file mode 100644 index 29688fb09..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_MissingBindSet/TestComponent.mappings.txt +++ /dev/null @@ -1,13 +0,0 @@ -Source Location: (46:1,7 [124] x:\dir\subdir\Test\TestComponent.cshtml) -| - public string ParentValue { get; set; } = "hi"; - - public void UpdateValue(string value) => ParentValue = value; -| -Generated Location: (741:21,7 [124] ) -| - public string ParentValue { get; set; } = "hi"; - - public void UpdateValue(string value) => ParentValue = value; -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_StartEndTag/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_StartEndTag/TestComponent.mappings.txt deleted file mode 100644 index 6ed1154bc..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_StartEndTag/TestComponent.mappings.txt +++ /dev/null @@ -1,9 +0,0 @@ -Source Location: (45:1,7 [55] x:\dir\subdir\Test\TestComponent.cshtml) -| - public string ParentValue { get; set; } = "hi"; -| -Generated Location: (932:30,7 [55] ) -| - public string ParentValue { get; set; } = "hi"; -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs deleted file mode 100644 index 66d2cc15a..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.codegen.cs +++ /dev/null @@ -1,46 +0,0 @@ -// -#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 : global::Microsoft.AspNetCore.Components.ComponentBase - { - #pragma warning disable 1998 - protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - __builder.OpenElement(0, "div"); - __builder.AddAttribute(1, "myvalue", global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - ParentValue - -#line default -#line hidden -#nullable disable - )); - __builder.AddAttribute(2, "myevent", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: DoSomething).InvokeAsync(); }, value: ParentValue), ParentValue)); - __builder.SetUpdatesAttributeName("myvalue"); - __builder.CloseElement(); - } - #pragma warning restore 1998 -#nullable restore -#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" - - public string ParentValue { get; set; } = "hi"; - - Task DoSomething() - { - return Task.CompletedTask; - } - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt deleted file mode 100644 index 1ec0f41e2..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.ir.txt +++ /dev/null @@ -1,24 +0,0 @@ -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 - global::Microsoft.AspNetCore.Components.ComponentBase - - MethodDeclaration - - protected override - void - BuildRenderTree - MarkupElement - (0:0,0 [60] x:\dir\subdir\Test\TestComponent.cshtml) - div - HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " - CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( - LazyIntermediateToken - (13:0,13 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - IntermediateToken - - CSharp - ) - HtmlAttribute - (12:0,12 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " - CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: __value => { ParentValue = __value; return global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, callback: DoSomething).InvokeAsync(); }, value: ParentValue) - IntermediateToken - - CSharp - , - IntermediateToken - - CSharp - ParentValue - IntermediateToken - - CSharp - ) - CSharpCode - (69:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (69:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n Task DoSomething()\n {\n return Task.CompletedTask;\n }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt deleted file mode 100644 index 5a54fb773..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithBindAfter/TestComponent.mappings.txt +++ /dev/null @@ -1,19 +0,0 @@ -Source Location: (69:2,7 [131] x:\dir\subdir\Test\TestComponent.cshtml) -| - public string ParentValue { get; set; } = "hi"; - - Task DoSomething() - { - return Task.CompletedTask; - } -| -Generated Location: (1522:32,7 [131] ) -| - public string ParentValue { get; set; } = "hi"; - - Task DoSomething() - { - return Task.CompletedTask; - } -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs deleted file mode 100644 index 00118c7bf..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.codegen.cs +++ /dev/null @@ -1,46 +0,0 @@ -// -#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 : global::Microsoft.AspNetCore.Components.ComponentBase - { - #pragma warning disable 1998 - protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - __builder.OpenElement(0, "div"); - __builder.AddAttribute(1, "myvalue", global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( -#nullable restore -#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - ParentValue - -#line default -#line hidden -#nullable disable - )); - __builder.AddAttribute(2, "myevent", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: ValueChanged, value: ParentValue), ParentValue)); - __builder.SetUpdatesAttributeName("myvalue"); - __builder.CloseElement(); - } - #pragma warning restore 1998 -#nullable restore -#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" - - public string ParentValue { get; set; } = "hi"; - - Task ValueChanged(string value) - { - return Task.CompletedTask; - } - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.ir.txt deleted file mode 100644 index 659c732c9..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.ir.txt +++ /dev/null @@ -1,24 +0,0 @@ -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 - global::Microsoft.AspNetCore.Components.ComponentBase - - MethodDeclaration - - protected override - void - BuildRenderTree - MarkupElement - (0:0,0 [63] x:\dir\subdir\Test\TestComponent.cshtml) - div - HtmlAttribute - (16:0,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " - CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( - LazyIntermediateToken - (17:0,17 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue - IntermediateToken - - CSharp - ) - HtmlAttribute - (16:0,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " - CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, callback: ValueChanged, value: ParentValue) - IntermediateToken - - CSharp - , - IntermediateToken - - CSharp - ParentValue - IntermediateToken - - CSharp - ) - CSharpCode - (72:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (72:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n Task ValueChanged(string value)\n {\n return Task.CompletedTask;\n }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt deleted file mode 100644 index 09c174a61..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSet/TestComponent.mappings.txt +++ /dev/null @@ -1,19 +0,0 @@ -Source Location: (72:2,7 [144] x:\dir\subdir\Test\TestComponent.cshtml) -| - public string ParentValue { get; set; } = "hi"; - - Task ValueChanged(string value) - { - return Task.CompletedTask; - } -| -Generated Location: (1381:32,7 [144] ) -| - public string ParentValue { get; set; } = "hi"; - - Task ValueChanged(string value) - { - return Task.CompletedTask; - } -| - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.codegen.cs deleted file mode 100644 index ad0622448..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.codegen.cs +++ /dev/null @@ -1,43 +0,0 @@ -// -#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 : global::Microsoft.AspNetCore.Components.ComponentBase - { - #pragma warning disable 1998 - protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) - { - __builder.OpenElement(0, "div"); - __builder.AddAttribute(1, "myvalue", global::Microsoft.AspNetCore.Components.BindConverter.FormatValue((() => @ParentValue))); - __builder.AddAttribute(2, "myevent", global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => (() => @ParentValue) = __value, (() => @ParentValue), setter: (value => ValueChanged(value)), after: (() => AfterValueChanged()))); - __builder.SetUpdatesAttributeName("myvalue"); - __builder.CloseElement(); - } - #pragma warning restore 1998 -#nullable restore -#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" - - public string ParentValue { get; set; } = "hi"; - - Task ValueChanged(string value) - { - return Task.CompletedTask; - } - - Task AfterValueChanged() - { - return Task.CompletedTask; - } - -#line default -#line hidden -#nullable disable - } -} -#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.ir.txt deleted file mode 100644 index 3019f524d..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.ir.txt +++ /dev/null @@ -1,24 +0,0 @@ -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 - global::Microsoft.AspNetCore.Components.ComponentBase - - MethodDeclaration - - protected override - void - BuildRenderTree - MarkupElement - (0:0,0 [134] x:\dir\subdir\Test\TestComponent.cshtml) - div - HtmlAttribute - (16:0,16 [21] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " - CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.BindConverter.FormatValue( - IntermediateToken - - CSharp - (() => @ParentValue) - IntermediateToken - - CSharp - ) - HtmlAttribute - (16:0,16 [21] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " - CSharpExpressionAttributeValue - - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => (() => @ParentValue) = __value, - IntermediateToken - - CSharp - (() => @ParentValue) - IntermediateToken - - CSharp - , setter: (value => ValueChanged(value)) - IntermediateToken - - CSharp - , after: (() => AfterValueChanged()) - IntermediateToken - - CSharp - ) - CSharpCode - (143:2,7 [226] x:\dir\subdir\Test\TestComponent.cshtml) - LazyIntermediateToken - (143:2,7 [226] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n\n Task ValueChanged(string value)\n {\n return Task.CompletedTask;\n }\n\n Task AfterValueChanged()\n {\n return Task.CompletedTask;\n }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.mappings.txt deleted file mode 100644 index a685a94bf..000000000 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WithGetSetAndAfter_Lambda/TestComponent.mappings.txt +++ /dev/null @@ -1,29 +0,0 @@ -Source Location: (143:2,7 [226] x:\dir\subdir\Test\TestComponent.cshtml) -| - public string ParentValue { get; set; } = "hi"; - - Task ValueChanged(string value) - { - return Task.CompletedTask; - } - - Task AfterValueChanged() - { - return Task.CompletedTask; - } -| -Generated Location: (1214:24,7 [226] ) -| - public string ParentValue { get; set; } = "hi"; - - Task ValueChanged(string value) - { - return Task.CompletedTask; - } - - Task AfterValueChanged() - { - return Task.CompletedTask; - } -| - From 473432c870768d26319a0064fa9d1b3434c7927a Mon Sep 17 00:00:00 2001 From: jacalvar Date: Mon, 14 Mar 2022 18:52:52 +0100 Subject: [PATCH 24/33] Fix incorrect 'async' added to a method --- .../src/Components/ComponentBindLoweringPass.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs index 5409d84b8..1b49553b0 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs @@ -721,7 +721,7 @@ static CSharpExpressionIntermediateNode ExtractEventNodeExpression(TagHelperDire } } - private async void RewriteNodesForComponentDelegateBind( + private void RewriteNodesForComponentDelegateBind( IntermediateToken original, IntermediateToken setter, IntermediateToken after, From c44b5aac18af0981b53ee616fe5c934e0f4ee9ea Mon Sep 17 00:00:00 2001 From: jacalvar Date: Tue, 15 Mar 2022 16:21:33 +0100 Subject: [PATCH 25/33] Fix regression --- .../ComponentAttributeIntermediateNode.cs | 4 ++-- .../TestComponent.codegen.cs | 4 ++-- .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 12 ++++++------ .../TestComponent.ir.txt | 6 +++--- .../TestComponent.mappings.txt | 8 ++++---- .../TestComponent.ir.txt | 4 ++-- .../TestComponent.codegen.cs | 4 ++-- .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 4 ++-- .../TestComponent.ir.txt | 2 +- .../TestComponent.ir.txt | 6 +++--- .../TestComponent.ir.txt | 4 ++-- .../TestComponent.ir.txt | 2 +- 15 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ComponentAttributeIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ComponentAttributeIntermediateNode.cs index d160623c6..7eb2fc598 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ComponentAttributeIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ComponentAttributeIntermediateNode.cs @@ -100,10 +100,10 @@ public ComponentAttributeIntermediateNode(TagHelperDirectiveAttributeParameterIn AttributeName = directiveAttributeParameterNode.AttributeNameWithoutParameter; AttributeStructure = directiveAttributeParameterNode.AttributeStructure; BoundAttribute = directiveAttributeParameterNode.BoundAttribute; - PropertyName = directiveAttributeParameterNode.BoundAttribute.GetPropertyName(); + PropertyName = directiveAttributeParameterNode.BoundAttributeParameter.GetPropertyName(); Source = directiveAttributeParameterNode.Source; TagHelper = directiveAttributeParameterNode.TagHelper; - TypeName = directiveAttributeParameterNode.BoundAttribute.IsWeaklyTyped() ? null : directiveAttributeParameterNode.BoundAttribute.TypeName; + TypeName = directiveAttributeParameterNode.BoundAttributeParameter.TypeName; for (var i = 0; i < directiveAttributeParameterNode.Children.Count; i++) { diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs index 6e639b6be..4a484575b 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs @@ -27,7 +27,7 @@ private void __RazorDirectiveTokenHelpers__() { #pragma warning disable 1998 protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { - __o = + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" true @@ -35,7 +35,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line default #line hidden #nullable disable - ; + ); } #pragma warning restore 1998 } diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt index d6aeeca39..b3f45338d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt @@ -18,7 +18,7 @@ Document - HtmlContent - (42:0,42 [2] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (42:0,42 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n MarkupElement - (44:1,0 [64] x:\dir\subdir\Test\TestComponent.cshtml) - input - ComponentAttribute - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - onclick - AttributeStructure.DoubleQuotes + ComponentAttribute - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - PreventDefault - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true HtmlAttribute - - @onclick:preventDefault - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.mappings.txt index ed40a1ee9..7e5e9c17d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.mappings.txt @@ -5,6 +5,6 @@ Generated Location: (320:12,0 [41] ) Source Location: (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) |true| -Generated Location: (1084:32,32 [4] ) +Generated Location: (1190:32,32 [4] ) |true| diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs index 5ebec5122..cecfacc01 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs @@ -36,7 +36,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line hidden #nullable disable ); - __o = + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" true @@ -44,8 +44,8 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line default #line hidden #nullable disable - ; - __o = + ); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" Foo @@ -53,8 +53,8 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line default #line hidden #nullable disable - ; - __o = + ); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" false @@ -62,7 +62,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line default #line hidden #nullable disable - ; + ); } #pragma warning restore 1998 #nullable restore diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt index 659a6ce5c..4f9bc31b5 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt @@ -25,13 +25,13 @@ Document - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, LazyIntermediateToken - (62:1,18 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - () => Foo = false IntermediateToken - - CSharp - ) - ComponentAttribute - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - onfocus - AttributeStructure.DoubleQuotes + ComponentAttribute - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - PreventDefault - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true - ComponentAttribute - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - onclick - AttributeStructure.DoubleQuotes + ComponentAttribute - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - StopPropagation - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Foo - ComponentAttribute - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - onfocus - AttributeStructure.DoubleQuotes + ComponentAttribute - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - StopPropagation - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - false HtmlContent - (193:1,149 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt index 09788dee5..f9563b1fa 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt @@ -10,24 +10,24 @@ Generated Location: (1205:32,18 [17] ) Source Location: (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) |true| -Generated Location: (1442:41,62 [4] ) +Generated Location: (1548:41,62 [4] ) |true| Source Location: (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) |Foo| -Generated Location: (1697:50,94 [3] ) +Generated Location: (1910:50,94 [3] ) |Foo| Source Location: (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) |false| -Generated Location: (1982:59,125 [5] ) +Generated Location: (2302:59,125 [5] ) |false| Source Location: (202:2,7 [30] x:\dir\subdir\Test\TestComponent.cshtml) | bool Foo { get; set; } | -Generated Location: (2180:69,7 [30] ) +Generated Location: (2501:69,7 [30] ) | bool Foo { get; set; } | diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt index 514314786..8cad10932 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt @@ -20,5 +20,5 @@ Document - MarkupElement - (44:1,0 [74] x:\dir\subdir\Test\TestComponent.cshtml) - button HtmlContent - (101:1,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (101:1,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Click Me - ComponentAttribute - - onclick - onclick - AttributeStructure.Minimized - ComponentAttribute - - onclick - onclick - AttributeStructure.Minimized + ComponentAttribute - - onclick - PreventDefault - AttributeStructure.Minimized + ComponentAttribute - - onclick - StopPropagation - AttributeStructure.Minimized diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.codegen.cs index 425590cc6..2d1c1bf3d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.codegen.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.codegen.cs @@ -36,7 +36,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line hidden #nullable disable ); - __o = + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" ShouldPreventDefault() @@ -44,7 +44,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #line default #line hidden #nullable disable - ; + ); } #pragma warning restore 1998 #nullable restore diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt index ee6d0d2be..0ed0d31e3 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt @@ -23,7 +23,7 @@ Document - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, LazyIntermediateToken - (61:1,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnFocus IntermediateToken - - CSharp - ) - ComponentAttribute - (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - onfocus - AttributeStructure.DoubleQuotes + ComponentAttribute - (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - PreventDefault - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ShouldPreventDefault() HtmlContent - (121:1,77 [2] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.mappings.txt index 37cc2f888..db5044541 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.mappings.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.mappings.txt @@ -10,7 +10,7 @@ Generated Location: (1204:32,17 [7] ) Source Location: (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) |ShouldPreventDefault()| -Generated Location: (1420:41,51 [22] ) +Generated Location: (1526:41,51 [22] ) |ShouldPreventDefault()| Source Location: (130:2,7 [95] x:\dir\subdir\Test\TestComponent.cshtml) @@ -19,7 +19,7 @@ Source Location: (130:2,7 [95] x:\dir\subdir\Test\TestComponent.cshtml) bool ShouldPreventDefault() { return false; } | -Generated Location: (1635:51,7 [95] ) +Generated Location: (1742:51,7 [95] ) | void OnFocus(FocusEventArgs e) { } diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt index 08cc6d946..f8fbaca93 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.ir.txt @@ -9,7 +9,7 @@ Document - ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree MarkupElement - (44:1,0 [64] x:\dir\subdir\Test\TestComponent.cshtml) - input - ComponentAttribute - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - onclick - AttributeStructure.DoubleQuotes + ComponentAttribute - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - PreventDefault - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true HtmlAttribute - - @onclick:preventDefault - diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt index 234e4d8f8..bcf8439c2 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt @@ -16,13 +16,13 @@ Document - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, LazyIntermediateToken - (62:1,18 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - () => Foo = false IntermediateToken - - CSharp - ) - ComponentAttribute - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - onfocus - AttributeStructure.DoubleQuotes + ComponentAttribute - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - PreventDefault - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true - ComponentAttribute - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - onclick - AttributeStructure.DoubleQuotes + ComponentAttribute - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - StopPropagation - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Foo - ComponentAttribute - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - onfocus - AttributeStructure.DoubleQuotes + ComponentAttribute - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - StopPropagation - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - false CSharpCode - (202:2,7 [30] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt index 8d0efc3f0..7b4919bb9 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt @@ -11,5 +11,5 @@ Document - MarkupElement - (44:1,0 [74] x:\dir\subdir\Test\TestComponent.cshtml) - button HtmlContent - (101:1,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) LazyIntermediateToken - (101:1,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Click Me - ComponentAttribute - - onclick - onclick - AttributeStructure.Minimized - ComponentAttribute - - onclick - onclick - AttributeStructure.Minimized + ComponentAttribute - - onclick - PreventDefault - AttributeStructure.Minimized + ComponentAttribute - - onclick - StopPropagation - AttributeStructure.Minimized diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt index 366872695..6acdd8a2e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_WithDelegate_PreventDefault/TestComponent.ir.txt @@ -14,7 +14,7 @@ Document - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, LazyIntermediateToken - (61:1,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnFocus IntermediateToken - - CSharp - ) - ComponentAttribute - (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - onfocus - AttributeStructure.DoubleQuotes + ComponentAttribute - (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - PreventDefault - AttributeStructure.DoubleQuotes CSharpExpression - LazyIntermediateToken - (95:1,51 [22] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ShouldPreventDefault() CSharpCode - (130:2,7 [95] x:\dir\subdir\Test\TestComponent.cshtml) From dc35dcc44bbcea8a71e31c13fa3ceab10694abb2 Mon Sep 17 00:00:00 2001 From: jacalvar Date: Tue, 15 Mar 2022 16:56:23 +0100 Subject: [PATCH 26/33] Clarifying comment --- .../src/Components/ComponentBindLoweringPass.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs index 1b49553b0..336a80f7c 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs @@ -1093,10 +1093,11 @@ public BindEntry(IntermediateNodeReference bindNodeReference) public string GetOriginalAttributeName() => BindNode?.OriginalAttributeName ?? BindGetNode?.OriginalAttributeName; + // Return the attribute name, for @bind it's the attribute, for @bind:get is the attribute without the parameter part. public string GetEffectiveBindNodeAttributeName() => BindNode?.AttributeName ?? BindGetNode?.AttributeNameWithoutParameter; public string GetEffectiveBindNodeChangeAttributeName() => BindNode?.TagHelper.GetChangeAttributeName() ?? BindGetNode?.TagHelper.GetChangeAttributeName(); - internal string GetEffectiveBindNodeExpressionAttributeName() => BindNode?.TagHelper.GetExpressionAttributeName() ?? BindGetNode?.TagHelper.GetExpressionAttributeName(); + public string GetEffectiveBindNodeExpressionAttributeName() => BindNode?.TagHelper.GetExpressionAttributeName() ?? BindGetNode?.TagHelper.GetExpressionAttributeName(); } } From cfe3530e0d48ea8203613661b2ff8cfd50ac34d2 Mon Sep 17 00:00:00 2001 From: jacalvar Date: Tue, 15 Mar 2022 18:03:25 +0100 Subject: [PATCH 27/33] Add version 7.0 to RazorLanguageVersion, check for Version 7.0 for bind:get and bind:set style --- .../Components/ComponentBindLoweringPass.cs | 13 +++++ .../Components/ComponentDiagnosticFactory.cs | 15 ++++- .../src/RazorLanguageVersion.cs | 9 ++- .../src/RazorProjectEngine.cs | 2 +- .../ComponentCodeGenerationTestBase.cs | 44 ++++++++++++++ .../test/RazorLanguageVersionTest.cs | 16 ++++- .../TestComponent.codegen.cs | 58 +++++++++++++++++++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 27 +++++++++ .../TestComponent.mappings.txt | 18 ++++++ .../TestComponent.codegen.cs | 42 ++++++++++++++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 18 ++++++ .../TestComponent.mappings.txt | 13 +++++ .../Language/RazorProjectEngineTestBase.cs | 2 +- 15 files changed, 274 insertions(+), 5 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.diagnostics.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.diagnostics.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.mappings.txt diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs index 336a80f7c..3084c5cb1 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs @@ -14,6 +14,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Components; internal class ComponentBindLoweringPass : ComponentIntermediateNodePassBase, IRazorOptimizationPass { + private readonly bool _bindGetSetSupported; + + public ComponentBindLoweringPass(bool bindGetSetSupported) + { + _bindGetSetSupported = bindGetSetSupported; + } + // Run after event handler pass public override int Order => 100; @@ -90,6 +97,12 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte if (node.BoundAttributeParameter.Metadata.ContainsKey(ComponentMetadata.Bind.BindAttributeGetSet)) { + if (!_bindGetSetSupported) + { + node.Diagnostics.Add(ComponentDiagnosticFactory.CreateBindAttributeParameter_UnsupportedSyntaxBindGetSet( + node.Source, + node.AttributeName)); + } if (!bindEntries.TryGetValue((reference.Parent, node.AttributeNameWithoutParameter), out var existingEntry)) { bindEntries[(reference.Parent, node.AttributeNameWithoutParameter)] = new BindEntry(reference); diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs index 200a224f3..615c457b6 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs @@ -526,7 +526,6 @@ public static RazorDiagnostic CreateBindAttributeParameter_InvalidSyntaxBindAndB () => "Attribute '{0}:after' can not be used with '{0}:set'. Invoke the code in '{0}:after' inside '{0}:set' instead.", RazorDiagnosticSeverity.Error); - public static RazorDiagnostic CreateBindAttributeParameter_InvalidSyntaxBindSetAfter(SourceSpan? source, string attribute) { var diagnostic = RazorDiagnostic.Create( @@ -536,4 +535,18 @@ public static RazorDiagnostic CreateBindAttributeParameter_InvalidSyntaxBindSetA return diagnostic; } + public static readonly RazorDiagnosticDescriptor BindAttributeParameter_UnsupportedSyntaxBindGetSet = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10020", + () => "Attribute '{0}' can't only be used with RazorLanguageVersion 7.0 or higher.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreateBindAttributeParameter_UnsupportedSyntaxBindGetSet(SourceSpan? source, string attribute) + { + var diagnostic = RazorDiagnostic.Create( + BindAttributeParameter_UnsupportedSyntaxBindGetSet, + source ?? SourceSpan.Undefined, + attribute); + return diagnostic; + } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/RazorLanguageVersion.cs b/src/Microsoft.AspNetCore.Razor.Language/src/RazorLanguageVersion.cs index 0b68336f7..5e1a2d37d 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/RazorLanguageVersion.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/RazorLanguageVersion.cs @@ -26,7 +26,9 @@ public sealed class RazorLanguageVersion : IEquatable, ICo public static readonly RazorLanguageVersion Version_6_0 = new RazorLanguageVersion(6, 0); - public static readonly RazorLanguageVersion Latest = Version_6_0; + public static readonly RazorLanguageVersion Version_7_0 = new RazorLanguageVersion(7, 0); + + public static readonly RazorLanguageVersion Latest = Version_7_0; public static readonly RazorLanguageVersion Experimental = new RazorLanguageVersion(1337, 1337); @@ -47,6 +49,11 @@ public static bool TryParse(string languageVersion, out RazorLanguageVersion ver version = Experimental; return true; } + else if (languageVersion == "7.0") + { + version = Version_7_0; + return true; + } else if (languageVersion == "6.0") { version = Version_6_0; diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/RazorProjectEngine.cs b/src/Microsoft.AspNetCore.Razor.Language/src/RazorProjectEngine.cs index 40c42b46f..1b7cb85cd 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/RazorProjectEngine.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/RazorProjectEngine.cs @@ -254,7 +254,7 @@ private static void AddComponentFeatures(RazorProjectEngineBuilder builder, Razo builder.Features.Add(new ComponentKeyLoweringPass()); builder.Features.Add(new ComponentReferenceCaptureLoweringPass()); builder.Features.Add(new ComponentSplatLoweringPass()); - builder.Features.Add(new ComponentBindLoweringPass()); + builder.Features.Add(new ComponentBindLoweringPass(razorLanguageVersion.CompareTo(RazorLanguageVersion.Version_7_0) >= 0)); builder.Features.Add(new ComponentCssScopePass()); builder.Features.Add(new ComponentTemplateDiagnosticPass()); builder.Features.Add(new ComponentGenericTypePass()); diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index 3a640a175..4ef77b006 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -3,6 +3,7 @@ #nullable disable +using System; using System.Globalization; using System.Linq; using Microsoft.AspNetCore.Razor.Language.Components; @@ -2691,6 +2692,49 @@ public static class BindAttributes AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); } + [Fact] + public void BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions() + { + _configuration = RazorConfiguration.Create( + RazorLanguageVersion.Version_6_0, + "unnamed", + Array.Empty(), + false); + + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public int Value { get; set; } + + [Parameter] + public Action ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; + + public void UpdateValue(int value) => ParentValue = value; +}", throwOnFailure: false); + + // Assert + Assert.Collection(generated.Diagnostics, + diagnostic => Assert.Equal("RZ10020", diagnostic.Id)); + + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + } + [Fact] public void BindToElement_MixingSetWithAfter() { diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs b/src/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs index 2c38efba6..7d858df56 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs @@ -123,6 +123,20 @@ public void TryParse60() Assert.Same(RazorLanguageVersion.Version_6_0, version); } + [Fact] + public void TryParse70() + { + // Arrange + var value = "7.0"; + + // Act + var result = RazorLanguageVersion.TryParse(value, out var version); + + // Assert + Assert.True(result); + Assert.Same(RazorLanguageVersion.Version_7_0, version); + } + [Fact] public void TryParseLatest() { @@ -134,7 +148,7 @@ public void TryParseLatest() // Assert Assert.True(result); - Assert.Same(RazorLanguageVersion.Version_6_0, version); + Assert.Same(RazorLanguageVersion.Version_7_0, version); } [Fact] diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.codegen.cs new file mode 100644 index 000000000..dfb767b60 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.codegen.cs @@ -0,0 +1,58 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = new global::System.Action( + UpdateValue); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public void UpdateValue(int value) => ParentValue = value; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.diagnostics.txt new file mode 100644 index 000000000..f75c4853c --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,31): Error RZ10020: Attribute 'bind-Value:get' can't only be used with RazorLanguageVersion 7.0 or higher. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.ir.txt new file mode 100644 index 000000000..073dd9baa --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.ir.txt @@ -0,0 +1,27 @@ +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 - global::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 + Component - (0:0,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - UpdateValue + HtmlContent - (75:0,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (75:0,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public void UpdateValue(int value) => ParentValue = value;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.mappings.txt new file mode 100644 index 000000000..fe537597e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1022:25,30 [11] ) +|ParentValue| + +Source Location: (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public void UpdateValue(int value) => ParentValue = value; +| +Generated Location: (1638:47,7 [116] ) +| + public int ParentValue { get; set; } = 42; + + public void UpdateValue(int value) => ParentValue = value; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.codegen.cs new file mode 100644 index 000000000..8b4cd7490 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", (global::System.Action)(UpdateValue)); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public void UpdateValue(int value) => ParentValue = value; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.diagnostics.txt new file mode 100644 index 000000000..f75c4853c --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,31): Error RZ10020: Attribute 'bind-Value:get' can't only be used with RazorLanguageVersion 7.0 or higher. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.ir.txt new file mode 100644 index 000000000..11abda08c --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - UpdateValue + CSharpCode - (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public void UpdateValue(int value) => ParentValue = value;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.mappings.txt new file mode 100644 index 000000000..25810998e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (84:1,7 [116] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public void UpdateValue(int value) => ParentValue = value; +| +Generated Location: (1205:31,7 [116] ) +| + public int ParentValue { get; set; } = 42; + + public void UpdateValue(int value) => ParentValue = value; +| + diff --git a/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorProjectEngineTestBase.cs b/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorProjectEngineTestBase.cs index 85332e2ae..b41b6f07e 100644 --- a/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorProjectEngineTestBase.cs +++ b/src/test/Microsoft.AspNetCore.Razor.Test.Common/Language/RazorProjectEngineTestBase.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #nullable disable From 2441c434bb41f9aee6ed18f8bfd6b36549297755 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Wed, 23 Mar 2022 16:41:47 +0100 Subject: [PATCH 28/33] Update src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs Co-authored-by: Steve Sanderson --- .../src/Components/ComponentDiagnosticFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs index 615c457b6..e9876a725 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs @@ -538,7 +538,7 @@ public static RazorDiagnostic CreateBindAttributeParameter_InvalidSyntaxBindSetA public static readonly RazorDiagnosticDescriptor BindAttributeParameter_UnsupportedSyntaxBindGetSet = new RazorDiagnosticDescriptor( $"{DiagnosticPrefix}10020", - () => "Attribute '{0}' can't only be used with RazorLanguageVersion 7.0 or higher.", + () => "Attribute '{0}' can only be used with RazorLanguageVersion 7.0 or higher.", RazorDiagnosticSeverity.Error); public static RazorDiagnostic CreateBindAttributeParameter_UnsupportedSyntaxBindGetSet(SourceSpan? source, string attribute) From feb4d63cad3e762d642a6d7d96e255ddb6643aa9 Mon Sep 17 00:00:00 2001 From: jacalvar Date: Thu, 24 Mar 2022 15:57:38 +0100 Subject: [PATCH 29/33] Update baseline --- .../TestComponent.diagnostics.txt | 2 +- .../TestComponent.diagnostics.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.diagnostics.txt index f75c4853c..37f16c4b0 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.diagnostics.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.diagnostics.txt @@ -1 +1 @@ -x:\dir\subdir\Test\TestComponent.cshtml(1,31): Error RZ10020: Attribute 'bind-Value:get' can't only be used with RazorLanguageVersion 7.0 or higher. +x:\dir\subdir\Test\TestComponent.cshtml(1,31): Error RZ10020: Attribute 'bind-Value:get' can only be used with RazorLanguageVersion 7.0 or higher. diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.diagnostics.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.diagnostics.txt index f75c4853c..37f16c4b0 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.diagnostics.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithGetSet_ProducesErrorOnOlderLanguageVersions/TestComponent.diagnostics.txt @@ -1 +1 @@ -x:\dir\subdir\Test\TestComponent.cshtml(1,31): Error RZ10020: Attribute 'bind-Value:get' can't only be used with RazorLanguageVersion 7.0 or higher. +x:\dir\subdir\Test\TestComponent.cshtml(1,31): Error RZ10020: Attribute 'bind-Value:get' can only be used with RazorLanguageVersion 7.0 or higher. From 7151eb5de6f922c604a55d924289973bdffe726b Mon Sep 17 00:00:00 2001 From: jacalvar Date: Tue, 21 Jun 2022 16:51:19 +0200 Subject: [PATCH 30/33] Unskip test --- .../ComponentCodeGenerationTestBase.cs | 12 ++-- .../TestComponent.codegen.cs | 56 +++++++++++++++++++ .../TestComponent.ir.txt | 27 +++++++++ .../TestComponent.mappings.txt | 14 +++++ .../TestComponent.codegen.cs | 40 +++++++++++++ .../TestComponent.ir.txt | 18 ++++++ .../TestComponent.mappings.txt | 9 +++ 7 files changed, 172 insertions(+), 4 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.mappings.txt diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index 4ef77b006..e05f79e4a 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -2166,7 +2166,7 @@ public class MyComponent : ComponentBase CompileToAssembly(generated); } - [Fact(Skip = "tmp")] + [Fact] public void BindToComponent_WithAfter_AsyncLambdaProducesError() { // Arrange @@ -2188,7 +2188,7 @@ public class MyComponent : ComponentBase // Act var generated = CompileToCSharp(@" - { ParentValue = value; return Task.CompletedTask; }"" /> + { ParentValue = value; return Task.CompletedTask; })"" /> @code { public int ParentValue { get; set; } = 42; }"); @@ -2196,9 +2196,13 @@ public class MyComponent : ComponentBase // Assert AssertDocumentNodeMatchesBaseline(generated.CodeDocument); AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); - CompileToAssembly(generated); + var assembly = CompileToAssembly(generated, throwOnFailure: false); + // This has some errors + Assert.Collection( + assembly.Diagnostics.OrderBy(d => d.Id), + d => Assert.Equal("CS8030", d.Id)); } - + [Fact] public void BindToElement_WithStringAttribute_WritesAttributes() { diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.codegen.cs new file mode 100644 index 000000000..bb74374cd --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.codegen.cs @@ -0,0 +1,56 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = new global::System.Action( + (value => { ParentValue = value; return Task.CompletedTask; })); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.ir.txt new file mode 100644 index 000000000..5e2ec891d --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.ir.txt @@ -0,0 +1,27 @@ +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 - global::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 + Component - (0:0,0 [126] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - (value => { ParentValue = value; return Task.CompletedTask; }) + HtmlContent - (126:0,126 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (126:0,126 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (135:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (135:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.mappings.txt new file mode 100644 index 000000000..c2d001008 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1022:25,30 [11] ) +|ParentValue| + +Source Location: (135:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1689:47,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.codegen.cs new file mode 100644 index 000000000..ee851dc36 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", (global::System.Action)((value => { ParentValue = value; return Task.CompletedTask; }))); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.ir.txt new file mode 100644 index 000000000..7aa8a5072 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.ir.txt @@ -0,0 +1,18 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [126] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - (value => { ParentValue = value; return Task.CompletedTask; }) + CSharpCode - (135:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (135:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.mappings.txt new file mode 100644 index 000000000..7b3d6713e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_WithAfter_AsyncLambdaProducesError/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (135:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1256:31,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + From 0f2c6cd830c914a68143ad5e2568e0876a7ff7b7 Mon Sep 17 00:00:00 2001 From: jacalvar Date: Tue, 21 Jun 2022 18:24:40 +0200 Subject: [PATCH 31/33] Add tests to cover generics and type inference --- .../ComponentCodeGenerationTestBase.cs | 292 ++++++++++++++++++ .../TestComponent.codegen.cs | 67 ++++ .../TestComponent.ir.txt | 29 ++ .../TestComponent.mappings.txt | 23 ++ .../TestComponent.codegen.cs | 67 ++++ .../TestComponent.ir.txt | 31 ++ .../TestComponent.mappings.txt | 23 ++ .../TestComponent.codegen.cs | 68 ++++ .../TestComponent.ir.txt | 30 ++ .../TestComponent.mappings.txt | 18 ++ .../TestComponent.codegen.cs | 68 ++++ .../TestComponent.ir.txt | 32 ++ .../TestComponent.mappings.txt | 18 ++ .../TestComponent.codegen.cs | 77 +++++ .../TestComponent.ir.txt | 32 ++ .../TestComponent.mappings.txt | 28 ++ .../TestComponent.codegen.cs | 77 +++++ .../TestComponent.ir.txt | 30 ++ .../TestComponent.mappings.txt | 28 ++ .../TestComponent.codegen.cs | 78 +++++ .../TestComponent.ir.txt | 31 ++ .../TestComponent.mappings.txt | 23 ++ .../TestComponent.codegen.cs | 78 +++++ .../TestComponent.ir.txt | 33 ++ .../TestComponent.mappings.txt | 23 ++ .../TestComponent.codegen.cs | 42 +++ .../TestComponent.ir.txt | 20 ++ .../TestComponent.mappings.txt | 13 + .../TestComponent.codegen.cs | 42 +++ .../TestComponent.ir.txt | 22 ++ .../TestComponent.mappings.txt | 13 + .../TestComponent.codegen.cs | 53 ++++ .../TestComponent.ir.txt | 21 ++ .../TestComponent.mappings.txt | 13 + .../TestComponent.codegen.cs | 53 ++++ .../TestComponent.ir.txt | 23 ++ .../TestComponent.mappings.txt | 13 + .../TestComponent.codegen.cs | 42 +++ .../TestComponent.ir.txt | 22 ++ .../TestComponent.mappings.txt | 13 + .../TestComponent.codegen.cs | 42 +++ .../TestComponent.ir.txt | 20 ++ .../TestComponent.mappings.txt | 13 + .../TestComponent.codegen.cs | 53 ++++ .../TestComponent.ir.txt | 21 ++ .../TestComponent.mappings.txt | 13 + .../TestComponent.codegen.cs | 53 ++++ .../TestComponent.ir.txt | 23 ++ .../TestComponent.mappings.txt | 13 + 49 files changed, 1960 insertions(+) create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.mappings.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.codegen.cs create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.ir.txt create mode 100644 src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.mappings.txt diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index e05f79e4a..7c51f2efc 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -1857,6 +1857,156 @@ public class MyComponent : ComponentBase CompileToAssembly(generated); } + [Fact] + public void BindToGenericComponent_InferredType_WithGetSet_EventCallback() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public TValue Value { get; set; } + + [Parameter] + public EventCallback ValueChanged { get; set; } + } + + public class CustomValue + { + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public CustomValue ParentValue { get; set; } = new CustomValue(); + + public EventCallback UpdateValue { get; set; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToGenericComponent_ExplicitType_WithGetSet_EventCallback() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public TValue Value { get; set; } + + [Parameter] + public EventCallback ValueChanged { get; set; } + } + + public class CustomValue + { + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public CustomValue ParentValue { get; set; } = new CustomValue(); + + public EventCallback UpdateValue { get; set; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public TValue Value { get; set; } + + [Parameter] + public EventCallback ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" +@typeparam TParam + +@code { + public TParam ParentValue { get; set; } = default; + + public EventCallback UpdateValue { get; set; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public TValue Value { get; set; } + + [Parameter] + public EventCallback ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" +@typeparam TParam + +@code { + public TParam ParentValue { get; set; } = default; + + public EventCallback UpdateValue { get; set; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + [Fact] public void BindToComponent_WithGetSet_EventCallback_ReceivesAction() { @@ -2030,6 +2180,148 @@ public void Update() { } CompileToAssembly(generated); } + [Fact] + public void BindToGenericComponent_InferredType_WithAfter_Action() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public TValue Value { get; set; } + + [Parameter] + public Action ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; + + public void Update() { } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void BindToGenericComponent_ExplicitType_WithAfter_Action() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public TValue Value { get; set; } + + [Parameter] + public Action ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; + + public void Update() { } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void GenericComponentBindToGenericComponent_InferredType_WithAfter_Action() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public TValue Value { get; set; } + + [Parameter] + public Action ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" +@typeparam TParam + +@code { + public TParam ParentValue { get; set; } + + public void Update() { } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + public TValue Value { get; set; } + + [Parameter] + public Action ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" +@typeparam TParam + +@code { + public TParam ParentValue { get; set; } + + public void Update() { } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + [Fact] public void BindToComponent_WithAfter_ActionLambda() { diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.codegen.cs new file mode 100644 index 000000000..654fac836 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.codegen.cs @@ -0,0 +1,67 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = typeof( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + int + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = new global::System.Action( + __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); }); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent<>); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public void Update() { } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.ir.txt new file mode 100644 index 000000000..f85ffaf1e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.ir.txt @@ -0,0 +1,29 @@ +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 - global::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 + Component - (0:0,0 [85] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentTypeArgument - (21:0,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - TValue + LazyIntermediateToken - (21:0,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - int + ComponentAttribute - (43:0,43 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (43:0,43 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (43:0,43 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); } + HtmlContent - (85:0,85 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (85:0,85 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (94:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (94:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public void Update() { }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.mappings.txt new file mode 100644 index 000000000..a16ab777b --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.mappings.txt @@ -0,0 +1,23 @@ +Source Location: (21:0,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|int| +Generated Location: (916:25,21 [3] ) +|int| + +Source Location: (43:0,43 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1207:34,43 [11] ) +|ParentValue| + +Source Location: (94:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public void Update() { } +| +Generated Location: (1949:56,7 [82] ) +| + public int ParentValue { get; set; } = 42; + + public void Update() { } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.codegen.cs new file mode 100644 index 000000000..b3a829287 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.codegen.cs @@ -0,0 +1,67 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = typeof( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + CustomValue + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, UpdateValue, ParentValue))); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent<>); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public CustomValue ParentValue { get; set; } = new CustomValue(); + + public EventCallback UpdateValue { get; set; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.ir.txt new file mode 100644 index 000000000..9b4a2f850 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/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 - global::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 + Component - (0:0,0 [96] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentTypeArgument - (21:0,21 [11] x:\dir\subdir\Test\TestComponent.cshtml) - TValue + LazyIntermediateToken - (21:0,21 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - CustomValue + ComponentAttribute - (51:0,51 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (51:0,51 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (51:0,51 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - UpdateValue + IntermediateToken - - CSharp - , ParentValue) + HtmlContent - (96:0,96 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (96:0,96 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (105:1,7 [140] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (105:1,7 [140] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public CustomValue ParentValue { get; set; } = new CustomValue();\n\n public EventCallback UpdateValue { get; set; }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.mappings.txt new file mode 100644 index 000000000..394b5e1eb --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.mappings.txt @@ -0,0 +1,23 @@ +Source Location: (21:0,21 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|CustomValue| +Generated Location: (916:25,21 [11] ) +|CustomValue| + +Source Location: (51:0,51 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1231:34,51 [11] ) +|ParentValue| + +Source Location: (105:1,7 [140] x:\dir\subdir\Test\TestComponent.cshtml) +| + public CustomValue ParentValue { get; set; } = new CustomValue(); + + public EventCallback UpdateValue { get; set; } +| +Generated Location: (2168:56,7 [140] ) +| + public CustomValue ParentValue { get; set; } = new CustomValue(); + + public EventCallback UpdateValue { get; set; } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.codegen.cs new file mode 100644 index 000000000..4d03da6f0 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.codegen.cs @@ -0,0 +1,68 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + global::__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(__builder, -1, -1, +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + , -1, + __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); }); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent<>); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public void Update() { } + +#line default +#line hidden +#nullable disable + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, TValue __arg0, int __seq1, global::System.Action __arg1) + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "Value", __arg0); + __builder.AddAttribute(__seq1, "ValueChanged", __arg1); + __builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.ir.txt new file mode 100644 index 000000000..3eab3137c --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.ir.txt @@ -0,0 +1,30 @@ +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 - global::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 + Component - (0:0,0 [72] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); } + HtmlContent - (72:0,72 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (72:0,72 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public void Update() { }\n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.mappings.txt new file mode 100644 index 000000000..05b7a7fe4 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1001:25,30 [11] ) +|ParentValue| + +Source Location: (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public void Update() { } +| +Generated Location: (1533:43,7 [82] ) +| + public int ParentValue { get; set; } = 42; + + public void Update() { } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.codegen.cs new file mode 100644 index 000000000..c14eaa14e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.codegen.cs @@ -0,0 +1,68 @@ +// +#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 : global::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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + global::__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(__builder, -1, -1, +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + , -1, global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, UpdateValue, ParentValue))); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent<>); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public CustomValue ParentValue { get; set; } = new CustomValue(); + + public EventCallback UpdateValue { get; set; } + +#line default +#line hidden +#nullable disable + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, TValue __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback __arg1) + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "Value", __arg0); + __builder.AddAttribute(__seq1, "ValueChanged", __arg1); + __builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.ir.txt new file mode 100644 index 000000000..f4b4071e7 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.ir.txt @@ -0,0 +1,32 @@ +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 - global::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 + Component - (0:0,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - UpdateValue + IntermediateToken - - CSharp - , ParentValue) + HtmlContent - (75:0,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (75:0,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (84:1,7 [140] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (84:1,7 [140] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public CustomValue ParentValue { get; set; } = new CustomValue();\n\n public EventCallback UpdateValue { get; set; }\n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.mappings.txt new file mode 100644 index 000000000..ee94de2b5 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.mappings.txt @@ -0,0 +1,18 @@ +Source Location: (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1001:25,30 [11] ) +|ParentValue| + +Source Location: (84:1,7 [140] x:\dir\subdir\Test\TestComponent.cshtml) +| + public CustomValue ParentValue { get; set; } = new CustomValue(); + + public EventCallback UpdateValue { get; set; } +| +Generated Location: (1596:43,7 [140] ) +| + public CustomValue ParentValue { get; set; } = new CustomValue(); + + public EventCallback UpdateValue { get; set; } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.codegen.cs new file mode 100644 index 000000000..b21bfc9e9 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.codegen.cs @@ -0,0 +1,77 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +global::System.Object TParam = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = typeof( +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + TParam + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, UpdateValue, ParentValue))); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent<>); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public TParam ParentValue { get; set; } = default; + + public EventCallback UpdateValue { get; set; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.ir.txt new file mode 100644 index 000000000..90a5ddb3a --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.ir.txt @@ -0,0 +1,32 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - - TParam + DesignTimeDirective - + DirectiveToken - (11:0,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TParam + 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 + Component - (19:1,0 [91] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentTypeArgument - (40:1,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TValue + LazyIntermediateToken - (40:1,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - TParam + ComponentAttribute - (65:1,46 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (65:1,46 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (65:1,46 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - UpdateValue + IntermediateToken - - CSharp - , ParentValue) + HtmlContent - (110:1,91 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (110:1,91 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (119:2,7 [120] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (119:2,7 [120] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public TParam ParentValue { get; set; } = default;\n\n public EventCallback UpdateValue { get; set; }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.mappings.txt new file mode 100644 index 000000000..1a08445a5 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.mappings.txt @@ -0,0 +1,28 @@ +Source Location: (11:0,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|TParam| +Generated Location: (581:17,22 [6] ) +|TParam| + +Source Location: (40:1,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|TParam| +Generated Location: (1143:35,21 [6] ) +|TParam| + +Source Location: (65:1,46 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1443:44,46 [11] ) +|ParentValue| + +Source Location: (119:2,7 [120] x:\dir\subdir\Test\TestComponent.cshtml) +| + public TParam ParentValue { get; set; } = default; + + public EventCallback UpdateValue { get; set; } +| +Generated Location: (2370:66,7 [120] ) +| + public TParam ParentValue { get; set; } = default; + + public EventCallback UpdateValue { get; set; } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.codegen.cs new file mode 100644 index 000000000..cda55e41e --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.codegen.cs @@ -0,0 +1,77 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +global::System.Object TParam = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __o = typeof( +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + TParam + +#line default +#line hidden +#nullable disable + ); + __o = global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + __o = new global::System.Action( + __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); }); + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent<>); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public TParam ParentValue { get; set; } + + public void Update() { } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.ir.txt new file mode 100644 index 000000000..a73d5c79a --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.ir.txt @@ -0,0 +1,30 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - - TParam + DesignTimeDirective - + DirectiveToken - (11:0,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TParam + 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 + Component - (19:1,0 [88] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentTypeArgument - (40:1,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TValue + LazyIntermediateToken - (40:1,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - TParam + ComponentAttribute - (65:1,46 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (65:1,46 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (65:1,46 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); } + HtmlContent - (107:1,88 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (107:1,88 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (116:2,7 [79] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (116:2,7 [79] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public TParam ParentValue { get; set; }\n\n public void Update() { }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.mappings.txt new file mode 100644 index 000000000..595dd57ae --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.mappings.txt @@ -0,0 +1,28 @@ +Source Location: (11:0,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|TParam| +Generated Location: (581:17,22 [6] ) +|TParam| + +Source Location: (40:1,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|TParam| +Generated Location: (1143:35,21 [6] ) +|TParam| + +Source Location: (65:1,46 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1443:44,46 [11] ) +|ParentValue| + +Source Location: (116:2,7 [79] x:\dir\subdir\Test\TestComponent.cshtml) +| + public TParam ParentValue { get; set; } + + public void Update() { } +| +Generated Location: (2188:66,7 [79] ) +| + public TParam ParentValue { get; set; } + + public void Update() { } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.codegen.cs new file mode 100644 index 000000000..49ab855b6 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.codegen.cs @@ -0,0 +1,78 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +global::System.Object TParam = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + global::__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(__builder, -1, -1, +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + , -1, + __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); }); +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent<>); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public TParam ParentValue { get; set; } + + public void Update() { } + +#line default +#line hidden +#nullable disable + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, TValue __arg0, int __seq1, global::System.Action __arg1) + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "Value", __arg0); + __builder.AddAttribute(__seq1, "ValueChanged", __arg1); + __builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.ir.txt new file mode 100644 index 000000000..bcd19fe87 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/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 - global::Microsoft.AspNetCore.Components.ComponentBase - - TParam + DesignTimeDirective - + DirectiveToken - (11:0,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TParam + 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 + Component - (19:1,0 [72] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (49:1,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (49:1,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (49:1,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); } + HtmlContent - (91:1,72 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (91:1,72 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (100:2,7 [79] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (100:2,7 [79] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public TParam ParentValue { get; set; }\n\n public void Update() { }\n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.mappings.txt new file mode 100644 index 000000000..d4d73911d --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.mappings.txt @@ -0,0 +1,23 @@ +Source Location: (11:0,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|TParam| +Generated Location: (581:17,22 [6] ) +|TParam| + +Source Location: (49:1,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1228:35,30 [11] ) +|ParentValue| + +Source Location: (100:2,7 [79] x:\dir\subdir\Test\TestComponent.cshtml) +| + public TParam ParentValue { get; set; } + + public void Update() { } +| +Generated Location: (1760:53,7 [79] ) +| + public TParam ParentValue { get; set; } + + public void Update() { } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.codegen.cs new file mode 100644 index 000000000..c0cca4047 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.codegen.cs @@ -0,0 +1,78 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +global::System.Object TParam = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + } + #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(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + global::__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(__builder, -1, -1, +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + , -1, global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, UpdateValue, ParentValue))); +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.MyComponent<>); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public TParam ParentValue { get; set; } = default; + + public EventCallback UpdateValue { get; set; } + +#line default +#line hidden +#nullable disable + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, TValue __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback __arg1) + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "Value", __arg0); + __builder.AddAttribute(__seq1, "ValueChanged", __arg1); + __builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.ir.txt new file mode 100644 index 000000000..2a9526e96 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.ir.txt @@ -0,0 +1,33 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - - TParam + DesignTimeDirective - + DirectiveToken - (11:0,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TParam + 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 + Component - (19:1,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (49:1,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (49:1,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (49:1,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - UpdateValue + IntermediateToken - - CSharp - , ParentValue) + HtmlContent - (94:1,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (94:1,75 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (103:2,7 [120] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (103:2,7 [120] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public TParam ParentValue { get; set; } = default;\n\n public EventCallback UpdateValue { get; set; }\n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.mappings.txt new file mode 100644 index 000000000..dac382f49 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.mappings.txt @@ -0,0 +1,23 @@ +Source Location: (11:0,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|TParam| +Generated Location: (581:17,22 [6] ) +|TParam| + +Source Location: (49:1,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1228:35,30 [11] ) +|ParentValue| + +Source Location: (103:2,7 [120] x:\dir\subdir\Test\TestComponent.cshtml) +| + public TParam ParentValue { get; set; } = default; + + public EventCallback UpdateValue { get; set; } +| +Generated Location: (1823:53,7 [120] ) +| + public TParam ParentValue { get; set; } = default; + + public EventCallback UpdateValue { get; set; } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.codegen.cs new file mode 100644 index 000000000..cc3ad96a8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent>(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", (global::System.Action)(__value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); })); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public void Update() { } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.ir.txt new file mode 100644 index 000000000..e5fe73e4b --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [85] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentTypeArgument - (21:0,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - TValue + LazyIntermediateToken - (21:0,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - int + ComponentAttribute - (43:0,43 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (43:0,43 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (43:0,43 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); } + CSharpCode - (94:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (94:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public void Update() { }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.mappings.txt new file mode 100644 index 000000000..5695b67eb --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (94:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public void Update() { } +| +Generated Location: (1330:31,7 [82] ) +| + public int ParentValue { get; set; } = 42; + + public void Update() { } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.codegen.cs new file mode 100644 index 000000000..b23ea6186 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent>(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, UpdateValue, ParentValue)))); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public CustomValue ParentValue { get; set; } = new CustomValue(); + + public EventCallback UpdateValue { get; set; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.ir.txt new file mode 100644 index 000000000..649e9ffee --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.ir.txt @@ -0,0 +1,22 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [96] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentTypeArgument - (21:0,21 [11] x:\dir\subdir\Test\TestComponent.cshtml) - TValue + LazyIntermediateToken - (21:0,21 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - CustomValue + ComponentAttribute - (51:0,51 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (51:0,51 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (51:0,51 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - UpdateValue + IntermediateToken - - CSharp - , ParentValue) + CSharpCode - (105:1,7 [140] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (105:1,7 [140] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public CustomValue ParentValue { get; set; } = new CustomValue();\n\n public EventCallback UpdateValue { get; set; }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.mappings.txt new file mode 100644 index 000000000..95784a6d0 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (105:1,7 [140] x:\dir\subdir\Test\TestComponent.cshtml) +| + public CustomValue ParentValue { get; set; } = new CustomValue(); + + public EventCallback UpdateValue { get; set; } +| +Generated Location: (1551:31,7 [140] ) +| + public CustomValue ParentValue { get; set; } = new CustomValue(); + + public EventCallback UpdateValue { get; set; } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.codegen.cs new file mode 100644 index 000000000..410a07f61 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.codegen.cs @@ -0,0 +1,53 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + global::__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(__builder, 0, 1, +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + , 2, __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); }); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + + public void Update() { } + +#line default +#line hidden +#nullable disable + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, TValue __arg0, int __seq1, global::System.Action __arg1) + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "Value", __arg0); + __builder.AddAttribute(__seq1, "ValueChanged", __arg1); + __builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.ir.txt new file mode 100644 index 000000000..124e318b8 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.ir.txt @@ -0,0 +1,21 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [72] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); } + CSharpCode - (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n\n public void Update() { }\n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.mappings.txt new file mode 100644 index 000000000..b3bfc4704 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithAfter_Action/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (81:1,7 [82] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; + + public void Update() { } +| +Generated Location: (1085:28,7 [82] ) +| + public int ParentValue { get; set; } = 42; + + public void Update() { } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.codegen.cs new file mode 100644 index 000000000..398fc4b19 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.codegen.cs @@ -0,0 +1,53 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + global::__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(__builder, 0, 1, +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + , 2, global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, UpdateValue, ParentValue))); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public CustomValue ParentValue { get; set; } = new CustomValue(); + + public EventCallback UpdateValue { get; set; } + +#line default +#line hidden +#nullable disable + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, TValue __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback __arg1) + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "Value", __arg0); + __builder.AddAttribute(__seq1, "ValueChanged", __arg1); + __builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.ir.txt new file mode 100644 index 000000000..6c64a686c --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/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 - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - UpdateValue + IntermediateToken - - CSharp - , ParentValue) + CSharpCode - (84:1,7 [140] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (84:1,7 [140] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public CustomValue ParentValue { get; set; } = new CustomValue();\n\n public EventCallback UpdateValue { get; set; }\n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.mappings.txt new file mode 100644 index 000000000..6b9fc8079 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (84:1,7 [140] x:\dir\subdir\Test\TestComponent.cshtml) +| + public CustomValue ParentValue { get; set; } = new CustomValue(); + + public EventCallback UpdateValue { get; set; } +| +Generated Location: (1148:28,7 [140] ) +| + public CustomValue ParentValue { get; set; } = new CustomValue(); + + public EventCallback UpdateValue { get; set; } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.codegen.cs new file mode 100644 index 000000000..18d4a01c9 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent>(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>(global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, UpdateValue, ParentValue)))); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public TParam ParentValue { get; set; } = default; + + public EventCallback UpdateValue { get; set; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.ir.txt new file mode 100644 index 000000000..00dda9fbf --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.ir.txt @@ -0,0 +1,22 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - - TParam + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (19:1,0 [91] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentTypeArgument - (40:1,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TValue + LazyIntermediateToken - (40:1,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - TParam + ComponentAttribute - (65:1,46 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (65:1,46 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (65:1,46 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - UpdateValue + IntermediateToken - - CSharp - , ParentValue) + CSharpCode - (119:2,7 [120] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (119:2,7 [120] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public TParam ParentValue { get; set; } = default;\n\n public EventCallback UpdateValue { get; set; }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.mappings.txt new file mode 100644 index 000000000..fd9ab4215 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericBindToGenericComponent_ExplicitType_WithGetSet_EventCallback/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (119:2,7 [120] x:\dir\subdir\Test\TestComponent.cshtml) +| + public TParam ParentValue { get; set; } = default; + + public EventCallback UpdateValue { get; set; } +| +Generated Location: (1534:31,7 [120] ) +| + public TParam ParentValue { get; set; } = default; + + public EventCallback UpdateValue { get; set; } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.codegen.cs new file mode 100644 index 000000000..3d99bb148 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent>(0); + __builder.AddAttribute(1, "Value", global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(2, "ValueChanged", (global::System.Action)(__value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); })); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public TParam ParentValue { get; set; } + + public void Update() { } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.ir.txt new file mode 100644 index 000000000..145c23ba4 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.ir.txt @@ -0,0 +1,20 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - - TParam + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (19:1,0 [88] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentTypeArgument - (40:1,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TValue + LazyIntermediateToken - (40:1,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - TParam + ComponentAttribute - (65:1,46 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (65:1,46 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (65:1,46 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); } + CSharpCode - (116:2,7 [79] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (116:2,7 [79] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public TParam ParentValue { get; set; }\n\n public void Update() { }\n diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.mappings.txt new file mode 100644 index 000000000..978b33d5f --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_ExplicitType_WithAfter_Action/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (116:2,7 [79] x:\dir\subdir\Test\TestComponent.cshtml) +| + public TParam ParentValue { get; set; } + + public void Update() { } +| +Generated Location: (1350:31,7 [79] ) +| + public TParam ParentValue { get; set; } + + public void Update() { } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.codegen.cs new file mode 100644 index 000000000..04182db2f --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.codegen.cs @@ -0,0 +1,53 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + global::__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(__builder, 0, 1, +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + , 2, __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); }); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public TParam ParentValue { get; set; } + + public void Update() { } + +#line default +#line hidden +#nullable disable + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, TValue __arg0, int __seq1, global::System.Action __arg1) + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "Value", __arg0); + __builder.AddAttribute(__seq1, "ValueChanged", __arg1); + __builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.ir.txt new file mode 100644 index 000000000..14fa5b3a6 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.ir.txt @@ -0,0 +1,21 @@ +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 - global::Microsoft.AspNetCore.Components.ComponentBase - - TParam + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (19:1,0 [72] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (49:1,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (49:1,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (49:1,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - __value => { ParentValue = __value; global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.InvokeSynchronousDelegate(Update); } + CSharpCode - (100:2,7 [79] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (100:2,7 [79] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public TParam ParentValue { get; set; }\n\n public void Update() { }\n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.mappings.txt new file mode 100644 index 000000000..0b2c3090f --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithAfter_Action/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (100:2,7 [79] x:\dir\subdir\Test\TestComponent.cshtml) +| + public TParam ParentValue { get; set; } + + public void Update() { } +| +Generated Location: (1093:28,7 [79] ) +| + public TParam ParentValue { get; set; } + + public void Update() { } +| + diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.codegen.cs b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.codegen.cs new file mode 100644 index 000000000..0ee61ee1a --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.codegen.cs @@ -0,0 +1,53 @@ +// +#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 : global::Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + global::__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(__builder, 0, 1, +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + , 2, global::Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, UpdateValue, ParentValue))); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public TParam ParentValue { get; set; } = default; + + public EventCallback UpdateValue { get; set; } + +#line default +#line hidden +#nullable disable + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, TValue __arg0, int __seq1, global::Microsoft.AspNetCore.Components.EventCallback __arg1) + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "Value", __arg0); + __builder.AddAttribute(__seq1, "ValueChanged", __arg1); + __builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.ir.txt new file mode 100644 index 000000000..685c03a36 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/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 - global::Microsoft.AspNetCore.Components.ComponentBase - - TParam + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (19:1,0 [75] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (49:1,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value - AttributeStructure.DoubleQuotes + CSharpExpression - + LazyIntermediateToken - (49:1,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + ComponentAttribute - (49:1,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - UpdateValue + IntermediateToken - - CSharp - , ParentValue) + CSharpCode - (103:2,7 [120] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (103:2,7 [120] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public TParam ParentValue { get; set; } = default;\n\n public EventCallback UpdateValue { get; set; }\n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.mappings.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.mappings.txt new file mode 100644 index 000000000..172dd783a --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponentBindToGenericComponent_InferredType_WithGetSet_EventCallback/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (103:2,7 [120] x:\dir\subdir\Test\TestComponent.cshtml) +| + public TParam ParentValue { get; set; } = default; + + public EventCallback UpdateValue { get; set; } +| +Generated Location: (1156:28,7 [120] ) +| + public TParam ParentValue { get; set; } = default; + + public EventCallback UpdateValue { get; set; } +| + From eaab3d673128d3dad8d12e60d659ee7de36740b9 Mon Sep 17 00:00:00 2001 From: jacalvar Date: Tue, 21 Jun 2022 19:38:09 +0200 Subject: [PATCH 32/33] Update the Razor Language Version on the SDK --- .../Diagnostics/RazorSourceGeneratorResources.resx | 2 +- src/RazorSdk/Targets/Sdk.Razor.CurrentVersion.targets | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/RazorSdk/SourceGenerators/Diagnostics/RazorSourceGeneratorResources.resx b/src/RazorSdk/SourceGenerators/Diagnostics/RazorSourceGeneratorResources.resx index 3609a5757..0b33e3d77 100644 --- a/src/RazorSdk/SourceGenerators/Diagnostics/RazorSourceGeneratorResources.resx +++ b/src/RazorSdk/SourceGenerators/Diagnostics/RazorSourceGeneratorResources.resx @@ -121,7 +121,7 @@ Invalid RazorLangVersion - Invalid value '{0}'' for RazorLangVersion. Valid values include 'Latest' or a valid version in range 1.0 to 5.0. + Invalid value '{0}'' for RazorLangVersion. Valid values include 'Latest' or a valid version in range 1.0 to 7.0. Recomputing tag helpers diff --git a/src/RazorSdk/Targets/Sdk.Razor.CurrentVersion.targets b/src/RazorSdk/Targets/Sdk.Razor.CurrentVersion.targets index fd259e30e..043250e42 100644 --- a/src/RazorSdk/Targets/Sdk.Razor.CurrentVersion.targets +++ b/src/RazorSdk/Targets/Sdk.Razor.CurrentVersion.targets @@ -44,6 +44,16 @@ Copyright (c) .NET Foundation. All rights reserved. + + + <_TargetingNETCoreApp30OrLater>true + <_TargetingNET50OrLater>true + <_TargetingNET60OrLater>true + <_TargetingNET70OrLater>true + true + 7.0 + + <_TargetingNETCoreApp30OrLater>true From a8ed31ca47af12b19af63583554d7039ae2322b7 Mon Sep 17 00:00:00 2001 From: jacalvar Date: Tue, 21 Jun 2022 19:54:14 +0200 Subject: [PATCH 33/33] Update baselines --- .../TestComponent.ir.txt | 4 +++- .../TestComponent.ir.txt | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression_NestedGeneric/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression_NestedGeneric/TestComponent.ir.txt index 107143df5..bedb00e74 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression_NestedGeneric/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression_NestedGeneric/TestComponent.ir.txt @@ -20,7 +20,9 @@ Document - LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParamChanged - SomeParamChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , ParentValue) ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParamExpression - SomeParamExpression - AttributeStructure.DoubleQuotes CSharpExpression - IntermediateToken - - CSharp - () => ParentValue diff --git a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression_NestedGeneric/TestComponent.ir.txt b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression_NestedGeneric/TestComponent.ir.txt index 54585cf84..87bffa8a1 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression_NestedGeneric/TestComponent.ir.txt +++ b/src/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_EventCallback_SpecifiesValueAndExpression_NestedGeneric/TestComponent.ir.txt @@ -13,7 +13,9 @@ Document - LazyIntermediateToken - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParamChanged - SomeParamChanged - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, __value => ParentValue = __value, ParentValue) + IntermediateToken - - CSharp - global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.CreateInferredEventCallback(this, + IntermediateToken - - CSharp - __value => ParentValue = __value + IntermediateToken - - CSharp - , ParentValue) ComponentAttribute - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) - SomeParamExpression - SomeParamExpression - AttributeStructure.DoubleQuotes CSharpExpression - IntermediateToken - - CSharp - () => ParentValue