Repository navigation
Fix: Binding doesn't respect special IValueConverter return values - #12060
bakerhillpins wants to merge 16 commits into
Conversation
Unit tests that support Binding IValueConverter converters that return Binding.DoNothing and BindableProperty.UnsetValue.
This is a first pass at updating the Binding classes to support the IValueConverter and IMultiValueConverter as spec'd on the desktop. Issues remain with over processing these return values, for example they can get picked up by StringFormat when they should not.
Fix: Allow FallbackValue to be replaced with default value where necessary. Process return values from GetSourceValue. Don't update MultiBindings unless there's been a change in one of the included bindings.
Use same implementation as MultiBinding. IValueConverter.ConvertBack talks about using FallbackValue and NulltargetValue with the special return values but the documentation clearly states that those 2 properties on a Binding are only applied to Source value operations.
|
Hey there @bakerhillpins! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
DRY - use common method for Apply to remove duplicated code.
Rework flow so that FallbackValue is only calculated for a from source Binding operation when it's needed (rather than as a default value initialization).
|
Hope I didn't miss the pipeline run. I made some changes for DRY and optimization of fix-11740 branch: main branch: |
|
Adding the perf label as well as this does have some exciting changes. @jonathanpeppers not sure if you are interested in checking this as well? |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
does this cover compiled bindings too ? |
yes, Note the "performance" post above. |
jonathanpeppers
left a comment
There was a problem hiding this comment.
For all performance changes, we should add a benchmark here:
https://github.com/dotnet/maui/tree/main/src/Core/tests/Benchmarks
A new benchmark comparing the different binding modes, would be great!
This way we have numbers for how much this improves things. And we will know it for sure won't be worse on accident!
|
I didn't add perf code, I simply enabled the 2 perf tests in the TypedBindingTests. There's room for more DRY changes. Specifically putting a subclass in between Should the subclass be added? This change would apparently also remove duplicate documentation code. |
Remove the converters that were added as they duplicated functionality that already exists in existing implementation. The TestConverterReturn class isn't actually needed.
Coalesce a context value from multiple sources as is done in Binding.Apply. Include appropriate tests.
|
Add fix and tests for #10792 |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
@jfversluis @StephaneDelcroix I can't express how disappointed I am that this is still waiting for a single reviewer. I'd happily update to resolve the conflicts that are now blocking. |
|
@bakerhillpins you didn't address my comment, if you could add a benchmark if this supposedly improves performance: #12060 (review) By how much does it improve things? There is also a merge conflict, if you'd like to address that. Thanks. |
|
@jonathanpeppers This PR is not and never was about changes for the sake of performance. The performance code mentioned is commented out in the MS source. I simply ran it to see that I hadn't regressed and mentioned that in my response to you. The issues resolved are discussed in the PR's initial post. I did however change the order of binding processing to fix an issue where bindings on an object were being evaluated 2x because property bindings were being evaluated before the BindingContext binding was on an object. Thus the bindings on that object would be evaluated a 2nd time when the BindingContext was applied. This included children bindings. #10806
This has been sitting here for months without conflict waiting for review/comment at the beginning of which time I asked for feedback and received nothing. As I mentioned, I'm willing to take the time to fix the conflict but right now I don't feel like anyone is taking my time seriously. |
|
@bakerhillpins but we don't have a BenchmarkDotNet benchmark of multi-binding. I would want to see the results of that before merging this. Your description here seems like you did something manual instead of using BenchmarkDotNet: If you need an example, I wrote one recently in: #14830 Thanks. |
Why? I made NO PERFORMANCE changes.
You don't appear to be reading what I'm writing and I don't know how to tell you any more clearly. The "perfomance code" is in your binding unit tests and commented out. I didn't write it, I simply used it as a sanity check. |
Conflicting files src/Controls/src/Core/BindableObject.cs
|
What is the status of this PR? I can feel the pain and frustration of the creator who obviously put a lot of time and thinking into this PR. |
@berhir MS puts on a good show with open source and asking for PRs/community development but they don't appear to back it up. I doubt it's a personal thing, based upon the release cycle and quality I'm seeing they are pushing too hard/fast. It's the early days of .NET all over again, unfortunately. Though YMMV. |
|
I'm just a passerby interested in #10806 being fixed. @bakerhillpins: Your PR is exciting! I read the posts here and it looks to me that @jonathanpeppers just wants to know that this PR does not introduce a performance regressions as Maybe a benchmark similar to this one #17756 (comment) would be sufficient to persuade people that no such regression occurred. Maybe @albyrock87 can share some benchmarking code to make it easier to measure it. One additional thought is that if this PR can be split into multiple smaller PRs, it might be easier to review it. 1200 LOC is big. Not trying to offend you even more, just sharing my honest opinion. |
Thank you for noticing. From my perspective it's all bug fixes and always was.. MS made an assumption it was performance related because I ran some of MS's own "performance" code and then randomly labeled it as perf related. It would seem that no one read the 3 referenced bug reports that were fixed to determine what the PR was about. The only "performance" change was a bug fix (#10806) where bindings are being executed 2x down the entire xaml tree. The 1st time is with the incorrect BindingContext value.
Not going to be me.
Most of the changes are TESTS that I added to pick up on all the missing functionality and bugs I found in the binding code.
You did not, but Thank you for that. I as well. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
|
Hey @bakerhillpins , As you can see I tried at all costs to avoid
I wanted to help by preparing a PR targeting your repo to merge Maybe I'm missing something, but I wanted to tell you that I tried :) and what was the outcome. Thanks for all the work you've done here. |
|
Hi @bakerhillpins. We have added the "s/pr-needs-author-input" label to this issue, which indicates that we have an open question/action for you before we can take further action. This PRwill be closed automatically in 14 days if we do not hear back from you by then - please feel free to re-open it if you come back to this PR after that time. |
Description of Change
Update Binding classes in MAUI to support special return values from the
IValueConverterassigned to theBinding.Converterproperty.Make changes to stop Bindings from being resolved multiple times during the course of a single update or change to the children of the View.
I've modified the MAUI source to support the both the Binding.DoNothing and the BindableProperty.UnsetValue functionality described in the IValueConverter and IMultiValueConverter docs. These changes support both the Binding Fallbacks and the MultiBinding discussions in the docs and this would then operate as WPF does.
The one omission here is it's unclear how the StringFormat behavior should be handled as it's not specifically discussed anywhere in MAUI or WPF documentation that I can find. Discussions on StackOverflow indicate that WPF bindings ignore StringFormat during application of TargetNullValue or FallbackValue and so I'm assuming that MAUI should keep this and I've made changes to support that.
It should also be noted that IValueConverter.ConvertBack discusses using Fallback and Targetnull Values however the documentation for these clearly states it's applied to Source values only:
The TargetNullValue property allows a replacement value to be defined that will be used when the binding source is resolved, but the value is null.I originally targeted the NET6.0 branch because the documentation (until yesterday morning) specifically said to do this if you expected this to be applied to NET6. I have that branch available if needed.
Issues Fixed
fixes #11740
fixes #10792
fixes #10806