-
-
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
Make styled property storage typed #3255
Conversation
Major refactor of the Avalonia core to make the styled property store typed.
04c02b3
to
0cfa159
Compare
It's not needed any more.
Don't believe the new value given to us in the `AvaloniaPropertyChangedEventArgs`: it may have already changed. Instead, read the current value of the property from the object.
Alternative fix for binding stack overflow
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.
Glanced over most of your changes. I think it would be good to figure out if we can address LocalValue
setter performance. After cobbling together a quick hack to store typed local values I was able to improve memory usage further and improve perf by like 10-15%.
Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|
Set_Int_Property_LocalValue | 11.92 us | 0.2315 us | 0.2573 us | 0.0610 | - | - | 256 B |
Delete some files that should have been deleted in merge.
Will this remove value coercion for |
It will, yes. Is this a problem for you? We may need to design a replacement before we commit this change. As I mentioned, the current way coercion works slows down every single property set (including values from bindings), so it'd probably have a different API/semantics. |
Yes, I’m using it for data consistency. It seems to me that it should be pretty easy to optimize the case where a property doesn’t use validation on any type by having a flag on the property that specifies whether any of its metadata has a validation function. |
Since this is a breaking API change anyway: did you consider moving the static registration methods to their respective subclass? I think it's a bit cleaner to write: StyledProperty<double> FooProperty = StyledProperty.Register<...>(...);
DirectProperty<double> BarProperty = DirectProperty.Register<...>(...); |
Moving them like this was confusing the diff.
We could move them and if necessary keep the existing deprecated methods, but this should be done in a separate PR. However, I'm not completely sure that it's a change worth making at this point, when everyone's code is using the existing methods... |
Further reduces allocated memory in the common case of only a local value being set.
@mstr2 regarding coercion/validation, any thoughts on the current API as compared to the WPF/UWP API where validation is a "static" callback and only coercion receives a reference to the control? Not sure whether to change our API to match WPF/UWP or not. Edit: UWP doesn't have validation/coercion; I was mistaken. |
Doesn't actually fill in the "details" property for styled properties because this API is going to change shortly with the new devtools.
From a very high-level perspective, it is my understanding that validation and coercion in WPF address two slightly different things. Class-level validation is used to enforce that all valid objects be a class (as in set theory). More precisely, all valid objects share a common property, and an object that does not have that property can never be a valid object. Instance-level coercion, on the other hand, is a constrained range of valid objects. This range can depend on many things and might change at any time. While it might be elegant in theory, actual production code will often not make that distinction in practice. I understand that Avalonia is currently using a simpler approach, where the distinction between these two aspects is done by throwing an exception (object does not have a required property) or returning a coerced version of the object (object is valid, but out of range). All other things being equal, I will always prefer the WPF behavior for the simple reason that matching this behavior will mean that, when faced with a coding problem, someone looking up solutions on the internet will find it more likely that WPF solutions will work in Avalonia. |
Compiler warns that `_value` is potentially null, but it can be a value or refernce type.
For typed bindings, we'll have an `AvaloniaPropertyChangedEventArgs<T>` where `T` is the same as the type of the `AvaloniaPropertyObservable`. For non-typed bindings we'll have `object` as `T` so use the non-typed `AvaloniaProperty`.
Thanks for the thorough review @MarchingCube! I think I've addressed all your feedback. In addition, I realized that the property store can be typed on |
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.
LGTM!
commit 3984121 Merge: 6c40771 cf8aa6e Author: Steven Kirk <[email protected]> Date: Fri Jan 24 04:04:01 2020 +0100 Merge pull request AvaloniaUI#3465 from MarchingCube/fix-color-comparisons Optimize Color equality checks commit cf8aa6e Author: Dariusz Komosinski <[email protected]> Date: Thu Jan 23 22:47:27 2020 +0100 Optimize Color equality checks. commit 6c40771 Merge: e3aa3bc 527bac1 Author: Steven Kirk <[email protected]> Date: Thu Jan 23 10:30:49 2020 +0100 Merge pull request AvaloniaUI#3255 from AvaloniaUI/refactor/value-store Make styled property storage typed commit 527bac1 Merge: 3994176 e3aa3bc Author: Steven Kirk <[email protected]> Date: Thu Jan 23 10:12:51 2020 +0100 Merge branch 'master' into refactor/value-store commit 3994176 Author: Steven Kirk <[email protected]> Date: Thu Jan 23 10:11:14 2020 +0100 Revert "Removed unused owner reference." This reverts commit d0e2a84. commit 3bc1594 Author: Steven Kirk <[email protected]> Date: Thu Jan 23 10:05:26 2020 +0100 Revert "Removed unused field." This reverts commit 270f971. commit ab26c55 Merge: 9ec8a2f 89ba4a6 Author: Steven Kirk <[email protected]> Date: Wed Jan 22 23:30:59 2020 +0100 Merge pull request AvaloniaUI#3287 from AvaloniaUI/refactor/wpf-validation-coercion Switch to WPF-styled property validation/coercion commit 89ba4a6 Author: Steven Kirk <[email protected]> Date: Wed Jan 22 19:44:10 2020 +0100 Prevent tests interfering with other tests. commit 7f26635 Author: Steven Kirk <[email protected]> Date: Wed Jan 22 19:27:26 2020 +0100 Wire up validation/coercion for attached properties. commit c6acca5 Author: Steven Kirk <[email protected]> Date: Wed Jan 22 19:07:48 2020 +0100 Fix method name after merge. commit e3aa3bc Merge: d69e815 65e4470 Author: Steven Kirk <[email protected]> Date: Wed Jan 22 19:00:15 2020 +0100 Merge pull request AvaloniaUI#3342 from AvaloniaUI/fixes/3328-move-treeview Fix DetachedFromLogicalTree event args parent, and allow TreeViews to be reparented commit 65e4470 Merge: 5a67237 d69e815 Author: Jumar Macato <[email protected]> Date: Wed Jan 22 08:55:41 2020 +0800 Merge branch 'master' into fixes/3328-move-treeview commit d69e815 Merge: 8a3f592 3dca330 Author: Dariusz Komosiński <[email protected]> Date: Tue Jan 21 11:37:45 2020 +0100 Merge pull request AvaloniaUI#3403 from jp2masa/update-obsolete-api-usages Fixed drag and drop obsolete API usage commit 3dca330 Merge: f88d7cc 8a3f592 Author: Dariusz Komosiński <[email protected]> Date: Tue Jan 21 11:11:23 2020 +0100 Merge branch 'master' into update-obsolete-api-usages commit 8a3f592 Merge: fdfd5be 7e42523 Author: danwalmsley <[email protected]> Date: Mon Jan 20 13:15:58 2020 -0300 Merge pull request AvaloniaUI#3453 from AvaloniaUI/fixes/x11-backend-cope-with-0size-window Fixes/x11 backend cope with 0size window commit 7e42523 Author: Jumar Macato <[email protected]> Date: Mon Jan 20 23:27:00 2020 +0800 Additional sanity checks for monitor resolution commit 32df775 Author: Dan Walmsley <[email protected]> Date: Mon Jan 20 12:06:31 2020 -0300 Add hack to prevent renderer crashing on 0x0 window x11. commit 1f1d3a8 Author: Dan Walmsley <[email protected]> Date: Mon Jan 20 11:53:26 2020 -0300 prevent crashing in finalizer commit 9fc7842 Author: Dan Walmsley <[email protected]> Date: Mon Jan 20 11:52:33 2020 -0300 Revert "X11 backend wont crash with 0 sized window." This reverts commit d491098. commit d491098 Author: Dan Walmsley <[email protected]> Date: Mon Jan 20 11:47:04 2020 -0300 X11 backend wont crash with 0 sized window. commit fdfd5be Merge: 93b94a5 f56a891 Author: danwalmsley <[email protected]> Date: Mon Jan 20 11:10:30 2020 -0300 Merge pull request AvaloniaUI#3451 from AvaloniaUI/feature/implement-avalonia-native-exception-dispatch Implement ExceptionDispatch for OSX commit f56a891 Author: Dan Walmsley <[email protected]> Date: Mon Jan 20 10:43:22 2020 -0300 prevent possibility of double cancellation of main loop. commit 9df55b0 Author: Dan Walmsley <[email protected]> Date: Mon Jan 20 09:40:48 2020 -0300 Use loopcancellation instead of adding a seperate api. commit 9ec8a2f Merge: 69e7023 93b94a5 Author: Steven Kirk <[email protected]> Date: Mon Jan 20 11:33:11 2020 +0100 Merge branch 'master' into refactor/value-store commit 69e7023 Author: Steven Kirk <[email protected]> Date: Mon Jan 20 11:30:49 2020 +0100 Added some documentation to value stores. commit 4cc378e Author: Steven Kirk <[email protected]> Date: Mon Jan 20 11:13:37 2020 +0100 Property store can be typed on IValue. commit a1353c7 Author: Steven Kirk <[email protected]> Date: Mon Jan 20 11:03:13 2020 +0100 Remove unused method. commit 6f92e37 Author: Steven Kirk <[email protected]> Date: Mon Jan 20 11:02:54 2020 +0100 Fix typo. commit 3a80cee Author: Steven Kirk <[email protected]> Date: Mon Jan 20 11:02:28 2020 +0100 Add nullability annotations. commit c2d5f62 Author: Steven Kirk <[email protected]> Date: Mon Jan 20 11:01:35 2020 +0100 Avoid boxing if property is correct type. For typed bindings, we'll have an `AvaloniaPropertyChangedEventArgs<T>` where `T` is the same as the type of the `AvaloniaPropertyObservable`. For non-typed bindings we'll have `object` as `T` so use the non-typed `AvaloniaProperty`. commit 1ff6e35 Author: Steven Kirk <[email protected]> Date: Mon Jan 20 10:56:30 2020 +0100 Disable nullable around generic T. Compiler warns that `_value` is potentially null, but it can be a value or refernce type. commit 270f971 Author: Steven Kirk <[email protected]> Date: Mon Jan 20 10:54:13 2020 +0100 Removed unused field. commit f7f9e41 Author: Steven Kirk <[email protected]> Date: Mon Jan 20 10:51:44 2020 +0100 Setter not needed. commit fa81c42 Author: Steven Kirk <[email protected]> Date: Mon Jan 20 10:51:37 2020 +0100 BindingValue should be marked [Flags]. commit c3fb152 Author: Dan Walmsley <[email protected]> Date: Sun Jan 19 20:12:56 2020 -0300 Working exception dispatch commit 69c0521 Author: Dan Walmsley <[email protected]> Date: Sun Jan 19 19:51:36 2020 -0300 Add methods for dispatching exceptions on osx. commit c357558 Author: Dan Walmsley <[email protected]> Date: Sun Jan 19 19:35:52 2020 -0300 basic implementation of exception dispatch on avalonia.native. commit f88d7cc Merge: dcab86a 93b94a5 Author: Dariusz Komosiński <[email protected]> Date: Sat Jan 18 22:13:28 2020 +0100 Merge branch 'master' into update-obsolete-api-usages commit 93b94a5 Merge: e88d13b 89f5986 Author: Steven Kirk <[email protected]> Date: Fri Jan 17 23:27:40 2020 +0100 Merge pull request AvaloniaUI#3315 from MarchingCube/alloc-scene-hittest Rework deferred renderer scene hit testing commit 89f5986 Merge: 65fa7e0 e88d13b Author: Dariusz Komosiński <[email protected]> Date: Fri Jan 17 22:53:04 2020 +0100 Merge branch 'master' into alloc-scene-hittest commit e88d13b Merge: b501b64 7162fd2 Author: Steven Kirk <[email protected]> Date: Fri Jan 17 22:51:28 2020 +0100 Merge pull request AvaloniaUI#3320 from MarchingCube/fix-win32-right-modifiers Win32: Fix right ALT, CTRL and SHIFT being reported as left. commit d0e2a84 Author: Steven Kirk <[email protected]> Date: Fri Jan 17 22:50:45 2020 +0100 Removed unused owner reference. commit 00c1c35 Author: Steven Kirk <[email protected]> Date: Fri Jan 17 22:42:59 2020 +0100 Go direct to property store. To avoid a call to `VerifyAccess` (which shows up when profiling). commit afce446 Author: Steven Kirk <[email protected]> Date: Fri Jan 17 22:42:11 2020 +0100 Removed useless default values. There's already an overload without the parameter. commit 685f3f7 Author: Steven Kirk <[email protected]> Date: Fri Jan 17 22:31:15 2020 +0100 Fix typos. commit 7162fd2 Merge: 3f58f70 b501b64 Author: Dariusz Komosiński <[email protected]> Date: Fri Jan 17 21:22:03 2020 +0100 Merge branch 'master' into fix-win32-right-modifiers commit b501b64 Merge: 7a27e43 694585c Author: Dariusz Komosiński <[email protected]> Date: Fri Jan 17 21:11:59 2020 +0100 Merge pull request AvaloniaUI#3447 from rstm-sf/doc/fix_typo_color_prop Fix typo in the doc for Color properties commit 694585c Author: Rustam Sayfutdinov <[email protected]> Date: Fri Jan 17 21:45:51 2020 +0300 Fix typo in the doc for Color properties commit 7a27e43 Merge: ee9d0ce db9f60a Author: Steven Kirk <[email protected]> Date: Fri Jan 17 16:53:23 2020 +0100 Merge pull request AvaloniaUI#3357 from donandren/issues/3356 Fix ImmediateRenderer hit testing for Adorner type layers commit db9f60a Merge: 0f83088 ee9d0ce Author: Steven Kirk <[email protected]> Date: Fri Jan 17 16:38:06 2020 +0100 Merge branch 'master' into issues/3356 commit ee9d0ce Merge: 4c690d4 9953bdd Author: Steven Kirk <[email protected]> Date: Fri Jan 17 16:37:46 2020 +0100 Merge pull request AvaloniaUI#3427 from MarchingCube/improve-togglebutton Implement ToggleButton events commit 9953bdd Merge: 3cdc9c9 4c690d4 Author: Steven Kirk <[email protected]> Date: Fri Jan 17 14:47:21 2020 +0100 Merge branch 'master' into improve-togglebutton commit 4c690d4 Merge: 155e9d4 a238fd3 Author: Steven Kirk <[email protected]> Date: Fri Jan 17 12:49:20 2020 +0100 Merge pull request AvaloniaUI#3444 from MarchingCube/fix-selecting-items-control-init Fix SelectingItemsControl init behavior commit a238fd3 Author: Dariusz Komosiński <[email protected]> Date: Fri Jan 17 11:04:29 2020 +0100 Unify SelectingItemsControl init handling and add extra checks to ensure correctness. commit 1e673ec Author: Dariusz Komosiński <[email protected]> Date: Fri Jan 17 10:57:54 2020 +0100 Add failing unit test for init issue. commit 814dddc Merge: 4065742 5805eaf Author: Steven Kirk <[email protected]> Date: Tue Jan 14 11:25:59 2020 +0100 Merge branch 'refactor/value-store' into refactor/wpf-validation-coercion commit 5805eaf Author: Steven Kirk <[email protected]> Date: Tue Jan 14 10:36:04 2020 +0100 Fix compile errors after merge with master. Due to `OnPropertyChanged` signature changing on branch. commit 9de6522 Merge: 4736801 155e9d4 Author: Steven Kirk <[email protected]> Date: Tue Jan 14 10:14:53 2020 +0100 Merge branch 'master' into refactor/value-store commit 3cdc9c9 Merge: b400b45 155e9d4 Author: Dariusz Komosiński <[email protected]> Date: Fri Jan 10 18:22:16 2020 +0100 Merge branch 'master' into improve-togglebutton commit 155e9d4 Merge: 3d3ef68 ef42e93 Author: Steven Kirk <[email protected]> Date: Fri Jan 10 16:41:22 2020 +0100 Merge pull request AvaloniaUI#3424 from AvaloniaUI/port/items-repeater Port ItemsRepeater changes from WinUI commit ef42e93 Author: Steven Kirk <[email protected]> Date: Fri Jan 10 11:01:32 2020 +0100 Add doc comment for NonVirtualizingLayoutContext. commit 1559151 Author: Steven Kirk <[email protected]> Date: Fri Jan 10 11:01:16 2020 +0100 Use correct context type. commit dcab86a Author: José Pedro <[email protected]> Date: Fri Jan 3 23:06:43 2020 +0000 Fixed drag and drop obsolete API usage. commit b400b45 Author: Dariusz Komosinski <[email protected]> Date: Thu Jan 9 22:28:16 2020 +0100 Use expression bodied events and properties. commit 35f2608 Author: Dariusz Komosinski <[email protected]> Date: Thu Jan 9 22:27:56 2020 +0100 Implement events for ToggleButton. commit 9a0be51 Merge: c6e6ad5 3d3ef68 Author: Steven Kirk <[email protected]> Date: Thu Jan 9 11:55:34 2020 +0100 Merge branch 'master' into port/items-repeater commit c6e6ad5 Author: Steven Kirk <[email protected]> Date: Thu Jan 9 11:35:05 2020 +0100 Fix bug with UniformGridLayout MaximumRowsOrColumns and requested size Ported from microsoft/microsoft-ui-xaml@007ab33 commit 0236ced Author: Steven Kirk <[email protected]> Date: Thu Jan 9 11:32:39 2020 +0100 Fix ItemsRepeater overwriting DataContext Ported from microsoft/microsoft-ui-xaml@0e24e05 commit bb7276d Author: Steven Kirk <[email protected]> Date: Thu Jan 9 10:46:13 2020 +0100 Extend the fix for Recycling the focused element to non virtualized l… …ayouts * Ensure that we set the m_processingItesmSourceChange flag for non-virtualizing layouts as well as virtualizing ones. Ported from microsoft/microsoft-ui-xaml@cc335ac commit 09297db Author: Steven Kirk <[email protected]> Date: Thu Jan 9 10:37:44 2020 +0100 Fix repeater holding onto elements If a consumer changes the ItemsSource with a non recycling layout then the items from the old source would be perpetually held by repeater, a potentially substantial leak. Ported from microsoft/microsoft-ui-xaml@e158eec commit 1f46076 Author: Steven Kirk <[email protected]> Date: Thu Jan 9 10:35:15 2020 +0100 Use NonVirtualizingLayoutContext. - Add and use `NonVirtualizingLayoutContext` in `NonVirtualizingLayout` - Return -1 instead of throwing if element is not a child of `ItemsRepeater` Ported from microsoft/microsoft-ui-xaml@22adf4d commit 261e477 Author: Steven Kirk <[email protected]> Date: Thu Jan 9 10:23:29 2020 +0100 ItemsRepeater fix. * Remove item from repeater children if there is no itemtemplate when being recycled. Ported from microsoft/microsoft-ui-xaml@c4d4d99 commit 55275e0 Author: Steven Kirk <[email protected]> Date: Thu Jan 9 10:01:53 2020 +0100 Fix stack layout arrange when items use stretch and final size is mor… …e than desired size. Ported from microsoft/microsoft-ui-xaml@f37ebd5 commit 36fdb8e Author: Steven Kirk <[email protected]> Date: Thu Jan 9 09:24:28 2020 +0100 Add a MaximumRowsOrColumns to Uniformgridlayout * Add a MaximumRowsOrColumns property to UniformGridLayout * Fix nit * Fix bugs Ported from microsoft/microsoft-ui-xaml@6bd03c9?w=1 commit 4cca4f0 Author: Steven Kirk <[email protected]> Date: Thu Jan 9 08:35:28 2020 +0100 update to repeater to allow passing in uielements in itemssource * minor update to repeater to allow passing in uielements in itemssource * minor fixes Ported from microsoft/microsoft-ui-xaml@95d5ff0 commit 0f83088 Merge: 3439a37 3d3ef68 Author: Steven Kirk <[email protected]> Date: Thu Jan 9 07:59:26 2020 +0100 Merge branch 'master' into issues/3356 commit 3d3ef68 Merge: 08c9710 a71b3ba Author: Steven Kirk <[email protected]> Date: Thu Jan 9 07:57:59 2020 +0100 Merge pull request AvaloniaUI#3378 from AvaloniaUI/feature/drawing-image Display Drawings in Image control commit a71b3ba Merge: db76f04 08c9710 Author: Jumar Macato <[email protected]> Date: Wed Jan 8 22:20:48 2020 +0800 Merge branch 'master' into feature/drawing-image commit 08c9710 Merge: d9bf203 fea0d76 Author: Jumar Macato <[email protected]> Date: Wed Jan 8 18:41:07 2020 +0800 Merge pull request AvaloniaUI#3347 from macpawluk/issues/immediate-renderer Fix for issue AvaloniaUI#3344 - ImmediateRenderer trimming content commit fea0d76 Merge: 5a235a9 d9bf203 Author: Steven Kirk <[email protected]> Date: Wed Jan 8 11:17:03 2020 +0100 Merge branch 'master' into issues/immediate-renderer commit d9bf203 Merge: b8ff41d 3338215 Author: danwalmsley <[email protected]> Date: Mon Jan 6 10:16:48 2020 -0300 Merge pull request AvaloniaUI#3409 from AvaloniaUI/fixes/osx-black-corners fixes the black window corners on OSX. commit 3338215 Author: Dan Walmsley <[email protected]> Date: Mon Jan 6 10:01:06 2020 -0300 fixes the black window corners on OSX. commit b8ff41d Merge: 9c3fd08 cab67d6 Author: Steven Kirk <[email protected]> Date: Sun Jan 5 18:49:22 2020 +0100 Merge pull request AvaloniaUI#3405 from JaggerJo/remove-script-not-needed-anymore Delete 'avalonia-rename.ps1' Script commit cab67d6 Author: Josua Jäger <[email protected]> Date: Sun Jan 5 17:54:38 2020 +0100 Delete avalonia-rename.ps1 Looks like the script is not needed anymore. I was initially searching for a script to build all Nuget Packages. Removing scripts that are no longer needed / up to date seems like a good idea. commit 9c3fd08 Merge: 7ee9610 c8b0087 Author: Jumar Macato <[email protected]> Date: Thu Jan 2 23:46:28 2020 +0800 Merge pull request AvaloniaUI#3391 from jp2masa/update-obsolete-api-usages Fixed PlatformHotkeyConfiguration obsolete API usage commit c8b0087 Merge: 11b1ec2 7ee9610 Author: Dariusz Komosiński <[email protected]> Date: Thu Jan 2 14:51:20 2020 +0100 Merge branch 'master' into update-obsolete-api-usages commit 7ee9610 Merge: 91af53a 37e541e Author: Nikita Tsukanov <[email protected]> Date: Mon Dec 30 12:50:50 2019 +0300 Merge pull request AvaloniaUI#3398 from yahiheb/duplicate-link Remove duplicate link (mentioned below) commit 37e541e Merge: 7db73df 91af53a Author: Jumar Macato <[email protected]> Date: Mon Dec 30 14:32:39 2019 +0800 Merge branch 'master' into duplicate-link commit 91af53a Merge: 4340831 d50f33e Author: Jumar Macato <[email protected]> Date: Mon Dec 30 09:57:51 2019 +0800 Merge pull request AvaloniaUI#3397 from yahiheb/typo Fix typo commit 7db73df Author: Yahia Chiheb <[email protected]> Date: Mon Dec 30 02:32:28 2019 +0100 Remove duplicate link (mentioned below) commit d50f33e Author: Yahia Chiheb <[email protected]> Date: Mon Dec 30 02:25:32 2019 +0100 Fix typo commit 11b1ec2 Author: José Pedro <[email protected]> Date: Mon Dec 23 23:45:02 2019 +0000 Fixed PlatformHotkeyConfiguration obsolete API usage. commit db76f04 Merge: 580697b 4340831 Author: Steven Kirk <[email protected]> Date: Fri Dec 20 15:01:45 2019 +0100 Merge branch 'master' into feature/drawing-image commit 580697b Author: Steven Kirk <[email protected]> Date: Fri Dec 20 14:08:39 2019 +0100 Make DrawingPresenter obsolete. commit 4340831 Merge: e822c24 c64cc71 Author: Benedikt Stebner <[email protected]> Date: Fri Dec 20 13:55:41 2019 +0100 Merge pull request AvaloniaUI#3377 from donandren/issues/3376 Fixes font fallback when non default weight/style used commit de31680 Author: Steven Kirk <[email protected]> Date: Fri Dec 20 13:41:51 2019 +0100 Make D2D backend match Skia. Skia doesn't support getting DPI from loaded bitmaps and always returns 96. Do the same in D2D. commit 37d0078 Author: Steven Kirk <[email protected]> Date: Fri Dec 20 13:33:00 2019 +0100 Invalidate DrawingImage when Drawing changed. And add some XML docs. commit dbe4301 Author: Steven Kirk <[email protected]> Date: Fri Dec 20 13:28:55 2019 +0100 Sanitize image drawing API. - Remove opacity parameter - should push an opacity instead - Add a WPF-compatible overload of `DrawImage` to `DrawingContext` commit c64cc71 Author: Andrey Kunchev <[email protected]> Date: Fri Dec 20 14:26:13 2019 +0200 fix fontfallback for font with some styles like bold/italic etc. commit dd864dd Author: Andrey Kunchev <[email protected]> Date: Fri Dec 20 14:23:40 2019 +0200 add a test for same situation for direct2d commit 44fa215 Author: Andrey Kunchev <[email protected]> Date: Fri Dec 20 14:23:16 2019 +0200 add failing test for AvaloniaUI#3376 commit fd08fdc Author: Steven Kirk <[email protected]> Date: Fri Dec 20 12:34:54 2019 +0100 Update ControlCatalog image page. To display `DrawingImage`. commit 11a714d Author: Steven Kirk <[email protected]> Date: Fri Dec 20 12:34:25 2019 +0100 Use Size not PixelSize in ImageTests. `Image` now bases the size of a bitmap on `IImage.Size`. commit 6bd9ca8 Author: Steven Kirk <[email protected]> Date: Thu Dec 19 17:35:59 2019 +0100 Initial implementation of DrawingImage. commit a8e7538 Author: Steven Kirk <[email protected]> Date: Thu Dec 19 17:29:46 2019 +0100 Added IImage interface. `IImage` represents a base interface for raster and vector images. `IBitmap` now implements this interface and `DrawingContext` accepts this interface in `DrawImage`. The interface defines a `Draw` method which introduces a level of indirection for drawing the image through the image itself. Renamed `IDrawingContextImpl.DrawImage` to `DrawBitmap` as this only handles drawing bitmap images. `Bitmap` now calls this method directly on the platform implementation. commit e822c24 Merge: fe2d2ac 4d8266d Author: Jumar Macato <[email protected]> Date: Fri Dec 20 10:59:24 2019 +0800 Merge pull request AvaloniaUI#3373 from AvaloniaUI/fixes/3371-image-sizing Added Image.StretchDirection and fix Image measurement commit 4d8266d Author: Steven Kirk <[email protected]> Date: Fri Dec 20 00:10:16 2019 +0100 Port Image sizing algorithm from WPF. Fixes AvaloniaUI#3371 Fixes AvaloniaUI#2380 commit 062ec0c Author: Steven Kirk <[email protected]> Date: Thu Dec 19 23:46:26 2019 +0100 Added Image.StretchDirection. But not yet implemented. commit a0f72ff Author: Steven Kirk <[email protected]> Date: Thu Dec 19 23:33:15 2019 +0100 Added failing tests for AvaloniaUI#3371. commit fe2d2ac Merge: e48bbe6 e41c586 Author: Jumar Macato <[email protected]> Date: Fri Dec 20 00:42:41 2019 +0800 Merge pull request AvaloniaUI#3327 from AvaloniaUI/fixes/3323-resourcedictionary-resource Fix referencing resources in merged dictionaries commit e41c586 Merge: 01c1669 e48bbe6 Author: Steven Kirk <[email protected]> Date: Thu Dec 19 16:18:14 2019 +0100 Merge branch 'master' into fixes/3323-resourcedictionary-resource commit e48bbe6 Merge: e7f546e 4c2b77f Author: Steven Kirk <[email protected]> Date: Thu Dec 19 15:55:21 2019 +0100 Merge pull request AvaloniaUI#3369 from AvaloniaUI/fixes/2732-textbox-undo Snapshot TextBox undo text after paste. commit 4c2b77f Author: Steven Kirk <[email protected]> Date: Thu Dec 19 15:37:37 2019 +0100 Snapshot undo text after paste. Fixes AvaloniaUI#2732 commit 4736801 Author: Steven Kirk <[email protected]> Date: Wed Dec 18 22:56:05 2019 +0100 Remove unused methods. commit 3a914c2 Author: Steven Kirk <[email protected]> Date: Wed Dec 18 22:55:37 2019 +0100 Don't declare property fields AvaloniaProperty<>. Instead use `StyledProperty<>`. commit 42bbb5e Author: Steven Kirk <[email protected]> Date: Wed Dec 18 22:33:01 2019 +0100 Removed unused methods. commit c542c49 Merge: 623a925 e7f546e Author: Steven Kirk <[email protected]> Date: Wed Dec 18 22:25:38 2019 +0100 Merge branch 'master' into refactor/value-store commit e7f546e Merge: 3dbbe6d fc5ada5 Author: danwalmsley <[email protected]> Date: Tue Dec 17 18:26:34 2019 -0300 Merge pull request AvaloniaUI#3363 from PJB3005/19-12-16-egl Fix loading EGL functions on GLX. commit fc5ada5 Author: Pieter-Jan Briers <[email protected]> Date: Tue Dec 17 19:13:06 2019 +0100 Use invariant culture. commit 623a925 Author: Steven Kirk <[email protected]> Date: Tue Dec 17 12:42:43 2019 +0100 Clarify difference between BindingValue and BindingNotifcation. commit 37db6c7 Author: Steven Kirk <[email protected]> Date: Tue Dec 17 12:39:39 2019 +0100 Fix one-way bindings with notifications. commit f0301d5 Merge: 9137cc8 3dbbe6d Author: Steven Kirk <[email protected]> Date: Tue Dec 17 12:32:45 2019 +0100 Merge branch 'master' into refactor/value-store commit fb1dcc1 Author: Pieter-Jan Briers <[email protected]> Date: Mon Dec 16 20:45:52 2019 +0100 Fix loading EGL functions on GLX. This fixes apps refusing to run on Arch Linux. commit 65fa7e0 Merge: 55bdfcd a7ebcf8 Author: Dariusz Komosiński <[email protected]> Date: Fri Dec 13 20:54:11 2019 +0100 Merge branch 'master' into alloc-scene-hittest commit 3f58f70 Merge: ff4e412 a7ebcf8 Author: Dariusz Komosiński <[email protected]> Date: Fri Dec 13 20:53:30 2019 +0100 Merge branch 'master' into fix-win32-right-modifiers commit 3439a37 Author: Andrey Kunchev <[email protected]> Date: Thu Dec 12 15:01:10 2019 +0200 sync custom hittesting also to overlaylayer commit fc44379 Author: Andrey Kunchev <[email protected]> Date: Thu Dec 12 14:59:17 2019 +0200 fix immediaterenderer custom hittesting for WindowNotificationManager fixes AvaloniaUI#3356 commit 36dd50e Author: Andrey Kunchev <[email protected]> Date: Thu Dec 12 14:46:34 2019 +0200 fix immediate rendering hit testing for AdornerLayer commit 5a67237 Author: Steven Kirk <[email protected]> Date: Wed Dec 11 09:32:59 2019 +0100 Fix updating index when TreeView reparented. When an entire treeview is reparented, don't detach the child `TreeViewItem`s. Fixes AvaloniaUI#3328 commit 14ed1fd Author: Steven Kirk <[email protected]> Date: Wed Dec 11 09:31:54 2019 +0100 Added failing test for AvaloniaUI#3328. commit 5a235a9 Author: macpawluk <[email protected]> Date: Wed Dec 11 08:35:32 2019 +0100 Fix ImmediateRenderer for children with transform commit b773238 Author: macpawluk <[email protected]> Date: Wed Dec 11 08:39:19 2019 +0100 Unit tests covering issues of ImmediateRenderer with transformed children commit a70da65 Author: Steven Kirk <[email protected]> Date: Tue Dec 10 16:24:26 2019 +0100 Reafactor logical tree attach/detach events. - When detaching set `Parent` to `null` before raising the `DetachedFromLogicalTree` event - To do this, we need to store the logical root in the control so that e.g. a child control can be detached in a `DetachedFromLogicalTree` handler - Add `Source` and `Parent` properties to `LogicalTreeAttachmentEventArgs` to give more context on what caused the attachment/detachment commit 39fd3af Author: Steven Kirk <[email protected]> Date: Tue Dec 10 15:11:37 2019 +0100 Added sanity test for logical parent. Allows early detection of issue AvaloniaUI#3328. commit 01c1669 Merge: 601abac 7f11d83 Author: Jumar Macato <[email protected]> Date: Tue Dec 10 15:17:14 2019 +0800 Merge branch 'master' into fixes/3323-resourcedictionary-resource commit ff4e412 Merge: c674a8b 5b029f8 Author: Dariusz Komosiński <[email protected]> Date: Mon Dec 9 13:56:48 2019 +0100 Merge branch 'master' into fix-win32-right-modifiers commit 55bdfcd Author: Dariusz Komosinski <[email protected]> Date: Sat Dec 7 23:04:20 2019 +0100 Make sure that GetVisualAt without filter will use fast hit test path. commit 9e812f2 Author: Dariusz Komosinski <[email protected]> Date: Sat Dec 7 23:02:25 2019 +0100 Add HitTestFirst that allows for hit testing first matching visual. Implement better enumerator that can be used for both first and multiple hits. commit 12f4ae0 Author: Dariusz Komosinski <[email protected]> Date: Sat Dec 7 19:06:37 2019 +0100 Update license header. commit d9aab14 Author: Dariusz Komosinski <[email protected]> Date: Sat Dec 7 18:56:15 2019 +0100 Fix enumerator boxing case in visual hit testing. commit 58b33ed Author: Dariusz Komosinski <[email protected]> Date: Sat Dec 7 18:55:51 2019 +0100 Fix new mouse buttons causing boxing. commit c04b08a Author: Dariusz Komosinski <[email protected]> Date: Sat Nov 30 23:17:37 2019 +0100 Copy pooled collections to Avalonia.Base project. commit 29b7d2e Author: Dariusz Komosinski <[email protected]> Date: Sun Oct 6 21:31:50 2019 +0200 Rework scene hit testing. commit c674a8b Merge: 5912615 70e6f06 Author: Dariusz Komosiński <[email protected]> Date: Fri Dec 6 22:48:57 2019 +0100 Merge branch 'master' into fix-win32-right-modifiers commit 601abac Author: Steven Kirk <[email protected]> Date: Thu Dec 5 15:35:27 2019 +0100 Set resource parent for merged dictionaries. Allows `DynamicResource` and `StaticResource` in merged resource dictionaries to work properly. Fixes AvaloniaUI#3323 commit c2f3f3f Author: Steven Kirk <[email protected]> Date: Thu Dec 5 15:31:54 2019 +0100 Added failing tests for AvaloniaUI#3323. commit 5912615 Merge: 25aade0 bd0151f Author: Dariusz Komosiński <[email protected]> Date: Wed Dec 4 21:01:13 2019 +0100 Merge branch 'master' into fix-win32-right-modifiers commit 25aade0 Merge: cede1eb 800a5f8 Author: Dariusz Komosiński <[email protected]> Date: Wed Dec 4 16:13:19 2019 +0100 Merge branch 'master' into fix-win32-right-modifiers commit 9137cc8 Author: Steven Kirk <[email protected]> Date: Wed Dec 4 11:30:29 2019 +0100 Added overload of GetValueOrDefault that takes no param. To match `Nullable<T>`. commit 8196e05 Author: Steven Kirk <[email protected]> Date: Wed Dec 4 11:27:00 2019 +0100 ValueOrDefault -> GetValueOrDefault. To match `Nullable<T>`. commit 8e9a1cc Author: Steven Kirk <[email protected]> Date: Wed Dec 4 11:25:53 2019 +0100 Use _value field where possible. Allows more code to be inlined by not checking `HasValue` twice. commit cede1eb Merge: de874b5 d63180f Author: Dariusz Komosiński <[email protected]> Date: Wed Dec 4 11:20:49 2019 +0100 Merge branch 'master' into fix-win32-right-modifiers commit b140310 Merge: 6ddc953 d63180f Author: Steven Kirk <[email protected]> Date: Wed Dec 4 11:15:50 2019 +0100 Merge branch 'master' into refactor/value-store commit de874b5 Author: Dariusz Komosinski <[email protected]> Date: Tue Dec 3 22:58:30 2019 +0100 Win32 magic to properly identify left and right keys. commit e50c6f8 Author: Dariusz Komosinski <[email protected]> Date: Tue Dec 3 21:40:16 2019 +0100 Right shift is also affected. commit 8c18ed0 Author: Dariusz Komosinski <[email protected]> Date: Tue Dec 3 21:39:51 2019 +0100 Unify page up and down key codes. commit 0462f48 Merge: be4d1ef 572f230 Author: Dariusz Komosiński <[email protected]> Date: Tue Dec 3 17:21:47 2019 +0100 Merge branch 'master' into fix-win32-right-modifiers commit be4d1ef Author: Dariusz Komosiński <[email protected]> Date: Tue Dec 3 16:37:22 2019 +0100 Fix right ALT and CTRL being reported as left. commit 4065742 Author: Steven Kirk <[email protected]> Date: Sun Nov 24 21:58:18 2019 +0100 Reintroduce coercion to NumericUpDown. commit 1616e76 Author: Steven Kirk <[email protected]> Date: Sun Nov 24 11:28:56 2019 +0100 Added benchmarks for property validation/coercion. commit 0f04f4d Author: Steven Kirk <[email protected]> Date: Sun Nov 24 11:03:49 2019 +0100 Add WPF-style property coercion. commit aa81db7 Author: Steven Kirk <[email protected]> Date: Fri Nov 22 11:09:39 2019 +0100 Added WPF-style validation for AvaloniaProperty. commit 6ddc953 Author: Steven Kirk <[email protected]> Date: Thu Nov 21 19:39:41 2019 +0100 Implement diagnostic API. Doesn't actually fill in the "details" property for styled properties because this API is going to change shortly with the new devtools. commit d5dc470 Author: Steven Kirk <[email protected]> Date: Thu Nov 21 18:58:14 2019 +0100 Fixed issue with LocalValue and bindings. commit 44e1bd5 Author: Steven Kirk <[email protected]> Date: Thu Nov 21 18:15:57 2019 +0100 Use LocalValueEntry instead of boxing. Further reduces allocated memory in the common case of only a local value being set. commit 557898a Author: Steven Kirk <[email protected]> Date: Thu Nov 21 11:59:57 2019 +0100 Move methods back to original order. Moving them like this was confusing the diff. commit a29a2db Author: Steven Kirk <[email protected]> Date: Thu Nov 21 11:58:39 2019 +0100 Removed unused method. commit 55eea62 Author: Steven Kirk <[email protected]> Date: Thu Nov 21 11:58:11 2019 +0100 Implement IEquatable on Optional. commit 8b1efc5 Author: Steven Kirk <[email protected]> Date: Thu Nov 21 11:56:46 2019 +0100 Make Optional readonly. commit 1343104 Author: Steven Kirk <[email protected]> Date: Sun Nov 17 07:04:21 2019 +0100 Remove TryGetValueUntyped. commit 8ed800a Author: Steven Kirk <[email protected]> Date: Sat Nov 16 12:19:37 2019 +0100 I did the merge wrong. Delete some files that should have been deleted in merge. commit 13c6fb6 Merge: 60422d6 44d885f Author: Steven Kirk <[email protected]> Date: Sat Nov 16 12:07:41 2019 +0100 Merge branch 'master' into refactor/value-store commit 60422d6 Author: Steven Kirk <[email protected]> Date: Fri Nov 15 09:31:07 2019 +0100 Handle GetBindingObservable<object>(). commit aa9386d Author: Steven Kirk <[email protected]> Date: Fri Nov 15 09:30:46 2019 +0100 Add another sanity check to BindingValue. commit c5acd37 Merge: b8717bf 49b91d1 Author: Steven Kirk <[email protected]> Date: Fri Nov 15 01:03:12 2019 +0100 Merge pull request AvaloniaUI#3258 from AvaloniaUI/fixes/binding-stack-overflow Alternative fix for binding stack overflow commit 49b91d1 Author: Steven Kirk <[email protected]> Date: Fri Nov 15 00:17:18 2019 +0100 Fix stack overflow. Don't believe the new value given to us in the `AvaloniaPropertyChangedEventArgs`: it may have already changed. Instead, read the current value of the property from the object. commit aa3dfcd Author: Steven Kirk <[email protected]> Date: Fri Nov 15 00:16:10 2019 +0100 Remove DeferredSetter. It's not needed any more. commit b8717bf Author: Steven Kirk <[email protected]> Date: Thu Nov 14 20:34:32 2019 +0100 Tidy up API. commit e404544 Author: Steven Kirk <[email protected]> Date: Thu Nov 14 16:09:47 2019 +0100 Move check to avalonia properties. commit 0cfa159 Author: Steven Kirk <[email protected]> Date: Thu Nov 14 15:30:52 2019 +0100 Remove ignored validate parameter. commit 6be3acb Author: Steven Kirk <[email protected]> Date: Thu Nov 14 15:16:37 2019 +0100 Make ValueStore typed. Major refactor of the Avalonia core to make the styled property store typed. commit fc2439e Author: Steven Kirk <[email protected]> Date: Thu Nov 14 15:15:26 2019 +0100 Added some benchmarks for styled properties. # Conflicts: # samples/RenderDemo/Pages/RenderTargetBitmapPage.cs # src/Avalonia.Controls/Notifications/WindowNotificationManager.cs # src/Avalonia.Controls/Primitives/AdornerLayer.cs # src/Skia/Avalonia.Skia/FontManagerImpl.cs
What does the pull request do?
Previously, when a value was set on a styled property, that property was boxed and added to the
ValueStore
. This PR refactors the value store and the API ofAvaloniaObject
to store values without boxing.IAvaloniaObject
has been changed to have two overloads of each get/set/bind/clear method:StyledPropertyBase<T>
DirectPropertyBase<T>
In addition, the
IObservable<>
passed toBind
has changed to anIObservable<BindingValue<T>>
:BindingValue<T>
is a struct which allows representation of extra state in a typed manner:Because the get/set/bind/clear methods are now typed on the value
T
, the value store can now store values without boxing.Untyped
AvaloniaProperty
access is still allowed and calls are routed through theAvaloniaProperty
itself to the correct generic method.Bindings which produce an
IObservable<T>
are wrapped in an adapter to convert them toIObservable<BindingValue<T>>
.Benchmarks
master
:This PR:
Note that the
Set_Int_Property_Multiple_Priorities
andSet_Int_Property_TemplatedParent
tests are now slower/allocate more due to the change in behavior listed under "Breaking Changes" -> "Values". However despite the fact they're storing multiple values instead of a single value, the total allocated memory is still a fraction of what it was beforeNot addressed in this PR
IObservable<object>
meaning that they have to be wrapped. This means that you won't see much perf improvement from this PR alone. Changes to fix this will come in later PRs.The stackoverflow problems described in StackOverflowException in binding #855 and [Slider] Two-Way Binding to Slider.Value produces Stack Overflow #824 are not addressed. We previously usedMerged into this PR by Alternative fix for binding stack overflow #3258DeferedSetter
to get around these problems, but that had a non-zero performance impact. The fix for these issues will come in a separate PR to make reviewing of just that part more easy.AvaloniaObject.GetValue
/SetValue
/Bind
methods can be moved to extension methods, but that will require a change to the XAML compilerChecklist
Breaking changes
Properties
AvaloniaProperty<T>
then you should change them toStyledProperty<>
orDirectProperty<,>
fieldsOnPropertyChanged
has changed and is now a generic method in order to avoid allocation and boxing. To cast theoldValue
andnewValue
parameters to a concrete type, use.ValueOrDefault<T>()
onOptional<T>
andBindingValue<T>
Values
Previously all values set via
SetValue
were only active until a binding of the same or higher priority produced a value, in which case theSetValue
value was lost.This meant that style setters with needed to create a binding with a single value, otherwise the setter value would be lost when e.g. a setter with
StyleTrigger
binding was activated.This PR changes that behavior:
LocalValue
priority values now work as before but other priority values are stored alongside bindings in the entries for the priority value and as such will not be overwritten by binding values. This will allow more efficient style values in a future PR as single values will no longer have to be created as single-value non-completing bindingsBinding
AvaloniaObject.Bind
overloads have been moved to be extension methods, so you may have to addthis.
to yourBind()
call when binding tothis
Validation
Styled property value validation and coercion was a major performance bottleneck, because it imposed a metadata lookup on every styled property set and binding update, regardless of whether validation was enabled for the property (and for 99% of properties, it isn't)In WPF/UWP value validation is defined outside of metadata, so we could bring validation back in a later PR in this form if needed. However even in WPF/UWP coercion imposes the overhead of a metadata lookup so it's unlikely we'd bring this back. The problem is less of an issue in Avalonia due to direct properties however.#3287 implements WPF-style property validation and coercion and targets this branch. I've kept it as a separate PR for now to ease review. #3287 should be merged into this PR before this PR is merged.#3287 mergedAvalonia properties now take a separate validation and coercion callback the same as WPF. The validation callback cannot be overridden, though the coercion callback can.
Depends on #3287