Skip to content

Replace concrete collection types with interfaces in public API surface#1326

Merged
stephentoub merged 4 commits intomainfrom
copilot/refactor-api-collections-to-interfaces
Feb 20, 2026
Merged

Replace concrete collection types with interfaces in public API surface#1326
stephentoub merged 4 commits intomainfrom
copilot/refactor-api-collections-to-interfaces

Conversation

Copy link
Contributor

Copilot AI commented Feb 20, 2026

Public API properties were exposing concrete collection types (List<T>, T[]) instead of IList<T>.

  • ProtectedResourceMetadata: 6 properties changed from List<string> to IList<string> (AuthorizationServers, BearerMethodsSupported, ScopesSupported, ResourceSigningAlgValuesSupported, AuthorizationDetailsTypesSupported, DpopSigningAlgValuesSupported)
  • ToolResultContentBlock: Content changed from List<ContentBlock> to IList<ContentBlock>
  • ListTasksResult: Tasks changed from McpTask[] to IList<McpTask>
  • DynamicClientRegistrationResponse: 3 properties changed from string[]? to IList<string>? (RedirectUris, GrantTypes, ResponseTypes)

AuthorizationServerMetadata and DynamicClientRegistrationRequest also use concrete collection types but are internal sealed, so left as-is. All dictionaries and sets in the public API already use interface types.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor public API to use interfaces for collections Replace concrete List<T> with IList<T> in public API surface Feb 20, 2026
Copilot AI requested a review from stephentoub February 20, 2026 03:22
@stephentoub
Copy link
Contributor

@copilot, any dictionaries or sets?

Copy link
Contributor Author

Copilot AI commented Feb 20, 2026

@copilot, any dictionaries or sets?

Checked all public.*Dictionary<, public.*HashSet<, public.*SortedSet<, public.*SortedDictionary<, and public.*ConcurrentDictionary< in src/. All dictionaries in public API already use IDictionary<> or IReadOnlyDictionary<>. No HashSet<>, SortedSet<>, SortedDictionary<>, or ConcurrentDictionary<> appear in public API at all.

@stephentoub
Copy link
Contributor

@copilot any more lists or arrays?

…tRegistrationResponse

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 20, 2026

@copilot any more lists or arrays?

Found two more: ListTasksResult.Tasks was McpTask[] and DynamicClientRegistrationResponse had three string[]? properties (RedirectUris, GrantTypes, ResponseTypes). All changed to IList<T> in 3782009.

Copilot AI changed the title Replace concrete List<T> with IList<T> in public API surface Replace concrete collection types with interfaces in public API surface Feb 20, 2026
@stephentoub stephentoub marked this pull request as ready for review February 20, 2026 03:42
@stephentoub stephentoub enabled auto-merge (squash) February 20, 2026 03:42
Copy link
Contributor

@halter73 halter73 left a comment

Choose a reason for hiding this comment

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

I considered more changes to IList when you had me change the filter types, but I wasn't sure if we had different conventions for JSON DTOs. I don't see any reason why not to use IList though.

@stephentoub stephentoub merged commit 5c35ea9 into main Feb 20, 2026
8 of 9 checks passed
@stephentoub stephentoub deleted the copilot/refactor-api-collections-to-interfaces branch February 20, 2026 03:48
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.

3 participants

Comments