Skip to content

Fix IReadOnlyDictionary being treated as array-like instead of dictionary#2287

Merged
lahma merged 2 commits intosebastienros:mainfrom
lahma:ireadonly-array-like
Feb 15, 2026
Merged

Fix IReadOnlyDictionary being treated as array-like instead of dictionary#2287
lahma merged 2 commits intosebastienros:mainfrom
lahma:ireadonly-array-like

Conversation

@lahma
Copy link
Collaborator

@lahma lahma commented Feb 15, 2026

Types implementing IReadOnlyDictionary<string, TValue> but not IDictionary<string, TValue> were incorrectly classified as array-like because IReadOnlyDictionary inherits IReadOnlyCollection which set the isCollection flag, while the dictionary detection only checked for IDictionary<,>.

Added IReadOnlyDictionary<,> detection in TypeDescriptor.AnalyzeType so these types are properly recognized as dictionaries and serialized as objects by JSON.stringify instead of arrays.

Fixes #2284

lahma and others added 2 commits February 15, 2026 20:23
…nary

Types implementing IReadOnlyDictionary<string, TValue> but not
IDictionary<string, TValue> were incorrectly classified as array-like
because IReadOnlyDictionary inherits IReadOnlyCollection which set the
isCollection flag, while the dictionary detection only checked for
IDictionary<,>.

Added IReadOnlyDictionary<,> detection in TypeDescriptor.AnalyzeType so
these types are properly recognized as dictionaries and serialized as
objects by JSON.stringify instead of arrays.

Fixes sebastienros#2284

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lahma lahma enabled auto-merge (squash) February 15, 2026 18:38
@lahma lahma merged commit 4111b46 into sebastienros:main Feb 15, 2026
7 of 8 checks passed
@lahma lahma deleted the ireadonly-array-like branch February 15, 2026 18:52
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.

IReadOnlyDictionary is treated as array-like

1 participant