Skip to content

Added support for serializing IEnumerables & structs.#333

Merged
robgruen merged 8 commits into
mainfrom
dev/robgruen/ienumerable
Jul 6, 2026
Merged

Added support for serializing IEnumerables & structs.#333
robgruen merged 8 commits into
mainfrom
dev/robgruen/ienumerable

Conversation

@robgruen

@robgruen robgruen commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

This pull request significantly improves the handling of .NET collection, dictionary, and value types during schema export, ensuring that the generated TypeScript schemas more accurately reflect JSON serialization behavior. The changes address previous issues where collections and certain value types (like Guid and DateTime) were incorrectly exported as empty interfaces or leaked internal implementation details. The update also adds comprehensive tests to verify correct schema generation for a wide variety of types.

Improvements to type handling and schema export:

  • Added robust detection and handling for array-like (IEnumerable<T>, List<T>, etc.) and dictionary-like (IDictionary<K,V>, Dictionary<K,V>, etc.) types, ensuring they are exported as TypeScript arrays and maps respectively, without leaking internal .NET implementation details. [1] [2] [3] [4] [5] [6] [7]
  • Improved mapping of scalar value types that serialize as strings (e.g., Guid, DateTime, DateTimeOffset, DateOnly, TimeOnly) to TypeScript string type, preventing them from being exported as empty interfaces. [1] [2] [3]

Test coverage enhancements:

  • Added new test types in Schemas.cs to cover collections, dictionaries, self-referential enumerables, and structs, verifying correct schema export for each case.
  • Introduced comprehensive unit tests to ensure correct TypeScript schema generation for the above scenarios, including edge cases such as self-referential enumerables and scalar value types.

These changes collectively make schema generation more robust, accurate, and aligned with how .NET types are serialized to JSON, while also preventing schema bloat and infinite recursion in pathological cases.

Fixes: #218

@robgruen robgruen requested a review from a team as a code owner July 6, 2026 18:02
@robgruen robgruen added this pull request to the merge queue Jul 6, 2026
Merged via the queue into main with commit 83f1fbf Jul 6, 2026
7 checks passed
@robgruen robgruen deleted the dev/robgruen/ienumerable branch July 6, 2026 20:15
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.

IEnumerable<T> not handled

2 participants