Skip to content

Upgrade Avalonia projects to v12#177

Merged
highbyte merged 1 commit intomasterfrom
feature/avalonia-v12
Apr 17, 2026
Merged

Upgrade Avalonia projects to v12#177
highbyte merged 1 commit intomasterfrom
feature/avalonia-v12

Conversation

@highbyte
Copy link
Copy Markdown
Owner

Summary

Upgrades Avalonia from 11.3.x to 12.0.1 across all six Avalonia projects (Core library + Desktop/Browser/iOS/Android apps).

Priority per the upgrade plan: Desktop and Browser must run; iOS and Android only need to compile.

Package changes

  • All 8 Avalonia.* packages → 12.0.1 (including Avalonia.Skia, Avalonia.Android, Avalonia.iOS, Avalonia.Browser).
  • SkiaSharp native-asset packages bumped to the 3.119.3-preview.1.1 line (Avalonia 12 Skia requires it).
  • Dropped Avalonia.Diagnostics (no 12.x release yet — temporarily removes Ctrl+F12 DevTools in Debug desktop builds).
  • Dropped Avalonia.ReactiveUI (deprecated for v12) and replaced it with the ReactiveUI core package (not deprecated, actively maintained).
  • Removed the unused CommunityToolkit.Mvvm reference.

ReactiveUI migration

Avalonia.ReactiveUI's only real contribution in this codebase was registering AvaloniaScheduler as RxApp.MainThreadScheduler via .UseReactiveUI(). It's replaced with:

  • A custom AvaloniaDispatcherScheduler shim (~30 lines, posts to Dispatcher.UIThread).
  • Explicit ReactiveUI 23.x bootstrap via RxAppBuilder.CreateReactiveUIBuilder()...BuildApp() in App.OnFrameworkInitializationCompleted. (ReactiveUI 23 no longer auto-initializes — first use of ReactiveObject throws TypeInitializationException without this.)
  • Find/replace across 8 ViewModels: RxApp.MainThreadSchedulerRxSchedulers.MainThreadScheduler (the RxApp class was split into RxSchedulers / RxState in ReactiveUI 23).
  • Browser .csproj adds <TrimmerRootAssembly Include="ReactiveUI" /> — the WASM AOT trimmer otherwise strips RxSchedulers / RxAppBuilder and the app throws TypeLoadException at load time.

All existing ReactiveObject / RaiseAndSetIfChanged / ReactiveCommand / ObservableAsPropertyHelper usage is unchanged.

v12 breaking-change fixes

  • App.axaml.cs: removed the DisableAvaloniaDataAnnotationValidation method and its call — the data-annotations binding plugin was removed in v12 (compiled bindings are now the default).
  • C64MenuView.axaml.cs: migrated clipboard from GetTextAsync / SetTextAsync to the new IAsyncDataTransfer / DataTransferItem API.
  • OverlayDialogHelper.cs: GetVisualRoot()TopLevel.GetTopLevel(...) (the visual-tree helper extension is gone).
  • MainWindow.axaml.cs: removed InitializeComponent(attachDevTools: false) — the parameter was removed in v12.
  • Android MainActivity.cs: rewritten for the v12 model — non-generic AvaloniaMainActivity + a new AvaloniaAndroidApplication<App> subclass hosting CustomizeAppBuilder.
  • iOS/Android .csproj target frameworks: net9.0-ios / net9.0-androidnet10.0-ios / net10.0-android (Avalonia 12 mobile requires .NET 10).

Test plan

  • Full solution build succeeds (0 errors, Debug & Release).
  • Desktop app launches, menu opens, clipboard copy+paste works, a C64 system loads & runs.
  • Browser app boots in a browser, main view renders, Lua script panel works.
  • iOS/Android only verified to compile — no runtime test required this cycle (not actively used).

Known follow-ups

  • Re-add Avalonia.Diagnostics (DevTools) once a 12.x release is published — marker comment left in Core.csproj.
  • SkiaSharp.NativeAssets.* are pinned to a prerelease; bump to stable when one compatible with Avalonia 12 ships.
  • The TrimmerRootAssembly Include="ReactiveUI" in the Browser project preserves ~150KB of ReactiveUI IL from trimming. If WASM payload size becomes a concern, this is the first thing to revisit.

Upgrades Avalonia from 11.3.x to 12.0.1 across Core/Desktop/Browser/iOS/Android.
Migrates off deprecated Avalonia.ReactiveUI to ReactiveUI core with a custom
AvaloniaDispatcherScheduler shim. Bumps iOS/Android target frameworks to net10
and rewrites the Android entry point for the new AvaloniaAndroidApplication
model. Also drops v12-incompatible APIs (DataAnnotations plugin, clipboard
text helpers, attachDevTools parameter) and removes the unused
CommunityToolkit.Mvvm reference.
@sonarqubecloud
Copy link
Copy Markdown

@highbyte highbyte merged commit 77176c3 into master Apr 17, 2026
7 checks passed
@highbyte highbyte deleted the feature/avalonia-v12 branch April 17, 2026 17:31
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