From c19ca48c7b15d25106c13f795e57e2a7ebaece90 Mon Sep 17 00:00:00 2001 From: Tig Date: Wed, 17 Dec 2025 05:42:48 -0700 Subject: [PATCH] Require non-null IApplication in MessageBox API (#4499) --- Terminal.Gui/Views/MessageBox.cs | 101 +++++++++++++++---------------- 1 file changed, 48 insertions(+), 53 deletions(-) diff --git a/Terminal.Gui/Views/MessageBox.cs b/Terminal.Gui/Views/MessageBox.cs index 07fccc069..09fae545a 100644 --- a/Terminal.Gui/Views/MessageBox.cs +++ b/Terminal.Gui/Views/MessageBox.cs @@ -11,8 +11,8 @@ namespace Terminal.Gui.Views; /// or if the user pressed (typically Esc). /// /// -/// uses the default Dialog color scheme. -/// uses the Error color scheme. +/// uses the default Dialog color scheme. +/// uses the Error color scheme. /// /// /// Important: All MessageBox methods require an instance to be passed. @@ -126,11 +126,11 @@ public static class MessageBox /// /// Thrown if is . /// - /// Consider using which automatically sizes the + /// Consider using which automatically sizes the /// MessageBox. /// public static int? ErrorQuery ( - IApplication? app, + IApplication app, int width, int height, string title, @@ -165,7 +165,7 @@ public static class MessageBox /// /// The MessageBox is centered and auto-sized based on title, message, and buttons. /// - public static int? ErrorQuery (IApplication? app, string title, string message, params string [] buttons) + public static int? ErrorQuery (IApplication app, string title, string message, params string [] buttons) { return QueryFull ( app, @@ -195,11 +195,11 @@ public static class MessageBox /// /// Thrown if is . /// - /// Consider using which automatically sizes the + /// Consider using which automatically sizes the /// MessageBox. /// public static int? ErrorQuery ( - IApplication? app, + IApplication app, int width, int height, string title, @@ -236,7 +236,7 @@ public static class MessageBox /// /// The MessageBox is centered and auto-sized based on title, message, and buttons. /// - public static int? ErrorQuery (IApplication? app, string title, string message, int defaultButton = 0, params string [] buttons) + public static int? ErrorQuery (IApplication app, string title, string message, int defaultButton = 0, params string [] buttons) { return QueryFull ( app, @@ -270,11 +270,11 @@ public static class MessageBox /// /// Thrown if is . /// - /// Consider using which automatically + /// Consider using which automatically /// sizes the MessageBox. /// public static int? ErrorQuery ( - IApplication? app, + IApplication app, int width, int height, string title, @@ -317,7 +317,7 @@ public static class MessageBox /// The MessageBox is centered and auto-sized based on title, message, and buttons. /// public static int? ErrorQuery ( - IApplication? app, + IApplication app, string title, string message, int defaultButton = 0, @@ -352,10 +352,10 @@ public static class MessageBox /// /// Thrown if is . /// - /// Consider using which automatically sizes the + /// Consider using which automatically sizes the /// MessageBox. /// - public static int? Query (IApplication? app, int width, int height, string title, string message, params string [] buttons) + public static int? Query (IApplication app, int width, int height, string title, string message, params string [] buttons) { return QueryFull ( app, @@ -384,7 +384,7 @@ public static class MessageBox /// /// The MessageBox is centered and auto-sized based on title, message, and buttons. /// - public static int? Query (IApplication? app, string title, string message, params string [] buttons) + public static int? Query (IApplication app, string title, string message, params string [] buttons) { return QueryFull ( app, @@ -414,11 +414,11 @@ public static class MessageBox /// /// Thrown if is . /// - /// Consider using which automatically sizes the + /// Consider using which automatically sizes the /// MessageBox. /// public static int? Query ( - IApplication? app, + IApplication app, int width, int height, string title, @@ -455,7 +455,7 @@ public static class MessageBox /// /// The MessageBox is centered and auto-sized based on title, message, and buttons. /// - public static int? Query (IApplication? app, string title, string message, int defaultButton = 0, params string [] buttons) + public static int? Query (IApplication app, string title, string message, int defaultButton = 0, params string [] buttons) { return QueryFull ( app, @@ -489,11 +489,11 @@ public static class MessageBox /// /// Thrown if is . /// - /// Consider using which automatically sizes + /// Consider using which automatically sizes /// the MessageBox. /// public static int? Query ( - IApplication? app, + IApplication app, int width, int height, string title, @@ -536,7 +536,7 @@ public static class MessageBox /// The MessageBox is centered and auto-sized based on title, message, and buttons. /// public static int? Query ( - IApplication? app, + IApplication app, string title, string message, int defaultButton = 0, @@ -557,7 +557,7 @@ public static class MessageBox } private static int? QueryFull ( - IApplication? app, + IApplication app, bool useErrorColors, int width, int height, @@ -568,25 +568,22 @@ public static class MessageBox params string [] buttons ) { - ArgumentNullException.ThrowIfNull (app); - - // Create button array for Dialog var count = 0; - List