Content-Length: 312644 | pFad | https://github.com/dotnet/aspnetcore/issues/27218#issue-729838356

4A .NET 5 Razor build error with templated (generic) component with abstract generic base class. · Issue #27218 · dotnet/aspnetcore · GitHub
Skip to content

.NET 5 Razor build error with templated (generic) component with abstract generic base class. #27218

Closed
@majorimi

Description

@majorimi

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:

public abstract class MyComponentBase : ComponentBase
{ ... }

Razor component Code behind file Component1.razor.cs:

public partial class Component1 : MyComponentBase
{ ... }

Razor component file Component1.razor:

@inherits MyComponentBase

However there is a build error with generic @typeparam components. But both class (generated and codebehind) has the same generic base types:

Severity	Code	Description	Project	File	Line	Suppression State
Error	CS0263	Partial declarations of 'TypeaheadInput<TItem>' must not specify different base classes	Blazor.Components.Typeahead	D:\Projects\GitHub\blazor-components\src\Blazor.Components.Typeahead\obj\Debug\net5.0\RazorDeclaration\TypeaheadInput.razor.g.cs	78	Active

Generic code is very similar to the above code:
Abstract generic base class in MyComponentBase.cs :

public abstract class MyComponentBase<TItem>  : ComponentBase
{ ... }

Razor component Code behind file Component1.razor.cs:

public partial class Component1<TItem> : MyComponentBase<TItem>
{ ... }

Razor component file Component1.razor`:

@typeparam TItem
@inherits MyComponentBase<TItem>

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-mediumThis issue impacts approximately half of our customersarea-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.feature-razor.languageseverity-majorThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/dotnet/aspnetcore/issues/27218#issue-729838356

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy