Skip to content

Replace IReadOnlyDictionary with IEnumerable<KeyValuePair>#13

Merged
drasticactions merged 5 commits into
developfrom
dict-fix
May 21, 2026
Merged

Replace IReadOnlyDictionary with IEnumerable<KeyValuePair>#13
drasticactions merged 5 commits into
developfrom
dict-fix

Conversation

@drasticactions
Copy link
Copy Markdown
Owner

@drasticactions drasticactions commented May 21, 2026

Fixes #12

スクリーンショット 2026-05-22 1 10 15

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an AT Protocol query-parameter serialization bug where endpoints requiring repeated query keys (e.g. app.bsky.feed.getPosts?uris=a&uris=b) previously failed due to Dictionary.Add collisions. It updates the public client API and the URL-building/generation pipeline to use an IEnumerable<KeyValuePair<string,string>> parameter model that can represent repeated keys.

Changes:

  • Replaces IReadOnlyDictionary<string, string> query-parameter plumbing with IEnumerable<KeyValuePair<string, string>> across IATProtoClient and HTTP URL building to support repeated query keys.
  • Updates the source generator to emit a sequence of KeyValuePair entries (one per array item) instead of building a dictionary.
  • Adds unit tests for repeated-key query serialization and for the generator output; updates the AuthTest sample to demonstrate multi-URI getPosts.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/CarpaNet.UnitTests/Identity/IdentityResolverTests.cs Updates mock client interface signatures to match the new query-parameter type.
tests/CarpaNet.UnitTests/Http/XrpcHttpHandlerTests.cs Adds coverage ensuring repeated keys serialize as repeated query parameters.
tests/CarpaNet.UnitTests/Generation/ApiGeneratorTests.cs Adds tests asserting generated parameter classes emit KeyValuePair sequences and avoid dictionaries for arrays.
src/CarpaNet/IATProtoClient.cs Changes public interface GET/Subscribe parameter type to IEnumerable<KeyValuePair<string,string>>.
src/CarpaNet/Http/XrpcHttpHandler.cs Updates URL building APIs to accept IEnumerable<KeyValuePair<...>> and emit repeated query params; adjusts repo-resolution lookup logic.
src/CarpaNet/ATProtoClient.cs Propagates the new parameter type through the concrete client implementation.
src/CarpaNet.SourceGen/Generation/ApiGenerator.cs Changes generated ToDictionary() implementation to return a sequence of KeyValuePair entries (supporting repeated keys).
src/CarpaNet.OAuth/ATProtoOAuthClient.cs Updates OAuth client implementation signatures to match the new parameter type.
samples/AuthTest/Program.cs Adds an interactive “Get posts by URIs” sample flow exercising repeated uris query parameters.
samples/AuthTest/AuthTest.csproj Resolves the app.bsky.feed.getPosts lexicon for the new sample usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/CarpaNet/IATProtoClient.cs
Comment thread src/CarpaNet.SourceGen/Generation/ApiGenerator.cs
Comment thread src/CarpaNet/Http/XrpcHttpHandler.cs Outdated
@drasticactions drasticactions merged commit a24d54b into develop May 21, 2026
4 checks passed
@drasticactions drasticactions deleted the dict-fix branch May 21, 2026 16:36
Mostafa-Ehab added a commit to Mostafa-Ehab/CarpaNet that referenced this pull request May 24, 2026
Replace IReadOnlyDictionary with IEnumerable<KeyValuePair> (drasticactions#13)
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.

GetPostsParameters.ToDictionary() throws ArgumentException for multiple URIs — IReadOnlyDictionary cannot represent repeated query parameters

2 participants