Browse Source

Import SwiftProtobuf in generated code (#952)

Motivation:

Generated code may rely on messages which ship with SwiftProtobuf, as
such we should always import SwiftProtobuf.

Modifications:

- Import SwiftProtobuf in codegen

Result:

Resolves #951
George Barnett 5 years ago
parent
commit
24d36a02a8

+ 1 - 0
Sources/Examples/Echo/Model/echo.grpc.swift

@@ -22,6 +22,7 @@
 //
 //
 import GRPC
 import GRPC
 import NIO
 import NIO
+import SwiftProtobuf
 
 
 
 
 /// Usage: instantiate Echo_EchoClient, then call methods of this protocol to make API calls.
 /// Usage: instantiate Echo_EchoClient, then call methods of this protocol to make API calls.

+ 1 - 0
Sources/Examples/HelloWorld/Model/helloworld.grpc.swift

@@ -22,6 +22,7 @@
 //
 //
 import GRPC
 import GRPC
 import NIO
 import NIO
+import SwiftProtobuf
 
 
 
 
 /// Usage: instantiate Helloworld_GreeterClient, then call methods of this protocol to make API calls.
 /// Usage: instantiate Helloworld_GreeterClient, then call methods of this protocol to make API calls.

+ 1 - 0
Sources/Examples/RouteGuide/Model/route_guide.grpc.swift

@@ -22,6 +22,7 @@
 //
 //
 import GRPC
 import GRPC
 import NIO
 import NIO
+import SwiftProtobuf
 
 
 
 
 /// Usage: instantiate Routeguide_RouteGuideClient, then call methods of this protocol to make API calls.
 /// Usage: instantiate Routeguide_RouteGuideClient, then call methods of this protocol to make API calls.

+ 1 - 0
Sources/protoc-gen-grpc-swift/Generator.swift

@@ -90,6 +90,7 @@ class Generator {
     let moduleNames = [
     let moduleNames = [
       self.options.gRPCModuleName,
       self.options.gRPCModuleName,
       "NIO",
       "NIO",
+      "SwiftProtobuf",
     ]
     ]
 
 
     for moduleName in (moduleNames + self.options.extraModuleImports).sorted() {
     for moduleName in (moduleNames + self.options.extraModuleImports).sorted() {

+ 1 - 0
dev/codegen-tests/01-echo/golden/echo.grpc.swift

@@ -22,6 +22,7 @@
 //
 //
 import GRPC
 import GRPC
 import NIO
 import NIO
+import SwiftProtobuf
 
 
 
 
 /// Usage: instantiate Echo_EchoClient, then call methods of this protocol to make API calls.
 /// Usage: instantiate Echo_EchoClient, then call methods of this protocol to make API calls.

+ 1 - 0
dev/codegen-tests/02-multifile/golden/a.grpc.swift

@@ -22,6 +22,7 @@
 //
 //
 import GRPC
 import GRPC
 import NIO
 import NIO
+import SwiftProtobuf
 
 
 
 
 /// Usage: instantiate A_ServiceAClient, then call methods of this protocol to make API calls.
 /// Usage: instantiate A_ServiceAClient, then call methods of this protocol to make API calls.

+ 1 - 0
dev/codegen-tests/02-multifile/golden/b.grpc.swift

@@ -22,6 +22,7 @@
 //
 //
 import GRPC
 import GRPC
 import NIO
 import NIO
+import SwiftProtobuf
 
 
 
 
 /// Usage: instantiate B_ServiceBClient, then call methods of this protocol to make API calls.
 /// Usage: instantiate B_ServiceBClient, then call methods of this protocol to make API calls.

+ 1 - 0
dev/codegen-tests/03-multifile-with-module-map/golden/a.grpc.swift

@@ -22,6 +22,7 @@
 //
 //
 import GRPC
 import GRPC
 import NIO
 import NIO
+import SwiftProtobuf
 import ModuleB
 import ModuleB
 
 
 
 

+ 1 - 0
dev/codegen-tests/03-multifile-with-module-map/golden/b.grpc.swift

@@ -22,6 +22,7 @@
 //
 //
 import GRPC
 import GRPC
 import NIO
 import NIO
+import SwiftProtobuf
 
 
 
 
 /// Usage: instantiate B_ServiceBClient, then call methods of this protocol to make API calls.
 /// Usage: instantiate B_ServiceBClient, then call methods of this protocol to make API calls.

+ 1 - 0
dev/codegen-tests/04-service-with-message-import/golden/service.grpc.swift

@@ -22,6 +22,7 @@
 //
 //
 import GRPC
 import GRPC
 import NIO
 import NIO
+import SwiftProtobuf
 
 
 
 
 /// Usage: instantiate Codegentest_FooClient, then call methods of this protocol to make API calls.
 /// Usage: instantiate Codegentest_FooClient, then call methods of this protocol to make API calls.

+ 1 - 0
dev/codegen-tests/05-service-only/golden/test.grpc.swift

@@ -22,6 +22,7 @@
 //
 //
 import GRPC
 import GRPC
 import NIO
 import NIO
+import SwiftProtobuf
 
 
 
 
 /// Usage: instantiate Codegentest_FooClient, then call methods of this protocol to make API calls.
 /// Usage: instantiate Codegentest_FooClient, then call methods of this protocol to make API calls.

+ 1 - 0
dev/codegen-tests/06-test-client-only/golden/test.grpc.swift

@@ -22,6 +22,7 @@
 //
 //
 import GRPC
 import GRPC
 import NIO
 import NIO
+import SwiftProtobuf
 
 
 
 
 internal final class Codegentest_FooTestClient: Codegentest_FooClientProtocol {
 internal final class Codegentest_FooTestClient: Codegentest_FooClientProtocol {