Open
Description
using Microsoft.AspNetCore.Components;
namespace Test;
[CascadingTypeParameter(nameof(TRow))]
public class Parent<TRow>: ComponentBase
{
[Parameter]
public RenderFragment<TRow>? ChildContent { get; set; }
}
public class Child<TRow> : ComponentBase
{
[Parameter]
public RenderFragment<TRow>? ChildContent { get; set; }
}
<Parent TRow="string?">
<Child Context="childContext">@childContext.Length</Child>
</Parent>
In design time build, there's an error:
error CS8639: The typeof operator cannot be used on a nullable reference type
Because this code is generated:
protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
{
__o = typeof(
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
string?
#line default
#line hidden
#nullable disable
);
__builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment<string?>)((context) => (__builder2) => {
var __typeInference_CreateChild_0 = global::__Blazor.Test.TestComponent.TypeInference.CreateChild_0(__builder2, -1, default(string?)!, -1, (childContext) => (__builder3) => {
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = childContext.Length;
#line default
#line hidden
#nullable disable
}
);
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = typeof(global::Test.Child<>);
#line default
#line hidden
#nullable disable
}
));
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = typeof(global::Test.Parent<>);
#line default
#line hidden
#nullable disable
}