uno.extensions
uno.extensions copied to clipboard
`MessageDialog` throws `ArgumentNullException` without a title
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
- Uno.Sdk: 5.2.175
- UnoExtensionsVersion: 4.1.24
- UnoToolkitVersion: 6.0.24
- UnoThemesVersion: 5.0.13
- Sample app used: ShowMessageDialogAsyncTest(stable versions).zip
Latest Dev
- Uno.Sdk: 5.4.0-dev.738
- UnoExtensionsVersion: 4.3.0-dev.5
- UnoToolkitVersion: 6.2.0-dev.6
- UnoThemesVersion: 5.2.0-dev.9
- Sample app used: ShowMessageDialogAsyncTest(latest dev versions).zip
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:
-
❌ [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