Skip to content

Add support for Codable types#296

Merged
vsanthanam merged 17 commits intomainfrom
vsanthanam/codable-support-3
Dec 8, 2025
Merged

Add support for Codable types#296
vsanthanam merged 17 commits intomainfrom
vsanthanam/codable-support-3

Conversation

@vsanthanam
Copy link
Copy Markdown
Owner

No description provided.

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 29, 2025

Codecov Report

❌ Patch coverage is 89.75904% with 119 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.25%. Comparing base (9d43d06) to head (04d8615).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...ces/JBirdCodableSupport/Decoder/ArrayDecoder.swift 89.21% 29 Missing ⚠️
...es/JBirdCodableSupport/Encoder/ObjectEncoder.swift 73.95% 25 Missing ⚠️
...ces/JBirdCodableSupport/Encoder/ArrayEncoder.swift 73.91% 24 Missing ⚠️
...es/JBirdCodableSupport/Decoder/ObjectDecoder.swift 93.43% 17 Missing ⚠️
...ces/JBirdCodableSupport/Encoder/ValueEncoder.swift 77.55% 11 Missing ⚠️
.../JBirdCodableSupport/Encoder/InternalEncoder.swift 90.62% 6 Missing ⚠️
.../JBirdCore/Protocols/JSONNumberRepresentable.swift 66.66% 3 Missing ⚠️
Sources/JBirdCodableSupport/IndexKey.swift 80.00% 2 Missing ⚠️
...s/JBirdCodableSupport/BackingTypeDescription.swift 93.75% 1 Missing ⚠️
.../JBirdCodableSupport/Decoder/InternalDecoder.swift 98.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #296      +/-   ##
==========================================
- Coverage   95.57%   93.25%   -2.33%     
==========================================
  Files          25       37      +12     
  Lines        1762     2919    +1157     
==========================================
+ Hits         1684     2722    +1038     
- Misses         78      197     +119     
Flag Coverage Δ
llvm-cov 93.25% <89.75%> (-2.33%) ⬇️
swiftpm 93.25% <89.75%> (-2.33%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vsanthanam vsanthanam force-pushed the vsanthanam/codable-support-3 branch 11 times, most recently from 978abda to f663c66 Compare December 6, 2025 02:28
@vsanthanam vsanthanam changed the title Add support for Codable types Add support for Decodable types Dec 6, 2025
@vsanthanam vsanthanam force-pushed the vsanthanam/codable-support-3 branch 2 times, most recently from 6c18cb8 to f85de5a Compare December 6, 2025 17:26
@vsanthanam vsanthanam force-pushed the vsanthanam/codable-support-3 branch 6 times, most recently from 4f60ff2 to d9d00b7 Compare December 6, 2025 22:06
@vsanthanam vsanthanam changed the title Add support for Decodable types Add support for Codable types Dec 6, 2025
@vsanthanam vsanthanam force-pushed the vsanthanam/codable-support-3 branch 2 times, most recently from a25bb94 to 51f8cac Compare December 6, 2025 23:06
@vsanthanam vsanthanam force-pushed the vsanthanam/codable-support-3 branch from 51f8cac to 2fad330 Compare December 6, 2025 23:16
@vsanthanam vsanthanam linked an issue Dec 7, 2025 that may be closed by this pull request
@vsanthanam vsanthanam requested a review from Copilot December 7, 2025 01:20
Copy link
Copy Markdown
Contributor

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 adds comprehensive Codable protocol support to the JBird JSON library through a new JBirdCodableSupport module. The implementation provides custom JSON encoder and decoder that work with the library's existing JSON type system.

Key Changes

  • Introduces JSON.Encoder and JSON.Decoder types that conform to Swift's Codable protocols
  • Implements full encoder/decoder infrastructure including value, object, and array encoding/decoding containers
  • Adds BackingTypeDescription enum for better error messages during type mismatches

Reviewed changes

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

Show a summary per file
File Description
Sources/JBirdCodableSupport/EntryPoint.swift Public API entry points for JSON.Encoder and JSON.Decoder
Sources/JBirdCodableSupport/Encoder/*.swift Internal encoder implementation (ArrayEncoder, ObjectEncoder, ValueEncoder, InternalEncoder)
Sources/JBirdCodableSupport/Decoder/*.swift Internal decoder implementation (ArrayDecoder, ObjectDecoder, ValueDecoder, InternalDecoder)
Sources/JBirdCodableSupport/BackingTypeDescription.swift Helper type for better decoding error messages
Sources/JBird/JBird.swift Updated umbrella module to conditionally export JBirdCodableSupport with CodableSupport trait
Tests/JBirdCodableSupportTests/**/*.swift Comprehensive test coverage for all encoder/decoder functionality
Package.swift & Package@swift-6.1.swift Added JBirdCodableSupport library and CodableSupport trait configuration
JBird.xcodeproj/project.pbxproj Added JBirdCodableSupport framework target with proper dependency linking
.github/workflows/ci.yml Updated CI to include JBirdCodableSupport in build matrix

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

Comment on lines +233 to +235
init?(intValue: Int) {
self.init(intValue)
}
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

The init?(intValue:) initializer is incorrectly calling itself, which would cause infinite recursion. It should call init(_:) instead: self.init(intValue).

Copilot uses AI. Check for mistakes.
Comment on lines +437 to +439
init?(intValue: Int) {
self.init(intValue)
}
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

The init?(intValue:) initializer is incorrectly calling itself, which would cause infinite recursion. It should call init(_:) instead: self.init(intValue).

Copilot uses AI. Check for mistakes.

@Test("Decode Doubles")
func decodeDoubles() throws {
// let value: Doubles = [3.14159, -0.1234]
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

Remove commented-out code. If this test data was intentionally changed, the old version should be removed.

Suggested change
// let value: Doubles = [3.14159, -0.1234]

Copilot uses AI. Check for mistakes.
@vsanthanam vsanthanam force-pushed the vsanthanam/codable-support-3 branch from 0403f95 to ade410b Compare December 8, 2025 01:36
@vsanthanam vsanthanam force-pushed the vsanthanam/codable-support-3 branch 2 times, most recently from b6e5eb4 to 24df66f Compare December 8, 2025 02:13
@vsanthanam vsanthanam force-pushed the vsanthanam/codable-support-3 branch from 24df66f to 75db339 Compare December 8, 2025 02:18
@vsanthanam vsanthanam force-pushed the vsanthanam/codable-support-3 branch from a737743 to 5cb4098 Compare December 8, 2025 03:14
@vsanthanam vsanthanam force-pushed the vsanthanam/codable-support-3 branch 3 times, most recently from 7c91cbd to 938f24d Compare December 8, 2025 04:28
@vsanthanam vsanthanam force-pushed the vsanthanam/codable-support-3 branch from 938f24d to e566895 Compare December 8, 2025 04:46
@vsanthanam vsanthanam force-pushed the vsanthanam/codable-support-3 branch from 987cbb5 to f23c14d Compare December 8, 2025 05:27
@vsanthanam vsanthanam force-pushed the vsanthanam/codable-support-3 branch from 1eee835 to 412b160 Compare December 8, 2025 06:16
@vsanthanam vsanthanam force-pushed the vsanthanam/codable-support-3 branch from bd11454 to 04d8615 Compare December 8, 2025 06:27
@vsanthanam vsanthanam marked this pull request as ready for review December 8, 2025 06:41
@vsanthanam vsanthanam merged commit ab92961 into main Dec 8, 2025
45 of 47 checks passed
@vsanthanam vsanthanam deleted the vsanthanam/codable-support-3 branch December 8, 2025 06:44
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.

Support Codable models

2 participants