Skip to content

feat: change all collections to ordered collections #2347

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Michael-Wamae
Copy link
Contributor

@Michael-Wamae Michael-Wamae commented May 5, 2025

@Michael-Wamae Michael-Wamae requested a review from a team as a code owner May 5, 2025 07:50
Copy link

sonarqubecloud bot commented May 5, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
66.4% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@darrelmiller
Copy link
Member

@Michael-Wamae Sorry for the randomization, @baywet and I have had some intense negotiations and have come to a compromise.

Facts:

  • Emitting collections in a non-deterministic order is a problem for customers that we have had multiple requests to fix.
  • Swashbuckle has the ability for developers to control the ordering of collections
  • ASPNET would like to sort collections alphabetically
  • OrderedDictionary has performance cost and is not supported in downrev versions of .NET
  • No customer has asked for us to maintain the order of the input document (Darrel does not count as a customer)
  • Future versions of .NET will support using the collection initialization syntax for interfaces

Compromise:

  • Go back to using Dictionary during reading to avoid perf costs and need to implement a custom implementation for downrev .net
  • Wait for customer signal to implement maintaining of input order
  • Change the API surface area back to IDictionary to allow future implementations to use OrderedDictionary without it being a breaking change and continue allowing Swashbuckle customers to provide custom ordering
  • IDictionary will require customers to explicitly provide the type until .NET adds implicit support
  • Add WriterSettings option to enable sorting using a comparer to meet the need for deterministic ordering

Sorry again for sending you down the wrong path. Hopefully, what we have learned here will reduce future maintenance work.

/cc @baywet

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

Successfully merging this pull request may close these issues.

Change all collections to ordered collections
2 participants