Skip to content

Conversation

DinahK-2SO
Copy link
Contributor

@DinahK-2SO DinahK-2SO commented Aug 29, 2025

An implementation of

This pull request introduces new experimental features to the Windows Storage Pickers API, specifically enabling support for suggested folders and enhanced file type choices. These changes are gated behind a new feature flag, Feature_StoragePickers2, and are only available in the experimental channel. The updates affect the FileOpenPicker, FileSavePicker, and FolderPicker classes, as well as related internal data structures and the public API contract.

Feature flag and API contract updates:

  • Added the new feature definition and flag for Feature_StoragePickers2, including its XML specification and auto-generated header (TerminalVelocityFeatures-StoragePickers2.xml, TerminalVelocityFeatures-StoragePickers2.h). The feature is always enabled in the experimental channel and disabled in preview/stable channels. [1] [2]
  • Updated the IDL contract to version 2.0 and added new properties (SuggestedFolder, SuggestedStartFolder, FileTypeChoices) to the pickers, gated by the new feature flag. [1] [2] [3] [4]

New properties and API surface:

  • Added support for SuggestedFolder and SuggestedStartFolder properties to FileOpenPicker, FileSavePicker, and FolderPicker, with validation and feature gating. Also added the FileTypeChoices property to FileOpenPicker. [1] [2] [3] [4] [5] [6] [7] [8] [9]

Internal data structure changes:

  • Updated constructors and usage of FileTypeChoicesMap and FileTypeFilterVector to support feature gating and picker-specific logic. [1] [2] [3] [4]

Parameter handling and validation:

  • Modified parameter capture logic in pickers to include the new suggested folder properties and file type choices, and updated validation to use a unified folder path validation method. [1] [2] [3]

Miscellaneous:

  • Minor includes and code hygiene improvements, such as new headers for string handling.

@DinahK-2SO DinahK-2SO force-pushed the user/DinahK-2SO/storage_pickers_new_functionality branch from 9a2af4e to 52e0974 Compare September 29, 2025 18:18
@DinahK-2SO DinahK-2SO marked this pull request as ready for review September 29, 2025 18:19
@DinahK-2SO DinahK-2SO changed the title New properties in Storage.Pickers - SuggestedDefaultFolder, FileTypeChoices New properties in Storage.Pickers - SuggestedDefaultFolder, SuggestedFolder, FileTypeChoices Sep 29, 2025
ghost1372 referenced this pull request in ghost1372/DevWinUI Sep 30, 2025
}

void ValidateSuggestedFolder(winrt::hstring const& path)
void ValidateFolderPath(winrt::hstring const& path, std::string const& propertyName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In ValidateFolderPath, how does the implementation handle edge cases like relative paths (e.g., .\folder, ..\parent), standard UNC paths (e.g., \server\share), and non-existent folders (e.g., C:\NonExistent)? The code doesn’t seem to reject relative paths or check folder existence, which could lead to runtime errors?

Can you clarify the intended behavior for these cases and share how they were tested!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Saharsh979 for joining the review.

All path strings in the storage pickers are full path.
The relative path are not supported yet.

{
FileTypeChoicesMap();
FileTypeChoicesMap(bool forSavePicker = true);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curiosity - Can you explain the rationale behind this update?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is for velocity. The FileSavePicker already has FileTypeChoices, so it doesn't need an velocity check.
This PR is adding FileTypeChoices property to the FileOpenPicker, meaning that we need a velocity check when this customized map type is used for in the FIleOpenPicker.

In future when we remove this velocity, we can remove the forSavePicker flag too.
Note that this is an internal class, it should not impact the public API contract.

{
return m_fileTypeFilter;
}
winrt::hstring FileOpenPicker::SuggestedFolder()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curiosity: Maybe it might be worthwhile to test performance as well? Could complex or large FileTypeChoices lists slow down picker init?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be ok. It is the same property logic existing in FileSavePicker.

hstring SuggestedFolder();
void SuggestedFolder(hstring const& value);

hstring SuggestedStartFolder();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - Is there a possibility to move common logic to a base class?

Copy link
Contributor Author

@DinahK-2SO DinahK-2SO Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is a good point. We might do some refactoring in future.

Copy link
Collaborator

@codendone codendone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@DinahK-2SO
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DinahK-2SO
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DinahK-2SO DinahK-2SO force-pushed the user/DinahK-2SO/storage_pickers_new_functionality branch from 550d668 to 0618e5b Compare October 3, 2025 13:00
@DinahK-2SO
Copy link
Contributor Author

DinahK-2SO commented Oct 3, 2025

Thanks @codendone and @Saharsh979 for reviewing this PR. The pipeline build failed last night - caused by the missing head file of velocity. So I pushed a fix in the last iteration. Please review the updates when you have a moment.

@DinahK-2SO
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DinahK-2SO DinahK-2SO merged commit 4774aae into main Oct 4, 2025
34 checks passed
@DinahK-2SO DinahK-2SO deleted the user/DinahK-2SO/storage_pickers_new_functionality branch October 4, 2025 04:14
DinahK-2SO added a commit that referenced this pull request Oct 4, 2025
…lder, FileTypeChoices (#5771)

This is a design spec for adding new functionality to the Microsoft.Windows.Storage.Pickers APIs, including 2 main changes:

- the SuggestedFolder and SuggestedStartFolder properties for all three picker types,
- the new FileTypeChoices property for FileOpenPicker. 

Code implementation details can be found in (#5772)
guimafelipe added a commit that referenced this pull request Oct 4, 2025
…uggestedFolder, FileTypeChoices (#5772)"

This reverts commit 4774aae.
DinahK-2SO added a commit that referenced this pull request Oct 10, 2025
…uggestedFolder, FileTypeChoices (#5772)"

This reverts commit 4774aae.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants