ookii-dialogs-wpf icon indicating copy to clipboard operation
ookii-dialogs-wpf copied to clipboard

Why ShowDialog for VistaFolderBrowserDialog returns nullable `bool?`

Open roman-khazanskii opened this issue 3 years ago • 3 comments
trafficstars

Comment states:

        //
        // Summary:
        //     Displays the folder browser dialog.
        //
        // Parameters:
        //   owner:
        //     Handle to the window that owns the dialog.
        //
        // Returns:
        //     If the user clicks the OK button, true is returned; otherwise, false.

Is it even possible to have a null returned from there?

roman-khazanskii avatar Apr 12 '22 14:04 roman-khazanskii

No technical reason... The code was written many years ago so I'd guess that the intent of the original author was to return null in case the VistaFolderBrowserDialog was not supported by the operating system where the app is running, but the code doesn't have that behavior implemented and couldn't return null, so we could change it to a regular bool in a future release

https://github.com/ookii-dialogs/ookii-dialogs-wpf/blob/v5.0.1/src/Ookii.Dialogs.Wpf/VistaFolderBrowserDialog.cs#L250

augustoproiete avatar Apr 12 '22 16:04 augustoproiete

Okay, this is not a real issue, I was just wondering if I should handle null case. Thanks!

roman-khazanskii avatar Apr 12 '22 21:04 roman-khazanskii

I randomly found this issue, and since I'm the original author, I can answer this (if royally late). The various common file dialog classes were designed to have the exact same API as the original WPF OpenFileDialog and SaveFileDialog classes, so they could serve as a drop-in replacement. Although WPF doesn't have a native FolderBrowserDialog, I still wanted to use the same API.

So as you might have guessed, the ShowDialog method of those native classes returns bool?, and therefore so do the Ookii.Dialogs classes, even though they never return null.

SvenGroot avatar Jul 20 '23 22:07 SvenGroot