Repository navigation
perf(binding)!: move the fixed steps of a generated binding into runtime helpers - #552
Merged
Merged
Conversation
…vely - Update ReactiveUI to 27.0.1, ReactiveUI.Primitives to 10.2.1, TUnit, Windows App SDK, TraceEvent and ReactiveUI.Avalonia. - Remove direct package references that a referenced project or package already brings in. The resolved package graph is unchanged. - Move the binding benchmarks off their ReactiveUI 26.0.1 pin. - Target net11.0 as well as net10.0 in the threading example.
- Remove the legacy API branch, the RxApp exception handler path and ReactiveUI's own IViewFor namespace. - Delete the ReactiveUI 23 test project and the ReactiveUI 23 and 24 version pins. - Remove checks in the host and command generators that no input can reach, and test the cases that can. - Target both frameworks in the Execute sample projects, and log through Splat instead of Trace. BREAKING CHANGE: the attribute generators no longer generate for ReactiveUI 25 or earlier.
- Move the hook guard, the plugin fallback, the conversion stage, the custom command binder check and the service locator view lookup into public runtime helpers, so each generated method states only what differs per call site. - Turn nullable warnings off in generated files, so csc skips nullable flow analysis over them. - Pass typed accessors to the new helpers instead of object-typed ones. - Start every DebuggerDisplay with its type name. A consumer with 600 binding call sites generates 62,805 lines instead of 113,952. Refs #548
…no value - Add ITypedPropertyBindingHook, which reads a BindingHookPath through IBindingHookPropertyVisitor in each property's own types. - Add ICreatesTypedCommandBinding, which takes the command parameter stream typed. - Call the typed member from the generated-binding helpers when a registration implements it. Refs #548
…c factories - Make BindingHookProperty a sealed class that holds its typed accessors as delegates. - Flatten TypedConstantInfo into one sealed record with a kind and the expression text. - Write forwarded attributes as text, not through syntax nodes. - Read array elements from the operation tree, which removes branches no input reached.
- Take the 10.2.2 release across the Primitives packages. - Name two deep-chain tests after ReactiveUI's semantics without the word legacy.
- Loading ReactiveUI.Binding by the version ReactiveUI asks for fails when the build's version is lower. - The seed takes the assembly the test project references, at any version.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #552 +/- ##
==========================================
+ Coverage 99.01% 99.15% +0.13%
==========================================
Files 472 475 +3
Lines 18920 18829 -91
Branches 2813 2808 -5
==========================================
- Hits 18734 18670 -64
+ Misses 186 159 -27 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… as existing ones - Rename the Legacy types, methods and files of the custom-converters example to Existing. - Target net10.0 and net11.0 in that example. - State in BindingHookProperty which hook contract carries values as objects.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
A generated binding now states only what differs per call site and calls public runtime helpers for the rest. On a 600 call site consumer the generated code fell from 113,952 lines to 62,805, and a warm compile fell from about 4.3 s to about 2.5 s.
BindingHooks.ShouldBind,PluginObservationSource.ChooseandChooseDistinct,GeneratedConversion.Convert,CommandBinderService.BindCustomandDefaultViewLocator.GetRegisteredView<TViewModel>instead of writing those steps out per call site.ITypedPropertyBindingHookandICreatesTypedCommandBindinglet a registered hook or command binder receive values in their own types, so value types are not boxed.BindingHookPath,BindingHookPropertyandIBindingHookPropertyVisitorcarry the typed path.DebuggerDisplaytext starts with the type's name.TypedConstantInfois one sealed record with static factories, and forwarded attributes are written as text.Why
Refs #548. Binding dispatch code ran to 100 to 200 lines per call site and doubled the compile time of a large WPF project. Most of those lines were the same in every binding, so they belong in the runtime.
This uses
Refsbecause the remaining compile cost is the compiler binding each generated call, which this change reduces but does not remove.Breaking changes
ReactiveUI.SourceGeneratorsneeds ReactiveUI 26 or later. A project on an older ReactiveUI stays on the previous release of the generators.ReactiveUI.BindingorReactiveUI.Binding.Reactivetogether with the generator, which is automatic because the runtime package ships the generator.No existing public API in the runtime packages is removed or changed.
How this was verified
Tests cover every new runtime helper and interface in both runtime flavours, and every changed source file is fully covered. The examples ran on Linux, with a native AOT publish that reports no trim or AOT warnings, and on a Windows 11 VM for the .NET Framework, WPF, WinForms and threading examples. Apple targets were not run because no Apple host was available.
Notes for the reviewer
BindingEmitterHelpers,ConversionEmitter,ChainRegistrationEmitterandBindCommandCodeGenerator, then the runtime helpers they call. The roughly 180 changed snapshots are mechanical and follow from those emitters.PublicAPI.txtfiles gain the same lines in each framework and flavour.GetSymbolInfoand under 1% in this repository's code. Two attempts to cut that, a cache in the analyzer and a fast path for member lookup, measured no gain and are not included.Legacy...types and methods toExisting.... The website's custom converters page quotes those names and needs the same rename in its own pull request.Checklist