添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account feature-blazor-component-model Any feature that affects the component model for Blazor (Parameters, Rendering, Lifecycle, etc) nullable severity-major This label is used by an internal tool

Describe the bug

When C# 8 nullable reference checks are enabled, you get some CS8601: possible null reference assignment that I think should not be there.

For example, take Component1.razor :

<h3>Component 1</h3>
@Content
@code {
    [Parameter]
    public RenderFragment? Content { get; set; }
    [Parameter]
    public Func<int, int>? MyFunc { get; set; }
    [Parameter]
    public (int, int)? MyTuple { get; set; }

Which is used into Component2.razor:

<h3>Component 2</h3>
<Component1 Content="ContentNullable"  /* Warning CS8601 */
            MyFunc="MyFuncNullable"    /* Warning CS8601 */
            MyTuple="MyTupleNullable"> /* Ok */
</Component1>
@code {
    public RenderFragment? ContentNullable { get; set; }
    public Func<int, int>? MyFuncNullable { get; set; }
    public (int, int)? MyTupleNullable { get; set; }

And you get the CS8601 warning on Content and MyFunc parameters assignment.

The code generated for Component2.razor includes the following relevant lines:

__builder.AddAttribute(2, "Content", new Microsoft.AspNetCore.Components.RenderFragment(
#nullable restore
            ContentNullable
#nullable disable
__builder.AddAttribute(3, "MyFunc", new System.Func<System.Int32, System.Int32>(
#nullable restore
        MyFuncNullable
#nullable disable
__builder.AddAttribute(4, "MyTuple", Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck<(System.Int32, System.Int32)?>(
#nullable restore
            MyTupleNullable
#nullable disable

Further technical details

  • ASP.NET Core version: 3.1.300
  • Include the output of dotnet --info
  • SDK de .NET Core (reflejando cualquier global.json):
     Version:   3.1.300
     Commit:    b2475c1295
    Entorno de tiempo de ejecución:
     OS Name:     Windows
     OS Version:  10.0.18363
     OS Platform: Windows
     RID:         win10-x64
     Base Path:   C:\Program Files\dotnet\sdk\3.1.300\
    Host (useful for support):
      Version: 3.1.4
      Commit:  0c2e69caa6
    .NET Core SDKs installed:
      3.1.300 [C:\Program Files\dotnet\sdk]
    .NET Core runtimes installed:
      Microsoft.AspNetCore.All 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
      Microsoft.AspNetCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
      Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
      Microsoft.NETCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      Microsoft.WindowsDesktop.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
    To install additional .NET Core runtimes or SDKs:
      https://aka.ms/dotnet-download
              

    Thanks for contacting us.
    We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We will evaluate the request when we are planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

    We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

    feature-blazor-component-model Any feature that affects the component model for Blazor (Parameters, Rendering, Lifecycle, etc) labels Apr 20, 2021

    Hi. Thanks for contacting us.
    We're closing this issue as there was not much community interest in this ask for quite a while now.
    You can learn more about our triage process and how we handle issues by reading our Triage Process writeup.

    feature-blazor-component-model Any feature that affects the component model for Blazor (Parameters, Rendering, Lifecycle, etc) nullable severity-major This label is used by an internal tool