Skip to content

Conversation

@domkm
Copy link
Contributor

@domkm domkm commented Jun 4, 2024

Related to #433

@domkm
Copy link
Contributor Author

domkm commented Jun 4, 2024

I used @unchecked Sendable on JSONDictionary because of the underlying [String:Any] dictionary. @unchecked can be removed if we change the underlying to [String:Sendable].

Copy link
Member

@mickael-menu mickael-menu left a comment

Choose a reason for hiding this comment

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

Thanks @domkm!

I don't plan to merge strict-concurrency into develop unless we can get rid of all the warnings. I guess the warnings are still there in your PR? If yes, could you rebase to develop without including the changes from strict-concurrency?

I used @unchecked Sendable on JSONDictionary because of the underlying [String:Any] dictionary. @unchecked can be removed if we change the underlying to [String:Sendable].

Using [String: Sendable] is fine by me, it's supposed to contain only JSON values anyway (String, Int, etc.), so Sendable seems appropriate.

@domkm
Copy link
Contributor Author

domkm commented Jun 6, 2024

I don't plan to merge strict-concurrency into develop unless we can get rid of all the warnings. I guess the warnings are still there in your PR? If yes, could you rebase to develop without including the changes from strict-concurrency?

Sure, I can rebase it on develop if you'd prefer, but may I ask why you don't want to merge with strict concurrency warnings? The warnings highlight potential bugs, many of which are errors in Swift 6. In other words, hiding the warnings just hides issues but doesn't change behavior.

Using [String: Sendable] is fine by me, it's supposed to contain only JSON values anyway (String, Int, etc.), so Sendable seems appropriate.

Cool. Should it be Codable too?

@mickael-menu
Copy link
Member

but may I ask why you don't want to merge with strict concurrency warnings? The warnings highlight potential bugs, many of which are errors in Swift 6. In other words, hiding the warnings just hides issues but doesn't change behavior.

We have a strict no warnings policy to merge things in the repo (that's why your PR fails all the checks). The goal is to progressively address these issues before Swift 6, without allowing other types of warnings to slip through.

Cool. Should it be Codable too?

Yes that's a good idea. 👍

@domkm
Copy link
Contributor Author

domkm commented Jun 7, 2024

Unfortunately, I wasn't able to make JSONDictionary values Codable without cascading issues, as there are many places that assume it can contain NSNull and nil.

I'm also curious, what is the purpose of this JSONDictionary encoding/decoding scheme instead of using Codable directly?

@mickael-menu
Copy link
Member

I'm also curious, what is the purpose of this JSONDictionary encoding/decoding scheme instead of using Codable directly?

I don't remember exactly, but it might be because we use JSONSerialization.jsonObject() to parse JSON, which returns Any and can't be casted to [String: Codable].

@domkm
Copy link
Contributor Author

domkm commented Jun 8, 2024

I don't remember exactly, but it might be because we use JSONSerialization.jsonObject() to parse JSON, which returns Any and can't be casted to [String: Codable].

Would it make sense to make these types, or at least the main ones, Codable? In my project, I extended Locator and Manifest to be Codable, and I would guess that almost every project at least extends Locator.

@mickael-menu
Copy link
Member

mickael-menu commented Jun 9, 2024

Would it make sense to make these types, or at least the main ones, Codable? In my project, I extended Locator and Manifest to be Codable, and I would guess that almost every project at least extends Locator.

Sure, they are all meant to be serializable to JSON. JSONDictionary itself could be Codable using a custom implementation.

Note that many of the models have complex (de)serialization rules so we can't use the default Codable implementation.

Copy link
Member

@mickael-menu mickael-menu left a comment

Choose a reason for hiding this comment

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

Thank you!

@mickael-menu mickael-menu merged commit e9100ce into readium:develop Jun 9, 2024
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.

2 participants