Skip to content

Conversation

@spanglerco
Copy link
Contributor

Pull Request

Description

Makes OpenApiDocument.Tags preserve the provided set when it is a HashSet with custom comparer, a SortedSet, or an ImmutableSortedSet (not available when targeting netstandard2.0). Previously, the setter would make a copy of the set using an internal comparer.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe):

Related Issue(s)

Fixes #2678

Changes Made

  • Update the OpenApiDocument.Tags setter to preserve sets with a custom comparer and sorted sets

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • All existing tests pass

Checklist

  • My code follows the code style of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Versions applicability

  • My change applies to the version 1.X of the library, if so PR link:
  • My change applies to the version 2.X of the library, if so PR link:
  • My change applies to the version 3.X of the library, if so PR link:
  • I have evaluated the applicability of my change against the other versions above.

See the contributing guidelines for more information about how patches are applied across multiple versions.

Additional Notes

This PR targets support/v2 per the comments in the related issue. Let me know if I should rebase onto main instead.

@spanglerco spanglerco requested a review from a team as a code owner January 15, 2026 21:59
Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

@baywet baywet enabled auto-merge January 16, 2026 17:34
@baywet baywet linked an issue Jan 16, 2026 that may be closed by this pull request
new HashSet<OpenApiTag>(value, OpenApiTagComparer.Instance);
_tags = value switch
{
HashSet<OpenApiTag> tags when tags.Comparer != EqualityComparer<OpenApiTag>.Default => value,

Check warning

Code scanning / CodeQL

Reference equality test on System.Object Warning

Reference equality for System.Object comparisons (
this
argument has type IEqualityComparer).
@baywet baywet merged commit 008576c into microsoft:support/v2 Jan 16, 2026
8 checks passed
@baywet baywet mentioned this pull request Jan 16, 2026
@spanglerco spanglerco deleted the issue2678 branch January 16, 2026 19:08
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.

Cannot use a custom sort for OpenApiDocument.Tags in v2

2 participants