-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add OpenFolderDialog v2 #4039
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
Add OpenFolderDialog v2 #4039
Conversation
src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/OpenFolderDialog.cs
Show resolved
Hide resolved
|
The reason I haven't submitted a PR myself is that I wasn't able to test the code. Did you manage to run it from an app? It looks like the only thing you changed is the name - I used That said, I am not that picky about the name, as long as we get the dialog! |
Tell this Microsoft, they have chosen "OpenFileDialog" for picking/selecting a file instead of "SelectFileDialog". Thus "OpenFolderDialog" matches the line of "OpenFileDialog". On Winforms its called "FolderBrowserDialog". And on the Windows API Code Pack they called it "CommonOpenFileDialog" allowing setting a property "IsFolderPicker" to true. So if even Microsoft haven't followed any line, there is no ultimate solution for its name. I for myself think that (existing) "OpenFileDialog" and (new) "OpenFolderDialog" seems quite nice together, while calling one "OpenFileDialog" and the other "FolderBrowserDialog" is not matching at all. Anyway, we have several ways of calling it and there is no good or bad one. They all make sense, its just a matter of taste. I can rename it if necessary. |
|
@Symbai having open and save file dialogs separate instead a common select file one has some advantages, such as remembering different recent locations for the two tasks separately. I am sure the team will pick a name they see best fit. |
|
Thanks for the update, I appreciate that. I can wait, take your time. |
|
Adding @MikeHillberg for API review... |
|
What's the status on this? |
| /// Represents a common dialog box that allows the user to open one or more file(s). | ||
| /// This class cannot be inherited. | ||
| /// </summary> | ||
| public sealed class OpenFolderDialog : FileDialog |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be a CommonDialog rather than a FileDialog? Making it a FileDialog gives it APIs that don't make sense for a folder, such as CheckFileExists, DefaultExt, SafeFileName, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CommonDialog has no fields and especially no validations, they're all in FileDialog. So either we copy everything except the few APIs you mentioned (which people have criticized on v1), or we just accept the fact that some APIs are irrelevant. Or we make a new base class for both, but that's a deeper change.
FYI: The Windows API Code Pack-Shell also has a FileDialog which becomes a Folder Dialog by setting a property to true. It also has SafeFileName (which will be the folder path then).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't have API that's known to never work though. We want great documentation, but at the same time we want to design easy APIs that don't require outside reading. Basic OOP design is that a subclass add functionality, not remove it.
What makes it difficult is that we also use subclassing for sharing implementations. If the FileDialog code is stable maybe a copy of the relevant parts of it into OpenFolderDialog is OK, and maybe as a separate PR when it's important enough. I think there are also places in code where common functionality has been put into static helpers to provide shared code for cases like this.
|
What's the status on this? Is this ever getting reviewed by someone either merging it or telling me what exactly I have it to change it to so it will be merged? |
|
Closing as WPF team is unable to review for 5 months and refuses to tell whats the problem. If anyone else wants to do this to themselves, go ahead. I'm giving up on this repo and this team, sorry. |
|
What a pity. It seems the WPF team has very little resources or little interest. WPF feels dead to me :( |
|
Reopening issue, I left a comment for @Symbai. |
|
Let us know if you'd like to resubmit, looks like your repo PR has been deleted. |
|
I am happy to resubmit if needed, but I think some design discussion should take place first. Is that also waiting for the testing infrastructure? |
|
Based on the previous PR I don't believe this change would require the test repo for finalizing it. I'd appreciate if you could bring back the design main points and give us and the community clear options. @MikeHillberg brings some good points, would be good if you could address them. Thanks @miloush! |
|
Right. So, from my point of view there are basically 3 things to decide: 1. InheritanceThe options were: I am against a). It is a common dialog that everyone expects to be shown using From these options, I prefer c). It is a file dialog after all, and there is a lot of code in There are other options too. We might not want to do a breaking change moving properties around, but there might be a possibility to split the inheritance chain, that is, 2. NamingThe options were: I don't see any rationale for a) in a new WPF code. My worry about c) was that there is no "open" operation on folder involved and there would be no corresponding "save" operation/dialog, but as stated above I am quite easy between b) and c). 3. Legacy supportWindows XP which .NET Framework version of WPF supports does not have the common dialog APIs. The options are: a) throw If anyone thinks I forgot something, feel free to chime in. |
|
@miloush That's a great summary of the design discussion required for this PR and I think you've covered everything. Here's my personal opinion on this discussion: 1. Inheritance If we need full compatiblity and zero API changes to FileDialog (No new base class), we could either use a static class with the shared code or an internal implementation class. By "internal implementation class", I mean a new internal class that contains the shared implementation code from FileDialog and the new folder dialog. The public API would forward their calls to the internal class. I personally don't like option c). There is a bunch of API that would do nothing and I don't think that it's very developer-friendly. 2. Naming 3. Legacy support |
|
@fabiant3 You wanted to re-open this PR, right? It looks closed to me :) What @miloush and @ThomasGoulet73 posted sounds smart to me. On the other side, I'd be happy to have any WPF option at all. This piece is missing for many years. Don't give up on this! 👍 |
|
I tried to look more into the splitting inheritance option and I don't think it is that beneficial after all if we can't move around public members - they would have to be defined on both the The whole picking folder capability of the file dialog feels like stitched in as an after-thought, and pretending on the WPF side that there is a clean design is a fallacy. I am now actually inclined to just add
These are the current public properties on the Applicable to folders:
Doing something, but wouldn't be necessary for folders:
Valid but currently without any effect:
Invalid (the native call returns an error):
So in fact @ThomasGoulet73, there isn't that many properties that would do nothing, and all of them would have either worked in the past or might work in the future/on other platform. As for legacy implementation, I am not quite sure what is the support requirements for running on a supported version of Windows but in a compatibility mode. |
|
This should'nt be closed... MS should fix it... |
Fixes #438, this is mostly a copy of @miloush's work based on the feedback on my previous attempt.