Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Refactor ReadResult decoding for Swift 6#735

Merged
mickael-menu merged 3 commits intodevelopfrom
fix/read-result-decoding
Feb 24, 2026
Merged

Refactor ReadResult decoding for Swift 6#735
mickael-menu merged 3 commits intodevelopfrom
fix/read-result-decoding

Conversation

Copy link
Member

mickael-menu commented Feb 24, 2026

Splits the Streamable.readAsX() async functions into an async read() and synchronous asX() functions. This is to avoid crossing isolation contexts with non sendable objects such as [String: Any].

Copilot AI review requested due to automatic review settings February 24, 2026 17:33
mickael-menu temporarily deployed to LCP February 24, 2026 17:33 -- with GitHub Actions Inactive
mickael-menu temporarily deployed to LCP February 24, 2026 17:33 -- with GitHub Actions Inactive
Copilot started reviewing on behalf of mickael-menu February 24, 2026 17:33 View session
Copilot AI reviewed Feb 24, 2026
Copy link

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 refactors the ReadResult decoding API for Swift 6 compatibility by splitting async reading from synchronous decoding operations. The refactoring addresses Swift 6's stricter concurrency requirements by avoiding crossing isolation contexts with non-Sendable types like [String: Any].

Changes:

  • Split Streamable.readAsX() async functions into separate read() (async) and asX() (synchronous) methods on ReadResult and ReadResult
  • Made XML parsing methods synchronous (except for file I/O in open(file:) which uses Task.detached)
  • Added comprehensive tests for the new ReadResult decoding API using Swift Testing framework
  • Updated all call sites across the codebase to use the new read().asX() pattern
  • Deprecated the old readAsX() methods with migration guidance

Reviewed changes

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

Show a summary per file
File Description
Tests/SharedTests/Toolkit/Data/ReadResultTests.swift New comprehensive test suite for ReadResult decoding methods using Swift Testing framework
Tests/SharedTests/Publication/Services/Positions/PositionsServiceTests.swift Updated to use read().asString() pattern
Tests/SharedTests/Publication/PublicationTests.swift Updated to use read().asString() pattern
Sources/Streamer/Parser/Readium/ReadiumWebPubParser.swift Refactored to use read().asRWPM() pattern, moved extension from Streamable to ReadResult
Sources/Streamer/Parser/Readium/ReadiumGuidedNavigationService.swift Updated to use read().asJSONObject() pattern
Sources/Shared/Toolkit/XML/XML.swift Made open(data:) and open(string:) synchronous; open(file:) uses Task.detached for async I/O
Sources/Shared/Toolkit/Format/Sniffers/RPFFormatSniffer.swift Updated to use read().asJSONObject() pattern
Sources/Shared/Toolkit/Format/Sniffers/EPUBFormatSniffer.swift Updated to use read().asString() pattern and removed await from synchronous XML parsing
Sources/Shared/Toolkit/Format/FormatSnifferBlob.swift Removed await from synchronous XML parsing call
Sources/Shared/Toolkit/Data/Streamable.swift Deprecated readAsString(), readAsJSON(), and readAsJSONObject() with migration messages
Sources/Shared/Toolkit/Data/Resource/ResourceContentExtractor.swift Updated to use read().asString() and made XML parsing synchronous
Sources/Shared/Toolkit/Data/ReadResult.swift New file with decode(), asString(), asJSON(), asJSONObject(), and asXML() methods for both ReadResult and ReadResult
Sources/Shared/Toolkit/Data/ReadError.swift Moved ReadResult typealias to ReadResult.swift
Sources/Shared/Publication/Services/Positions/PositionsService.swift Updated to use read().asJSONObject() pattern
Sources/Shared/Publication/Services/Content/Iterators/HTMLResourceContentIterator.swift Updated to use read().asString() pattern
Sources/LCP/Toolkit/ReadResult.swift Refactored readAsLCPL() from Streamable extension to asLCPL() on ReadResult

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

mickael-menu temporarily deployed to LCP February 24, 2026 17:47 -- with GitHub Actions Inactive
mickael-menu temporarily deployed to LCP February 24, 2026 17:47 -- with GitHub Actions Inactive
mickael-menu merged commit bf4faf3 into develop Feb 24, 2026
5 checks passed
mickael-menu deleted the fix/read-result-decoding branch February 24, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot Copilot left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants