-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
affected-mediumThis issue impacts approximately half of our customersThis issue impacts approximately half of our customersarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-razor.languageseverity-majorThis label is used by an internal toolThis label is used by an internal tool
Milestone
Description
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>
majorimi and kattunga
Metadata
Metadata
Assignees
Labels
affected-mediumThis issue impacts approximately half of our customersThis issue impacts approximately half of our customersarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-razor.languageseverity-majorThis label is used by an internal toolThis label is used by an internal tool