From db99c1cdeeed6c1a71ae080c00305e0899260079 Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Mon, 2 Sep 2024 16:57:26 +0200 Subject: [PATCH 1/2] Import `FoundationEssentials` in `NIOFoundationCompat` --- Sources/NIOFoundationCompat/ByteBuffer-foundation.swift | 4 ++++ Sources/NIOFoundationCompat/Codable+ByteBuffer.swift | 4 ++++ .../NIOFoundationCompat/JSONSerialization+ByteBuffer.swift | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/Sources/NIOFoundationCompat/ByteBuffer-foundation.swift b/Sources/NIOFoundationCompat/ByteBuffer-foundation.swift index 7aedfb17b0..a8c22f68af 100644 --- a/Sources/NIOFoundationCompat/ByteBuffer-foundation.swift +++ b/Sources/NIOFoundationCompat/ByteBuffer-foundation.swift @@ -12,7 +12,11 @@ // //===----------------------------------------------------------------------===// +#if canImport(FoundationEssentials) +import FoundationEssentials +#else import Foundation +#endif import NIOCore /// Errors that may be thrown by ByteBuffer methods that call into Foundation. diff --git a/Sources/NIOFoundationCompat/Codable+ByteBuffer.swift b/Sources/NIOFoundationCompat/Codable+ByteBuffer.swift index 0f61ad0ae1..f40fa4145c 100644 --- a/Sources/NIOFoundationCompat/Codable+ByteBuffer.swift +++ b/Sources/NIOFoundationCompat/Codable+ByteBuffer.swift @@ -12,7 +12,11 @@ // //===----------------------------------------------------------------------===// +#if canImport(FoundationEssentials) +import FoundationEssentials +#else import Foundation +#endif import NIOCore extension ByteBuffer { diff --git a/Sources/NIOFoundationCompat/JSONSerialization+ByteBuffer.swift b/Sources/NIOFoundationCompat/JSONSerialization+ByteBuffer.swift index d8f00438ca..7403051831 100644 --- a/Sources/NIOFoundationCompat/JSONSerialization+ByteBuffer.swift +++ b/Sources/NIOFoundationCompat/JSONSerialization+ByteBuffer.swift @@ -12,7 +12,11 @@ // //===----------------------------------------------------------------------===// +#if canImport(FoundationEssentials) +import FoundationEssentials +#else import Foundation +#endif import NIOCore extension JSONSerialization { From 047c8a9365f761c2a385da89edd36dde152089e6 Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Mon, 2 Sep 2024 17:04:49 +0200 Subject: [PATCH 2/2] Fix format --- Sources/NIOFoundationCompat/ByteBuffer-foundation.swift | 3 ++- Sources/NIOFoundationCompat/Codable+ByteBuffer.swift | 3 ++- Sources/NIOFoundationCompat/JSONSerialization+ByteBuffer.swift | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Sources/NIOFoundationCompat/ByteBuffer-foundation.swift b/Sources/NIOFoundationCompat/ByteBuffer-foundation.swift index a8c22f68af..0b32aa2c92 100644 --- a/Sources/NIOFoundationCompat/ByteBuffer-foundation.swift +++ b/Sources/NIOFoundationCompat/ByteBuffer-foundation.swift @@ -12,12 +12,13 @@ // //===----------------------------------------------------------------------===// +import NIOCore + #if canImport(FoundationEssentials) import FoundationEssentials #else import Foundation #endif -import NIOCore /// Errors that may be thrown by ByteBuffer methods that call into Foundation. public enum ByteBufferFoundationError: Error { diff --git a/Sources/NIOFoundationCompat/Codable+ByteBuffer.swift b/Sources/NIOFoundationCompat/Codable+ByteBuffer.swift index f40fa4145c..1edd07d007 100644 --- a/Sources/NIOFoundationCompat/Codable+ByteBuffer.swift +++ b/Sources/NIOFoundationCompat/Codable+ByteBuffer.swift @@ -12,12 +12,13 @@ // //===----------------------------------------------------------------------===// +import NIOCore + #if canImport(FoundationEssentials) import FoundationEssentials #else import Foundation #endif -import NIOCore extension ByteBuffer { /// Attempts to decode the `length` bytes from `index` using the `JSONDecoder` `decoder` as `T`. diff --git a/Sources/NIOFoundationCompat/JSONSerialization+ByteBuffer.swift b/Sources/NIOFoundationCompat/JSONSerialization+ByteBuffer.swift index 7403051831..da97f7f1c9 100644 --- a/Sources/NIOFoundationCompat/JSONSerialization+ByteBuffer.swift +++ b/Sources/NIOFoundationCompat/JSONSerialization+ByteBuffer.swift @@ -12,12 +12,13 @@ // //===----------------------------------------------------------------------===// +import NIOCore + #if canImport(FoundationEssentials) import FoundationEssentials #else import Foundation #endif -import NIOCore extension JSONSerialization {