-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
EpicGroups multiple user stories. Can be grouped under a theme.Groups multiple user stories. Can be grouped under a theme.area-xamlXAML, CSS, Triggers, BehaviorsXAML, CSS, Triggers, Behaviors
Milestone
Description
We agreed to implement a new public API to allow creating "compiled" bindings (TypedBinding<TSource, TProperty>) in code via source-generators and interceptors based on the proposal #20574 (see Alternative design).
- Introduce new public method
BindableObjectExtensions.SetBinding<TSource, TProperty>(BindableProperty property, Func<TSource, TProperty> getter, ...)as defined in the proposal - Create a new source generator
- Intercept calls to
SetBinding<TSource, TProperty>(...) - Parse getter lambda expression
- Implement support for properties
- Implement support for indexers
- Implement support for
as-casts - Implement support for C-style casts
- Implement support for conditional access to members
- Implement diagnostics reporting
- Build cacheable data model
- Generate setter from the getter lambda
- Generate handlers array from the getter lambda
- Intercept calls to
- Enable the source generator by default in MAUI apps
- Introduce a feature switch to disable the source generator
- Add unit tests for correct caching of the generated code
- Run benchmarks comparing reflection-based binding, source-generated binding, and hand-written typed binding
-
Write docs/developer guide- tracked in .NET MAUI 9: Compiled bindings can be used with C# markup docs-maui#2304
Possible future improvements
- Replace usage of
TypedBinding.ForSingleNestingLevel(...)with the source generated interceptors - [Binding SG] Dogfood binding source generator in the MAUI codebase #23393 - Implement support for generic parameters
- Use the new overload in existing unit tests
- Add more public methods that could be intercepted (this has not been discussed/agreed on yet) - [Binding SG] Add an API for creating instances of TypedBinding #23239
- for example:
BindingBase Binding.Create<TSource, TProperty>(Func<TSource, TProperty> getter, ...)TBindable Bind<TBindable, TSource, TProperty>(this TBindable bindableObject, Func<TSource, TProperty> getter, ...) where TBindable : BindableObject.
- for example:
- Improve efficiency by grouping calls to
SetBindingwith the samegettersignature into one interceptor - Split individual generated methods into separate files for more granular caching - [Binding SG] Split bindings source generated code into multiple files #23116
- Explore the option of resolving method groups instead of just lambda expressions
- Use roslyn-sdk test library
akhanalcsakhanalcs
Metadata
Metadata
Assignees
Labels
EpicGroups multiple user stories. Can be grouped under a theme.Groups multiple user stories. Can be grouped under a theme.area-xamlXAML, CSS, Triggers, BehaviorsXAML, CSS, Triggers, Behaviors
Type
Projects
Status
Done