uno.extensions icon indicating copy to clipboard operation
uno.extensions copied to clipboard

`MessageDialog` throws `ArgumentNullException` without a title

Open eriklimakc opened this issue 7 months ago • 1 comments

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:

  • Opening MessageDialog using default Material Button Style or default Fluent Button Style
  • MessageDialog with Content Only
  • MessageDialog with Title and Content
  • MessageDialog with Title, Content and custom Buttons

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 avatar Jul 10 '24 17:07 eriklimakc