-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
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
.NET 5 Razor build error with templated (generic) component with abstract generic base class. #27218
Comments
Thank you for filing this issue. In order for us to investigate this issue, please provide a minimalistic repro project (ideally a GitHub repo) that illustrates the problem. |
@mkArtakMSFT Ok no problem. I have created a repo with basically the code above. It was very suppressing. NO Build error... For a moment I went crazy but by comparing what can be the difference I have found 1 in the .csproj files.
And BUILD ERROR. It seems nullable messing with generic base types in Blazor components. Here is the repo. It has only 2 commits first commit will build the second breaks it with Nullable. |
Thanks for contacting us. |
Seems like this might be a duplicate of #26971 |
This issue has been plaguing our project for months. It means most of our solution can have nullable enabled but for a particular Blazor project which can't build because of this issue. |
@hesuruio I have the exact same issue. The current workaround is to NOT specify the base class in the code-behind file:
Specifying the base class in the code-behind file is not technically needed (because the inheritance is defined by |
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. |
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. |
Cannot reproduce this in .NET 6 or newer, so I think it's fixed. (Tried that to see if it's fixed by dotnet/razor#8348). |
I'm developing some components which have lots of common code. I removed code duplication by created
abstract
base classes which can be inherited in Blazor code behind files. It works fine with non generic components. Code looks like this:Abstract base class in
MyComponentBase.cs
:Razor component Code behind file
Component1.razor.cs
:Razor component file
Component1.razor
:However there is a build error with generic
@typeparam
components. But both class (generated and codebehind) has the same generic base types:Generic code is very similar to the above code:
Abstract generic base class in
MyComponentBase.cs
:Razor component Code behind file
Component1.razor.cs
:Razor component file
Component1.razor`:The text was updated successfully, but these errors were encountered: