GtkSharp / GtkSharp

.NET wrapper for Gtk and other related libraries
Other
873 stars 98 forks source link

Don't format Gtk.MessageDialog when there is no argument #405

Open HubKing opened 1 year ago

HubKing commented 1 year ago

The following code

        var m = new Gtk.MessageDialog(this,
            DialogFlags.Modal,
            MessageType.Warning,
            ButtonsType.Cancel,
            "Hello {}"
        );

throws a format exception: Input string was not in a correct format.

Judging by the stack trace, it seems that this library is calling .NET's string formatter. But I did not want to format anything; I did not pass any argument. I think, most of the time, when programmers use a message box, they just need to show a constant string message quickly, rather than formatting a string. Wouldn't it be more efficient if the library skips string formatting, if there is no argument?