Add support for generic Collection types and all integer type variants #26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
SwiftSnapshot was failing to render:
IdentifiedArray<Tagged<Attendee, UUID>, Attendee>UInt64,Int64,Int32, etc.This caused errors when used with projects like pointfreeco/syncups:
The issues occurred because:
[Any]fell through to the reflection fallback, which couldn't properly handle themIntwas handled as a primitive type, leaving other integer variants unsupportedSolution
1. Generic Collection Support
Added Collection protocol detection in
ValueRendererto handle any type conforming to theCollectionprotocol. The renderer now:2. All Integer Type Variants
Added support for all Swift integer types:
Int8,Int16,Int32,Int64,UInt,UInt8,UInt16,UInt32,UInt64Examples
Generic Collection:
Generated code:
Integer Types:
Changes
Core Implementation
renderCollection()method with full documentationData(which also conforms to Collection)Tests
GenericCollectionTests.swift (new): 8 comprehensive tests covering:
IntegerTypesTests.swift (new): 13 comprehensive tests covering:
SwiftSnapshotTests.swift: Added inline verification test
Rendering Priority (Updated)
Test Results
IdentifiedArray<Tagged<Attendee, UUID>, Attendee>Backward Compatibility
This change is fully backward compatible:
Fixes the reported issues with IdentifiedArray and integer types in the syncups project and enables SwiftSnapshot to work with any custom Collection type and all Swift integer variants.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.