Aspnetcore: Blazor - Issue with auto-generated component code.

Created on 6 Nov 2020  ·  5Comments  ·  Source: dotnet/aspnetcore

Describe the bug

I have a component that wraps another component. I want an optional parameter in the first component. The render of the first component fails when the optional parameter is omitted. See #23892 for what I believe is the same issue.

To Reproduce


Component 1:

MbGrid (the component that I want to wrap) has a parameter of

[Parameter] public Func<TRowData, object>? SortExpressionSecond { get; set; } = null;

GCGrid (the wrapping component) has the parameter of

[Parameter] public Func<TRowData, object>? pSortExpressionSecond { get; set; } = null;

and a razor file of

<MBGrid SortExpressionSecond="pSortExpressionSecond" />

When I instantiate GCGrid as

<MBGrid />

the render of GCGrid fails with

Error: System.ArgumentException: Delegate to an instance method cannot have null 'this'.

Exceptions (if any)

Further technical details

C:\Solutions\OHI\Optimiser>dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.100-rc.2.20479.15
 Commit:    da7dfa8840

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19042
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.100-rc.2.20479.15\

Host (useful for support):
  Version: 5.0.0-rc.2.20475.5
  Commit:  c5a3f49c88

.NET SDKs installed:
  5.0.100-rc.2.20479.15 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-rc.2.20475.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-rc.2.20475.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0-rc.2.20475.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

area-blazor bug

All 5 comments

Closing this in favor of the previously reported https://github.com/dotnet/aspnetcore/issues/23892 which we will re-open. Tracking this as a bug.

@captainsafia Please also unlock the conversation on #23892, as otherwise there's no way to upvote the issue.

@stefanloerwald It's unlocked now.

Hi @captainsafia I just took at look and #23892 seems still to be locked.

🤦‍♀️ Try now?

Was this page helpful?
0 / 5 - 0 ratings