Skip to content
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

Add a component parameter with an overridden base property without the parameter attribute throws ArgumentException #250

Closed
nickmuller opened this issue Nov 5, 2020 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@nickmuller
Copy link

Describe the bug or question
Add a component parameter with a component property which overrides an abstract property of an abstract class without the parameter attribute throws ArgumentException.

With this test:

public class BoolFieldTest : TestContext
{
    [Fact]
    public void Test()
    {
        RenderComponent<BoolField>(parameters => parameters
            .Add(x => x.Value, null));
    }

    public class BoolField : BaseFieldComponent<bool?>
    {
        [Parameter] public override bool? Value { get; set; }
    }

    public abstract class BaseFieldComponent<T> : ComponentBase
    {
        public abstract T Value { get; set; }
    }
}

Results in this output:

System.ArgumentException
The parameter selector 'x => x.Value' does not resolve to a public property on the component 'BoolFieldTest+BoolField' with a [Parameter] or [CascadingParameter] attribute.
   at Bunit.ComponentParameterCollectionBuilder`1.GetParameterInfo[TValue](Expression`1 parameterSelector) in /_/src/bunit.core/ComponentParameterCollectionBuilder.cs:line 355
   at Bunit.ComponentParameterCollectionBuilder`1.Add[TValue](Expression`1 parameterSelector, TValue value) in /_/src/bunit.core/ComponentParameterCollectionBuilder.cs:line 55

Expected behavior:
I would expect this to work. As a workaround I now set the [Parameter] attribute on the abstract property.

Version info:

  • Library version: v1.0.0-beta-11
@nickmuller nickmuller changed the title Add a component parameter with a component property which overrides an abstract property of an abstract class without the parameter attribute throws ArgumentException Add a component parameter with an overridden base property without the parameter attribute throws ArgumentException Nov 5, 2020
@egil egil added the investigate This issue require further investigation before closing. label Nov 5, 2020
@egil egil self-assigned this Nov 5, 2020
@egil egil added bug Something isn't working and removed investigate This issue require further investigation before closing. labels Nov 5, 2020
@egil
Copy link
Member

egil commented Nov 5, 2020

Hey @nickmuller

Thanks for reporting this. That is indeed a bug, and I will push a fix later that solves it. It should be available as a nightly build after that, if you are blocked: #209

@egil egil closed this as completed Nov 5, 2020
@egil
Copy link
Member

egil commented Nov 5, 2020

Fixed in latest nightly: https://github.com/egil?tab=packages&repo_name=bUnit

@nickmuller
Copy link
Author

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants