From 75e74ea398d8eac08a10fa039e63aebafbc2816d Mon Sep 17 00:00:00 2001 From: Michael Rebello Date: Thu, 9 Jan 2025 10:54:27 -0800 Subject: [PATCH] Use Swift 6 when available & upgrade to Xcode 16.2 (#331) After some discussion in https://github.com/apple/swift-protobuf/issues/1729, I noticed that the compilation error when building with Swift 6 is actually an issue with the config in `Tests/UnitTests/ConnectLibraryTests/buf.gen.yaml` which was still running on `1.25.2` instead of `1.28.2` like other parts of the project. Changes in this PR: - Updates that directory to run on `1.28.2` which includes https://github.com/apple/swift-protobuf/commit/3bc7630e56dced84859b5a058b7d39caca538760 and resolves the problem described in the aforementioned issue - Switches CI to use Xcode 16.2 and macOS 15 - Switches our `Package.swift` to use Swift 6 when available via `swiftLanguageVersions: [.version("6"), .v5]` - Updates the Eliza SPM app to use Swift 6 This is related to https://github.com/connectrpc/connect-swift/issues/310, but we will not be able to actually implement those until we fully switch to using Swift 6 (a breaking change). --------- Signed-off-by: Michael Rebello --- .github/workflows/ci.yaml | 54 +++--- .github/workflows/release.yml | 12 +- .../project.pbxproj | 4 +- Package.swift | 2 +- .../conformance/v1/client_compat.pb.swift | 78 ++------ .../connectrpc/conformance/v1/config.pb.swift | 84 ++------- .../conformance/v1/server_compat.pb.swift | 10 +- .../conformance/v1/service.pb.swift | 175 ++++-------------- .../connectrpc/conformance/v1/suite.pb.swift | 56 ++---- .../ConnectLibraryTests/buf.gen.yaml | 2 +- 10 files changed, 131 insertions(+), 346 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4da8ca16..c4281bff 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,12 +9,12 @@ permissions: contents: read jobs: build-eliza-cocoapods-example: - runs-on: macos-14 + runs-on: macos-15 steps: - uses: actions/checkout@v4 - name: Select Xcode version - # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode - run: sudo xcode-select --switch /Applications/Xcode_16.app + # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode + run: sudo xcode-select --switch /Applications/Xcode_16.2.app - name: Install xcbeautify run: brew install xcbeautify - name: Build Eliza CocoaPods example @@ -23,12 +23,12 @@ jobs: pod install set -o pipefail && xcodebuild -workspace ElizaCocoaPodsApp.xcworkspace -scheme ElizaCocoaPodsApp build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcbeautify build-eliza-swiftpm-example: - runs-on: macos-14 + runs-on: macos-15 steps: - uses: actions/checkout@v4 - name: Select Xcode version - # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode - run: sudo xcode-select --switch /Applications/Xcode_16.app + # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode + run: sudo xcode-select --switch /Applications/Xcode_16.2.app - name: Install xcbeautify run: brew install xcbeautify - name: Build Eliza Swift PM example @@ -36,56 +36,56 @@ jobs: cd Examples/ElizaSwiftPackageApp set -o pipefail && xcodebuild -scheme ElizaSwiftPackageApp build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcbeautify build-library-ios: - runs-on: macos-14 + runs-on: macos-15 steps: - uses: actions/checkout@v4 - name: Select Xcode version - # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode - run: sudo xcode-select --switch /Applications/Xcode_16.app + # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode + run: sudo xcode-select --switch /Applications/Xcode_16.2.app - name: Install xcbeautify run: brew install xcbeautify - name: Build Connect iOS library run: set -o pipefail && xcodebuild -scheme Connect-Package -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.0' | xcbeautify build-library-macos: - runs-on: macos-14 + runs-on: macos-15 steps: - uses: actions/checkout@v4 - name: Select Xcode version - # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode - run: sudo xcode-select --switch /Applications/Xcode_16.app + # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode + run: sudo xcode-select --switch /Applications/Xcode_16.2.app - name: Install xcbeautify run: brew install xcbeautify - name: Build Connect macOS library run: set -o pipefail && xcodebuild -scheme Connect-Package -destination 'platform=macOS' | xcbeautify build-library-tvos: - runs-on: macos-14 + runs-on: macos-15 steps: - uses: actions/checkout@v4 - name: Select Xcode version - # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode - run: sudo xcode-select --switch /Applications/Xcode_16.app + # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode + run: sudo xcode-select --switch /Applications/Xcode_16.2.app - name: Install xcbeautify run: brew install xcbeautify - name: Build Connect tvOS library run: set -o pipefail && xcodebuild -scheme Connect-Package -destination 'platform=tvOS Simulator,name=Apple TV,OS=18.0' | xcbeautify build-library-watchos: - runs-on: macos-14 + runs-on: macos-15 steps: - uses: actions/checkout@v4 - name: Select Xcode version - # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode - run: sudo xcode-select --switch /Applications/Xcode_16.app + # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode + run: sudo xcode-select --switch /Applications/Xcode_16.2.app - name: Install xcbeautify run: brew install xcbeautify - name: Build Connect watchOS library run: set -o pipefail && xcodebuild -scheme Connect-Package -destination 'platform=watchOS Simulator,name=Apple Watch Series 10 (42mm),OS=11.0' | xcbeautify build-plugin-and-generate: - runs-on: macos-14 + runs-on: macos-15 steps: - uses: actions/checkout@v4 - name: Select Xcode version - # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md - run: sudo xcode-select --switch /Applications/Xcode_15.2.app + # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md + run: sudo xcode-select --switch /Applications/Xcode_16.2.app - uses: bufbuild/buf-setup-action@v1.48.0 with: github_token: ${{ github.token }} @@ -98,26 +98,26 @@ jobs: git update-index --refresh --add --remove git diff-index --quiet HEAD -- run-conformance-tests: - runs-on: macos-14 + runs-on: macos-15 steps: - uses: actions/checkout@v4 - name: Select Xcode version - # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode - run: sudo xcode-select --switch /Applications/Xcode_16.app + # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode + run: sudo xcode-select --switch /Applications/Xcode_16.2.app - name: Install conformance runner run: make installconformancerunner - name: Run conformance tests run: make testconformance run-unit-tests: - runs-on: macos-14 + runs-on: macos-15 steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version: 1.21.x - name: Select Xcode version - # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode - run: sudo xcode-select --switch /Applications/Xcode_16.app + # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode + run: sudo xcode-select --switch /Applications/Xcode_16.2.app - name: Run unit tests run: make testunit run-swiftlint: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 32e4726d..f7196900 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,12 +8,12 @@ permissions: contents: write jobs: release: - runs-on: macos-14 + runs-on: macos-15 steps: - uses: actions/checkout@v4 - name: Select Xcode version - # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode - run: sudo xcode-select --switch /Applications/Xcode_16.app + # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode + run: sudo xcode-select --switch /Applications/Xcode_16.2.app - uses: bufbuild/buf-setup-action@v1.48.0 with: github_token: ${{ github.token }} @@ -37,12 +37,12 @@ jobs: files: | ./.tmp/bin/artifacts/* publish-podspecs: - runs-on: macos-14 + runs-on: macos-15 steps: - uses: actions/checkout@v4 - name: Select Xcode version - # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode - run: sudo xcode-select --switch /Applications/Xcode_16.app + # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode + run: sudo xcode-select --switch /Applications/Xcode_16.2.app - name: Publish podspecs to CocoaPods env: COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} diff --git a/Examples/ElizaSwiftPackageApp/ElizaSwiftPackageApp.xcodeproj/project.pbxproj b/Examples/ElizaSwiftPackageApp/ElizaSwiftPackageApp.xcodeproj/project.pbxproj index 4b976d65..e7b75330 100644 --- a/Examples/ElizaSwiftPackageApp/ElizaSwiftPackageApp.xcodeproj/project.pbxproj +++ b/Examples/ElizaSwiftPackageApp/ElizaSwiftPackageApp.xcodeproj/project.pbxproj @@ -379,7 +379,7 @@ SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_STRICT_CONCURRENCY = complete; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = 1; }; name = Debug; @@ -413,7 +413,7 @@ SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_STRICT_CONCURRENCY = complete; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = 1; }; name = Release; diff --git a/Package.swift b/Package.swift index 108b5e2b..34762dd4 100644 --- a/Package.swift +++ b/Package.swift @@ -166,5 +166,5 @@ let package = Package( path: "Plugins/ConnectSwiftPlugin" ), ], - swiftLanguageVersions: [.v5] + swiftLanguageVersions: [.version("6"), .v5] ) diff --git a/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/client_compat.pb.swift b/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/client_compat.pb.swift index d6cdf89d..2d6b8d70 100644 --- a/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/client_compat.pb.swift +++ b/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/client_compat.pb.swift @@ -1,5 +1,6 @@ // DO NOT EDIT. // swift-format-ignore-file +// swiftlint:disable all // // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: connectrpc/conformance/v1/client_compat.proto @@ -38,7 +39,7 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP /// these from stdin and, for each one, invokes an RPC as directed /// and writes the results (in the form of a ClientCompatResponse /// message) to stdout. -struct Connectrpc_Conformance_V1_ClientCompatRequest { +struct Connectrpc_Conformance_V1_ClientCompatRequest: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -230,7 +231,7 @@ struct Connectrpc_Conformance_V1_ClientCompatRequest { var unknownFields = SwiftProtobuf.UnknownStorage() - struct Cancel { + struct Cancel: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -300,7 +301,7 @@ struct Connectrpc_Conformance_V1_ClientCompatRequest { /// after all request messages are sent and the send side is /// closed (as if the after_close_send_ms field were present /// and zero). - enum OneOf_CancelTiming: Equatable { + enum OneOf_CancelTiming: Equatable, Sendable { /// When present, the client should cancel *instead of* /// closing the send side of the stream, after all requests /// have been sent. @@ -332,28 +333,6 @@ struct Connectrpc_Conformance_V1_ClientCompatRequest { /// This applies only to server and bidi stream RPCs. case afterNumResponses(UInt32) - #if !swift(>=4.1) - static func ==(lhs: Connectrpc_Conformance_V1_ClientCompatRequest.Cancel.OneOf_CancelTiming, rhs: Connectrpc_Conformance_V1_ClientCompatRequest.Cancel.OneOf_CancelTiming) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.beforeCloseSend, .beforeCloseSend): return { - guard case .beforeCloseSend(let l) = lhs, case .beforeCloseSend(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.afterCloseSendMs, .afterCloseSendMs): return { - guard case .afterCloseSendMs(let l) = lhs, case .afterCloseSendMs(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.afterNumResponses, .afterNumResponses): return { - guard case .afterNumResponses(let l) = lhs, case .afterNumResponses(let r) = rhs else { preconditionFailure() } - return l == r - }() - default: return false - } - } - #endif } init() {} @@ -365,7 +344,7 @@ struct Connectrpc_Conformance_V1_ClientCompatRequest { } /// The outcome of one ClientCompatRequest. -struct Connectrpc_Conformance_V1_ClientCompatResponse { +struct Connectrpc_Conformance_V1_ClientCompatResponse: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -411,28 +390,10 @@ struct Connectrpc_Conformance_V1_ClientCompatResponse { /// (e.g. a unary request that defines zero or multiple request messages). /// /// However, once the RPC is issued, any resulting error should instead be encoded in response. - enum OneOf_Result: Equatable { + enum OneOf_Result: Equatable, Sendable { case response(Connectrpc_Conformance_V1_ClientResponseResult) case error(Connectrpc_Conformance_V1_ClientErrorResult) - #if !swift(>=4.1) - static func ==(lhs: Connectrpc_Conformance_V1_ClientCompatResponse.OneOf_Result, rhs: Connectrpc_Conformance_V1_ClientCompatResponse.OneOf_Result) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.response, .response): return { - guard case .response(let l) = lhs, case .response(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.error, .error): return { - guard case .error(let l) = lhs, case .error(let r) = rhs else { preconditionFailure() } - return l == r - }() - default: return false - } - } - #endif } init() {} @@ -440,7 +401,7 @@ struct Connectrpc_Conformance_V1_ClientCompatResponse { /// The result of a ClientCompatRequest, which may or may not be successful. /// The client will build this message and return it back to the test runner. -struct Connectrpc_Conformance_V1_ClientResponseResult { +struct Connectrpc_Conformance_V1_ClientResponseResult: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -505,7 +466,7 @@ struct Connectrpc_Conformance_V1_ClientResponseResult { /// The client is not able to fulfill the ClientCompatRequest. This may be due /// to a runtime error or an unexpected internal error such as the requested protocol /// not being supported. This is completely independent of the actual RPC invocation. -struct Connectrpc_Conformance_V1_ClientErrorResult { +struct Connectrpc_Conformance_V1_ClientErrorResult: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -523,7 +484,7 @@ struct Connectrpc_Conformance_V1_ClientErrorResult { /// Details about various values as observed on the wire. This message is used /// only by the reference client when reporting results and should not be populated /// by clients under test. -struct Connectrpc_Conformance_V1_WireDetails { +struct Connectrpc_Conformance_V1_WireDetails: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -571,17 +532,6 @@ struct Connectrpc_Conformance_V1_WireDetails { fileprivate var _actualGrpcwebTrailers: String? = nil } -#if swift(>=5.5) && canImport(_Concurrency) -extension Connectrpc_Conformance_V1_ClientCompatRequest: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_ClientCompatRequest.Cancel: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_ClientCompatRequest.Cancel.OneOf_CancelTiming: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_ClientCompatResponse: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_ClientCompatResponse.OneOf_Result: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_ClientResponseResult: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_ClientErrorResult: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_WireDetails: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - // MARK: - Code below here is support for the SwiftProtobuf runtime. fileprivate let _protobuf_package = "connectrpc.conformance.v1" @@ -633,7 +583,15 @@ extension Connectrpc_Conformance_V1_ClientCompatRequest: SwiftProtobuf.Message, var _cancel: Connectrpc_Conformance_V1_ClientCompatRequest.Cancel? = nil var _rawRequest: Connectrpc_Conformance_V1_RawHTTPRequest? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/config.pb.swift b/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/config.pb.swift index 9b0f58b5..d9be0819 100644 --- a/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/config.pb.swift +++ b/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/config.pb.swift @@ -1,5 +1,6 @@ // DO NOT EDIT. // swift-format-ignore-file +// swiftlint:disable all // // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: connectrpc/conformance/v1/config.proto @@ -34,7 +35,7 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP typealias Version = _2 } -enum Connectrpc_Conformance_V1_HTTPVersion: SwiftProtobuf.Enum { +enum Connectrpc_Conformance_V1_HTTPVersion: SwiftProtobuf.Enum, Swift.CaseIterable { typealias RawValue = Int case unspecified // = 0 case httpVersion1 // = 1 @@ -66,11 +67,6 @@ enum Connectrpc_Conformance_V1_HTTPVersion: SwiftProtobuf.Enum { } } -} - -#if swift(>=4.2) - -extension Connectrpc_Conformance_V1_HTTPVersion: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. static let allCases: [Connectrpc_Conformance_V1_HTTPVersion] = [ .unspecified, @@ -78,11 +74,10 @@ extension Connectrpc_Conformance_V1_HTTPVersion: CaseIterable { .httpVersion2, .httpVersion3, ] -} -#endif // swift(>=4.2) +} -enum Connectrpc_Conformance_V1_Protocol: SwiftProtobuf.Enum { +enum Connectrpc_Conformance_V1_Protocol: SwiftProtobuf.Enum, Swift.CaseIterable { typealias RawValue = Int case unspecified // = 0 case connect // = 1 @@ -118,11 +113,6 @@ enum Connectrpc_Conformance_V1_Protocol: SwiftProtobuf.Enum { } } -} - -#if swift(>=4.2) - -extension Connectrpc_Conformance_V1_Protocol: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. static let allCases: [Connectrpc_Conformance_V1_Protocol] = [ .unspecified, @@ -130,17 +120,18 @@ extension Connectrpc_Conformance_V1_Protocol: CaseIterable { .grpc, .grpcWeb, ] -} -#endif // swift(>=4.2) +} -enum Connectrpc_Conformance_V1_Codec: SwiftProtobuf.Enum { +enum Connectrpc_Conformance_V1_Codec: SwiftProtobuf.Enum, Swift.CaseIterable { typealias RawValue = Int case unspecified // = 0 case proto // = 1 case json // = 2 /// not used; will be ignored + /// + /// NOTE: This enum value was marked as deprecated in the .proto file case text // = 3 case UNRECOGNIZED(Int) @@ -168,11 +159,6 @@ enum Connectrpc_Conformance_V1_Codec: SwiftProtobuf.Enum { } } -} - -#if swift(>=4.2) - -extension Connectrpc_Conformance_V1_Codec: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. static let allCases: [Connectrpc_Conformance_V1_Codec] = [ .unspecified, @@ -180,11 +166,10 @@ extension Connectrpc_Conformance_V1_Codec: CaseIterable { .json, .text, ] -} -#endif // swift(>=4.2) +} -enum Connectrpc_Conformance_V1_Compression: SwiftProtobuf.Enum { +enum Connectrpc_Conformance_V1_Compression: SwiftProtobuf.Enum, Swift.CaseIterable { typealias RawValue = Int case unspecified // = 0 case identity // = 1 @@ -225,11 +210,6 @@ enum Connectrpc_Conformance_V1_Compression: SwiftProtobuf.Enum { } } -} - -#if swift(>=4.2) - -extension Connectrpc_Conformance_V1_Compression: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. static let allCases: [Connectrpc_Conformance_V1_Compression] = [ .unspecified, @@ -240,11 +220,10 @@ extension Connectrpc_Conformance_V1_Compression: CaseIterable { .deflate, .snappy, ] -} -#endif // swift(>=4.2) +} -enum Connectrpc_Conformance_V1_StreamType: SwiftProtobuf.Enum { +enum Connectrpc_Conformance_V1_StreamType: SwiftProtobuf.Enum, Swift.CaseIterable { typealias RawValue = Int case unspecified // = 0 case unary // = 1 @@ -282,11 +261,6 @@ enum Connectrpc_Conformance_V1_StreamType: SwiftProtobuf.Enum { } } -} - -#if swift(>=4.2) - -extension Connectrpc_Conformance_V1_StreamType: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. static let allCases: [Connectrpc_Conformance_V1_StreamType] = [ .unspecified, @@ -296,11 +270,10 @@ extension Connectrpc_Conformance_V1_StreamType: CaseIterable { .halfDuplexBidiStream, .fullDuplexBidiStream, ] -} -#endif // swift(>=4.2) +} -enum Connectrpc_Conformance_V1_Code: SwiftProtobuf.Enum { +enum Connectrpc_Conformance_V1_Code: SwiftProtobuf.Enum, Swift.CaseIterable { typealias RawValue = Int case unspecified // = 0 case canceled // = 1 @@ -371,11 +344,6 @@ enum Connectrpc_Conformance_V1_Code: SwiftProtobuf.Enum { } } -} - -#if swift(>=4.2) - -extension Connectrpc_Conformance_V1_Code: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. static let allCases: [Connectrpc_Conformance_V1_Code] = [ .unspecified, @@ -396,13 +364,12 @@ extension Connectrpc_Conformance_V1_Code: CaseIterable { .dataLoss, .unauthenticated, ] -} -#endif // swift(>=4.2) +} /// Config defines the configuration for running conformance tests. /// This enumerates all of the "flavors" of the test suite to run. -struct Connectrpc_Conformance_V1_Config { +struct Connectrpc_Conformance_V1_Config: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -439,7 +406,7 @@ struct Connectrpc_Conformance_V1_Config { /// used to determine the server configurations and test cases that /// will be run. They are defined in YAML files and are specified as part of the /// --conf flag to the test runner. -struct Connectrpc_Conformance_V1_Features { +struct Connectrpc_Conformance_V1_Features: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -562,7 +529,7 @@ struct Connectrpc_Conformance_V1_Features { /// run, the Config and the supported features therein are used to compute all /// of the cases relevant to the implementation under test. These configuration /// cases are then used to select which test cases are applicable. -struct Connectrpc_Conformance_V1_ConfigCase { +struct Connectrpc_Conformance_V1_ConfigCase: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -628,7 +595,7 @@ struct Connectrpc_Conformance_V1_ConfigCase { /// TLSCreds represents credentials for TLS. It includes both a /// certificate and corresponding private key. Both are encoded /// in PEM format. -struct Connectrpc_Conformance_V1_TLSCreds { +struct Connectrpc_Conformance_V1_TLSCreds: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -642,19 +609,6 @@ struct Connectrpc_Conformance_V1_TLSCreds { init() {} } -#if swift(>=5.5) && canImport(_Concurrency) -extension Connectrpc_Conformance_V1_HTTPVersion: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_Protocol: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_Codec: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_Compression: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_StreamType: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_Code: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_Config: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_Features: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_ConfigCase: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_TLSCreds: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - // MARK: - Code below here is support for the SwiftProtobuf runtime. fileprivate let _protobuf_package = "connectrpc.conformance.v1" diff --git a/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/server_compat.pb.swift b/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/server_compat.pb.swift index cbb6f897..39774ac9 100644 --- a/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/server_compat.pb.swift +++ b/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/server_compat.pb.swift @@ -1,5 +1,6 @@ // DO NOT EDIT. // swift-format-ignore-file +// swiftlint:disable all // // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: connectrpc/conformance/v1/server_compat.proto @@ -48,7 +49,7 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP /// Each test process is expected to start only one RPC server. /// When testing multiple configurations, multiple test processes /// will be started, each with different properties. -struct Connectrpc_Conformance_V1_ServerCompatRequest { +struct Connectrpc_Conformance_V1_ServerCompatRequest: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -120,7 +121,7 @@ struct Connectrpc_Conformance_V1_ServerCompatRequest { } /// The outcome of one ServerCompatRequest. -struct Connectrpc_Conformance_V1_ServerCompatResponse { +struct Connectrpc_Conformance_V1_ServerCompatResponse: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -143,11 +144,6 @@ struct Connectrpc_Conformance_V1_ServerCompatResponse { init() {} } -#if swift(>=5.5) && canImport(_Concurrency) -extension Connectrpc_Conformance_V1_ServerCompatRequest: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_ServerCompatResponse: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - // MARK: - Code below here is support for the SwiftProtobuf runtime. fileprivate let _protobuf_package = "connectrpc.conformance.v1" diff --git a/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/service.pb.swift b/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/service.pb.swift index 28087d51..99599ba7 100644 --- a/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/service.pb.swift +++ b/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/service.pb.swift @@ -1,5 +1,6 @@ // DO NOT EDIT. // swift-format-ignore-file +// swiftlint:disable all // // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: connectrpc/conformance/v1/service.proto @@ -36,7 +37,7 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP /// A definition of a response to be sent from a single-response endpoint. /// Can be used to define a response for unary or client-streaming calls. -struct Connectrpc_Conformance_V1_UnaryResponseDefinition { +struct Connectrpc_Conformance_V1_UnaryResponseDefinition: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -88,7 +89,7 @@ struct Connectrpc_Conformance_V1_UnaryResponseDefinition { var unknownFields = SwiftProtobuf.UnknownStorage() - enum OneOf_Response: Equatable { + enum OneOf_Response: Equatable, @unchecked Sendable { /// Response data to send case responseData(Data) /// Error to raise instead of response message @@ -96,24 +97,6 @@ struct Connectrpc_Conformance_V1_UnaryResponseDefinition { /// requested error. case error(Connectrpc_Conformance_V1_Error) - #if !swift(>=4.1) - static func ==(lhs: Connectrpc_Conformance_V1_UnaryResponseDefinition.OneOf_Response, rhs: Connectrpc_Conformance_V1_UnaryResponseDefinition.OneOf_Response) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.responseData, .responseData): return { - guard case .responseData(let l) = lhs, case .responseData(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.error, .error): return { - guard case .error(let l) = lhs, case .error(let r) = rhs else { preconditionFailure() } - return l == r - }() - default: return false - } - } - #endif } init() {} @@ -123,7 +106,7 @@ struct Connectrpc_Conformance_V1_UnaryResponseDefinition { /// A definition of responses to be sent from a streaming endpoint. /// Can be used to define responses for server-streaming or bidi-streaming calls. -struct Connectrpc_Conformance_V1_StreamResponseDefinition { +struct Connectrpc_Conformance_V1_StreamResponseDefinition: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -176,7 +159,7 @@ struct Connectrpc_Conformance_V1_StreamResponseDefinition { fileprivate var _rawResponse: Connectrpc_Conformance_V1_RawHTTPResponse? = nil } -struct Connectrpc_Conformance_V1_UnaryRequest { +struct Connectrpc_Conformance_V1_UnaryRequest: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -201,7 +184,7 @@ struct Connectrpc_Conformance_V1_UnaryRequest { fileprivate var _responseDefinition: Connectrpc_Conformance_V1_UnaryResponseDefinition? = nil } -struct Connectrpc_Conformance_V1_UnaryResponse { +struct Connectrpc_Conformance_V1_UnaryResponse: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -223,7 +206,7 @@ struct Connectrpc_Conformance_V1_UnaryResponse { fileprivate var _payload: Connectrpc_Conformance_V1_ConformancePayload? = nil } -struct Connectrpc_Conformance_V1_IdempotentUnaryRequest { +struct Connectrpc_Conformance_V1_IdempotentUnaryRequest: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -248,7 +231,7 @@ struct Connectrpc_Conformance_V1_IdempotentUnaryRequest { fileprivate var _responseDefinition: Connectrpc_Conformance_V1_UnaryResponseDefinition? = nil } -struct Connectrpc_Conformance_V1_IdempotentUnaryResponse { +struct Connectrpc_Conformance_V1_IdempotentUnaryResponse: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -270,7 +253,7 @@ struct Connectrpc_Conformance_V1_IdempotentUnaryResponse { fileprivate var _payload: Connectrpc_Conformance_V1_ConformancePayload? = nil } -struct Connectrpc_Conformance_V1_ServerStreamRequest { +struct Connectrpc_Conformance_V1_ServerStreamRequest: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -295,7 +278,7 @@ struct Connectrpc_Conformance_V1_ServerStreamRequest { fileprivate var _responseDefinition: Connectrpc_Conformance_V1_StreamResponseDefinition? = nil } -struct Connectrpc_Conformance_V1_ServerStreamResponse { +struct Connectrpc_Conformance_V1_ServerStreamResponse: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -317,7 +300,7 @@ struct Connectrpc_Conformance_V1_ServerStreamResponse { fileprivate var _payload: Connectrpc_Conformance_V1_ConformancePayload? = nil } -struct Connectrpc_Conformance_V1_ClientStreamRequest { +struct Connectrpc_Conformance_V1_ClientStreamRequest: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -345,7 +328,7 @@ struct Connectrpc_Conformance_V1_ClientStreamRequest { fileprivate var _responseDefinition: Connectrpc_Conformance_V1_UnaryResponseDefinition? = nil } -struct Connectrpc_Conformance_V1_ClientStreamResponse { +struct Connectrpc_Conformance_V1_ClientStreamResponse: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -367,7 +350,7 @@ struct Connectrpc_Conformance_V1_ClientStreamResponse { fileprivate var _payload: Connectrpc_Conformance_V1_ConformancePayload? = nil } -struct Connectrpc_Conformance_V1_BidiStreamRequest { +struct Connectrpc_Conformance_V1_BidiStreamRequest: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -409,7 +392,7 @@ struct Connectrpc_Conformance_V1_BidiStreamRequest { fileprivate var _responseDefinition: Connectrpc_Conformance_V1_StreamResponseDefinition? = nil } -struct Connectrpc_Conformance_V1_BidiStreamResponse { +struct Connectrpc_Conformance_V1_BidiStreamResponse: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -431,7 +414,7 @@ struct Connectrpc_Conformance_V1_BidiStreamResponse { fileprivate var _payload: Connectrpc_Conformance_V1_ConformancePayload? = nil } -struct Connectrpc_Conformance_V1_UnimplementedRequest { +struct Connectrpc_Conformance_V1_UnimplementedRequest: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -441,7 +424,7 @@ struct Connectrpc_Conformance_V1_UnimplementedRequest { init() {} } -struct Connectrpc_Conformance_V1_UnimplementedResponse { +struct Connectrpc_Conformance_V1_UnimplementedResponse: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -451,7 +434,7 @@ struct Connectrpc_Conformance_V1_UnimplementedResponse { init() {} } -struct Connectrpc_Conformance_V1_ConformancePayload { +struct Connectrpc_Conformance_V1_ConformancePayload: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -472,7 +455,7 @@ struct Connectrpc_Conformance_V1_ConformancePayload { var unknownFields = SwiftProtobuf.UnknownStorage() - struct RequestInfo { + struct RequestInfo: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -523,7 +506,7 @@ struct Connectrpc_Conformance_V1_ConformancePayload { fileprivate var _connectGetInfo: Connectrpc_Conformance_V1_ConformancePayload.ConnectGetInfo? = nil } - struct ConnectGetInfo { + struct ConnectGetInfo: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -542,7 +525,7 @@ struct Connectrpc_Conformance_V1_ConformancePayload { } /// An error definition used for specifying a desired error response -struct Connectrpc_Conformance_V1_Error { +struct Connectrpc_Conformance_V1_Error: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -576,7 +559,7 @@ struct Connectrpc_Conformance_V1_Error { } /// A tuple of name and values (ASCII) for a header or trailer entry. -struct Connectrpc_Conformance_V1_Header { +struct Connectrpc_Conformance_V1_Header: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -597,7 +580,7 @@ struct Connectrpc_Conformance_V1_Header { /// RawHTTPRequest models a raw HTTP request. This can be used to craft /// custom requests with odd properties (including certain kinds of /// malformed requests) to test edge cases in servers. -struct Connectrpc_Conformance_V1_RawHTTPRequest { +struct Connectrpc_Conformance_V1_RawHTTPRequest: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -642,34 +625,16 @@ struct Connectrpc_Conformance_V1_RawHTTPRequest { var unknownFields = SwiftProtobuf.UnknownStorage() - enum OneOf_Body: Equatable { + enum OneOf_Body: Equatable, Sendable { /// The body is a single message. case unary(Connectrpc_Conformance_V1_MessageContents) /// The body is a stream, encoded using a five-byte /// prefix before each item in the stream. case stream(Connectrpc_Conformance_V1_StreamContents) - #if !swift(>=4.1) - static func ==(lhs: Connectrpc_Conformance_V1_RawHTTPRequest.OneOf_Body, rhs: Connectrpc_Conformance_V1_RawHTTPRequest.OneOf_Body) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.unary, .unary): return { - guard case .unary(let l) = lhs, case .unary(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.stream, .stream): return { - guard case .stream(let l) = lhs, case .stream(let r) = rhs else { preconditionFailure() } - return l == r - }() - default: return false - } - } - #endif } - struct EncodedQueryParam { + struct EncodedQueryParam: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -702,7 +667,7 @@ struct Connectrpc_Conformance_V1_RawHTTPRequest { } /// MessageContents represents a message in a request body. -struct Connectrpc_Conformance_V1_MessageContents { +struct Connectrpc_Conformance_V1_MessageContents: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -746,7 +711,7 @@ struct Connectrpc_Conformance_V1_MessageContents { var unknownFields = SwiftProtobuf.UnknownStorage() /// The message data can be defined in one of three ways. - enum OneOf_Data: Equatable { + enum OneOf_Data: Equatable, @unchecked Sendable { /// Arbitrary bytes. case binary(Data) /// Arbitrary text. @@ -756,35 +721,13 @@ struct Connectrpc_Conformance_V1_MessageContents { /// resulting bytes will be the contents. case binaryMessage(SwiftProtobuf.Google_Protobuf_Any) - #if !swift(>=4.1) - static func ==(lhs: Connectrpc_Conformance_V1_MessageContents.OneOf_Data, rhs: Connectrpc_Conformance_V1_MessageContents.OneOf_Data) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.binary, .binary): return { - guard case .binary(let l) = lhs, case .binary(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.text, .text): return { - guard case .text(let l) = lhs, case .text(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.binaryMessage, .binaryMessage): return { - guard case .binaryMessage(let l) = lhs, case .binaryMessage(let r) = rhs else { preconditionFailure() } - return l == r - }() - default: return false - } - } - #endif } init() {} } /// StreamContents represents a sequence of messages in a request body. -struct Connectrpc_Conformance_V1_StreamContents { +struct Connectrpc_Conformance_V1_StreamContents: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -794,7 +737,7 @@ struct Connectrpc_Conformance_V1_StreamContents { var unknownFields = SwiftProtobuf.UnknownStorage() - struct StreamItem { + struct StreamItem: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -835,7 +778,7 @@ struct Connectrpc_Conformance_V1_StreamContents { /// RawHTTPResponse models a raw HTTP response. This can be used to craft /// custom responses with odd properties (including certain kinds of /// malformed responses) to test edge cases in clients. -struct Connectrpc_Conformance_V1_RawHTTPResponse { +struct Connectrpc_Conformance_V1_RawHTTPResponse: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -872,68 +815,18 @@ struct Connectrpc_Conformance_V1_RawHTTPResponse { var unknownFields = SwiftProtobuf.UnknownStorage() - enum OneOf_Body: Equatable { + enum OneOf_Body: Equatable, Sendable { /// The body is a single message. case unary(Connectrpc_Conformance_V1_MessageContents) /// The body is a stream, encoded using a five-byte /// prefix before each item in the stream. case stream(Connectrpc_Conformance_V1_StreamContents) - #if !swift(>=4.1) - static func ==(lhs: Connectrpc_Conformance_V1_RawHTTPResponse.OneOf_Body, rhs: Connectrpc_Conformance_V1_RawHTTPResponse.OneOf_Body) -> Bool { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch (lhs, rhs) { - case (.unary, .unary): return { - guard case .unary(let l) = lhs, case .unary(let r) = rhs else { preconditionFailure() } - return l == r - }() - case (.stream, .stream): return { - guard case .stream(let l) = lhs, case .stream(let r) = rhs else { preconditionFailure() } - return l == r - }() - default: return false - } - } - #endif } init() {} } -#if swift(>=5.5) && canImport(_Concurrency) -extension Connectrpc_Conformance_V1_UnaryResponseDefinition: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_UnaryResponseDefinition.OneOf_Response: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_StreamResponseDefinition: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_UnaryRequest: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_UnaryResponse: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_IdempotentUnaryRequest: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_IdempotentUnaryResponse: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_ServerStreamRequest: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_ServerStreamResponse: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_ClientStreamRequest: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_ClientStreamResponse: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_BidiStreamRequest: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_BidiStreamResponse: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_UnimplementedRequest: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_UnimplementedResponse: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_ConformancePayload: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_ConformancePayload.RequestInfo: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_ConformancePayload.ConnectGetInfo: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_Error: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_Header: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_RawHTTPRequest: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_RawHTTPRequest.OneOf_Body: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_RawHTTPRequest.EncodedQueryParam: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_MessageContents: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_MessageContents.OneOf_Data: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_StreamContents: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_StreamContents.StreamItem: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_RawHTTPResponse: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_RawHTTPResponse.OneOf_Body: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - // MARK: - Code below here is support for the SwiftProtobuf runtime. fileprivate let _protobuf_package = "connectrpc.conformance.v1" @@ -1494,8 +1387,8 @@ extension Connectrpc_Conformance_V1_UnimplementedRequest: SwiftProtobuf.Message, static let _protobuf_nameMap = SwiftProtobuf._NameMap() mutating func decodeMessage(decoder: inout D) throws { - while let _ = try decoder.nextFieldNumber() { - } + // Load everything into unknown fields + while try decoder.nextFieldNumber() != nil {} } func traverse(visitor: inout V) throws { @@ -1513,8 +1406,8 @@ extension Connectrpc_Conformance_V1_UnimplementedResponse: SwiftProtobuf.Message static let _protobuf_nameMap = SwiftProtobuf._NameMap() mutating func decodeMessage(decoder: inout D) throws { - while let _ = try decoder.nextFieldNumber() { - } + // Load everything into unknown fields + while try decoder.nextFieldNumber() != nil {} } func traverse(visitor: inout V) throws { diff --git a/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/suite.pb.swift b/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/suite.pb.swift index 603cfc28..15eea02f 100644 --- a/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/suite.pb.swift +++ b/Tests/UnitTests/ConnectLibraryTests/GeneratedSources/connectrpc/conformance/v1/suite.pb.swift @@ -1,5 +1,6 @@ // DO NOT EDIT. // swift-format-ignore-file +// swiftlint:disable all // // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: connectrpc/conformance/v1/suite.proto @@ -21,7 +22,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import Foundation import SwiftProtobuf // If the compiler emits an error on this type, it is because this file @@ -39,7 +39,7 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP /// suite, which can contain numerous cases. Each test suite has various properties /// that indicate the kinds of features that are tested. Test suites may be skipped /// based on whether the client or server under test implements these features. -struct Connectrpc_Conformance_V1_TestSuite { +struct Connectrpc_Conformance_V1_TestSuite: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -96,7 +96,7 @@ struct Connectrpc_Conformance_V1_TestSuite { var unknownFields = SwiftProtobuf.UnknownStorage() - enum TestMode: SwiftProtobuf.Enum { + enum TestMode: SwiftProtobuf.Enum, Swift.CaseIterable { typealias RawValue = Int /// Used when the test suite does not apply to a particular mode. Such tests @@ -137,9 +137,16 @@ struct Connectrpc_Conformance_V1_TestSuite { } } + // The compiler won't synthesize support with the UNRECOGNIZED case. + static let allCases: [Connectrpc_Conformance_V1_TestSuite.TestMode] = [ + .unspecified, + .client, + .server, + ] + } - enum ConnectVersionMode: SwiftProtobuf.Enum { + enum ConnectVersionMode: SwiftProtobuf.Enum, Swift.CaseIterable { typealias RawValue = Int /// Used when the suite is agnostic to the server's validation @@ -177,34 +184,19 @@ struct Connectrpc_Conformance_V1_TestSuite { } } + // The compiler won't synthesize support with the UNRECOGNIZED case. + static let allCases: [Connectrpc_Conformance_V1_TestSuite.ConnectVersionMode] = [ + .unspecified, + .require, + .ignore, + ] + } init() {} } -#if swift(>=4.2) - -extension Connectrpc_Conformance_V1_TestSuite.TestMode: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static let allCases: [Connectrpc_Conformance_V1_TestSuite.TestMode] = [ - .unspecified, - .client, - .server, - ] -} - -extension Connectrpc_Conformance_V1_TestSuite.ConnectVersionMode: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static let allCases: [Connectrpc_Conformance_V1_TestSuite.ConnectVersionMode] = [ - .unspecified, - .require, - .ignore, - ] -} - -#endif // swift(>=4.2) - -struct Connectrpc_Conformance_V1_TestCase { +struct Connectrpc_Conformance_V1_TestCase: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -276,7 +268,7 @@ struct Connectrpc_Conformance_V1_TestCase { var unknownFields = SwiftProtobuf.UnknownStorage() - struct ExpandedSize { + struct ExpandedSize: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -307,14 +299,6 @@ struct Connectrpc_Conformance_V1_TestCase { fileprivate var _expectedResponse: Connectrpc_Conformance_V1_ClientResponseResult? = nil } -#if swift(>=5.5) && canImport(_Concurrency) -extension Connectrpc_Conformance_V1_TestSuite: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_TestSuite.TestMode: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_TestSuite.ConnectVersionMode: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_TestCase: @unchecked Sendable {} -extension Connectrpc_Conformance_V1_TestCase.ExpandedSize: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - // MARK: - Code below here is support for the SwiftProtobuf runtime. fileprivate let _protobuf_package = "connectrpc.conformance.v1" diff --git a/Tests/UnitTests/ConnectLibraryTests/buf.gen.yaml b/Tests/UnitTests/ConnectLibraryTests/buf.gen.yaml index 4556dc37..260219ca 100644 --- a/Tests/UnitTests/ConnectLibraryTests/buf.gen.yaml +++ b/Tests/UnitTests/ConnectLibraryTests/buf.gen.yaml @@ -1,6 +1,6 @@ version: v1 plugins: - - plugin: buf.build/apple/swift:v1.25.2 + - plugin: buf.build/apple/swift:v1.28.2 opt: Visibility=Internal out: ./GeneratedSources - name: connect-swift