Skip to content

Conversation

@DinahK-2SO
Copy link
Contributor

@DinahK-2SO DinahK-2SO commented Oct 28, 2025

Description

This is a fix for issue:

The existing FileTypeChoices property was built on an unordered map, which does not preserve the user-defined order.

However, in the FileOpenPicker and FileSavePicker, the FileTypeChoices need to be displayed in the order they were inserted, rather than in a random order.

This is important for developers' and end-users' experience because:

  • Developers expect to see their file type options in the logical order they added them
  • The first added option is usually the default selection
  • Maintaining consistent ordering helps end users quickly locate the desired file type

Additionaly, the insertion order is respected in the legacy UWP FileSavePicker.

Fix

This is a backward-compatible fix. The goal of this fix is to maintain the existing Map type API contract and its good performance while ensuring that the display order of FileTypeChoices meets expectations.

This pull request refactors the implementation of the FileTypeChoicesMap to ensure that the insertion order of keys is preserved and provides efficient key lookups. It replaces the previous unordered map-based implementation with the implementation backed by a vector. The update also introduces custom iterator and view classes to support this ordered behavior and modifies related tests to verify the new insertion order.


Code change details:

Ordered map implementation and API changes:

  • Replaced the internal storage of FileTypeChoicesMap from an unordered map to a std::vector of key-value pairs (FileTypeChoiceVector), managed by a shared_ptr to preserve insertion order and support multiple views/iterators. [1] [2]
  • Added custom iterator (OrderedMapIterator) and view (OrderedMapView) classes to enable ordered iteration and lookup, updating all methods (Insert, Lookup, Remove, Clear, First, etc.) to operate on the new ordered vector structure. [1] [2]

API surface and helper improvements:

  • Updated method signatures to add noexcept where appropriate and refactored helper methods for key lookup using std::ranges::find. [1] [2]
  • Improved memory management and performance by pre-allocating vector capacity and using shared ownership for views and iterators.

Test updates for ordered behavior:

  • Modified picker tests to insert file type choices in a specific order and updated assertions to verify that the resulting filters maintain the insertion order, ensuring the new implementation is covered by tests. [1] [2] [3]

@DinahK-2SO
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DinahK-2SO
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DinahK-2SO
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DinahK-2SO DinahK-2SO merged commit 63e62e0 into main Nov 16, 2025
36 checks passed
@DinahK-2SO DinahK-2SO deleted the user/DinahK-2SO/filetypechoices_ordered branch November 16, 2025 05:31
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.

5 participants