Skip to content

feat: bump TodoApp.Avalonia sample from Avalonia 11 to 12 (12.1.0)#571

Merged
adrianhall merged 2 commits into
CommunityToolkit:mainfrom
adrianhall:issues/507
Jul 11, 2026
Merged

feat: bump TodoApp.Avalonia sample from Avalonia 11 to 12 (12.1.0)#571
adrianhall merged 2 commits into
CommunityToolkit:mainfrom
adrianhall:issues/507

Conversation

@adrianhall

Copy link
Copy Markdown
Collaborator

Summary

Bumps the TodoApp.Avalonia sample from Avalonia 11 to 12.1.0 (the latest release at time of implementation) for general currency, since 11.x will presumably reach end-of-support once 12 is established. This is a follow-up to #499 (which fixed NU1903 via an 11.3.18 patch bump only) and is its own scoped change per #507.

Closes #507

Changes

All changes verified against the official Avalonia 12 breaking changes doc:

  • Package versions: bump the shared AvaloniaVersion property (Directory.Build.props) from 11.3.18 to 12.1.0, used by all Avalonia.* PackageReferences across the shared, Desktop, Android, and iOS projects.
  • Avalonia.Diagnostics removed in v12: drop the Debug-only PackageReference from TodoApp.Avalonia.csproj and TodoApp.Avalonia.Desktop.csproj (no AttachDevTools() call exists in the sample, so this is a clean removal).
  • Binding plugins removed in v12: remove BindingPlugins.DataValidators.RemoveAt(0); and its Avalonia.Data.Core* usings from App.axaml.cs. Behavior is preserved because v12 disables the data-annotations validation plugin by default.
  • Android now implements IActivityApplicationLifetime instead of ISingleViewApplicationLifetime: add a MainViewFactory-based branch in App.axaml.cs, ordered before the existing ISingleViewApplicationLifetime check (which is still required for iOS/browser/embedded Linux, per Avalonia's own migration guidance).
  • Android app-initialization rework:
    • Add TodoApp.Avalonia.Android/Application.cs: a new [Application]-attributed Application : AvaloniaAndroidApplication<App> class hosting the CustomizeAppBuilder override (.WithInterFont()).
    • Change MainActivity from generic AvaloniaMainActivity<App> to non-generic AvaloniaMainActivity (the CreateAppBuilder/CustomizeAppBuilder virtual methods were removed from the generic base class in v12; that logic now lives in Application.cs).
    • Wire up android:name=".Application" on the <application> element in AndroidManifest.xml.
  • MainView.axaml: rename Watermark="Add a new Item"PlaceholderText="Add a new Item" (old property is kept but obsolete in v12).
  • Trim-analyzer comment cleanup: drop the now-stale "Avalonia's BindingPlugins.DataValidators" mention from the SuppressTrimAnalysisWarnings justification comment in the Android/iOS .csproj files, since that code path no longer exists — only EF Core's DbContext(DbContextOptions) ctor remains a relevant trim-analyzer noise source.
  • iOS AppDelegate.cs: no changes required — confirmed against the breaking-changes doc that AvaloniaAppDelegate.CustomizeAppBuilder was not removed for iOS (only Window becoming null-until-scene-attached, which this sample doesn't touch), and confirmed via a real CI build that it still compiles unchanged.

Confirmed NOT applicable (verified via source grep against the breaking-changes doc)

Gestures.* attached events, clipboard/IDataObject APIs, GotFocusEventArgs, WindowState-in-styles, TextBlock.LetterSpacing, SystemDecorations/ExtendClientAreaChromeHints, KeyboardNavigationHandler, custom Screen construction, Direct2D1/Blazor/Tizen backends, headless xUnit/NUnit tests — no matches found in the sample source.

Related

Testing

ahall added 2 commits July 11, 2026 12:15
Bumps the shared AvaloniaVersion property (Directory.Build.props) from
11.3.18 to 12.1.0 and updates the sample for Avalonia 12's breaking
changes:

- Avalonia.Diagnostics package removed in v12: drop the Debug-only
  PackageReference from TodoApp.Avalonia and TodoApp.Avalonia.Desktop
  (no AttachDevTools() call exists in the sample).
- Binding plugins removed in v12: drop the
  BindingPlugins.DataValidators.RemoveAt(0) call and its
  Avalonia.Data.Core* usings from App.axaml.cs; behavior is preserved
  since v12 disables the data-annotations validation plugin by default.
- Android now implements IActivityApplicationLifetime instead of
  ISingleViewApplicationLifetime: add a MainViewFactory branch before
  the existing ISingleViewApplicationLifetime check (still required for
  iOS/browser/embedded Linux) in App.axaml.cs.
- Android app initialization reworked: add
  TodoApp.Avalonia.Android/Application.cs (AvaloniaAndroidApplication<App>
  with the [Application] attribute, hosting the CustomizeAppBuilder
  override moved from MainActivity), change MainActivity to the
  non-generic AvaloniaMainActivity (CreateAppBuilder/CustomizeAppBuilder
  were removed from the generic base class), and wire up
  android:name=".Application" in AndroidManifest.xml.
- Rename TextBox.Watermark to the non-obsolete PlaceholderText in
  MainView.axaml.
- Drop the now-stale BindingPlugins.DataValidators mention from the
  SuppressTrimAnalysisWarnings comment in the Android/iOS csproj files
  (EF Core's DbContext(DbContextOptions) ctor remains the relevant
  trim-analyzer noise source).

The TodoApp.Avalonia.iOS AppDelegate requires no changes: its
CustomizeAppBuilder override was not removed for iOS in Avalonia 12.

Verified locally: dotnet build succeeds (Debug and Release) for the
shared TodoApp.Avalonia and TodoApp.Avalonia.Desktop projects. The
Android and iOS heads require their respective mobile workloads, which
are validated via the build-samples.yml CI workflow rather than
locally.

Fixes CommunityToolkit#507
@adrianhall adrianhall merged commit 3b6fc78 into CommunityToolkit:main Jul 11, 2026
20 checks passed
@adrianhall adrianhall deleted the issues/507 branch July 11, 2026 11:46
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.

Major-version bump: Avalonia 11 → 12 (TodoApp.Avalonia sample)

1 participant