diff --git a/IntegrationTests/PluginTests/Resources/Sources/Package.swift b/IntegrationTests/PluginTests/Resources/Sources/Package.swift index 8f4d107..f94d66a 100644 --- a/IntegrationTests/PluginTests/Resources/Sources/Package.swift +++ b/IntegrationTests/PluginTests/Resources/Sources/Package.swift @@ -29,7 +29,7 @@ let package = Package( dependencies: [ // Dependency on grpc-swift-protobuf to be added by setup-plugin-tests.sh script .package( - url: "https://github.com/grpc/grpc-swift.git", + url: "https://github.com/grpc/grpc-swift-2.git", from: "2.0.0" ) ], @@ -37,8 +37,8 @@ let package = Package( .executableTarget( name: "grpc-adopter", dependencies: [ - .product(name: "GRPCCore", package: "grpc-swift"), - .product(name: "GRPCInProcessTransport", package: "grpc-swift"), + .product(name: "GRPCCore", package: "grpc-swift-2"), + .product(name: "GRPCInProcessTransport", package: "grpc-swift-2"), .product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"), ], plugins: [ diff --git a/Package.swift b/Package.swift index 2337c52..e40056b 100644 --- a/Package.swift +++ b/Package.swift @@ -23,8 +23,8 @@ let products: [Product] = [ targets: ["GRPCProtobuf"] ), .executable( - name: "protoc-gen-grpc-swift", - targets: ["protoc-gen-grpc-swift"] + name: "protoc-gen-grpc-swift-2", + targets: ["protoc-gen-grpc-swift-2"] ), .plugin( name: "GRPCProtobufGenerator", @@ -38,8 +38,8 @@ let products: [Product] = [ let dependencies: [Package.Dependency] = [ .package( - url: "https://github.com/grpc/grpc-swift.git", - from: "2.2.1" + url: "https://github.com/grpc/grpc-swift-2.git", + from: "2.0.0" ), .package( url: "https://github.com/apple/swift-protobuf.git", @@ -49,12 +49,12 @@ let dependencies: [Package.Dependency] = [ // ------------------------------------------------------------------------------------------------- -// This adds some build settings which allow us to map "@available(gRPCSwiftProtobuf 1.x, *)" to +// This adds some build settings which allow us to map "@available(gRPCSwiftProtobuf 2.x, *)" to // the appropriate OS platforms. -let nextMinorVersion = 3 +let nextMinorVersion = 1 let availabilitySettings: [SwiftSetting] = (0 ... nextMinorVersion).map { minor in let name = "gRPCSwiftProtobuf" - let version = "1.\(minor)" + let version = "2.\(minor)" let platforms = "macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0" let setting = "AvailabilityMacro=\(name) \(version):\(platforms)" return .enableExperimentalFeature(setting) @@ -71,12 +71,12 @@ let defaultSwiftSettings: [SwiftSetting] = // ------------------------------------------------------------------------------------------------- var targets: [Target] = [ - // protoc plugin for grpc-swift + // protoc plugin for grpc-swift-2 .executableTarget( - name: "protoc-gen-grpc-swift", + name: "protoc-gen-grpc-swift-2", dependencies: [ .target(name: "GRPCProtobufCodeGen"), - .product(name: "GRPCCodeGen", package: "grpc-swift"), + .product(name: "GRPCCodeGen", package: "grpc-swift-2"), .product(name: "SwiftProtobuf", package: "swift-protobuf"), .product(name: "SwiftProtobufPluginLibrary", package: "swift-protobuf"), ], @@ -87,7 +87,7 @@ var targets: [Target] = [ .target( name: "GRPCProtobuf", dependencies: [ - .product(name: "GRPCCore", package: "grpc-swift"), + .product(name: "GRPCCore", package: "grpc-swift-2"), .product(name: "SwiftProtobuf", package: "swift-protobuf"), ], swiftSettings: defaultSwiftSettings @@ -96,18 +96,18 @@ var targets: [Target] = [ name: "GRPCProtobufTests", dependencies: [ .target(name: "GRPCProtobuf"), - .product(name: "GRPCCore", package: "grpc-swift"), - .product(name: "GRPCInProcessTransport", package: "grpc-swift"), + .product(name: "GRPCCore", package: "grpc-swift-2"), + .product(name: "GRPCInProcessTransport", package: "grpc-swift-2"), .product(name: "SwiftProtobuf", package: "swift-protobuf"), ], swiftSettings: defaultSwiftSettings ), - // Code generator library for protoc-gen-grpc-swift + // Code generator library for protoc-gen-grpc-swift-2 .target( name: "GRPCProtobufCodeGen", dependencies: [ - .product(name: "GRPCCodeGen", package: "grpc-swift"), + .product(name: "GRPCCodeGen", package: "grpc-swift-2"), .product(name: "SwiftProtobufPluginLibrary", package: "swift-protobuf"), ], swiftSettings: defaultSwiftSettings @@ -116,7 +116,7 @@ var targets: [Target] = [ name: "GRPCProtobufCodeGenTests", dependencies: [ .target(name: "GRPCProtobufCodeGen"), - .product(name: "GRPCCodeGen", package: "grpc-swift"), + .product(name: "GRPCCodeGen", package: "grpc-swift-2"), .product(name: "SwiftProtobuf", package: "swift-protobuf"), .product(name: "SwiftProtobufPluginLibrary", package: "swift-protobuf"), ], @@ -131,7 +131,7 @@ var targets: [Target] = [ name: "GRPCProtobufGenerator", capability: .buildTool(), dependencies: [ - .target(name: "protoc-gen-grpc-swift"), + .target(name: "protoc-gen-grpc-swift-2"), .product(name: "protoc-gen-swift", package: "swift-protobuf"), ] ), @@ -152,7 +152,7 @@ var targets: [Target] = [ ] ), dependencies: [ - .target(name: "protoc-gen-grpc-swift"), + .target(name: "protoc-gen-grpc-swift-2"), .product(name: "protoc-gen-swift", package: "swift-protobuf"), ], path: "Plugins/GRPCProtobufGeneratorCommand" @@ -196,7 +196,7 @@ if Context.buildCGRPCProtobuf { ) for target in targets { - if target.name == "protoc-gen-grpc-swift" { + if target.name == "protoc-gen-grpc-swift-2" { target.dependencies.append(.target(name: "CGRPCProtobuf")) } } diff --git a/Plugins/GRPCProtobufGenerator/Plugin.swift b/Plugins/GRPCProtobufGenerator/Plugin.swift index 107069a..885893c 100644 --- a/Plugins/GRPCProtobufGenerator/Plugin.swift +++ b/Plugins/GRPCProtobufGenerator/Plugin.swift @@ -70,7 +70,7 @@ struct GRPCProtobufGenerator { ) throws -> [Command] { let configs = try readConfigFiles(configFiles, pluginWorkDirectory: pluginWorkDirectory) - let protocGenGRPCSwiftPath = try tool("protoc-gen-grpc-swift").url + let protocGenGRPCSwiftPath = try tool("protoc-gen-grpc-swift-2").url let protocGenSwiftPath = try tool("protoc-gen-swift").url var commands: [Command] = [] @@ -165,16 +165,16 @@ extension [URL: GenerationConfig] { } } -/// Construct the command to invoke `protoc` with the `protoc-gen-grpc-swift` plugin. +/// Construct the command to invoke `protoc` with the `protoc-gen-grpc-swift-2` plugin. /// - Parameters: /// - inputFile: The input `.proto` file. /// - config: The config for this operation. /// - baseDirectoryPath: The root path to the source `.proto` files used as the reference for relative path naming schemes. /// - protoDirectoryPaths: The paths passed to `protoc` in which to look for imported proto files. /// - protocPath: The path to `protoc` -/// - protocGenGRPCSwiftPath: The path to `protoc-gen-grpc-swift`. +/// - protocGenGRPCSwiftPath: The path to `protoc-gen-grpc-swift-2`. /// - configFilePath: The path to the config file in use. -/// - Returns: The command to invoke `protoc` with the `protoc-gen-grpc-swift` plugin. +/// - Returns: The command to invoke `protoc` with the `protoc-gen-grpc-swift-2` plugin. func protocGenGRPCSwiftCommand( inputFile: URL, config: GenerationConfig, @@ -222,7 +222,7 @@ func protocGenGRPCSwiftCommand( /// - baseDirectoryPath: The root path to the source `.proto` files used as the reference for relative path naming schemes. /// - protoDirectoryPaths: The paths passed to `protoc` in which to look for imported proto files. /// - protocPath: The path to `protoc` -/// - protocGenSwiftPath: The path to `protoc-gen-grpc-swift`. +/// - protocGenSwiftPath: The path to `protoc-gen-grpc-swift-2`. /// - configFilePath: The path to the config file in use. /// - Returns: The command to invoke `protoc` with the `protoc-gen-swift` plugin. func protocGenSwiftCommand( @@ -266,7 +266,7 @@ func protocGenSwiftCommand( } /// Derive the expected output file path to match the behavior of the `protoc-gen-swift` -/// and `protoc-gen-grpc-swift` `protoc` plugins using the `PathToUnderscores` naming scheme. +/// and `protoc-gen-grpc-swift-2` `protoc` plugins using the `PathToUnderscores` naming scheme. /// /// This means the generated file for an input proto file called "foo/bar/baz.proto" will /// have the name "foo\_bar\_baz.proto". diff --git a/Plugins/GRPCProtobufGeneratorCommand/Plugin.swift b/Plugins/GRPCProtobufGeneratorCommand/Plugin.swift index 830174a..0c525d2 100644 --- a/Plugins/GRPCProtobufGeneratorCommand/Plugin.swift +++ b/Plugins/GRPCProtobufGeneratorCommand/Plugin.swift @@ -99,7 +99,7 @@ struct GRPCProtobufGeneratorCommandPlugin { let config = commandConfig.common let protocPath = try deriveProtocPath(using: config, tool: tool) - let protocGenGRPCSwiftPath = try tool("protoc-gen-grpc-swift").url + let protocGenGRPCSwiftPath = try tool("protoc-gen-grpc-swift-2").url let protocGenSwiftPath = try tool("protoc-gen-swift").url let outputDirectory = URL(fileURLWithPath: config.outputPath) @@ -111,7 +111,7 @@ struct GRPCProtobufGeneratorCommandPlugin { let inputFileURLs = inputFiles.map { URL(fileURLWithPath: $0) } - // MARK: protoc-gen-grpc-swift + // MARK: protoc-gen-grpc-swift-2 if config.clients || config.servers { let arguments = constructProtocGenGRPCSwiftArguments( config: config, diff --git a/Plugins/PluginsShared/PluginUtils.swift b/Plugins/PluginsShared/PluginUtils.swift index 046ab51..16fc416 100644 --- a/Plugins/PluginsShared/PluginUtils.swift +++ b/Plugins/PluginsShared/PluginUtils.swift @@ -73,15 +73,15 @@ func constructProtocGenSwiftArguments( return protocArgs } -/// Construct the arguments to be passed to `protoc` when invoking the `protoc-gen-grpc-swift` `protoc` plugin. +/// Construct the arguments to be passed to `protoc` when invoking the `protoc-gen-grpc-swift-2` `protoc` plugin. /// - Parameters: /// - config: The config for this operation. /// - fileNaming: The file naming scheme to be used. /// - inputFiles: The input `.proto` files. /// - protoDirectoryPaths: The directories in which `protoc` will look for imports. -/// - protocGenGRPCSwiftPath: The path to the `protoc-gen-grpc-swift` `protoc` plugin. +/// - protocGenGRPCSwiftPath: The path to the `protoc-gen-grpc-swift-2` `protoc` plugin. /// - outputDirectory: The directory in which generated source files are created. -/// - Returns: The constructed arguments to be passed to `protoc` when invoking the `protoc-gen-grpc-swift` `protoc` plugin. +/// - Returns: The constructed arguments to be passed to `protoc` when invoking the `protoc-gen-grpc-swift-2` `protoc` plugin. func constructProtocGenGRPCSwiftArguments( config: GenerationConfig, fileNaming: GenerationConfig.FileNaming?, diff --git a/README.md b/README.md index f306bb2..c831887 100644 --- a/README.md +++ b/README.md @@ -14,5 +14,5 @@ for [gRPC Swift][gh-grpc-swift-protobuf]. [gh-swift-protobuf]: https://github.com/apple/swift-protobuf [gh-grpc-swift-protobuf]: https://github.com/grpc/grpc-swift-protobuf -[spi-grpc-swift]: https://swiftpackageindex.com/grpc/grpc-swift/documentation +[spi-grpc-swift]: https://swiftpackageindex.com/grpc/grpc-swift-2/documentation [spi-grpc-swift-protobuf]: https://swiftpackageindex.com/grpc/grpc-swift-protobuf/documentation diff --git a/Sources/GRPCProtobuf/Coding.swift b/Sources/GRPCProtobuf/Coding.swift index 90d15ab..0333873 100644 --- a/Sources/GRPCProtobuf/Coding.swift +++ b/Sources/GRPCProtobuf/Coding.swift @@ -18,7 +18,7 @@ public import GRPCCore public import SwiftProtobuf /// Serializes a Protobuf message into a sequence of bytes. -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) public struct ProtobufSerializer: GRPCCore.MessageSerializer { public init() {} @@ -42,7 +42,7 @@ public struct ProtobufSerializer: GRPCCore.Messa } /// Deserializes a sequence of bytes into a Protobuf message. -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) public struct ProtobufDeserializer: GRPCCore.MessageDeserializer { public init() {} diff --git a/Sources/GRPCProtobuf/ContiguousBytesAdapter.swift b/Sources/GRPCProtobuf/ContiguousBytesAdapter.swift index 54df2f5..c2e5fc7 100644 --- a/Sources/GRPCProtobuf/ContiguousBytesAdapter.swift +++ b/Sources/GRPCProtobuf/ContiguousBytesAdapter.swift @@ -24,7 +24,7 @@ public import SwiftProtobuf // internal but @usableFromInline /// it'd require a dependency on Protobuf in the core package), and `GRPCContiguousBytes` can't /// refine `SwiftProtobufContiguousBytes` for the same reason. @usableFromInline -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) struct ContiguousBytesAdapter< Bytes: GRPCContiguousBytes >: GRPCContiguousBytes, SwiftProtobufContiguousBytes { diff --git a/Sources/GRPCProtobuf/Documentation.docc/Articles/API-stability-of-generated-code.md b/Sources/GRPCProtobuf/Documentation.docc/Articles/API-stability-of-generated-code.md index 17c0e82..21929db 100644 --- a/Sources/GRPCProtobuf/Documentation.docc/Articles/API-stability-of-generated-code.md +++ b/Sources/GRPCProtobuf/Documentation.docc/Articles/API-stability-of-generated-code.md @@ -9,7 +9,7 @@ The API of the generated code depends on three factors: - The contents of the source `.proto` file. - The options you use when generating the code. -- The code generator (the `protoc-gen-grpc-swift` plugin for `protoc`). +- The code generator (the `protoc-gen-grpc-swift-2` plugin for `protoc`). While this document applies specifically to the gRPC code generated and *not* code for messages used as inputs and outputs of each method, the concepts still @@ -73,6 +73,6 @@ option. As gRPC Swift is developed the generated code may need to rely on newer functionality from its runtime counterparts (`GRPCCore` and `GRPCProtobuf`). -This means that you should use the versions of `protoc-gen-grpc-swift` and +This means that you should use the versions of `protoc-gen-grpc-swift-2` and `protoc-gen-swift` resolved with your package rather than getting them from an out-of-band (such as `homebrew`). diff --git a/Sources/GRPCProtobuf/Documentation.docc/Articles/Generating-stubs.md b/Sources/GRPCProtobuf/Documentation.docc/Articles/Generating-stubs.md index a3ebecd..708c60a 100644 --- a/Sources/GRPCProtobuf/Documentation.docc/Articles/Generating-stubs.md +++ b/Sources/GRPCProtobuf/Documentation.docc/Articles/Generating-stubs.md @@ -87,7 +87,7 @@ The options do not need to be specified and each have default values. ‡ If you don't provide any import paths then the path to the configuration file will be used on a per-source-file basis. -Many of these options map to `protoc-gen-grpc-swift` and `protoc-gen-swift` options. +Many of these options map to `protoc-gen-grpc-swift-2` and `protoc-gen-swift` options. If you require greater flexibility you may specify more than one configuration file. Configuration files apply to all `.proto` files equal to or below it in the file hierarchy. A configuration file @@ -96,7 +96,7 @@ lower in the file hierarchy supersedes one above it. ### Using protoc The [`grpc-swift-protobuf`](https://github.com/grpc/grpc-swift-protobuf) package provides -`protoc-gen-grpc-swift`, a program which is a plugin for the Protocol Buffers compiler, `protoc`. +`protoc-gen-grpc-swift-2`, a program which is a plugin for the Protocol Buffers compiler, `protoc`. To generate gRPC stubs for your `.proto` files directly you must run the `protoc` command with the `--grpc-swift_out=` option: @@ -104,18 +104,18 @@ the `--grpc-swift_out=` option: protoc --grpc-swift_out=. my-service.proto ``` -> `protoc-gen-grpc-swift` only generates gRPC stubs, it doesn't generate messages. You must use +> `protoc-gen-grpc-swift-2` only generates gRPC stubs, it doesn't generate messages. You must use > `protoc-gen-swift` to generate messages in addition to gRPC Stubs. -The presence of `--grpc-swift_out` tells `protoc` to use the `protoc-gen-grpc-swift` plugin. By +The presence of `--grpc-swift_out` tells `protoc` to use the `protoc-gen-grpc-swift-2` plugin. By default it'll look for the plugin in your `PATH`. You can also specify the path to the plugin explicitly: ```console -protoc --plugin=/path/to/protoc-gen-grpc-swift --grpc-swift_out=. my-service.proto +protoc --plugin=/path/to/protoc-gen-grpc-swift-2 --grpc-swift_out=. my-service.proto ``` -You can also specify various option the `protoc-gen-grpc-swift` via `protoc` using +You can also specify various option the `protoc-gen-grpc-swift-2` via `protoc` using the `--grpc-swift_opt` argument: ```console @@ -164,14 +164,14 @@ times, where each value is a space delimited pair of platform and version, e.g. #### Building the protoc plugin -> The version of `protoc-gen-grpc-swift` you use mustn't be newer than the version of +> The version of `protoc-gen-grpc-swift-2` you use mustn't be newer than the version of > the `grpc-swift-protobuf` you're using. -If your package depends on `grpc-swift-protobuf` then you can get a copy of `protoc-gen-grpc-swift` +If your package depends on `grpc-swift-protobuf` then you can get a copy of `protoc-gen-grpc-swift-2` by building it directly: ```console -swift build --product protoc-gen-grpc-swift +swift build --product protoc-gen-grpc-swift-2 ``` This command will build the plugin into `.build/debug` directory. You can get the full path using diff --git a/Sources/GRPCProtobuf/Documentation.docc/Articles/Understanding-the-generated-code.md b/Sources/GRPCProtobuf/Documentation.docc/Articles/Understanding-the-generated-code.md index ae7dc59..05bcafb 100644 --- a/Sources/GRPCProtobuf/Documentation.docc/Articles/Understanding-the-generated-code.md +++ b/Sources/GRPCProtobuf/Documentation.docc/Articles/Understanding-the-generated-code.md @@ -1,12 +1,12 @@ # Understanding the generated code -Understand what code is generated by `protoc-gen-grpc-swift` from a `.proto` +Understand what code is generated by `protoc-gen-grpc-swift-2` from a `.proto` file and how to use it. ## Overview The gRPC Swift Protobuf package provides a plugin to the Protocol Buffers -Compiler (`protoc`) called `protoc-gen-grpc-swift`. The plugin is responsible +Compiler (`protoc`) called `protoc-gen-grpc-swift-2`. The plugin is responsible for generating the gRPC specific code for services defined in a `.proto` file. ### Package namespace diff --git a/Sources/GRPCProtobuf/Documentation.docc/Documentation.md b/Sources/GRPCProtobuf/Documentation.docc/Documentation.md index 047ed75..f0ccd83 100644 --- a/Sources/GRPCProtobuf/Documentation.docc/Documentation.md +++ b/Sources/GRPCProtobuf/Documentation.docc/Documentation.md @@ -7,7 +7,7 @@ A package integrating Swift Protobuf with gRPC Swift. This package provides three products: - ``GRPCProtobuf``, a module providing runtime serialization and deserialization components for [SwiftProtobuf](https://github.com/apple/swift-protobuf). -- `protoc-gen-grpc-swift`, an executable which is a plugin for `protoc`, the Protocol Buffers +- `protoc-gen-grpc-swift-2`, an executable which is a plugin for `protoc`, the Protocol Buffers compiler. An article describing how to generate gRPC Swift stubs using it is available with the `grpc-swift` documentation on the [Swift Package Index](https://swiftpackageindex.com/grpc/grpc-swift/documentation). diff --git a/Sources/GRPCProtobuf/Errors/ErrorDetails+AnyPacking.swift b/Sources/GRPCProtobuf/Errors/ErrorDetails+AnyPacking.swift index d3bd45c..03f607d 100644 --- a/Sources/GRPCProtobuf/Errors/ErrorDetails+AnyPacking.swift +++ b/Sources/GRPCProtobuf/Errors/ErrorDetails+AnyPacking.swift @@ -61,7 +61,7 @@ extension Google_Protobuf_Any { } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails { // Note: this type isn't packable into an 'Any' protobuf so doesn't conform // to 'GoogleProtobufAnyPackable' despite holding types which are packable. diff --git a/Sources/GRPCProtobuf/Errors/ErrorDetails+CustomStringConvertible.swift b/Sources/GRPCProtobuf/Errors/ErrorDetails+CustomStringConvertible.swift index daee37a..ee1ed3e 100644 --- a/Sources/GRPCProtobuf/Errors/ErrorDetails+CustomStringConvertible.swift +++ b/Sources/GRPCProtobuf/Errors/ErrorDetails+CustomStringConvertible.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails: CustomStringConvertible { public var description: String { switch self.wrapped { @@ -47,63 +47,63 @@ extension ErrorDetails: CustomStringConvertible { // Some errors use protobuf messages as their storage so the default description isn't // representative -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails.ErrorInfo: CustomStringConvertible { public var description: String { "\(Self.self)(reason: \"\(self.reason)\", domain: \"\(self.domain)\", metadata: \(self.metadata))" } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails.DebugInfo: CustomStringConvertible { public var description: String { "\(Self.self)(stack: \(self.stack), detail: \"\(self.detail)\")" } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails.QuotaFailure.Violation: CustomStringConvertible { public var description: String { "\(Self.self)(subject: \"\(self.subject)\", violationDescription: \"\(self.violationDescription)\")" } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails.PreconditionFailure.Violation: CustomStringConvertible { public var description: String { "\(Self.self)(subject: \"\(self.subject)\", type: \"\(self.type)\", violationDescription: \"\(self.violationDescription)\")" } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails.BadRequest.FieldViolation: CustomStringConvertible { public var description: String { "\(Self.self)(field: \"\(self.field)\", violationDescription: \"\(self.violationDescription)\")" } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails.RequestInfo: CustomStringConvertible { public var description: String { "\(Self.self)(requestID: \"\(self.requestID)\", servingData: \"\(self.servingData)\")" } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails.ResourceInfo: CustomStringConvertible { public var description: String { "\(Self.self)(name: \"\(self.name)\", owner: \"\(self.owner)\", type: \"\(self.type)\", errorDescription: \"\(self.errorDescription)\")" } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails.Help.Link: CustomStringConvertible { public var description: String { "\(Self.self)(url: \"\(self.url)\", linkDescription: \"\(self.linkDescription)\")" } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails.LocalizedMessage: CustomStringConvertible { public var description: String { "\(Self.self)(locale: \"\(self.locale)\", message: \"\(self.message)\")" diff --git a/Sources/GRPCProtobuf/Errors/ErrorDetails+Types.swift b/Sources/GRPCProtobuf/Errors/ErrorDetails+Types.swift index ba876d8..28ba92c 100644 --- a/Sources/GRPCProtobuf/Errors/ErrorDetails+Types.swift +++ b/Sources/GRPCProtobuf/Errors/ErrorDetails+Types.swift @@ -16,7 +16,7 @@ internal import SwiftProtobuf -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails { /// Describes the cause of the error with structured details. /// diff --git a/Sources/GRPCProtobuf/Errors/ErrorDetails.swift b/Sources/GRPCProtobuf/Errors/ErrorDetails.swift index 31bfcdb..28c3602 100644 --- a/Sources/GRPCProtobuf/Errors/ErrorDetails.swift +++ b/Sources/GRPCProtobuf/Errors/ErrorDetails.swift @@ -24,7 +24,7 @@ public import SwiftProtobuf /// /// This type also allows you to provide wrap your own error details up as an "Any" /// protobuf (`Google_Protobuf_Any`). -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) public struct ErrorDetails: Sendable, Hashable { enum Wrapped: Sendable, Hashable { case errorInfo(ErrorInfo) @@ -199,7 +199,7 @@ public struct ErrorDetails: Sendable, Hashable { } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails { /// Returns error info if set. public var errorInfo: ErrorInfo? { diff --git a/Sources/GRPCProtobuf/Errors/GoogleRPCStatus.swift b/Sources/GRPCProtobuf/Errors/GoogleRPCStatus.swift index 6df2d46..df1ee97 100644 --- a/Sources/GRPCProtobuf/Errors/GoogleRPCStatus.swift +++ b/Sources/GRPCProtobuf/Errors/GoogleRPCStatus.swift @@ -35,7 +35,7 @@ public import SwiftProtobuf /// > inserted into the metadata keyed by "grpc-status-details-bin". The value of the metadata is /// > the serialized bytes of a "google.rpc.Status" protocol buffers message containing the status /// > code, message, and details. -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) public struct GoogleRPCStatus: Error, Hashable { /// A code representing the high-level domain of the error. public var code: RPCError.Code @@ -74,7 +74,7 @@ public struct GoogleRPCStatus: Error, Hashable { } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension GoogleRPCStatus { /// Creates a new message by decoding the given `SwiftProtobufContiguousBytes` value /// containing a serialized message in Protocol Buffer binary format. @@ -135,7 +135,7 @@ extension GoogleRPCStatus { } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension GoogleRPCStatus: RPCErrorConvertible { public var rpcErrorCode: RPCError.Code { self.code } public var rpcErrorMessage: String { self.message } diff --git a/Sources/GRPCProtobuf/Errors/RPCError+GoogleRPCStatus.swift b/Sources/GRPCProtobuf/Errors/RPCError+GoogleRPCStatus.swift index 7a6e122..f0aeb88 100644 --- a/Sources/GRPCProtobuf/Errors/RPCError+GoogleRPCStatus.swift +++ b/Sources/GRPCProtobuf/Errors/RPCError+GoogleRPCStatus.swift @@ -17,12 +17,12 @@ public import GRPCCore internal import SwiftProtobuf -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension Metadata { static let statusDetailsBinKey = "grpc-status-details-bin" } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension RPCError { /// Unpack a ``GoogleRPCStatus`` error from the error metadata. /// diff --git a/Sources/GRPCProtobufCodeGen/ProtobufCodeGenParser.swift b/Sources/GRPCProtobufCodeGen/ProtobufCodeGenParser.swift index 6f61d76..dfddec6 100644 --- a/Sources/GRPCProtobufCodeGen/ProtobufCodeGenParser.swift +++ b/Sources/GRPCProtobufCodeGen/ProtobufCodeGenParser.swift @@ -32,7 +32,7 @@ internal import struct Foundation.IndexPath #endif /// Parses a ``FileDescriptor`` object into a ``CodeGenerationRequest`` object. -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) package struct ProtobufCodeGenParser { let extraModuleImports: [String] let protoToModuleMappings: ProtoFileToModuleMappings @@ -100,7 +100,7 @@ package struct ProtobufCodeGenParser { } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ProtobufCodeGenParser { fileprivate func codeDependencies(file: FileDescriptor) -> [Dependency] { guard file.services.count > 0 else { @@ -143,7 +143,7 @@ extension ProtobufCodeGenParser { } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension GRPCCodeGen.ServiceDescriptor { fileprivate init( descriptor: SwiftProtobufPluginLibrary.ServiceDescriptor, @@ -171,7 +171,7 @@ extension GRPCCodeGen.ServiceDescriptor { } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension GRPCCodeGen.MethodDescriptor { fileprivate init( descriptor: SwiftProtobufPluginLibrary.MethodDescriptor, diff --git a/Sources/GRPCProtobufCodeGen/ProtobufCodeGenerator.swift b/Sources/GRPCProtobufCodeGen/ProtobufCodeGenerator.swift index ef15404..5407928 100644 --- a/Sources/GRPCProtobufCodeGen/ProtobufCodeGenerator.swift +++ b/Sources/GRPCProtobufCodeGen/ProtobufCodeGenerator.swift @@ -17,7 +17,7 @@ package import GRPCCodeGen package import SwiftProtobufPluginLibrary -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) package struct ProtobufCodeGenerator { internal var config: ProtobufCodeGenerator.Config @@ -67,7 +67,7 @@ package struct ProtobufCodeGenerator { } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ProtobufCodeGenerator { package struct Config { package var accessLevel: GRPCCodeGen.CodeGenerator.Config.AccessLevel diff --git a/Sources/protoc-gen-grpc-swift/GenerateGRPC.swift b/Sources/protoc-gen-grpc-swift-2/GenerateGRPC.swift similarity index 98% rename from Sources/protoc-gen-grpc-swift/GenerateGRPC.swift rename to Sources/protoc-gen-grpc-swift-2/GenerateGRPC.swift index 2272e65..5d55e5f 100644 --- a/Sources/protoc-gen-grpc-swift/GenerateGRPC.swift +++ b/Sources/protoc-gen-grpc-swift-2/GenerateGRPC.swift @@ -26,7 +26,7 @@ import Foundation #endif @main -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) final class GenerateGRPC: SwiftProtobufPluginLibrary.CodeGenerator { var version: String? { Version.versionString @@ -82,7 +82,7 @@ final class GenerateGRPC: SwiftProtobufPluginLibrary.CodeGenerator { } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension GenerateGRPC { private func uniqueOutputFileName( fileDescriptor: FileDescriptor, diff --git a/Sources/protoc-gen-grpc-swift/Options.swift b/Sources/protoc-gen-grpc-swift-2/Options.swift similarity index 98% rename from Sources/protoc-gen-grpc-swift/Options.swift rename to Sources/protoc-gen-grpc-swift-2/Options.swift index f32f2e6..a068a53 100644 --- a/Sources/protoc-gen-grpc-swift/Options.swift +++ b/Sources/protoc-gen-grpc-swift-2/Options.swift @@ -48,7 +48,7 @@ enum FileNaming: String { case dropPath = "DropPath" } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) struct GeneratorOptions { private(set) var protoToModuleMappings = ProtoFileToModuleMappings() private(set) var fileNaming = FileNaming.fullPath @@ -192,7 +192,7 @@ struct GeneratorOptions { } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension String.SubSequence { func trimmingWhitespaceAndNewlines() -> String { let trimmedSuffix = self.drop(while: { $0.isNewline || $0.isWhitespace }) @@ -201,7 +201,7 @@ extension String.SubSequence { } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension GRPCCodeGen.CodeGenerator.Config.AccessLevel { fileprivate init?(protocOption value: String) { switch value { diff --git a/Sources/protoc-gen-grpc-swift/Version.swift b/Sources/protoc-gen-grpc-swift-2/Version.swift similarity index 100% rename from Sources/protoc-gen-grpc-swift/Version.swift rename to Sources/protoc-gen-grpc-swift-2/Version.swift diff --git a/Tests/GRPCProtobufCodeGenTests/ProtobufCodeGenParserTests.swift b/Tests/GRPCProtobufCodeGenTests/ProtobufCodeGenParserTests.swift index 13ee37e..4c31520 100644 --- a/Tests/GRPCProtobufCodeGenTests/ProtobufCodeGenParserTests.swift +++ b/Tests/GRPCProtobufCodeGenTests/ProtobufCodeGenParserTests.swift @@ -27,7 +27,7 @@ struct ProtobufCodeGenParserTests { static let descriptorSetName = "test-service" static let fileDescriptorName = "test-service" - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) var codeGen: CodeGenerationRequest { get throws { let descriptor = try Self.fileDescriptor @@ -36,13 +36,13 @@ struct ProtobufCodeGenParserTests { } @Test("Filename") - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func fileName() throws { #expect(try self.codeGen.fileName == "test-service.proto") } @Test("Leading trivia") - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func leadingTrivia() throws { let expected = """ /// Leading trivia. @@ -63,7 +63,7 @@ struct ProtobufCodeGenParserTests { } @Test("Dependencies") - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func dependencies() throws { let expected: [GRPCCodeGen.Dependency] = [ .init(module: "GRPCProtobuf", accessLevel: .internal), // Always an internal import @@ -74,7 +74,7 @@ struct ProtobufCodeGenParserTests { @Suite("Service") struct Service { - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) var service: GRPCCodeGen.ServiceDescriptor { get throws { let request = try parseDescriptor(try TestService.fileDescriptor) @@ -84,14 +84,14 @@ struct ProtobufCodeGenParserTests { } @Test("Name") - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func name() throws { #expect(try self.service.name.identifyingName == "test.TestService") } @Suite("Methods") struct Methods { - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) var service: GRPCCodeGen.ServiceDescriptor { get throws { let request = try parseDescriptor(try TestService.fileDescriptor) @@ -100,25 +100,25 @@ struct ProtobufCodeGenParserTests { } } - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) var unary: GRPCCodeGen.MethodDescriptor { get throws { try self.service.methods[0] } } - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) var clientStreaming: GRPCCodeGen.MethodDescriptor { get throws { try self.service.methods[1] } } - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) var serverStreaming: GRPCCodeGen.MethodDescriptor { get throws { try self.service.methods[2] } } - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) var bidiStreaming: GRPCCodeGen.MethodDescriptor { get throws { try self.service.methods[3] } } @Test("Documentation") - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func documentation() throws { #expect(try self.unary.documentation == "/// Unary docs.\n") #expect(try self.clientStreaming.documentation == "/// Client streaming docs.\n") @@ -127,7 +127,7 @@ struct ProtobufCodeGenParserTests { } @Test("Name") - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func name() throws { try #expect(self.unary.name.identifyingName == "Unary") try #expect(self.clientStreaming.name.identifyingName == "ClientStreaming") @@ -136,7 +136,7 @@ struct ProtobufCodeGenParserTests { } @Test("Input") - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func input() throws { #expect(try self.unary.inputType == "Test_TestInput") #expect(try !self.unary.isInputStreaming) @@ -152,7 +152,7 @@ struct ProtobufCodeGenParserTests { } @Test("Output") - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func output() throws { #expect(try self.unary.outputType == "Test_TestOutput") #expect(try !self.unary.isOutputStreaming) @@ -175,7 +175,7 @@ struct ProtobufCodeGenParserTests { static let descriptorSetName = "foo-service" static let fileDescriptorName = "foo-service" - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) var codeGen: CodeGenerationRequest { get throws { let descriptor = try Self.fileDescriptor @@ -184,13 +184,13 @@ struct ProtobufCodeGenParserTests { } @Test("Name") - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func name() throws { #expect(try self.codeGen.fileName == "foo-service.proto") } @Test("Dependencies") - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func dependencies() throws { let expected: [GRPCCodeGen.Dependency] = [ .init(module: "GRPCProtobuf", accessLevel: .internal) // Always an internal import @@ -199,7 +199,7 @@ struct ProtobufCodeGenParserTests { } @Test("Service1") - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func service1() throws { let service = try self.codeGen.services[0] #expect(service.name.identifyingName == "foo.FooService1") @@ -207,7 +207,7 @@ struct ProtobufCodeGenParserTests { } @Test("Service1.Method") - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func service1Method() throws { let method = try self.codeGen.services[0].methods[0] #expect(method.name.identifyingName == "Foo") @@ -216,7 +216,7 @@ struct ProtobufCodeGenParserTests { } @Test("Service2") - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func service2() throws { let service = try self.codeGen.services[1] #expect(service.name.identifyingName == "foo.FooService2") @@ -224,7 +224,7 @@ struct ProtobufCodeGenParserTests { } @Test("Service2.Method") - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func service2Method() throws { let method = try self.codeGen.services[1].methods[0] #expect(method.name.identifyingName == "Foo") @@ -239,7 +239,7 @@ struct ProtobufCodeGenParserTests { static var fileDescriptorName: String { "bar-service" } @Test("Service name") - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func serviceName() throws { let descriptor = try Self.fileDescriptor let codeGen = try parseDescriptor(descriptor) @@ -255,7 +255,7 @@ struct ProtobufCodeGenParserTests { static let fileDescriptorName = "wkt-service" @Test("Dependencies") - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func dependencies() throws { let descriptor = try Self.fileDescriptor let codeGen = try parseDescriptor(descriptor) diff --git a/Tests/GRPCProtobufCodeGenTests/ProtobufCodeGeneratorTests.swift b/Tests/GRPCProtobufCodeGenTests/ProtobufCodeGeneratorTests.swift index 414dd5f..c4fdc62 100644 --- a/Tests/GRPCProtobufCodeGenTests/ProtobufCodeGeneratorTests.swift +++ b/Tests/GRPCProtobufCodeGenTests/ProtobufCodeGeneratorTests.swift @@ -48,7 +48,7 @@ struct ProtobufCodeGeneratorTests { } } - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) @Test( "Generate", arguments: [CodeGenerator.Config.AccessLevel.internal], @@ -1104,7 +1104,7 @@ struct ProtobufCodeGeneratorTests { } @Test("Generate with different module names") - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func generateWithDifferentModuleNames() throws { var config = ProtobufCodeGenerator.Config.defaults let defaultNames = config.moduleNames @@ -1140,7 +1140,7 @@ struct ProtobufCodeGeneratorTests { static let fileDescriptorName = "foo-messages" @Test("Generate") - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func generate() throws { var config: ProtobufCodeGenerator.Config = .defaults config.accessLevel = .public diff --git a/Tests/GRPCProtobufCodeGenTests/Utilities.swift b/Tests/GRPCProtobufCodeGenTests/Utilities.swift index b8c617a..c880f24 100644 --- a/Tests/GRPCProtobufCodeGenTests/Utilities.swift +++ b/Tests/GRPCProtobufCodeGenTests/Utilities.swift @@ -68,7 +68,7 @@ private func loadDescriptorSet( return DescriptorSet(proto: descriptorSet) } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) func parseDescriptor( _ descriptor: FileDescriptor, extraModuleImports: [String] = [], diff --git a/Tests/GRPCProtobufTests/Errors/DetailedErrorTests.swift b/Tests/GRPCProtobufTests/Errors/DetailedErrorTests.swift index c9a77da..1c9e3dc 100644 --- a/Tests/GRPCProtobufTests/Errors/DetailedErrorTests.swift +++ b/Tests/GRPCProtobufTests/Errors/DetailedErrorTests.swift @@ -40,7 +40,7 @@ struct DetailedErrorTests { (["Help", "Help", "Help"], [.help(.testValue), .help(.testValue), .help(.testValue)]), ] as [([String], [ErrorDetails])] ) - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func rpcStatus(details: [String], expected: [ErrorDetails]) async throws { let inProcess = InProcessTransport() try await withGRPCServer(transport: inProcess.server, services: [ErrorThrowingService()]) { _ in @@ -96,13 +96,13 @@ struct DetailedErrorTests { (.localizedMessage(.testValue), #"LocalizedMessage(locale: "l", message: "m")"#), ] as [(ErrorDetails, String)] ) - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func errorInfoDescription(_ details: ErrorDetails, expected: String) { #expect(String(describing: details) == expected) } @Test("Round-trip encoding of GoogleRPCStatus") - @available(gRPCSwiftProtobuf 1.0, *) + @available(gRPCSwiftProtobuf 2.0, *) func googleRPCStatusRoundTripCoding() throws { let detail = ErrorDetails.BadRequest(violations: [.init(field: "foo", description: "bar")]) let status = GoogleRPCStatus(code: .dataLoss, message: "Uh oh", details: [.badRequest(detail)]) @@ -116,7 +116,7 @@ struct DetailedErrorTests { } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) private struct ErrorThrowingService: ErrorService.SimpleServiceProtocol { func throwError( request: ThrowInput, @@ -187,17 +187,17 @@ private struct ErrorThrowingService: ErrorService.SimpleServiceProtocol { } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails.ErrorInfo { fileprivate static let testValue = Self(reason: "r", domain: "d", metadata: ["k": "v"]) } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails.RetryInfo { fileprivate static let testValue = Self(delay: .seconds(1)) } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails.DebugInfo { fileprivate static let testValue = Self( stack: ["foo.foo()", "foo.bar()"], @@ -205,7 +205,7 @@ extension ErrorDetails.DebugInfo { ) } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails.QuotaFailure { fileprivate static let testValue = Self( violations: [ @@ -214,7 +214,7 @@ extension ErrorDetails.QuotaFailure { ) } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails.PreconditionFailure { fileprivate static let testValue = Self( violations: [ @@ -223,7 +223,7 @@ extension ErrorDetails.PreconditionFailure { ) } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails.BadRequest { fileprivate static let testValue = Self( violations: [ @@ -232,17 +232,17 @@ extension ErrorDetails.BadRequest { ) } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails.RequestInfo { fileprivate static let testValue = Self(requestID: "id", servingData: "d") } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails.ResourceInfo { fileprivate static let testValue = Self(type: "t", name: "n", errorDescription: "d") } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails.Help { fileprivate static let testValue = Self( links: [ @@ -251,7 +251,7 @@ extension ErrorDetails.Help { ) } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorDetails.LocalizedMessage { fileprivate static let testValue = Self(locale: "l", message: "m") } diff --git a/Tests/GRPCProtobufTests/Errors/Generated/error-service.grpc.swift b/Tests/GRPCProtobufTests/Errors/Generated/error-service.grpc.swift index c675a71..dbad7e2 100644 --- a/Tests/GRPCProtobufTests/Errors/Generated/error-service.grpc.swift +++ b/Tests/GRPCProtobufTests/Errors/Generated/error-service.grpc.swift @@ -30,7 +30,7 @@ internal import SwiftProtobuf // MARK: - ErrorService /// Namespace containing generated types for the "ErrorService" service. -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) internal enum ErrorService { /// Service descriptor for the "ErrorService" service. internal static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "ErrorService") @@ -55,7 +55,7 @@ internal enum ErrorService { } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension GRPCCore.ServiceDescriptor { /// Service descriptor for the "ErrorService" service. internal static let ErrorService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "ErrorService") @@ -63,7 +63,7 @@ extension GRPCCore.ServiceDescriptor { // MARK: ErrorService (server) -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorService { /// Streaming variant of the service protocol for the "ErrorService" service. /// @@ -137,7 +137,7 @@ extension ErrorService { } // Default implementation of 'registerMethods(with:)'. -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorService.StreamingServiceProtocol { internal func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport { router.registerHandler( @@ -155,7 +155,7 @@ extension ErrorService.StreamingServiceProtocol { } // Default implementation of streaming methods from 'StreamingServiceProtocol'. -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorService.ServiceProtocol { internal func throwError( request: GRPCCore.StreamingServerRequest, @@ -170,7 +170,7 @@ extension ErrorService.ServiceProtocol { } // Default implementation of methods from 'ServiceProtocol'. -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorService.SimpleServiceProtocol { internal func throwError( request: GRPCCore.ServerRequest, @@ -188,7 +188,7 @@ extension ErrorService.SimpleServiceProtocol { // MARK: ErrorService (client) -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorService { /// Generated client protocol for the "ErrorService" service. /// @@ -264,7 +264,7 @@ extension ErrorService { } // Helpers providing default arguments to 'ClientProtocol' methods. -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorService.ClientProtocol { /// Call the "ThrowError" method. /// @@ -293,7 +293,7 @@ extension ErrorService.ClientProtocol { } // Helpers providing sugared APIs for 'ClientProtocol' methods. -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) extension ErrorService.ClientProtocol { /// Call the "ThrowError" method. /// diff --git a/Tests/GRPCProtobufTests/ProtobufCodingTests.swift b/Tests/GRPCProtobufTests/ProtobufCodingTests.swift index 9306238..d52895c 100644 --- a/Tests/GRPCProtobufTests/ProtobufCodingTests.swift +++ b/Tests/GRPCProtobufTests/ProtobufCodingTests.swift @@ -19,7 +19,7 @@ import GRPCProtobuf import SwiftProtobuf import XCTest -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) final class ProtobufCodingTests: XCTestCase { func testSerializeDeserializeRoundtrip() throws { let message = Google_Protobuf_Timestamp.with { @@ -74,7 +74,7 @@ final class ProtobufCodingTests: XCTestCase { } } -@available(gRPCSwiftProtobuf 1.0, *) +@available(gRPCSwiftProtobuf 2.0, *) struct TestMessage: SwiftProtobuf.Message { var text: String = "" var unknownFields = SwiftProtobuf.UnknownStorage() diff --git a/dev/protos/generate.sh b/dev/protos/generate.sh index 5af02e8..a8cf06d 100755 --- a/dev/protos/generate.sh +++ b/dev/protos/generate.sh @@ -21,12 +21,12 @@ protoc=$(which protoc) # Checkout and build the plugins. swift build --package-path "$root" --product protoc-gen-swift -swift build --package-path "$root" --product protoc-gen-grpc-swift +swift build --package-path "$root" --product protoc-gen-grpc-swift-2 # Grab the plugin paths. bin_path=$(swift build --package-path "$root" --show-bin-path) protoc_gen_swift="$bin_path/protoc-gen-swift" -protoc_gen_grpc_swift="$bin_path/protoc-gen-grpc-swift" +protoc_gen_grpc_swift="$bin_path/protoc-gen-grpc-swift-2" # Generates gRPC by invoking protoc with the gRPC Swift plugin. # Parameters: @@ -36,10 +36,10 @@ protoc_gen_grpc_swift="$bin_path/protoc-gen-grpc-swift" # - $4 onwards: options to forward to the plugin function generate_grpc { local proto=$1 - local args=("--plugin=$protoc_gen_grpc_swift" "--proto_path=${2}" "--grpc-swift_out=${3}") + local args=("--plugin=$protoc_gen_grpc_swift" "--proto_path=${2}" "--grpc-swift-2_out=${3}") for option in "${@:4}"; do - args+=("--grpc-swift_opt=$option") + args+=("--grpc-swift-2_opt=$option") done invoke_protoc "${args[@]}" "$proto" @@ -94,7 +94,7 @@ function generate_error_service { output="$root/Tests/GRPCProtobufTests/Errors/Generated" generate_message "$proto" "$(dirname "$proto")" "$output" "Visibility=Internal" "UseAccessLevelOnImports=true" - generate_grpc "$proto" "$(dirname "$proto")" "$output" "Visibility=Internal" "UseAccessLevelOnImports=true" "Availability=gRPCSwiftProtobuf 1.0" + generate_grpc "$proto" "$(dirname "$proto")" "$output" "Visibility=Internal" "UseAccessLevelOnImports=true" "Availability=gRPCSwiftProtobuf 2.0" } #- DESCRIPTOR SETS ------------------------------------------------------------