From 17427b66b6db14a9f4c445e46988b0c2f5d2b06b Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Wed, 24 Jul 2024 11:11:07 -0700 Subject: [PATCH] (113200224) JSON/PropertyList coders userInfo should require Sendable values --- Sources/FoundationEssentials/JSON/JSONDecoder.swift | 5 +++-- Sources/FoundationEssentials/JSON/JSONEncoder.swift | 5 +++-- Sources/FoundationEssentials/PropertyList/PlistDecoder.swift | 5 +++-- Sources/FoundationEssentials/PropertyList/PlistEncoder.swift | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Sources/FoundationEssentials/JSON/JSONDecoder.swift b/Sources/FoundationEssentials/JSON/JSONDecoder.swift index b7c629012..8501e8568 100644 --- a/Sources/FoundationEssentials/JSON/JSONDecoder.swift +++ b/Sources/FoundationEssentials/JSON/JSONDecoder.swift @@ -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() } @@ -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 } diff --git a/Sources/FoundationEssentials/JSON/JSONEncoder.swift b/Sources/FoundationEssentials/JSON/JSONEncoder.swift index cff1d0719..f34bed668 100644 --- a/Sources/FoundationEssentials/JSON/JSONEncoder.swift +++ b/Sources/FoundationEssentials/JSON/JSONEncoder.swift @@ -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() } @@ -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. diff --git a/Sources/FoundationEssentials/PropertyList/PlistDecoder.swift b/Sources/FoundationEssentials/PropertyList/PlistDecoder.swift index 7174cee3b..3b9c6a43a 100644 --- a/Sources/FoundationEssentials/PropertyList/PlistDecoder.swift +++ b/Sources/FoundationEssentials/PropertyList/PlistDecoder.swift @@ -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() } @@ -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. diff --git a/Sources/FoundationEssentials/PropertyList/PlistEncoder.swift b/Sources/FoundationEssentials/PropertyList/PlistEncoder.swift index f91a57ffd..e9ee30678 100644 --- a/Sources/FoundationEssentials/PropertyList/PlistEncoder.swift +++ b/Sources/FoundationEssentials/PropertyList/PlistEncoder.swift @@ -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() } @@ -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.