Blazor - Issue with auto-generated component code.
See original GitHub issueDescribe 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
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Blazor app won't compile due to auto-generated __Blazor ...
Describe the bug The auto-generated __Blazor namespaces can confuse the compiler and cause a failure to build.
Read more >Scoped CSS is not auto-generated in Blazor after changing ...
So it appears that the static web assets are only generated in Development mode. I amended the CreateHostBuilder method in Program.cs ...
Read more >Using Source Generators with Blazor components in .NET 6
In this post I describe a problem where upgrading my Blazor app to .NET 6 broke my source generators that relied on Blazor...
Read more >Blazor, can't get embedded component to refresh
After, when I change one of these parameters, new data needs tobe loading from the backend web api and part of the problem...
Read more >Handle errors in ASP.NET Core Blazor apps
This article describes how Blazor manages unhandled exceptions and how to develop apps that detect and handle errors.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
🤦♀️ Try now?
Hi @captainsafia I just took at look and #23892 seems still to be locked.