Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why ShowDialog for VistaFolderBrowserDialog returns nullable bool? #103

Open
roman-khazanskii opened this issue Apr 12, 2022 · 3 comments
Open

Comments

@roman-khazanskii
Copy link

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?

@augustoproiete
Copy link
Member

augustoproiete commented Apr 12, 2022

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

@roman-khazanskii
Copy link
Author

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

@SvenGroot
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants