-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Fix InlineDictionary Behavior for Single Item Reassignment #17370
Fix InlineDictionary Behavior for Single Item Reassignment #17370
Conversation
Previous Behavior: - When the `Set` method was called, it ignored the `overwrite` parameter if the dictionary contained only one item. - This caused the `Set` method to behave like the `Add` method, leading to unexpected behavior in composition animations. - Specifically, the second composition animation would not play because it could not replace the first animation. Instead, it was added after the first animation, preventing it from being executed. Updated Behavior: - The `InlineDictionary` now respects the `overwrite` parameter even when it contains only one item. - This ensures that the second composition animation can overwrite the first one, allowing it to play correctly.
2b879dd
to
55e84fc
Compare
Thank you! Could you please add a matching unit test to the |
You can test this PR using the following package version. |
You can test this PR using the following package version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the test! A couple of minor points and it should be good to go.
tests/Avalonia.Base.UnitTests/Utilities/InlineDictionaryTests.cs
Outdated
Show resolved
Hide resolved
@MrJul Thank you for your review. And I updated my code. |
You can test this PR using the following package version. |
* Fix InlineDictionary Behavior for Single Item Reassignment Previous Behavior: - When the `Set` method was called, it ignored the `overwrite` parameter if the dictionary contained only one item. - This caused the `Set` method to behave like the `Add` method, leading to unexpected behavior in composition animations. - Specifically, the second composition animation would not play because it could not replace the first animation. Instead, it was added after the first animation, preventing it from being executed. Updated Behavior: - The `InlineDictionary` now respects the `overwrite` parameter even when it contains only one item. - This ensures that the second composition animation can overwrite the first one, allowing it to play correctly. * Append unit test for InlineDictionary * keep the `(TKey)_data` in a variable and reuse it below line 90 so we avoid a double cast * Rename the test method * Remove the unnecessary assignment code.
What does the pull request do?
This PR addresses an issue with the
InlineDictionary
when handling reassignment of a single item.What is the current behavior?
Current Behavior:
Set
method was called, it ignored theoverwrite
parameter if the dictionary contained only one item.Set
method to behave like theAdd
method, leading to unexpected behavior in composition animations.See
Avalonia/src/Avalonia.Base/Rendering/Composition/Server/ServerObjectAnimations.cs
Lines 109 to 120 in 68a626f
What is the updated/expected behavior with this PR?
Updated Behavior:
InlineDictionary
now respects theoverwrite
parameter even when it contains only one item.How was the solution implemented (if it's not obvious)?
Checklist
Breaking changes
Obsoletions / Deprecations
Fixed issues
Fixes #17368