Skip to content

[Blazor] Error with changed parameter default value in derived type (preview 8) #13162

Closed
@oliversturm

Description

@oliversturm

I have this base class:

public abstract class FlexibleContainerChildElement<TParent> : ContainerChildElement<TParent>
{
  [Parameter]
  public virtual ElementType ElementType { get; set; } = ElementType.Div;

  protected override ElementType ContainerElementType => ElementType;
}

And here's the type CardTitle that derives from it:

@inherits FlexibleContainerChildElement<ICardBody>

@code {
    protected override void Register(ICardBody parent)
    {
        parent.SetTitle(this);
    }

    protected override string ContainerCssClass => "card-title";

    public override ElementType ElementType { get; set; } = ElementType.H5;
    
}

The derived type CardTitle changes the default value of the parameter property ElementType. For preview 8, I changed the visibility of the parameter property to public - previously it was protected.

With preview 8 I receive the following error at runtime in the browser. With preview 7 this was working as intended, no errors.

WASM: System.InvalidOperationException: The type 'ParentCoordinated.Shared.CardTitle' declares more than one parameter matching the name 'elementtype'. Parameter names are case-insensitive and must be unique.

I suspect that preview 8 broke the detection of [Parameter] values and now finds the property twice on the derived type.

Metadata

Metadata

Assignees

Labels

DoneThis issue has been fixedarea-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions