* Fix headless cleanup race: dispose before signalling TCS (#20664)
Restructure DispatchCore<TResult> so application.Dispose() runs in a
finally block before tcs.TrySet* is called. Previously, the using-var
scope closed after TrySetResult, leaving s_uiThread set when the next
non-headless test started.
Adds a regression test in IsolationTests that verifies Dispatcher.UIThread
is accessible from the calling thread immediately after a headless dispatch
completes (PerTest isolation only).
* Use Assert.SkipWhen in Dispatch_Cleanup_Should_Complete_Before_Task_Returns
* Restrict Dispatch_Cleanup_Should_Complete_Before_Task_Returns to NUnit
xUnit's AvaloniaFactDiscoverer wraps every [Fact] in session.Dispatch,
so awaiting another session.Dispatch inside the test body deadlocks on
the session's single background thread.
* Remove new test
It isn't reliable enough during CI.
---------
Co-authored-by: Jumar Macato <16554748+jmacato@users.noreply.github.com>
* mark ToplevelImpl._view as nullable.
* Update src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs
Co-authored-by: Max Katz <maxkatz6@outlook.com>
* return 1 as default scaling in android TopLevelImpl
---------
Co-authored-by: Max Katz <maxkatz6@outlook.com>
* Truncate the content when writing
To maintain consistency with other operating system APIs, see: https://github.com/AvaloniaUI/Avalonia/pull/20804 & https://github.com/AvaloniaUI/Avalonia/pull/20807
* Prevent accidental truncation when creating files
* Update comments
* Validate existing item type when creating storage
* Truncate files on creation in storage items
---------
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
* fix safe area calcs for navigation page
* update nav bar effective height on safe area change
* reset nav bar height if visibility changes
* add tests
* Fix Metal renderer memory leakage on macOS
* Remove no-op ResetContext call
* Disposable wrapper
* Success flag in ctor to dispose
* Rename variable name to _autoReleasePool
* Abstraction over AutoReleasePool
* Use Interlocked.Exchange in AutoReleasePool
---------
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
* Fix#20816: OneWay binding fails to update target after local change
When a OneWay binding target is modified locally (e.g., via user
interaction on a ToggleButton), subsequent PropertyChanged events from
the source were being ignored. This occurred because the binding
expression incorrectly suppressed the update.
This patch modifies UntypedBindingExpressionBase to ensure that OneWay
bindings always propagate changes from the source to the target,
overriding any previous local changes. Unit tests were also added to
prevent future regressions on this behavior.
Signed-off-by: Martim Claudino <martimffclaudino@tecnico.ulisboa.pt>
* fix: scope forceUpdate to OneWay mode, use SetCurrentValue in tests and clean usings
Signed-off-by: Martim Claudino <martimffclaudino@tecnico.ulisboa.pt>
---------
Signed-off-by: Martim Claudino <martimffclaudino@tecnico.ulisboa.pt>
* Win32: fix None/BorderOnly maximized position on secondary screens
* Fix WindowCustomizationsPage
* Use correct screen when minimized
* Fallback to nearest monitor
* Announce changes to live regions on macOS
It is necessary to manually request announcement of the new name of a live
region, alongside posting the general kAXLiveRegionChangedNotification.
* Refactor -raisePropertyChanged: to use switch statement
* Fix warning about switch not covering all cases
---------
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
* fix: focus correct date selector for day-first locales in DatePickerPresenter
SetInitialFocus had a copy-paste bug where the day-first branch
focused _monthSelector instead of _daySelector. This caused every
locale that puts day first (UK, Europe, Australia, India — dd/MM/yyyy)
to focus the wrong selector when the picker opened.
Refactored the three near-identical if/else branches into a
data-driven loop that pairs each host panel with its selector,
making this class of copy-paste bug structurally impossible.
* chore: retrigger CI
* chore: retrigger CI
---------
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
* fix: check format key in DataTransferItem.FindAccessor single-item path
The single-item fast path in FindAccessor returned the stored value for
any format query without checking if the requested format matched.
This caused TryGetRaw to return wrong data when queried with a format
different from the one stored (e.g., querying Bitmap on a text-only item
returned the text value instead of null).
Add the missing singleItem.Key.Equals(format) check, consistent with
the dictionary path (TryGetValue) and RemoveCore.
* chore: retrigger CI
* chore: retrigger CI
---------
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
* fix: correct null check variable in TryResolveFileReferenceUri on macOS
The null check on line 401 tested `fileUri` instead of `filePathUri`,
making it dead code since `fileUri` was already checked on line 394.
When `[fileUri filePathURL]` returned nil (non-file URL or unreachable
resource), the nil `filePathUri` was passed to `[filePathUri absoluteString]`
and then to `CreateAvnString`, causing a native crash.
* fix: initialize NSError to nil in SaveBookmarkToBytes on macOS
NSError* was declared without initialization, containing stack garbage.
On the success path (bookmarkData non-nil), Cocoa does not guarantee
zeroing the error out-parameter, so the subsequent `if (error != nil)`
check could read garbage and incorrectly call CreateAvnString with a
garbage pointer.
Initialize to nil and restructure to `else if` so the error is only
inspected when bookmarkData is nil (the failure path).
* chore: retrigger CI
* fix: guard out-parameters in SaveBookmarkToBytes
Initialize *ppv to nullptr on entry so callers never read garbage on
the nil-fileUri / nil-bookmarkData paths. Guard *err write with a
nullptr check for callers that pass no error out-parameter.
* chore: retrigger CI
---------
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
* test: add DataFormat.CreateInProcessFormat tests
Cover the new InProcess format API: kind, identifier, null/empty
validation, non-ASCII identifiers, HasSystemName for all four kinds,
ToSystemName throwing, equality/inequality, DataTransferItem
integration, and coexistence with other formats in DataTransfer.
* feat: implement DataFormat.CreateInProcessFormat<T> for in-process drag/drop
Add DataFormatKind.InProcess and DataFormat.CreateInProcessFormat<T>()
so users can pass arbitrary object references during in-process
drag-and-drop without crossing serialization boundaries.
- Add HasSystemName property to indicate whether ToSystemName() is valid
- Update ToSystemName to throw for InProcess (same as Universal)
- Guard all 7 platform backends (Win32, macOS, X11, Android, Browser,
iOS) to skip InProcess formats during clipboard/drag-drop enumeration
Closes#20097
* fix: remove HasSystemName API per review feedback
* replace hamburger view with drawer page. use ContentPage in control catalog
* Added Icons
* fix listbox and carousel page
* make MainView drawer page
* add PageNavigationHost to control catalog
---------
Co-authored-by: Javier Suárez Ruiz <javiersuarezruiz@hotmail.com>
* test: add regression test for access key with system key events
Regression test for #20961: verifies that access keys fire correctly
when triggered via Alt+key (system key events).
* fix: provide KeySymbol for system key events via MapVirtualKey
On Windows, WM_SYSKEYDOWN (Alt+key) intentionally skips ToUnicodeEx
to avoid corrupting keyboard state. This left KeySymbol null, which
broke access keys after #20662 switched from Key to KeySymbol.
Use MapVirtualKey(VK, MAPVK_VK_TO_CHAR) as a layout-aware fallback
for system key events — it resolves the character without touching
keyboard state.
Fixes#20961
* chore: retrigger CI