Skip to content

Tighten DecodeDictionary constraint to IDictionary#4527

Merged
pepone merged 1 commit into
icerpc:mainfrom
pepone:fix-4519
Apr 17, 2026
Merged

Tighten DecodeDictionary constraint to IDictionary#4527
pepone merged 1 commit into
icerpc:mainfrom
pepone:fix-4519

Conversation

@pepone
Copy link
Copy Markdown
Member

@pepone pepone commented Apr 17, 2026

Fixes #4519.

Copilot AI review requested due to automatic review settings April 17, 2026 09:01
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 updates the Slice and Ice dictionary decoding APIs to require concrete dictionary types (IDictionary<TKey, TValue>) rather than generic key/value pair collections, aligning the decoder contract with Slice dictionary semantics (no duplicate keys) and simplifying insertion logic.

Changes:

  • Tighten DecodeDictionary / DecodeDictionaryWithOptionalValueType generic constraints from ICollection<KeyValuePair<...>> to IDictionary<...>.
  • Switch decoder insertion from Add(KeyValuePair<...>) to Add(key, value) for both Slice and Ice decoders.
  • Remove generator tests and Slice definitions that relied on List<KeyValuePair<...>> as a dictionary mapping target.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
tests/IceRpc.Slice.Generator.Tests/DictionaryMappingTests.slice Updates dictionary mapping expectations to IDictionary and removes List<KeyValuePair>-based operations.
tests/IceRpc.Slice.Generator.Tests/DictionaryMappingTests.cs Removes tests that exercised List<KeyValuePair> dictionary mappings.
src/ZeroC.Slice.Codec/SliceDecoderExtensions.cs Tightens dictionary decode constraints to IDictionary and uses Add(key, value) (including optional-value variant).
src/IceRpc/Ice/Codec/IceDecoderExtensions.cs Tightens dictionary decode constraint to IDictionary and uses Add(key, value).

@bernardnormier
Copy link
Copy Markdown
Member

Don't forget to update the Slice doc after merging this PR.

Copy link
Copy Markdown
Member

@InsertCreativityHere InsertCreativityHere left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@pepone pepone merged commit 0e6fca3 into icerpc:main Apr 17, 2026
14 checks passed
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.

Tighten DecodeDictionary generic constraint to IDictionary<TKey,TValue>

5 participants