-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add null suppression to component reference capture (#8320)
* Add nullable enable option * Add tests * Add null suppression to component reference capture * Update baselines
- Loading branch information
Showing
27 changed files
with
503 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.codegen.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// <auto-generated/> | ||
#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 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 |
22 changes: 22 additions & 0 deletions
22
...sts/ComponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.ir.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 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 |
16 changes: 16 additions & 0 deletions
16
...mponentDesignTimeCodeGenerationTest/Component_WithRef_Nullable/TestComponent.mappings.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Source Location: (21:0,21 [11] x:\dir\subdir\Test\TestComponent.cshtml) | ||
|myComponent| | ||
Generated Location: (1045: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: (1437:43,7 [111] ) | ||
| | ||
private TestComponent myComponent = null!; | ||
public void Use() { System.GC.KeepAlive(myComponent); } | ||
| | ||
|
85 changes: 85 additions & 0 deletions
85
...tDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.codegen.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// <auto-generated/> | ||
#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 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<int> 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<T> CreateMyComponent_0<T>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, T __arg0, int __seq1, System.Action<global::Test.MyComponent<T>> __arg1) | ||
{ | ||
__builder.OpenComponent<global::Test.MyComponent<T>>(seq); | ||
__builder.AddAttribute(__seq0, "MyParameter", __arg0); | ||
__builder.AddComponentReferenceCapture(__seq1, (__value) => { __arg1((global::Test.MyComponent<T>)__value); }); | ||
__builder.CloseComponent(); | ||
return default; | ||
} | ||
} | ||
} | ||
#pragma warning restore 1591 |
27 changes: 27 additions & 0 deletions
27
...onentDesignTimeCodeGenerationTest/Component_WithRef_Nullable_Generic/TestComponent.ir.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 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<int> 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 |
Oops, something went wrong.