unoplatform / uno.extensions

Libraries to ease common developer tasks associated with building multi-platform mobile, desktop and web applications using Uno Platform or WinAppSDK.
https://platform.uno/
Other
72 stars 46 forks source link

`MessageDialog` throws `ArgumentNullException` without a title #2414

Open eriklimakc opened 2 months ago

eriklimakc commented 2 months ago

Current behavior

If MessageDialog is used without a title it throws an exception on platforms other than windows.

Expected behavior

No exception.

Workaround

Set the title to an empty string.

How to reproduce it (as minimally and precisely as possible)

var confirmDialog = new MessageDialogViewMap(
        Content: "Confirm this message?",
        DelayUserInput: true,
        DefaultButtonIndex: 1,
        Buttons: new DialogAction[]
        {
                        new(Label: "Yeh!",Id:"Y"),
                        new(Label: "Nah", Id:"N")
        }
    );

Or

var messageDialogResult = await _navigator.ShowMessageDialogAsync<string>(this, content: "This is Content");

Versions used for tests:

Stable

Latest Dev

Current tests included in my attached sample app:

Exceptions I am getting:

  1. [Desktop/WebAssembly/Android/iOS] When opening the MessageDialog without a Title

    *Reproducible with both the latest stable and latest dev versions, and no exception occurring on Windows.

    Exception: System.ArgumentNullException: 'Value cannot be null. Arg_ParamName_Name' (when Title is null)

    CallStack: (expand here to see the details) > Uno.dll!Windows.UI.Popups.MessageDialog.MessageDialog(string content, string title) Line 39 C# Uno.Extensions.Navigation.UI.dll!Uno.Extensions.Navigation.Navigators.MessageDialogNavigator.DisplayDialog(Uno.Extensions.Navigation.NavigationRequest request, System.Type viewType, object viewModel) Unknown Uno.Extensions.Navigation.UI.dll!Uno.Extensions.Navigation.Navigators.DialogNavigator.ExecuteRequestAsync(Uno.Extensions.Navigation.NavigationRequest request) Unknown Uno.Extensions.Navigation.UI.dll!Uno.Extensions.Navigation.Navigators.ControlNavigator.ControlNavigateAsync(Uno.Extensions.Navigation.NavigationRequest request) Unknown Uno.Extensions.Navigation.UI.dll!Uno.Extensions.Navigation.Navigators.ControlNavigator.ControlCoreNavigateAsync.AnonymousMethod__0(System.Threading.CancellationToken cancellation) Unknown Uno.Extensions.Core.dll!Uno.Extensions.DispatcherExtensions.ExecuteAsync.AnonymousMethod__0(System.Threading.CancellationToken ct) Unknown Uno.Extensions.Core.UI.dll!Uno.Extensions.DispatcherQueueExtensions.ExecuteAsync.AnonymousMethod__0() Unknown Uno.UI.Dispatching.dll!Uno.UI.Dispatching.NativeDispatcher.DispatchItems() Line 131 C# WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Unknown WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) Unknown WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeImpl() Unknown WindowsBase.dll!MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(object obj) Unknown System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown WindowsBase.dll!MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown WindowsBase.dll!System.Windows.Threading.DispatcherOperation.Invoke() Unknown WindowsBase.dll!System.Windows.Threading.Dispatcher.ProcessQueue() Unknown WindowsBase.dll!System.Windows.Threading.Dispatcher.WndProcHook(nint hwnd, int msg, nint wParam, nint lParam, ref bool handled) Unknown WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(nint hwnd, int msg, nint wParam, nint lParam, ref bool handled) Unknown WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Unknown WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) Unknown WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) Unknown WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(nint hwnd, int msg, nint wParam, nint lParam) Unknown [Native to Managed Transition] [Managed to Native Transition] WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame) Unknown PresentationFramework.dll!System.Windows.Application.RunDispatcher(object ignore) Unknown PresentationFramework.dll!System.Windows.Application.RunInternal(System.Windows.Window window) Unknown Uno.UI.Runtime.Skia.Wpf.dll!Uno.UI.Runtime.Skia.Wpf.WpfHost.RunLoop() Unknown Uno.UI.Runtime.Skia.dll!Uno.UI.Runtime.Skia.SkiaHost.RunCore() Unknown Uno.UI.Runtime.Skia.dll!Uno.UI.Runtime.Skia.SkiaHost.Run() Unknown ShowMessageDialogAsyncTest.dll!ShowMessageDialogAsyncTest.Program.Main(string[] args) Line 17 C#

Credits to @agneszitte for the repro and versions

eriklimakc commented 2 months ago

Tests will need to be added, in addition to https://github.com/unoplatform/uno.extensions/blob/main/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Dialogs/Given_MessageDialog.cs to validade that MessageDialog works properly in all cases.