From 1bf7624d13bd011b30ea14f3406510333ba26f29 Mon Sep 17 00:00:00 2001 From: Gus Cairo Date: Fri, 6 Sep 2024 15:47:54 +0100 Subject: [PATCH 1/5] Default UseAccessLevelOnImports to false --- Sources/protoc-gen-grpc-swift/Options.swift | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Sources/protoc-gen-grpc-swift/Options.swift b/Sources/protoc-gen-grpc-swift/Options.swift index 7c7077eff..2b0f96d46 100644 --- a/Sources/protoc-gen-grpc-swift/Options.swift +++ b/Sources/protoc-gen-grpc-swift/Options.swift @@ -74,16 +74,10 @@ struct GeneratorOptions { private(set) var gRPCModuleName = "GRPC" private(set) var swiftProtobufModuleName = "SwiftProtobuf" private(set) var generateReflectionData = false - #if compiler(>=6.0) private(set) var v2 = false #endif - - #if compiler(>=6.0) - private(set) var useAccessLevelOnImports = true - #else private(set) var useAccessLevelOnImports = false - #endif init(parameter: any CodeGeneratorParameter) throws { try self.init(pairs: parameter.parsedPairs) From ec7045791b8f8f8a11f258265448bcc80f78b6aa Mon Sep 17 00:00:00 2001 From: Gus Cairo Date: Fri, 6 Sep 2024 16:06:14 +0100 Subject: [PATCH 2/5] Regenerate --- Examples/v2/echo/Generated/echo.grpc.swift | 4 ++-- Examples/v2/hello-world/Generated/helloworld.grpc.swift | 4 ++-- Examples/v2/route-guide/Generated/route_guide.grpc.swift | 6 +++--- .../Generated/grpc_testing_benchmark_service.grpc.swift | 6 +++--- .../Generated/grpc_testing_worker_service.grpc.swift | 4 ++-- Tests/GRPCHTTP2TransportTests/Generated/control.grpc.swift | 6 +++--- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Examples/v2/echo/Generated/echo.grpc.swift b/Examples/v2/echo/Generated/echo.grpc.swift index 6c5f82d29..856ccc074 100644 --- a/Examples/v2/echo/Generated/echo.grpc.swift +++ b/Examples/v2/echo/Generated/echo.grpc.swift @@ -21,8 +21,8 @@ // For information on using the generated types, please see the documentation: // https://github.com/grpc/grpc-swift -internal import GRPCCore -internal import GRPCProtobuf +import GRPCCore +import GRPCProtobuf internal enum Echo_Echo { internal static let descriptor = GRPCCore.ServiceDescriptor.echo_Echo diff --git a/Examples/v2/hello-world/Generated/helloworld.grpc.swift b/Examples/v2/hello-world/Generated/helloworld.grpc.swift index 319c5e65e..0336b83ca 100644 --- a/Examples/v2/hello-world/Generated/helloworld.grpc.swift +++ b/Examples/v2/hello-world/Generated/helloworld.grpc.swift @@ -21,8 +21,8 @@ // For information on using the generated types, please see the documentation: // https://github.com/grpc/grpc-swift -internal import GRPCCore -internal import GRPCProtobuf +import GRPCCore +import GRPCProtobuf internal enum Helloworld_Greeter { internal static let descriptor = GRPCCore.ServiceDescriptor.helloworld_Greeter diff --git a/Examples/v2/route-guide/Generated/route_guide.grpc.swift b/Examples/v2/route-guide/Generated/route_guide.grpc.swift index e2fd21a5f..fd5b8b350 100644 --- a/Examples/v2/route-guide/Generated/route_guide.grpc.swift +++ b/Examples/v2/route-guide/Generated/route_guide.grpc.swift @@ -21,8 +21,8 @@ // For information on using the generated types, please see the documentation: // https://github.com/grpc/grpc-swift -internal import GRPCCore -internal import GRPCProtobuf +import GRPCCore +import GRPCProtobuf internal enum Routeguide_RouteGuide { internal static let descriptor = GRPCCore.ServiceDescriptor.routeguide_RouteGuide @@ -520,4 +520,4 @@ internal struct Routeguide_RouteGuideClient: Routeguide_RouteGuide.ClientProtoco handler: body ) } -} \ No newline at end of file +} diff --git a/Sources/performance-worker/Generated/grpc_testing_benchmark_service.grpc.swift b/Sources/performance-worker/Generated/grpc_testing_benchmark_service.grpc.swift index 47cbbeccb..90b79fcba 100644 --- a/Sources/performance-worker/Generated/grpc_testing_benchmark_service.grpc.swift +++ b/Sources/performance-worker/Generated/grpc_testing_benchmark_service.grpc.swift @@ -24,8 +24,8 @@ // For information on using the generated types, please see the documentation: // https://github.com/grpc/grpc-swift -internal import GRPCCore -internal import GRPCProtobuf +import GRPCCore +import GRPCProtobuf internal enum Grpc_Testing_BenchmarkService { internal static let descriptor = GRPCCore.ServiceDescriptor.grpc_testing_BenchmarkService @@ -551,4 +551,4 @@ internal struct Grpc_Testing_BenchmarkServiceClient: Grpc_Testing_BenchmarkServi handler: body ) } -} \ No newline at end of file +} diff --git a/Sources/performance-worker/Generated/grpc_testing_worker_service.grpc.swift b/Sources/performance-worker/Generated/grpc_testing_worker_service.grpc.swift index 467e2cdac..f1637253f 100644 --- a/Sources/performance-worker/Generated/grpc_testing_worker_service.grpc.swift +++ b/Sources/performance-worker/Generated/grpc_testing_worker_service.grpc.swift @@ -24,8 +24,8 @@ // For information on using the generated types, please see the documentation: // https://github.com/grpc/grpc-swift -internal import GRPCCore -internal import GRPCProtobuf +import GRPCCore +import GRPCProtobuf internal enum Grpc_Testing_WorkerService { internal static let descriptor = GRPCCore.ServiceDescriptor.grpc_testing_WorkerService diff --git a/Tests/GRPCHTTP2TransportTests/Generated/control.grpc.swift b/Tests/GRPCHTTP2TransportTests/Generated/control.grpc.swift index 6ec4497cf..d00d54964 100644 --- a/Tests/GRPCHTTP2TransportTests/Generated/control.grpc.swift +++ b/Tests/GRPCHTTP2TransportTests/Generated/control.grpc.swift @@ -22,8 +22,8 @@ // For information on using the generated types, please see the documentation: // https://github.com/grpc/grpc-swift -internal import GRPCCore -internal import GRPCProtobuf +import GRPCCore +import GRPCProtobuf internal enum Control { internal static let descriptor = GRPCCore.ServiceDescriptor.Control @@ -433,4 +433,4 @@ internal struct ControlClient: Control.ClientProtocol { handler: body ) } -} \ No newline at end of file +} From 295a8bd44d3d2b242f3653d99a864f3a611efd68 Mon Sep 17 00:00:00 2001 From: Gus Cairo Date: Fri, 6 Sep 2024 16:06:55 +0100 Subject: [PATCH 3/5] Disable InternalImportsByDefault on test and executable targets It doesn't make a lot of sense to specify access level modifiers on imports if the targets cannot be imported --- Examples/v2/echo/Subcommands/Collect.swift | 8 ++++---- Examples/v2/hello-world/HelloWorld.swift | 2 +- Examples/v2/hello-world/Subcommands/Greet.swift | 6 +++--- Examples/v2/hello-world/Subcommands/Serve.swift | 6 +++--- Package@swift-6.swift | 12 ++++-------- Sources/performance-worker/BenchmarkClient.swift | 8 ++++---- Sources/performance-worker/BenchmarkService.swift | 4 ++-- Sources/performance-worker/PerformanceWorker.swift | 10 +++++----- Sources/performance-worker/RPCStats.swift | 6 +++--- Tests/GRPCHTTP2TransportTests/ControlService.swift | 2 +- .../HTTP2TransportNIOPosixTests.swift | 10 +++++----- .../HTTP2TransportNIOTransportServicesTests.swift | 8 ++++---- .../HTTP2TransportTests.swift | 12 ++++++------ .../Test Utilities/HTTP2StatusCodeServer.swift | 10 +++++----- .../Test Utilities/XCTest+Utilities.swift | 2 +- Tests/GRPCHTTP2TransportTests/XCTestCase+Vsock.swift | 4 ++-- 16 files changed, 53 insertions(+), 57 deletions(-) diff --git a/Examples/v2/echo/Subcommands/Collect.swift b/Examples/v2/echo/Subcommands/Collect.swift index a617e83b9..63402e0c6 100644 --- a/Examples/v2/echo/Subcommands/Collect.swift +++ b/Examples/v2/echo/Subcommands/Collect.swift @@ -14,10 +14,10 @@ * limitations under the License. */ -internal import ArgumentParser -private import GRPCCore -private import GRPCHTTP2Core -private import GRPCHTTP2TransportNIOPosix +import ArgumentParser +import GRPCCore +import GRPCHTTP2Core +import GRPCHTTP2TransportNIOPosix @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) struct Collect: AsyncParsableCommand { diff --git a/Examples/v2/hello-world/HelloWorld.swift b/Examples/v2/hello-world/HelloWorld.swift index 1427fecd7..8d467670a 100644 --- a/Examples/v2/hello-world/HelloWorld.swift +++ b/Examples/v2/hello-world/HelloWorld.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -internal import ArgumentParser +import ArgumentParser @main @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) diff --git a/Examples/v2/hello-world/Subcommands/Greet.swift b/Examples/v2/hello-world/Subcommands/Greet.swift index 9d97bb517..aca973814 100644 --- a/Examples/v2/hello-world/Subcommands/Greet.swift +++ b/Examples/v2/hello-world/Subcommands/Greet.swift @@ -14,9 +14,9 @@ * limitations under the License. */ -internal import ArgumentParser -internal import GRPCHTTP2Transport -internal import GRPCProtobuf +import ArgumentParser +import GRPCHTTP2Transport +import GRPCProtobuf @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) struct Greet: AsyncParsableCommand { diff --git a/Examples/v2/hello-world/Subcommands/Serve.swift b/Examples/v2/hello-world/Subcommands/Serve.swift index 1d60c82d7..fe4e462ea 100644 --- a/Examples/v2/hello-world/Subcommands/Serve.swift +++ b/Examples/v2/hello-world/Subcommands/Serve.swift @@ -14,9 +14,9 @@ * limitations under the License. */ -internal import ArgumentParser -internal import GRPCHTTP2Transport -internal import GRPCProtobuf +import ArgumentParser +import GRPCHTTP2Transport +import GRPCProtobuf @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) struct Serve: AsyncParsableCommand { diff --git a/Package@swift-6.swift b/Package@swift-6.swift index 7b5b81394..04dee5de7 100644 --- a/Package@swift-6.swift +++ b/Package@swift-6.swift @@ -346,8 +346,7 @@ extension Target { ], swiftSettings: [ .swiftLanguageMode(.v6), - .enableUpcomingFeature("ExistentialAny"), - .enableUpcomingFeature("InternalImportsByDefault") + .enableUpcomingFeature("ExistentialAny") ] ) } @@ -710,8 +709,7 @@ extension Target { path: "Examples/v2/echo", swiftSettings: [ .swiftLanguageMode(.v6), - .enableUpcomingFeature("ExistentialAny"), - .enableUpcomingFeature("InternalImportsByDefault") + .enableUpcomingFeature("ExistentialAny") ] ) } @@ -773,8 +771,7 @@ extension Target { ], swiftSettings: [ .swiftLanguageMode(.v6), - .enableUpcomingFeature("ExistentialAny"), - .enableUpcomingFeature("InternalImportsByDefault") + .enableUpcomingFeature("ExistentialAny") ] ) } @@ -837,8 +834,7 @@ extension Target { ], swiftSettings: [ .swiftLanguageMode(.v6), - .enableUpcomingFeature("ExistentialAny"), - .enableUpcomingFeature("InternalImportsByDefault") + .enableUpcomingFeature("ExistentialAny") ] ) } diff --git a/Sources/performance-worker/BenchmarkClient.swift b/Sources/performance-worker/BenchmarkClient.swift index 3e1318b12..57afa894f 100644 --- a/Sources/performance-worker/BenchmarkClient.swift +++ b/Sources/performance-worker/BenchmarkClient.swift @@ -14,10 +14,10 @@ * limitations under the License. */ -private import Foundation -internal import GRPCCore -private import NIOConcurrencyHelpers -private import Synchronization +import Foundation +import GRPCCore +import NIOConcurrencyHelpers +import Synchronization @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) final class BenchmarkClient: Sendable { diff --git a/Sources/performance-worker/BenchmarkService.swift b/Sources/performance-worker/BenchmarkService.swift index 112b1f1f0..11631eaaf 100644 --- a/Sources/performance-worker/BenchmarkService.swift +++ b/Sources/performance-worker/BenchmarkService.swift @@ -14,8 +14,8 @@ * limitations under the License. */ -internal import GRPCCore -private import Synchronization +import GRPCCore +import Synchronization import struct Foundation.Data diff --git a/Sources/performance-worker/PerformanceWorker.swift b/Sources/performance-worker/PerformanceWorker.swift index e93bfca60..83c9f7e82 100644 --- a/Sources/performance-worker/PerformanceWorker.swift +++ b/Sources/performance-worker/PerformanceWorker.swift @@ -14,11 +14,11 @@ * limitations under the License. */ -internal import ArgumentParser -private import GRPCCore -private import GRPCHTTP2Core -private import GRPCHTTP2TransportNIOPosix -private import NIOPosix +import ArgumentParser +import GRPCCore +import GRPCHTTP2Core +import GRPCHTTP2TransportNIOPosix +import NIOPosix @main @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) diff --git a/Sources/performance-worker/RPCStats.swift b/Sources/performance-worker/RPCStats.swift index ef0703d9e..bc2bba74b 100644 --- a/Sources/performance-worker/RPCStats.swift +++ b/Sources/performance-worker/RPCStats.swift @@ -14,9 +14,9 @@ * limitations under the License. */ -private import Foundation -internal import GRPCCore -internal import NIOConcurrencyHelpers +import Foundation +import GRPCCore +import NIOConcurrencyHelpers /// Stores the real time latency histogram and error code count dictionary, /// for the RPCs made by a particular GRPCClient. It gets updated after diff --git a/Tests/GRPCHTTP2TransportTests/ControlService.swift b/Tests/GRPCHTTP2TransportTests/ControlService.swift index e9d5b322f..dfb83b132 100644 --- a/Tests/GRPCHTTP2TransportTests/ControlService.swift +++ b/Tests/GRPCHTTP2TransportTests/ControlService.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -internal import GRPCCore +import GRPCCore import struct Foundation.Data diff --git a/Tests/GRPCHTTP2TransportTests/HTTP2TransportNIOPosixTests.swift b/Tests/GRPCHTTP2TransportTests/HTTP2TransportNIOPosixTests.swift index 28bc49967..4f6993dde 100644 --- a/Tests/GRPCHTTP2TransportTests/HTTP2TransportNIOPosixTests.swift +++ b/Tests/GRPCHTTP2TransportTests/HTTP2TransportNIOPosixTests.swift @@ -14,13 +14,13 @@ * limitations under the License. */ -private import GRPCCore -private import GRPCHTTP2Core -private import GRPCHTTP2TransportNIOPosix -internal import XCTest +import GRPCCore +import GRPCHTTP2Core +import GRPCHTTP2TransportNIOPosix +import XCTest #if canImport(NIOSSL) -private import NIOSSL +import NIOSSL #endif @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) diff --git a/Tests/GRPCHTTP2TransportTests/HTTP2TransportNIOTransportServicesTests.swift b/Tests/GRPCHTTP2TransportTests/HTTP2TransportNIOTransportServicesTests.swift index be54c0890..8219540ec 100644 --- a/Tests/GRPCHTTP2TransportTests/HTTP2TransportNIOTransportServicesTests.swift +++ b/Tests/GRPCHTTP2TransportTests/HTTP2TransportNIOTransportServicesTests.swift @@ -15,10 +15,10 @@ */ #if canImport(Network) -private import GRPCCore -private import GRPCHTTP2Core -internal import GRPCHTTP2TransportNIOTransportServices -internal import XCTest +import GRPCCore +import GRPCHTTP2Core +import GRPCHTTP2TransportNIOTransportServices +import XCTest @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) final class HTTP2TransportNIOTransportServicesTests: XCTestCase { diff --git a/Tests/GRPCHTTP2TransportTests/HTTP2TransportTests.swift b/Tests/GRPCHTTP2TransportTests/HTTP2TransportTests.swift index b0652c2fe..2de224ffc 100644 --- a/Tests/GRPCHTTP2TransportTests/HTTP2TransportTests.swift +++ b/Tests/GRPCHTTP2TransportTests/HTTP2TransportTests.swift @@ -14,12 +14,12 @@ * limitations under the License. */ -internal import GRPCCore -private import GRPCHTTP2Core -private import GRPCHTTP2TransportNIOPosix -private import GRPCHTTP2TransportNIOTransportServices -private import GRPCProtobuf -internal import XCTest +import GRPCCore +import GRPCHTTP2Core +import GRPCHTTP2TransportNIOPosix +import GRPCHTTP2TransportNIOTransportServices +import GRPCProtobuf +import XCTest @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) final class HTTP2TransportTests: XCTestCase { diff --git a/Tests/GRPCHTTP2TransportTests/Test Utilities/HTTP2StatusCodeServer.swift b/Tests/GRPCHTTP2TransportTests/Test Utilities/HTTP2StatusCodeServer.swift index 3e1df197e..d4f6e00ee 100644 --- a/Tests/GRPCHTTP2TransportTests/Test Utilities/HTTP2StatusCodeServer.swift +++ b/Tests/GRPCHTTP2TransportTests/Test Utilities/HTTP2StatusCodeServer.swift @@ -14,11 +14,11 @@ * limitations under the License. */ -internal import GRPCHTTP2Core -private import NIOCore -private import NIOHPACK -private import NIOHTTP2 -private import NIOPosix +import GRPCHTTP2Core +import NIOCore +import NIOHPACK +import NIOHTTP2 +import NIOPosix /// An HTTP/2 test server which only responds to request headers by sending response headers and /// then closing. Each stream will be closed with the ":status" set to the value of the diff --git a/Tests/GRPCHTTP2TransportTests/Test Utilities/XCTest+Utilities.swift b/Tests/GRPCHTTP2TransportTests/Test Utilities/XCTest+Utilities.swift index 053065da4..3848388bc 100644 --- a/Tests/GRPCHTTP2TransportTests/Test Utilities/XCTest+Utilities.swift +++ b/Tests/GRPCHTTP2TransportTests/Test Utilities/XCTest+Utilities.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -private import XCTest +import XCTest func XCTAssertThrowsError( ofType: E.Type, diff --git a/Tests/GRPCHTTP2TransportTests/XCTestCase+Vsock.swift b/Tests/GRPCHTTP2TransportTests/XCTestCase+Vsock.swift index d66676c99..cb613fb63 100644 --- a/Tests/GRPCHTTP2TransportTests/XCTestCase+Vsock.swift +++ b/Tests/GRPCHTTP2TransportTests/XCTestCase+Vsock.swift @@ -14,8 +14,8 @@ * limitations under the License. */ -private import NIOPosix -internal import XCTest +import NIOPosix +import XCTest extension XCTestCase { func vsockAvailable() -> Bool { From ef63e34b94159e523f446c47748c1b23d902671e Mon Sep 17 00:00:00 2001 From: Gus Cairo Date: Fri, 6 Sep 2024 16:26:24 +0100 Subject: [PATCH 4/5] Formatting --- Examples/v2/route-guide/Generated/route_guide.grpc.swift | 2 +- .../Generated/grpc_testing_benchmark_service.grpc.swift | 2 +- Tests/GRPCHTTP2TransportTests/Generated/control.grpc.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/v2/route-guide/Generated/route_guide.grpc.swift b/Examples/v2/route-guide/Generated/route_guide.grpc.swift index fd5b8b350..cf7cb7182 100644 --- a/Examples/v2/route-guide/Generated/route_guide.grpc.swift +++ b/Examples/v2/route-guide/Generated/route_guide.grpc.swift @@ -520,4 +520,4 @@ internal struct Routeguide_RouteGuideClient: Routeguide_RouteGuide.ClientProtoco handler: body ) } -} +} \ No newline at end of file diff --git a/Sources/performance-worker/Generated/grpc_testing_benchmark_service.grpc.swift b/Sources/performance-worker/Generated/grpc_testing_benchmark_service.grpc.swift index 90b79fcba..663922d0b 100644 --- a/Sources/performance-worker/Generated/grpc_testing_benchmark_service.grpc.swift +++ b/Sources/performance-worker/Generated/grpc_testing_benchmark_service.grpc.swift @@ -551,4 +551,4 @@ internal struct Grpc_Testing_BenchmarkServiceClient: Grpc_Testing_BenchmarkServi handler: body ) } -} +} \ No newline at end of file diff --git a/Tests/GRPCHTTP2TransportTests/Generated/control.grpc.swift b/Tests/GRPCHTTP2TransportTests/Generated/control.grpc.swift index d00d54964..ebd5c8e76 100644 --- a/Tests/GRPCHTTP2TransportTests/Generated/control.grpc.swift +++ b/Tests/GRPCHTTP2TransportTests/Generated/control.grpc.swift @@ -433,4 +433,4 @@ internal struct ControlClient: Control.ClientProtocol { handler: body ) } -} +} \ No newline at end of file From 04dafe6d360821be4ffa7eee2236f674ad3f02d9 Mon Sep 17 00:00:00 2001 From: Gus Cairo Date: Mon, 9 Sep 2024 12:16:40 +0100 Subject: [PATCH 5/5] Fix tutorial --- .../Route-Guide/Resources/route-guide-sec03-step04-gen-grpc.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/Sources/GRPCCore/Documentation.docc/Tutorials/Route-Guide/Resources/route-guide-sec03-step04-gen-grpc.txt b/Sources/GRPCCore/Documentation.docc/Tutorials/Route-Guide/Resources/route-guide-sec03-step04-gen-grpc.txt index 1c084165e..ab2c22fd8 100644 --- a/Sources/GRPCCore/Documentation.docc/Tutorials/Route-Guide/Resources/route-guide-sec03-step04-gen-grpc.txt +++ b/Sources/GRPCCore/Documentation.docc/Tutorials/Route-Guide/Resources/route-guide-sec03-step04-gen-grpc.txt @@ -2,5 +2,4 @@ $ protoc --plugin=.build/debug/protoc-gen-grpc-swift \ -I Protos \ --grpc-swift_out=Sources/Generated \ --grpc-swift_opt=_V2=true \ - --grpc-swift_opt=UseAccessLevelOnImports=false \ Protos/route_guide.proto