Skip to content

feat(bindings): generate native platform adapters - #111

Merged
glennawatson merged 3 commits into
mainfrom
glennawatson/source-gen-property-adapter
Sep 18, 2026
Merged

glennawatson merged 3 commits into
mainfrom
glennawatson/source-gen-property-adapter

Conversation

@glennawatson

Copy link
Copy Markdown
Contributor

Summary

Generate native platform bindings through separate affinity-based plugins.

  • Select observation, conversion, command and collection-write mechanisms from the consumer's framework types using interface-based plugins and shared static helpers.
  • Support WPF, WinForms, MAUI, WinUI/Uno, Android, Apple and Blazor mechanisms inside the source generator, with helpers emitted only for bindings that use them.
  • Preserve higher-affinity custom providers with property-specific cached selection and refresh support; generated mechanisms win ties, and legacy expressions and object adapters are created only for winning custom providers.
  • Keep generated getters, delivery, comparisons, conversions and setters typed, including nullable, visibility, date and string conversions.
  • Bind native commands with command/control replacement, parameters, enabled state and disposal, and populate WinForms control collections through native setters.
  • Reduce generator allocations and avoid per-update collection-array copies and boxing on common generated paths; public object-valued contracts retain their required boundaries.
  • Validate native adapter behavior and allocations through existing test and benchmark projects, targeting .NET 10/11 with NativeAOT runs and GcVerbose traces.
  • Document native-event bindings and benefits for ordinary JIT applications.

Why

Generated bindings need ReactiveUI's platform behavior and custom-provider precedence.

  • Compile-time knowledge of supported mechanisms allows direct typed bindings while preserving runtime registrations that outrank the generated choice.

Breaking changes

None.

How this was verified

Solution builds and tests exercise generated bindings, native contracts, custom-provider precedence and refresh.

  • Generation and runtime benchmarks exercise .NET 10/11 and NativeAOT; GcVerbose traces check allocation behavior. Native benchmark fixtures measure managed wiring rather than platform rendering.

Notes for the reviewer

Start with plugin selection and the custom-provider boundary.

  • Review Plugins, per-invocation emission, ObservationAffinityChecker, and typed conversion and collection-write helpers; generated snapshots and public API baselines are mechanical.
  • Pay particular attention to per-property affinity, generated tie precedence, refresh races, and expressions being constructed only after a custom provider wins.

Checklist

  • I have read the Contribute guide
  • The PR title follows Conventional Commits
  • Tests cover this change, or the summary says why they do not
  • New or changed public API has XML documentation

- Select typed observation, conversion, command and collection mechanisms by affinity.
- Preserve higher-scoring custom providers, cached selection and refresh behavior.
- Keep generated value delivery typed and emit native support only when used.
- Remove redundant analysis, pipeline dependencies and avoidable collection copies.
- Cover platform contracts with tests and validated GcVerbose benchmarks on .NET 10/11 and NativeAOT.
- Document native bindings and benefits for regular JIT applications.
- Preserve typed conversions with scheduler delivery from main.
- Align generated snapshots and benchmark documentation.
@glennawatson
glennawatson enabled auto-merge (squash) September 18, 2026 03:59
@sonarqubecloud

Copy link
Copy Markdown

@glennawatson
glennawatson merged commit eee8186 into main Sep 18, 2026
20 checks passed
@glennawatson
glennawatson deleted the glennawatson/source-gen-property-adapter branch September 18, 2026 12:51
@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.79892% with 103 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.59%. Comparing base (e57d96e) to head (56e43c8).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...rs/Plugins/Observation/AndroidObservationPlugin.cs 59.37% 10 Missing and 3 partials ⚠️
...ors/Plugins/SetMethod/WinFormsCollectionSymbols.cs 68.18% 3 Missing and 4 partials ⚠️
...ceGenerators/CodeGeneration/BindToCodeGenerator.cs 79.31% 6 Missing ⚠️
...urceGenerators/CodeGeneration/ConversionEmitter.cs 90.76% 5 Missing and 1 partial ⚠️
...rators/Plugins/Conversion/AppleConversionPlugin.cs 77.77% 2 Missing and 4 partials ⚠️
...rators/Plugins/Observation/UnoObservationPlugin.cs 40.00% 5 Missing and 1 partial ⚠️
...eGenerators/Plugins/Observation/PlatformSymbols.cs 84.84% 5 Missing ⚠️
...rceGenerators/Plugins/ObservationPluginRegistry.cs 79.16% 5 Missing ⚠️
...ors/Plugins/Observation/AppKitObservationPlugin.cs 73.33% 2 Missing and 2 partials ⚠️
...rators/Plugins/Observation/KVOObservationPlugin.cs 83.33% 1 Missing and 3 partials ⚠️
... and 23 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #111      +/-   ##
==========================================
- Coverage   99.75%   97.59%   -2.16%     
==========================================
  Files         292      349      +57     
  Lines       11786    12539     +753     
  Branches     1277     1495     +218     
==========================================
+ Hits        11757    12238     +481     
- Misses         17      245     +228     
- Partials       12       56      +44     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant