Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON/PropertyList coders userInfo should require Sendable user info values #1169

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Sources/FoundationEssentials/JSON/JSONDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ open class JSONDecoder {
}

/// Contextual user-provided information for use during decoding.
open var userInfo: [CodingUserInfoKey : Any] {
@preconcurrency
open var userInfo: [CodingUserInfoKey : any Sendable] {
get {
optionsLock.lock()
defer { optionsLock.unlock() }
Expand Down Expand Up @@ -309,7 +310,7 @@ open class JSONDecoder {
var dataDecodingStrategy: DataDecodingStrategy = .base64
var nonConformingFloatDecodingStrategy: NonConformingFloatDecodingStrategy = .throw
var keyDecodingStrategy: KeyDecodingStrategy = .useDefaultKeys
var userInfo: [CodingUserInfoKey : Any] = [:]
var userInfo: [CodingUserInfoKey : any Sendable] = [:]
var json5: Bool = false
}

Expand Down
5 changes: 3 additions & 2 deletions Sources/FoundationEssentials/JSON/JSONEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ open class JSONEncoder {
}

/// Contextual user-provided information for use during encoding.
open var userInfo: [CodingUserInfoKey : Any] {
@preconcurrency
open var userInfo: [CodingUserInfoKey : any Sendable] {
get {
optionsLock.lock()
defer { optionsLock.unlock() }
Expand Down Expand Up @@ -324,7 +325,7 @@ open class JSONEncoder {
var dataEncodingStrategy: DataEncodingStrategy = .base64
var nonConformingFloatEncodingStrategy: NonConformingFloatEncodingStrategy = .throw
var keyEncodingStrategy: KeyEncodingStrategy = .useDefaultKeys
var userInfo: [CodingUserInfoKey : Any] = [:]
var userInfo: [CodingUserInfoKey : any Sendable] = [:]
}

/// The options set on the top-level encoder.
Expand Down
5 changes: 3 additions & 2 deletions Sources/FoundationEssentials/PropertyList/PlistDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ open class PropertyListDecoder {
// MARK: Options

/// Contextual user-provided information for use during decoding.
open var userInfo: [CodingUserInfoKey : Any] {
@preconcurrency
open var userInfo: [CodingUserInfoKey : any Sendable] {
get {
optionsLock.lock()
defer { optionsLock.unlock() }
Expand All @@ -62,7 +63,7 @@ open class PropertyListDecoder {

/// Options set on the top-level encoder to pass down the decoding hierarchy.
internal struct _Options {
var userInfo: [CodingUserInfoKey : Any] = [:]
var userInfo: [CodingUserInfoKey : any Sendable] = [:]
}

/// The options set on the top-level decoder.
Expand Down
5 changes: 3 additions & 2 deletions Sources/FoundationEssentials/PropertyList/PlistEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ open class PropertyListEncoder {
}

/// Contextual user-provided information for use during encoding.
open var userInfo: [CodingUserInfoKey : Any] {
@preconcurrency
open var userInfo: [CodingUserInfoKey : any Sendable] {
get {
optionsLock.lock()
defer { optionsLock.unlock() }
Expand All @@ -76,7 +77,7 @@ open class PropertyListEncoder {
/// Options set on the top-level encoder to pass down the encoding hierarchy.
internal struct _Options {
var outputFormat: PropertyListDecoder.PropertyListFormat = .binary
var userInfo: [CodingUserInfoKey : Any] = [:]
var userInfo: [CodingUserInfoKey : any Sendable] = [:]
}

/// The options set on the top-level encoder.
Expand Down