From 37d82a5e0fae42cdddf243d92e47b054c634e801 Mon Sep 17 00:00:00 2001 From: GabrielDuf Date: Tue, 2 Jun 2026 14:53:58 -0400 Subject: [PATCH] Avalonia: Fix notification not working --- .../WindowsAppNotificationBridge.cs | 31 ++++++++++++++----- .../UniGetUI.Avalonia.csproj | 16 ++++++++++ 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/UniGetUI.Avalonia/Infrastructure/WindowsAppNotificationBridge.cs b/src/UniGetUI.Avalonia/Infrastructure/WindowsAppNotificationBridge.cs index 8b6a76f718..425fa4e255 100644 --- a/src/UniGetUI.Avalonia/Infrastructure/WindowsAppNotificationBridge.cs +++ b/src/UniGetUI.Avalonia/Infrastructure/WindowsAppNotificationBridge.cs @@ -32,8 +32,8 @@ internal static class WindowsAppNotificationBridge private static readonly string[] _assemblyCandidates = { - "Microsoft.Windows.AppNotifications", - "Microsoft.WindowsAppSDK", + "Microsoft.Windows.AppNotifications.Projection", + "Microsoft.Windows.AppNotifications.Builder.Projection", }; public static bool ShowProgress(AbstractOperation operation) @@ -384,9 +384,6 @@ private static bool EnsureRegistered() return _isRegistered; } - managerType.GetMethod("Register", BindingFlags.Public | BindingFlags.Instance) - ?.Invoke(_managerDefault, null); - _removeByTagAsyncMethod = managerType.GetMethod( "RemoveByTagAsync", BindingFlags.Public | BindingFlags.Instance, @@ -416,6 +413,14 @@ private static bool EnsureRegistered() notifEventInfo.AddEventHandler(_managerDefault, lambda.Compile()); } + managerType.GetMethod( + "Register", + BindingFlags.Public | BindingFlags.Instance, + binder: null, + types: Type.EmptyTypes, + modifiers: null) + ?.Invoke(_managerDefault, null); + _isRegistered = _showMethod is not null; } catch (Exception ex) @@ -495,9 +500,19 @@ private static bool ShowTextToast( private static object InvokeFluent(object instance, string methodName, params object?[] args) { - return instance.GetType().GetMethod(methodName, BindingFlags.Public | BindingFlags.Instance) - ?.Invoke(instance, args) - ?? instance; + Type type = instance.GetType(); + Type[] argTypes = args.Select(a => a?.GetType() ?? typeof(object)).ToArray(); + + MethodInfo? method = type.GetMethod( + methodName, + BindingFlags.Public | BindingFlags.Instance, + binder: null, + types: argTypes, + modifiers: null) + ?? type.GetMethods(BindingFlags.Public | BindingFlags.Instance) + .FirstOrDefault(m => m.Name == methodName && m.GetParameters().Length == args.Length); + + return method?.Invoke(instance, args) ?? instance; } private static void SetPropertyIfPresent(object instance, string propertyName, object value) diff --git a/src/UniGetUI.Avalonia/UniGetUI.Avalonia.csproj b/src/UniGetUI.Avalonia/UniGetUI.Avalonia.csproj index 627aa0d4fa..3df4fe10bb 100644 --- a/src/UniGetUI.Avalonia/UniGetUI.Avalonia.csproj +++ b/src/UniGetUI.Avalonia/UniGetUI.Avalonia.csproj @@ -29,6 +29,22 @@ false + + None + true + true + false + $(NoWarn);MVVMTK0045 + win-x64;win-arm64 + win-arm64 + win-$(Platform) + win-x64 + + + + + + $(RuntimeIdentifier) win-arm64