feat: Add bind function to simulate @bind directive#750
Conversation
a9b49cb to
41f9cb2
Compare
|
I went ahead and added the documentation and stuff. So from my side everything is set and done. |
egil
left a comment
There was a problem hiding this comment.
Thanks Steven. This is a good start!
I have added some suggestions in this review and played around with the code locally. There are some rough edges that needs sanding here, code docs needs to be more precise, and we have to make sure we handle edge cases where users do something unexpected. E.g. what if the user choses the ValueChanged property instead of the Value property in the parameterSelector.
A thing I would like us to get better at is writing good error/exception messages in more places, like we do with the missing JSInterop setup messages, that basically tells the user what is wrong, and what to do about it. The last part is a game changer for people, and should help them get things working more easily. The changes in this PR could be the first place in the component parameter builder we start doing that.
Co-authored-by: Egil Hansen <egil@assimilated.dk>
|
I added a very verbose way for the user in terms of the inline-documentation plus the exception. Let me know if the direction fits for you. |
4ecee0c to
0494d35
Compare
|
pushed a few suggestions. let me know what you think |
Thanks for the better documentation. Seeing the code right now I am still unsure whether or not a chapter in the documentation is more helpful to a certain degree. Let's assume a user uses Guess I'll add some "e2e" tests |
After rethinking that, that should not be a problem as initially thought. The only thing is when someone derived from Anyway I pushed a small change which replaces public class MyComponent : ComponentBase
{
[Parameter] public DateTime LastChanged { get; set; }
[Parameter] public EventCallback<DateTime> LastChangedChanged { get; set; }
}And the user binds to the wrong property: |
It's always good to have a few "e2e" tests that uses the Perhaps compared to how the Basically render the same component twice using both methods, and then compare the properties to each other. They should be the same. In a .razor test file, this can be done from the same test.
I don't normally test the content of the error message, but do inspect it manually. It seems too unstable. But in certain cases a "contains" check makes sense. |
Co-authored-by: Egil Hansen <egil@assimilated.dk>
|
I added an e2e test. The original idea was to compare against |
|
I added an e2e test which tests the expected behavior from an user point of view. If you see open points, let me know |
|
I pushed some changes, but dont have time to make the test pass. The bunit.web.testcomponents project and related test project is deprecated and just kept around for those users who still has a dependency on it, but we should not add new stuff to it. However, there is nothing wrong with chaning bunit.core.test and bunit.web.test into razor project types so we can write tests in .razor files in them. Thats what I changed in the latest commit. |
Okay. Will check that later including the CHANGELOG.md thingy. Unfortunately not so much time right now |
|
Going on an extended weekend thing, but will hopefully have time tomorrow. But yeah, we're not in a rush with this, so better get it right than fast. |
Seems like you fixed it. Nice one ;) |
|
I think this is done. What do you think? (this should be a squash merge) |
Looks good to me. Thanks for updating |
* feat: Add bind function to simulate @Bind directive * add: Documentation and samples * added null checks and tests * Apply suggestions from code review Co-authored-by: Egil Hansen <egil@assimilated.dk> * Better explanation if Bind encounters an error * Added Tests * tweaks to error messages * Only replace last instance instead of every * Apply suggestions from code review Co-authored-by: Egil Hansen <egil@assimilated.dk> * added e2e test * wip - compare bind with Bind * Added small example for bind in CHANGELOG.md * improved bind compare test * Update CHANGELOG.md * fix changelog Co-authored-by: Egil Hansen <egil@assimilated.dk>
* feat: Add bind function to simulate @Bind directive * add: Documentation and samples * added null checks and tests * Apply suggestions from code review Co-authored-by: Egil Hansen <egil@assimilated.dk> * Better explanation if Bind encounters an error * Added Tests * tweaks to error messages * Only replace last instance instead of every * Apply suggestions from code review Co-authored-by: Egil Hansen <egil@assimilated.dk> * added e2e test * wip - compare bind with Bind * Added small example for bind in CHANGELOG.md * improved bind compare test * Update CHANGELOG.md * fix changelog Co-authored-by: Egil Hansen <egil@assimilated.dk>
* feat: Add bind function to simulate @Bind directive * add: Documentation and samples * added null checks and tests * Apply suggestions from code review Co-authored-by: Egil Hansen <egil@assimilated.dk> * Better explanation if Bind encounters an error * Added Tests * tweaks to error messages * Only replace last instance instead of every * Apply suggestions from code review Co-authored-by: Egil Hansen <egil@assimilated.dk> * added e2e test * wip - compare bind with Bind * Added small example for bind in CHANGELOG.md * improved bind compare test * Update CHANGELOG.md * fix changelog Co-authored-by: Egil Hansen <egil@assimilated.dk>
* feat: Add bind function to simulate @Bind directive * add: Documentation and samples * added null checks and tests * Apply suggestions from code review Co-authored-by: Egil Hansen <egil@assimilated.dk> * Better explanation if Bind encounters an error * Added Tests * tweaks to error messages * Only replace last instance instead of every * Apply suggestions from code review Co-authored-by: Egil Hansen <egil@assimilated.dk> * added e2e test * wip - compare bind with Bind * Added small example for bind in CHANGELOG.md * improved bind compare test * Update CHANGELOG.md * fix changelog Co-authored-by: Egil Hansen <egil@assimilated.dk>
* feat: Add bind function to simulate @Bind directive * add: Documentation and samples * added null checks and tests * Apply suggestions from code review Co-authored-by: Egil Hansen <egil@assimilated.dk> * Better explanation if Bind encounters an error * Added Tests * tweaks to error messages * Only replace last instance instead of every * Apply suggestions from code review Co-authored-by: Egil Hansen <egil@assimilated.dk> * added e2e test * wip - compare bind with Bind * Added small example for bind in CHANGELOG.md * improved bind compare test * Update CHANGELOG.md * fix changelog Co-authored-by: Egil Hansen <egil@assimilated.dk>
* feat: Add bind function to simulate @Bind directive * add: Documentation and samples * added null checks and tests * Apply suggestions from code review Co-authored-by: Egil Hansen <egil@assimilated.dk> * Better explanation if Bind encounters an error * Added Tests * tweaks to error messages * Only replace last instance instead of every * Apply suggestions from code review Co-authored-by: Egil Hansen <egil@assimilated.dk> * added e2e test * wip - compare bind with Bind * Added small example for bind in CHANGELOG.md * improved bind compare test * Update CHANGELOG.md * fix changelog Co-authored-by: Egil Hansen <egil@assimilated.dk>
Pull request description
Addresses and fixes #747
If the design is okay with you I would update the documentation and all necessary documents.
PR meta checklist
mainbranch for codeor targeted at
stablebranch for documentation that is live on bunit.dev.Code PR specific checklist