From 7a42271d754760265e3c967c68ea3aba4d709151 Mon Sep 17 00:00:00 2001 From: Jan Jones Date: Fri, 24 Feb 2023 10:44:39 +0100 Subject: [PATCH 1/4] Add nullable enable option --- .../RazorIntegrationTestBase.cs | 41 +++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/src/Compiler/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorIntegrationTestBase.cs b/src/Compiler/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorIntegrationTestBase.cs index 4a9f8576f21..456446e831d 100644 --- a/src/Compiler/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorIntegrationTestBase.cs +++ b/src/Compiler/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/RazorIntegrationTestBase.cs @@ -176,12 +176,30 @@ internal RazorProjectItem CreateProjectItem(string cshtmlRelativePath, string cs }; } - protected CompileToCSharpResult CompileToCSharp(string cshtmlContent, bool throwOnFailure = true, string cssScope = null, bool supportLocalizedComponentNames = false) + protected CompileToCSharpResult CompileToCSharp( + string cshtmlContent, + bool throwOnFailure = true, + string cssScope = null, + bool supportLocalizedComponentNames = false, + bool nullableEnable = false) { - return CompileToCSharp(DefaultFileName, cshtmlContent, throwOnFailure, cssScope: cssScope, supportLocalizedComponentNames: supportLocalizedComponentNames); + return CompileToCSharp( + DefaultFileName, + cshtmlContent, + throwOnFailure, + cssScope: cssScope, + supportLocalizedComponentNames: supportLocalizedComponentNames, + nullableEnable: nullableEnable); } - protected CompileToCSharpResult CompileToCSharp(string cshtmlRelativePath, string cshtmlContent, bool throwOnFailure = true, string fileKind = null, string cssScope = null, bool supportLocalizedComponentNames = false) + protected CompileToCSharpResult CompileToCSharp( + string cshtmlRelativePath, + string cshtmlContent, + bool throwOnFailure = true, + string fileKind = null, + string cssScope = null, + bool supportLocalizedComponentNames = false, + bool nullableEnable = false) { if (DeclarationOnly && DesignTime) { @@ -193,6 +211,13 @@ protected CompileToCSharpResult CompileToCSharp(string cshtmlRelativePath, strin throw new InvalidOperationException($"{nameof(DeclarationOnly)} cannot be used with {nameof(UseTwoPhaseCompilation)}."); } + var baseCompilation = BaseCompilation; + + if (nullableEnable) + { + baseCompilation = baseCompilation.WithOptions(baseCompilation.Options.WithNullableContextOptions(NullableContextOptions.Enable)); + } + if (UseTwoPhaseCompilation) { // The first phase won't include any metadata references for component discovery. This mirrors @@ -215,7 +240,7 @@ protected CompileToCSharpResult CompileToCSharp(string cshtmlRelativePath, strin codeDocument = projectEngine.ProcessDeclarationOnly(projectItem); var declaration = new CompileToCSharpResult { - BaseCompilation = BaseCompilation.AddSyntaxTrees(AdditionalSyntaxTrees), + BaseCompilation = baseCompilation.AddSyntaxTrees(AdditionalSyntaxTrees), CodeDocument = codeDocument, Code = codeDocument.GetCSharpDocument().GeneratedCode, Diagnostics = codeDocument.GetCSharpDocument().Diagnostics, @@ -225,7 +250,7 @@ protected CompileToCSharpResult CompileToCSharp(string cshtmlRelativePath, strin var tempAssembly = CompileToAssembly(declaration, throwOnFailure); // Add the 'temp' compilation as a metadata reference - var references = BaseCompilation.References.Concat(new[] { tempAssembly.Compilation.ToMetadataReference() }).ToArray(); + var references = baseCompilation.References.Concat(new[] { tempAssembly.Compilation.ToMetadataReference() }).ToArray(); projectEngine = CreateProjectEngine(Configuration, references, supportLocalizedComponentNames); // Now update the any additional files @@ -245,7 +270,7 @@ protected CompileToCSharpResult CompileToCSharp(string cshtmlRelativePath, strin codeDocument = DesignTime ? projectEngine.ProcessDesignTime(projectItem) : projectEngine.Process(projectItem); return new CompileToCSharpResult { - BaseCompilation = BaseCompilation.AddSyntaxTrees(AdditionalSyntaxTrees), + BaseCompilation = baseCompilation.AddSyntaxTrees(AdditionalSyntaxTrees), CodeDocument = codeDocument, Code = codeDocument.GetCSharpDocument().GeneratedCode, Diagnostics = codeDocument.GetCSharpDocument().Diagnostics, @@ -255,7 +280,7 @@ protected CompileToCSharpResult CompileToCSharp(string cshtmlRelativePath, strin { // For single phase compilation tests just use the base compilation's references. // This will include the built-in components. - var projectEngine = CreateProjectEngine(Configuration, BaseCompilation.References.ToArray(), supportLocalizedComponentNames); + var projectEngine = CreateProjectEngine(Configuration, baseCompilation.References.ToArray(), supportLocalizedComponentNames); var projectItem = CreateProjectItem(cshtmlRelativePath, cshtmlContent, fileKind, cssScope); @@ -275,7 +300,7 @@ protected CompileToCSharpResult CompileToCSharp(string cshtmlRelativePath, strin return new CompileToCSharpResult { - BaseCompilation = BaseCompilation.AddSyntaxTrees(AdditionalSyntaxTrees), + BaseCompilation = baseCompilation.AddSyntaxTrees(AdditionalSyntaxTrees), CodeDocument = codeDocument, Code = codeDocument.GetCSharpDocument().GeneratedCode, Diagnostics = codeDocument.GetCSharpDocument().Diagnostics, From 04a688688ddb655239a2c8571236e0c3da184c59 Mon Sep 17 00:00:00 2001 From: Jan Jones Date: Fri, 24 Feb 2023 10:44:48 +0100 Subject: [PATCH 2/4] Add tests --- .../ComponentCodeGenerationTestBase.cs | 52 ++++++++++++ .../TestComponent.codegen.cs | 53 ++++++++++++ .../TestComponent.ir.txt | 22 +++++ .../TestComponent.mappings.txt | 16 ++++ .../TestComponent.codegen.cs | 85 +++++++++++++++++++ .../TestComponent.ir.txt | 27 ++++++ .../TestComponent.mappings.txt | 26 ++++++ .../TestComponent.codegen.cs | 41 +++++++++ .../TestComponent.ir.txt | 13 +++ .../TestComponent.mappings.txt | 16 ++++ .../TestComponent.codegen.cs | 61 +++++++++++++ .../TestComponent.ir.txt | 18 ++++ .../TestComponent.mappings.txt | 16 ++++ 13 files changed, 446 insertions(+) create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.codegen.cs create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.ir.txt create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.mappings.txt create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.codegen.cs create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.ir.txt create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.mappings.txt create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.codegen.cs create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.ir.txt create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.mappings.txt create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.codegen.cs create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.ir.txt create mode 100644 src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.mappings.txt diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index c9a6ddabcec..975492a8f42 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -7322,6 +7322,58 @@ public class MyComponent : ComponentBase CompileToAssembly(generated); } + [Fact] // https://github.com/dotnet/razor/issues/8170 + public void Component_WithRef_Nullable() + { + // Act + var generated = CompileToCSharp(""" + + + @code { + private TestComponent myComponent = null!; + public void Use() { System.GC.KeepAlive(myComponent); } + } + """, + nullableEnable: true); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] // https://github.com/dotnet/razor/issues/8170 + public void Component_WithRef_Nullable_Generic() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(""" + using Microsoft.AspNetCore.Components; + + namespace Test; + + public class MyComponent : ComponentBase + { + [Parameter] public T MyParameter { get; set; } = default!; + } + """)); + + // Act + var generated = CompileToCSharp(""" + + + @code { + private MyComponent myComponent = null!; + public void Use() { System.GC.KeepAlive(myComponent); } + } + """, + nullableEnable: true); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + [Fact] public void Component_WithRef_WithChildContent() { diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.codegen.cs new file mode 100644 index 00000000000..04efc9c84dc --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/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 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) + { + __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + myComponent = default(global::Test.TestComponent); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(global::Test.TestComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + private TestComponent myComponent = null!; + public void Use() { System.GC.KeepAlive(myComponent); } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.ir.txt new file mode 100644 index 00000000000..a4c49be7c6a --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.ir.txt @@ -0,0 +1,22 @@ +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 [36] x:\dir\subdir\Test\TestComponent.cshtml) - TestComponent + ReferenceCapture - (21:0,21 [11] x:\dir\subdir\Test\TestComponent.cshtml) - myComponent + HtmlContent - (36:0,36 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (36:0,36 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + CSharpCode - (47:2,7 [111] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (47:2,7 [111] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private TestComponent myComponent = null!;\n public void Use() { System.GC.KeepAlive(myComponent); }\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.mappings.txt new file mode 100644 index 00000000000..f3696c34375 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.mappings.txt @@ -0,0 +1,16 @@ +Source Location: (21:0,21 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|myComponent| +Generated Location: (1052:27,21 [11] ) +|myComponent| + +Source Location: (47:2,7 [111] x:\dir\subdir\Test\TestComponent.cshtml) +| + private TestComponent myComponent = null!; + public void Use() { System.GC.KeepAlive(myComponent); } +| +Generated Location: (1443:43,7 [111] ) +| + private TestComponent myComponent = null!; + public void Use() { System.GC.KeepAlive(myComponent); } +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.codegen.cs new file mode 100644 index 00000000000..72855286f00 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.codegen.cs @@ -0,0 +1,85 @@ +// +#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) + { + var __typeInference_CreateMyComponent_0 = global::__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(__builder, -1, -1, +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + 1 + +#line default +#line hidden +#nullable disable + , -1, (__value) => { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + myComponent = __value; + +#line default +#line hidden +#nullable disable + } + ); + __o = __typeInference_CreateMyComponent_0. +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + MyParameter + +#line default +#line hidden +#nullable disable + ; +#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 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + private MyComponent myComponent = null!; + public void Use() { System.GC.KeepAlive(myComponent); } + +#line default +#line hidden +#nullable disable + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static global::Test.MyComponent CreateMyComponent_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, T __arg0, int __seq1, System.Action> __arg1) + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "MyParameter", __arg0); + __builder.AddComponentReferenceCapture(__seq1, (__value) => { __arg1((global::Test.MyComponent)__value); }); + __builder.CloseComponent(); + return default; + } + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.ir.txt new file mode 100644 index 00000000000..55e14e43717 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/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 [50] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ReferenceCapture - (19:0,19 [11] x:\dir\subdir\Test\TestComponent.cshtml) - myComponent + ComponentAttribute - (45:0,45 [1] x:\dir\subdir\Test\TestComponent.cshtml) - MyParameter - MyParameter - AttributeStructure.DoubleQuotes + LazyIntermediateToken - (45:0,45 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 1 + HtmlContent - (50:0,50 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (50:0,50 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + CSharpCode - (61:2,7 [114] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (61:2,7 [114] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private MyComponent myComponent = null!;\n public void Use() { System.GC.KeepAlive(myComponent); }\n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.mappings.txt new file mode 100644 index 00000000000..612106b5f23 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.mappings.txt @@ -0,0 +1,26 @@ +Source Location: (45:0,45 [1] x:\dir\subdir\Test\TestComponent.cshtml) +|1| +Generated Location: (1058:25,45 [1] ) +|1| + +Source Location: (19:0,19 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|myComponent| +Generated Location: (1234:33,19 [11] ) +|myComponent| + +Source Location: (32:0,32 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|MyParameter| +Generated Location: (1497:43,32 [11] ) +|MyParameter| + +Source Location: (61:2,7 [114] x:\dir\subdir\Test\TestComponent.cshtml) +| + private MyComponent myComponent = null!; + public void Use() { System.GC.KeepAlive(myComponent); } +| +Generated Location: (1864:60,7 [114] ) +| + private MyComponent myComponent = null!; + public void Use() { System.GC.KeepAlive(myComponent); } +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.codegen.cs new file mode 100644 index 00000000000..37f8eb49d50 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable/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.AddComponentReferenceCapture(1, (__value) => { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + myComponent = (Test.TestComponent)__value; + +#line default +#line hidden +#nullable disable + } + ); + __builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + private TestComponent myComponent = null!; + public void Use() { System.GC.KeepAlive(myComponent); } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.ir.txt new file mode 100644 index 00000000000..29d0db6a84e --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.ir.txt @@ -0,0 +1,13 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [36] x:\dir\subdir\Test\TestComponent.cshtml) - TestComponent + ReferenceCapture - (21:0,21 [11] x:\dir\subdir\Test\TestComponent.cshtml) - myComponent + CSharpCode - (47:2,7 [111] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (47:2,7 [111] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private TestComponent myComponent = null!;\n public void Use() { System.GC.KeepAlive(myComponent); }\n diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.mappings.txt new file mode 100644 index 00000000000..5b59b175caa --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.mappings.txt @@ -0,0 +1,16 @@ +Source Location: (21:0,21 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|myComponent| +Generated Location: (760:19,21 [11] ) +|myComponent| + +Source Location: (47:2,7 [111] x:\dir\subdir\Test\TestComponent.cshtml) +| + private TestComponent myComponent = null!; + public void Use() { System.GC.KeepAlive(myComponent); } +| +Generated Location: (1052:31,7 [111] ) +| + private TestComponent myComponent = null!; + public void Use() { System.GC.KeepAlive(myComponent); } +| + diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.codegen.cs new file mode 100644 index 00000000000..b967734f501 --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.codegen.cs @@ -0,0 +1,61 @@ +// +#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" + 1 + +#line default +#line hidden +#nullable disable + , 2, (__value) => { +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + myComponent = __value; + +#line default +#line hidden +#nullable disable + } + ); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + private MyComponent myComponent = null!; + public void Use() { System.GC.KeepAlive(myComponent); } + +#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, System.Action> __arg1) + { + __builder.OpenComponent>(seq); + __builder.AddAttribute(__seq0, "MyParameter", __arg0); + __builder.AddComponentReferenceCapture(__seq1, (__value) => { __arg1((global::Test.MyComponent)__value); }); + __builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.ir.txt new file mode 100644 index 00000000000..8c6774242aa --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable_Generic/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 [50] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ReferenceCapture - (19:0,19 [11] x:\dir\subdir\Test\TestComponent.cshtml) - myComponent + ComponentAttribute - (45:0,45 [1] x:\dir\subdir\Test\TestComponent.cshtml) - MyParameter - MyParameter - AttributeStructure.DoubleQuotes + LazyIntermediateToken - (45:0,45 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 1 + CSharpCode - (61:2,7 [114] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (61:2,7 [114] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private MyComponent myComponent = null!;\n public void Use() { System.GC.KeepAlive(myComponent); }\n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.mappings.txt new file mode 100644 index 00000000000..b7259814ccb --- /dev/null +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.mappings.txt @@ -0,0 +1,16 @@ +Source Location: (19:0,19 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|myComponent| +Generated Location: (921:26,19 [11] ) +|myComponent| + +Source Location: (61:2,7 [114] x:\dir\subdir\Test\TestComponent.cshtml) +| + private MyComponent myComponent = null!; + public void Use() { System.GC.KeepAlive(myComponent); } +| +Generated Location: (1152:37,7 [114] ) +| + private MyComponent myComponent = null!; + public void Use() { System.GC.KeepAlive(myComponent); } +| + From 1c8b84e016f262d490c625601f0ff5429bec4705 Mon Sep 17 00:00:00 2001 From: Jan Jones Date: Fri, 24 Feb 2023 11:05:13 +0100 Subject: [PATCH 3/4] Add null suppression to component reference capture --- .../ComponentDesignTimeNodeWriter.cs | 3 ++- .../TestComponent.codegen.cs | 4 ++-- .../TestComponent.mappings.txt | 18 +++++++++--------- .../Component_WithRef/TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../Element_WithRef/TestComponent.codegen.cs | 2 +- .../Element_WithRef/TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 2 +- .../TestComponent.codegen.cs | 2 +- .../TestComponent.mappings.txt | 4 ++-- 15 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDesignTimeNodeWriter.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDesignTimeNodeWriter.cs index 6aa033d2beb..f8d06e7c49f 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDesignTimeNodeWriter.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDesignTimeNodeWriter.cs @@ -1119,6 +1119,7 @@ protected override void WriteReferenceCaptureInnards(CodeRenderingContext contex var captureTypeName = node.IsComponentCapture ? TypeNameHelper.GetGloballyQualifiedNameIfNeeded(node.ComponentCaptureTypeName) : ComponentsApi.ElementReference.FullTypeName; + var nullSuppression = !context.Options.SuppressNullabilityEnforcement ? "!" : string.Empty; WriteCSharpCode(context, new CSharpCodeIntermediateNode { Source = node.Source, @@ -1128,7 +1129,7 @@ protected override void WriteReferenceCaptureInnards(CodeRenderingContext contex new IntermediateToken { Kind = TokenKind.CSharp, - Content = $" = default({captureTypeName});" + Content = $" = default({captureTypeName}){nullSuppression};" } } }); diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithCssScope/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithCssScope/TestComponent.codegen.cs index 13760fbbc1f..3fb86a564e4 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithCssScope/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithCssScope/TestComponent.codegen.cs @@ -48,7 +48,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. )); #nullable restore #line 7 "x:\dir\subdir\Test\TestComponent.cshtml" - myComponentReference = default(global::Test.TemplatedComponent); + myComponentReference = default(global::Test.TemplatedComponent)!; #line default #line hidden @@ -71,7 +71,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. #nullable disable #nullable restore #line 13 "x:\dir\subdir\Test\TestComponent.cshtml" - myElementReference = default(Microsoft.AspNetCore.Components.ElementReference); + myElementReference = default(Microsoft.AspNetCore.Components.ElementReference)!; #line default #line hidden diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithCssScope/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithCssScope/TestComponent.mappings.txt index 0c62ee6ed60..4843dd866df 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithCssScope/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithCssScope/TestComponent.mappings.txt @@ -22,32 +22,32 @@ Source Location: (439:10,1 [38] x:\dir\subdir\Test\TestComponent.cshtml) |if (DateTime.Now.Year > 1950) { | -Generated Location: (1972:64,1 [38] ) +Generated Location: (1973:64,1 [38] ) |if (DateTime.Now.Year > 1950) { | Source Location: (511:12,38 [18] x:\dir\subdir\Test\TestComponent.cshtml) |myElementReference| -Generated Location: (2171:73,38 [18] ) +Generated Location: (2172:73,38 [18] ) |myElementReference| Source Location: (557:12,84 [6] x:\dir\subdir\Test\TestComponent.cshtml) | | -Generated Location: (2386:78,84 [6] ) +Generated Location: (2388:78,84 [6] ) | | Source Location: (589:13,30 [10] x:\dir\subdir\Test\TestComponent.cshtml) |myVariable| -Generated Location: (2581:83,30 [10] ) +Generated Location: (2583:83,30 [10] ) |myVariable| Source Location: (637:13,78 [3] x:\dir\subdir\Test\TestComponent.cshtml) | }| -Generated Location: (2954:92,78 [3] ) +Generated Location: (2956:92,78 [3] ) | }| @@ -62,7 +62,7 @@ Source Location: (651:16,7 [245] x:\dir\subdir\Test\TestComponent.cshtml) for (var i = 0; i < 10; i++) { | -Generated Location: (3136:102,7 [245] ) +Generated Location: (3138:102,7 [245] ) | ElementReference myElementReference; TemplatedComponent myComponentReference; @@ -76,12 +76,12 @@ Generated Location: (3136:102,7 [245] ) Source Location: (912:25,28 [1] x:\dir\subdir\Test\TestComponent.cshtml) |i| -Generated Location: (3548:119,28 [1] ) +Generated Location: (3550:119,28 [1] ) |i| Source Location: (925:25,41 [1] x:\dir\subdir\Test\TestComponent.cshtml) |i| -Generated Location: (3724:127,41 [1] ) +Generated Location: (3726:127,41 [1] ) |i| Source Location: (931:25,47 [166] x:\dir\subdir\Test\TestComponent.cshtml) @@ -93,7 +93,7 @@ Source Location: (931:25,47 [166] x:\dir\subdir\Test\TestComponent.cshtml) System.GC.KeepAlive(myVariable); } | -Generated Location: (3896:134,47 [166] ) +Generated Location: (3898:134,47 [166] ) | } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.codegen.cs index 83367f90560..654a3b63beb 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.codegen.cs @@ -27,7 +27,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. )); #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - myInstance = default(global::Test.MyComponent); + myInstance = default(global::Test.MyComponent)!; #line default #line hidden diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt index 4b923a07f50..3e188ad4e99 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt @@ -8,7 +8,7 @@ Source Location: (84:2,7 [104] x:\dir\subdir\Test\TestComponent.cshtml) private Test.MyComponent myInstance; public void Foo() { System.GC.KeepAlive(myInstance); } | -Generated Location: (1503:45,7 [104] ) +Generated Location: (1504:45,7 [104] ) | private Test.MyComponent myInstance; public void Foo() { System.GC.KeepAlive(myInstance); } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.codegen.cs index 04efc9c84dc..73ef70dce9d 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.codegen.cs @@ -25,7 +25,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. )); #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - myComponent = default(global::Test.TestComponent); + myComponent = default(global::Test.TestComponent)!; #line default #line hidden diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.mappings.txt index f3696c34375..7602508752a 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.mappings.txt @@ -8,7 +8,7 @@ Source Location: (47:2,7 [111] x:\dir\subdir\Test\TestComponent.cshtml) private TestComponent myComponent = null!; public void Use() { System.GC.KeepAlive(myComponent); } | -Generated Location: (1443:43,7 [111] ) +Generated Location: (1444:43,7 [111] ) | private TestComponent myComponent = null!; public void Use() { System.GC.KeepAlive(myComponent); } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs index 69a71a16ae2..1be7ed201fe 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs @@ -26,7 +26,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. )); #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - myInstance = default(global::Test.MyComponent); + myInstance = default(global::Test.MyComponent)!; #line default #line hidden diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt index e1db88f1562..b81ec98378f 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt @@ -8,7 +8,7 @@ Source Location: (108:4,7 [104] x:\dir\subdir\Test\TestComponent.cshtml) private Test.MyComponent myInstance; public void Foo() { System.GC.KeepAlive(myInstance); } | -Generated Location: (1459:44,7 [104] ) +Generated Location: (1460:44,7 [104] ) | private Test.MyComponent myInstance; public void Foo() { System.GC.KeepAlive(myInstance); } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.codegen.cs index fa8cd729223..1c21e3c9a50 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.codegen.cs @@ -22,7 +22,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. { #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - myElem = default(Microsoft.AspNetCore.Components.ElementReference); + myElem = default(Microsoft.AspNetCore.Components.ElementReference)!; #line default #line hidden diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt index ba6e422db44..bfc3adf9820 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt @@ -8,7 +8,7 @@ Source Location: (91:2,7 [128] x:\dir\subdir\Test\TestComponent.cshtml) private Microsoft.AspNetCore.Components.ElementReference myElem; public void Foo() { System.GC.KeepAlive(myElem); } | -Generated Location: (1150:33,7 [128] ) +Generated Location: (1151:33,7 [128] ) | private Microsoft.AspNetCore.Components.ElementReference myElem; public void Foo() { System.GC.KeepAlive(myElem); } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.codegen.cs index c3652462c84..f0d2975a370 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.codegen.cs @@ -31,7 +31,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. ; #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - _element = default(Microsoft.AspNetCore.Components.ElementReference); + _element = default(Microsoft.AspNetCore.Components.ElementReference)!; #line default #line hidden diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.mappings.txt index 585bcbbdd21..62a1ab983a4 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.mappings.txt @@ -15,7 +15,7 @@ Source Location: (72:2,7 [164] x:\dir\subdir\Test\TestComponent.cshtml) [Parameter] public int Min { get; set; } public void Foo() { System.GC.KeepAlive(_element); } | -Generated Location: (1361:42,7 [164] ) +Generated Location: (1362:42,7 [164] ) | private ElementReference _element; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.codegen.cs index dbd1bc78dd6..ec8f500cf56 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.codegen.cs @@ -43,7 +43,7 @@ protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components. )); #nullable restore #line 1 "x:\dir\subdir\Test\TestComponent.cshtml" - _my = default(global::Test.MyComponent); + _my = default(global::Test.MyComponent)!; #line default #line hidden diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.mappings.txt index da84d6f2039..176d2ddd4ce 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.mappings.txt @@ -15,7 +15,7 @@ Generated Location: (1531:45,38 [3] ) Source Location: (23:0,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) |Item| -Generated Location: (1782:53,23 [4] ) +Generated Location: (1783:53,23 [4] ) |Item| Source Location: (56:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml) @@ -23,7 +23,7 @@ Source Location: (56:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml) private MyComponent _my; public void Foo() { System.GC.KeepAlive(_my); } | -Generated Location: (2142:70,7 [90] ) +Generated Location: (2143:70,7 [90] ) | private MyComponent _my; public void Foo() { System.GC.KeepAlive(_my); } From b68401000583364f53d4da43ede9e36864c68a35 Mon Sep 17 00:00:00 2001 From: Jan Jones Date: Wed, 1 Mar 2023 15:19:01 +0100 Subject: [PATCH 4/4] Update baselines --- .../TestComponent.mappings.txt | 20 +++++++++---------- .../TestComponent.mappings.txt | 4 ++-- .../TestComponent.codegen.cs | 2 +- .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 4 ++-- .../TestComponent.codegen.cs | 2 +- .../TestComponent.ir.txt | 2 +- .../TestComponent.mappings.txt | 8 ++++---- .../TestComponent.mappings.txt | 4 ++-- .../TestComponent.mappings.txt | 4 ++-- .../TestComponent.mappings.txt | 4 ++-- .../TestComponent.mappings.txt | 12 ++--------- 12 files changed, 30 insertions(+), 38 deletions(-) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithCssScope/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithCssScope/TestComponent.mappings.txt index f4f55dc869d..858def71a9c 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithCssScope/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithCssScope/TestComponent.mappings.txt @@ -1,4 +1,4 @@ -Source Location: (1:0,1 [41] x:\dir\subdir\Test\TestComponent.cshtml) +Source Location: (1:0,1 [41] x:\dir\subdir\Test\TestComponent.cshtml) |using Microsoft.AspNetCore.Components.Web| Generated Location: (320:12,0 [41] ) |using Microsoft.AspNetCore.Components.Web| @@ -22,32 +22,32 @@ Source Location: (439:10,1 [38] x:\dir\subdir\Test\TestComponent.cshtml) |if (DateTime.Now.Year > 1950) { | -Generated Location: (1972:64,1 [38] ) +Generated Location: (1966:64,1 [38] ) |if (DateTime.Now.Year > 1950) { | Source Location: (511:12,38 [18] x:\dir\subdir\Test\TestComponent.cshtml) |myElementReference| -Generated Location: (2171:73,38 [18] ) +Generated Location: (2165:73,38 [18] ) |myElementReference| Source Location: (557:12,84 [6] x:\dir\subdir\Test\TestComponent.cshtml) | | -Generated Location: (2386:78,84 [6] ) +Generated Location: (2381:78,84 [6] ) | | Source Location: (589:13,30 [10] x:\dir\subdir\Test\TestComponent.cshtml) |myVariable| -Generated Location: (2581:83,30 [10] ) +Generated Location: (2576:83,30 [10] ) |myVariable| Source Location: (637:13,78 [3] x:\dir\subdir\Test\TestComponent.cshtml) | }| -Generated Location: (2954:92,78 [3] ) +Generated Location: (2949:92,78 [3] ) | }| @@ -62,7 +62,7 @@ Source Location: (651:16,7 [245] x:\dir\subdir\Test\TestComponent.cshtml) for (var i = 0; i < 10; i++) { | -Generated Location: (3136:102,7 [245] ) +Generated Location: (3131:102,7 [245] ) | ElementReference myElementReference; TemplatedComponent myComponentReference; @@ -76,12 +76,12 @@ Generated Location: (3136:102,7 [245] ) Source Location: (912:25,28 [1] x:\dir\subdir\Test\TestComponent.cshtml) |i| -Generated Location: (3548:119,28 [1] ) +Generated Location: (3543:119,28 [1] ) |i| Source Location: (925:25,41 [1] x:\dir\subdir\Test\TestComponent.cshtml) |i| -Generated Location: (3724:127,41 [1] ) +Generated Location: (3719:127,41 [1] ) |i| Source Location: (931:25,47 [166] x:\dir\subdir\Test\TestComponent.cshtml) @@ -93,7 +93,7 @@ Source Location: (931:25,47 [166] x:\dir\subdir\Test\TestComponent.cshtml) System.GC.KeepAlive(myVariable); } | -Generated Location: (3896:134,47 [166] ) +Generated Location: (3891:134,47 [166] ) | } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt index 1913029382d..c4265a0eb10 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt @@ -1,4 +1,4 @@ -Source Location: (40:0,40 [10] x:\dir\subdir\Test\TestComponent.cshtml) +Source Location: (40:0,40 [10] x:\dir\subdir\Test\TestComponent.cshtml) |myInstance| Generated Location: (1110:29,40 [10] ) |myInstance| @@ -8,7 +8,7 @@ Source Location: (84:2,7 [104] x:\dir\subdir\Test\TestComponent.cshtml) private Test.MyComponent myInstance; public void Foo() { System.GC.KeepAlive(myInstance); } | -Generated Location: (1503:45,7 [104] ) +Generated Location: (1497:45,7 [104] ) | private Test.MyComponent myInstance; public void Foo() { System.GC.KeepAlive(myInstance); } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.codegen.cs index 73ef70dce9d..4fde7088fa3 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.codegen.cs @@ -15,7 +15,7 @@ private void __RazorDirectiveTokenHelpers__() { } #pragma warning restore 219 #pragma warning disable 0414 - private static System.Object __o = null; + private static object __o = null; #pragma warning restore 0414 #pragma warning disable 1998 protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.ir.txt index a4c49be7c6a..31e008726d0 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.ir.txt @@ -10,7 +10,7 @@ CSharpCode - IntermediateToken - - CSharp - #pragma warning disable 0414 CSharpCode - - IntermediateToken - - CSharp - private static System.Object __o = null; + IntermediateToken - - CSharp - private static object __o = null; CSharpCode - IntermediateToken - - CSharp - #pragma warning restore 0414 MethodDeclaration - - protected override - void - BuildRenderTree diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.mappings.txt index 7602508752a..96370f4aa78 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.mappings.txt @@ -1,6 +1,6 @@ Source Location: (21:0,21 [11] x:\dir\subdir\Test\TestComponent.cshtml) |myComponent| -Generated Location: (1052:27,21 [11] ) +Generated Location: (1045:27,21 [11] ) |myComponent| Source Location: (47:2,7 [111] x:\dir\subdir\Test\TestComponent.cshtml) @@ -8,7 +8,7 @@ Source Location: (47:2,7 [111] x:\dir\subdir\Test\TestComponent.cshtml) private TestComponent myComponent = null!; public void Use() { System.GC.KeepAlive(myComponent); } | -Generated Location: (1444:43,7 [111] ) +Generated Location: (1437:43,7 [111] ) | private TestComponent myComponent = null!; public void Use() { System.GC.KeepAlive(myComponent); } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.codegen.cs b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.codegen.cs index 72855286f00..66e16f168cd 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.codegen.cs +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.codegen.cs @@ -15,7 +15,7 @@ private void __RazorDirectiveTokenHelpers__() { } #pragma warning restore 219 #pragma warning disable 0414 - private static System.Object __o = null; + private static object __o = null; #pragma warning restore 0414 #pragma warning disable 1998 protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.ir.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.ir.txt index 55e14e43717..88be72d3faa 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.ir.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.ir.txt @@ -10,7 +10,7 @@ CSharpCode - IntermediateToken - - CSharp - #pragma warning disable 0414 CSharpCode - - IntermediateToken - - CSharp - private static System.Object __o = null; + IntermediateToken - - CSharp - private static object __o = null; CSharpCode - IntermediateToken - - CSharp - #pragma warning restore 0414 MethodDeclaration - - protected override - void - BuildRenderTree diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.mappings.txt index 612106b5f23..83ae92fc576 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.mappings.txt @@ -1,16 +1,16 @@ Source Location: (45:0,45 [1] x:\dir\subdir\Test\TestComponent.cshtml) |1| -Generated Location: (1058:25,45 [1] ) +Generated Location: (1051:25,45 [1] ) |1| Source Location: (19:0,19 [11] x:\dir\subdir\Test\TestComponent.cshtml) |myComponent| -Generated Location: (1234:33,19 [11] ) +Generated Location: (1227:33,19 [11] ) |myComponent| Source Location: (32:0,32 [11] x:\dir\subdir\Test\TestComponent.cshtml) |MyParameter| -Generated Location: (1497:43,32 [11] ) +Generated Location: (1490:43,32 [11] ) |MyParameter| Source Location: (61:2,7 [114] x:\dir\subdir\Test\TestComponent.cshtml) @@ -18,7 +18,7 @@ Source Location: (61:2,7 [114] x:\dir\subdir\Test\TestComponent.cshtml) private MyComponent myComponent = null!; public void Use() { System.GC.KeepAlive(myComponent); } | -Generated Location: (1864:60,7 [114] ) +Generated Location: (1857:60,7 [114] ) | private MyComponent myComponent = null!; public void Use() { System.GC.KeepAlive(myComponent); } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt index e67a25bea85..5c315dcca50 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt @@ -1,4 +1,4 @@ -Source Location: (19:0,19 [10] x:\dir\subdir\Test\TestComponent.cshtml) +Source Location: (19:0,19 [10] x:\dir\subdir\Test\TestComponent.cshtml) |myInstance| Generated Location: (1066:28,19 [10] ) |myInstance| @@ -8,7 +8,7 @@ Source Location: (108:4,7 [104] x:\dir\subdir\Test\TestComponent.cshtml) private Test.MyComponent myInstance; public void Foo() { System.GC.KeepAlive(myInstance); } | -Generated Location: (1459:44,7 [104] ) +Generated Location: (1453:44,7 [104] ) | private Test.MyComponent myInstance; public void Foo() { System.GC.KeepAlive(myInstance); } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt index 7598f352179..5eb383394e2 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt @@ -1,4 +1,4 @@ -Source Location: (37:0,37 [6] x:\dir\subdir\Test\TestComponent.cshtml) +Source Location: (37:0,37 [6] x:\dir\subdir\Test\TestComponent.cshtml) |myElem| Generated Location: (898:24,37 [6] ) |myElem| @@ -8,7 +8,7 @@ Source Location: (91:2,7 [128] x:\dir\subdir\Test\TestComponent.cshtml) private Microsoft.AspNetCore.Components.ElementReference myElem; public void Foo() { System.GC.KeepAlive(myElem); } | -Generated Location: (1150:33,7 [128] ) +Generated Location: (1144:33,7 [128] ) | private Microsoft.AspNetCore.Components.ElementReference myElem; public void Foo() { System.GC.KeepAlive(myElem); } diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.mappings.txt index 884aea8073b..da11f7b54d3 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.mappings.txt @@ -1,4 +1,4 @@ -Source Location: (37:0,37 [3] x:\dir\subdir\Test\TestComponent.cshtml) +Source Location: (37:0,37 [3] x:\dir\subdir\Test\TestComponent.cshtml) |Min| Generated Location: (918:25,37 [3] ) |Min| @@ -15,7 +15,7 @@ Source Location: (72:2,7 [164] x:\dir\subdir\Test\TestComponent.cshtml) [Parameter] public int Min { get; set; } public void Foo() { System.GC.KeepAlive(_element); } | -Generated Location: (1361:42,7 [164] ) +Generated Location: (1355:42,7 [164] ) | private ElementReference _element; diff --git a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.mappings.txt b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.mappings.txt index 2c7c9d44d09..10206cac394 100644 --- a/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.mappings.txt +++ b/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.mappings.txt @@ -15,11 +15,7 @@ Generated Location: (1524:45,38 [3] ) Source Location: (23:0,23 [4] x:\dir\subdir\Test\TestComponent.cshtml) |Item| -<<<<<<< HEAD -Generated Location: (1783:53,23 [4] ) -======= -Generated Location: (1775:53,23 [4] ) ->>>>>>> main +Generated Location: (1776:53,23 [4] ) |Item| Source Location: (56:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml) @@ -27,11 +23,7 @@ Source Location: (56:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml) private MyComponent _my; public void Foo() { System.GC.KeepAlive(_my); } | -<<<<<<< HEAD -Generated Location: (2143:70,7 [90] ) -======= -Generated Location: (2135:70,7 [90] ) ->>>>>>> main +Generated Location: (2136:70,7 [90] ) | private MyComponent _my; public void Foo() { System.GC.KeepAlive(_my); }