Skip to content

feat: upgrade to Avalonia 12#185

Merged
fuzzzerd merged 5 commits intomasterfrom
fuzzz/avalonia-12
Apr 23, 2026
Merged

feat: upgrade to Avalonia 12#185
fuzzzerd merged 5 commits intomasterfrom
fuzzz/avalonia-12

Conversation

@fuzzzerd
Copy link
Copy Markdown
Owner

Bumps Avalonia core from 11.2.4 to 12.0.1 and ports the one place the new API broke us (clipboard).

Changes

  • Directory.Packages.props — Avalonia / Avalonia.Desktop / Avalonia.Themes.Fluent / Avalonia.Fonts.Inter → 12.0.1; Avalonia.AvaloniaEdit / AvaloniaEdit.TextMate → 12.0.0; TextMateSharp.Grammars → 2.0.3.
  • Avalonia.Controls.DataGrid pinned to 12.0.0 — a stale 11.1.0 was coming in transitively via AvaloniaEdit and couldn't parse v12 bindings, which took out TableEditorControl.axaml. Adding an explicit top-level reference forces the correct version.
  • ClipboardService.cs rewritten against the new clipboard API:
    • SetTextAsync is now ClipboardExtensions.SetTextAsync (extension on IClipboard, requires using Avalonia.Input.Platform).
    • SetDataObjectAsync(IDataObject) is gone; replacement is a DataTransfer containing a DataTransferItem.Create(DataFormat.CreateBytesPlatformFormat(format), bytes) passed to IClipboard.SetDataAsync(IAsyncDataTransfer).
    • GetFormatsAsync() is now ClipboardExtensions.GetDataFormatsAsync() and returns DataFormat[]; we project .Identifier to keep IClipboardService's string[] shape so no callers change.
    • GetDataAsync(format) is now clipboard.TryGetDataAsync() returning a disposable IAsyncDataTransfer; we wrap it in using and pull the typed value with TryGetValueAsync(DataFormat.CreateBytesPlatformFormat(format)).
    • IClipboardService's public shape is unchanged, so MainWindowViewModel and RawClipboardWindow didn't need changes.
  • Avalonia.Diagnostics dropped entirely. Avalonia 12 removed in-process F12 DevTools. The replacement bridge (AvaloniaUI.DiagnosticsSupport + an external AvaloniaUI Developer Tools desktop app) requires a paid license. The previous Avalonia.Diagnostics 11.3.14 restored alongside 12.0.1 core but crashes at runtime when F12 attaches. Rather than ship a dead F12 binding or adopt a paid tool, the package is removed.
  • Avalonia.Xaml.Interactions dropped. No XAML or C# in the codebase referenced it.
  • FluentAvaloniaUI dropped. The only usage was one helper class (DataPackage) in the clipboard copy path, which Avalonia 12's DataTransferItem replaces directly. None of FluentAvaloniaUI's controls were ever used; it had been unused from the moment of the ClipboardService rewrite above.

Why the clipboard API changed (upstream context)

Avalonia PR #20521 replaced the IDataObject + string model with an async-first, typed, multi-item model:

  • Platform clipboards (Win32 / NSPasteboard / Wayland) are natively async; the old wrappers faked sync.
  • Raw string format identifiers gave no guidance on platform-vs-application-vs-in-process scoping. The new DataFormat type makes that explicit and typed (DataFormat<byte[]>, DataFormat<string>, etc.).
  • Real clipboards hold multiple items with multiple format representations each; IDataObject flattened that to one blob.

"AS IS" passthrough semantics are preserved for platform-specific formats (CreateBytesPlatformFormat), which is what SharpFM needs for FileMaker's Mac-XM* types.

Bump Avalonia core packages from 11.2.4 to 12.0.1 and port ClipboardService
to the new IAsyncDataTransfer / DataFormat API.

- SetTextAsync: now an extension method in Avalonia.Input.Platform.
- SetDataAsync: build a DataTransfer with a DataTransferItem holding a
  DataFormat.CreateBytesPlatformFormat(format) value, then SetDataAsync.
- GetFormatsAsync: read DataFormat[] via GetDataFormatsAsync and expose
  their string Identifier to keep IClipboardService's shape.
- GetDataAsync: TryGetDataAsync returns a disposable IAsyncDataTransfer;
  pull the value for the requested format and dispose.

Pin Avalonia.Controls.DataGrid to 12.0.0 explicitly to override the stale
11.1.0 transitive that ships via AvaloniaEdit and can't parse v12 bindings.

Avalonia.Diagnostics has no 12.x release; 11.3.14 is the last maintained
version and restores cleanly alongside 12.0.1. It remains Debug-only gated
in the csproj.
Avalonia 12 removed in-process DevTools. The replacement
(AvaloniaUI.DiagnosticsSupport + external AvaloniaUI Developer Tools app)
requires a paid license we don't have, and the previous Avalonia.Diagnostics
11.3.14 crashes at runtime when F12 attaches against the 12.x core.

Drop the reference entirely rather than ship a dead F12 binding.
Accidentally added in e3dbde8; should stay out of the repo's gitignore so
each contributor can decide what to ignore via their personal global
gitignore or a local exclude.
@github-actions
Copy link
Copy Markdown

Test Results

✔️ Tests 1155 / 1155 - passed in 10.5s
✔️ Coverage 78.08% - passed with 70% threshold
📏 13104 / 15325 lines covered 🌿 4506 / 7229 branches covered
🔍 click here for more details

✏️ updated for commit ad721e2

@fuzzzerd fuzzzerd merged commit 2fcb266 into master Apr 23, 2026
6 checks passed
@fuzzzerd fuzzzerd deleted the fuzzz/avalonia-12 branch April 23, 2026 02:45
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