From 24d36a02a8a420a13421c855cff234dcfd07270c Mon Sep 17 00:00:00 2001 From: George Barnett Date: Mon, 24 Aug 2020 13:44:38 +0100 Subject: [PATCH] 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 --- Sources/Examples/Echo/Model/echo.grpc.swift | 1 + Sources/Examples/HelloWorld/Model/helloworld.grpc.swift | 1 + Sources/Examples/RouteGuide/Model/route_guide.grpc.swift | 1 + Sources/protoc-gen-grpc-swift/Generator.swift | 1 + dev/codegen-tests/01-echo/golden/echo.grpc.swift | 1 + dev/codegen-tests/02-multifile/golden/a.grpc.swift | 1 + dev/codegen-tests/02-multifile/golden/b.grpc.swift | 1 + .../03-multifile-with-module-map/golden/a.grpc.swift | 1 + .../03-multifile-with-module-map/golden/b.grpc.swift | 1 + .../04-service-with-message-import/golden/service.grpc.swift | 1 + dev/codegen-tests/05-service-only/golden/test.grpc.swift | 1 + dev/codegen-tests/06-test-client-only/golden/test.grpc.swift | 1 + 12 files changed, 12 insertions(+) diff --git a/Sources/Examples/Echo/Model/echo.grpc.swift b/Sources/Examples/Echo/Model/echo.grpc.swift index b839b28ef..2e85e5eeb 100644 --- a/Sources/Examples/Echo/Model/echo.grpc.swift +++ b/Sources/Examples/Echo/Model/echo.grpc.swift @@ -22,6 +22,7 @@ // import GRPC import NIO +import SwiftProtobuf /// Usage: instantiate Echo_EchoClient, then call methods of this protocol to make API calls. diff --git a/Sources/Examples/HelloWorld/Model/helloworld.grpc.swift b/Sources/Examples/HelloWorld/Model/helloworld.grpc.swift index 3ca06cfb0..75e998398 100644 --- a/Sources/Examples/HelloWorld/Model/helloworld.grpc.swift +++ b/Sources/Examples/HelloWorld/Model/helloworld.grpc.swift @@ -22,6 +22,7 @@ // import GRPC import NIO +import SwiftProtobuf /// Usage: instantiate Helloworld_GreeterClient, then call methods of this protocol to make API calls. diff --git a/Sources/Examples/RouteGuide/Model/route_guide.grpc.swift b/Sources/Examples/RouteGuide/Model/route_guide.grpc.swift index 410588b22..890ee8195 100644 --- a/Sources/Examples/RouteGuide/Model/route_guide.grpc.swift +++ b/Sources/Examples/RouteGuide/Model/route_guide.grpc.swift @@ -22,6 +22,7 @@ // import GRPC import NIO +import SwiftProtobuf /// Usage: instantiate Routeguide_RouteGuideClient, then call methods of this protocol to make API calls. diff --git a/Sources/protoc-gen-grpc-swift/Generator.swift b/Sources/protoc-gen-grpc-swift/Generator.swift index 5d3cf5b33..78d798ca9 100644 --- a/Sources/protoc-gen-grpc-swift/Generator.swift +++ b/Sources/protoc-gen-grpc-swift/Generator.swift @@ -90,6 +90,7 @@ class Generator { let moduleNames = [ self.options.gRPCModuleName, "NIO", + "SwiftProtobuf", ] for moduleName in (moduleNames + self.options.extraModuleImports).sorted() { diff --git a/dev/codegen-tests/01-echo/golden/echo.grpc.swift b/dev/codegen-tests/01-echo/golden/echo.grpc.swift index fb41201c0..f8640482e 100644 --- a/dev/codegen-tests/01-echo/golden/echo.grpc.swift +++ b/dev/codegen-tests/01-echo/golden/echo.grpc.swift @@ -22,6 +22,7 @@ // import GRPC import NIO +import SwiftProtobuf /// Usage: instantiate Echo_EchoClient, then call methods of this protocol to make API calls. diff --git a/dev/codegen-tests/02-multifile/golden/a.grpc.swift b/dev/codegen-tests/02-multifile/golden/a.grpc.swift index f4d7cc2f3..1d6427cc9 100644 --- a/dev/codegen-tests/02-multifile/golden/a.grpc.swift +++ b/dev/codegen-tests/02-multifile/golden/a.grpc.swift @@ -22,6 +22,7 @@ // import GRPC import NIO +import SwiftProtobuf /// Usage: instantiate A_ServiceAClient, then call methods of this protocol to make API calls. diff --git a/dev/codegen-tests/02-multifile/golden/b.grpc.swift b/dev/codegen-tests/02-multifile/golden/b.grpc.swift index 1c64beb9e..85b3c3514 100644 --- a/dev/codegen-tests/02-multifile/golden/b.grpc.swift +++ b/dev/codegen-tests/02-multifile/golden/b.grpc.swift @@ -22,6 +22,7 @@ // import GRPC import NIO +import SwiftProtobuf /// Usage: instantiate B_ServiceBClient, then call methods of this protocol to make API calls. diff --git a/dev/codegen-tests/03-multifile-with-module-map/golden/a.grpc.swift b/dev/codegen-tests/03-multifile-with-module-map/golden/a.grpc.swift index ba430d2e9..83527fe3d 100644 --- a/dev/codegen-tests/03-multifile-with-module-map/golden/a.grpc.swift +++ b/dev/codegen-tests/03-multifile-with-module-map/golden/a.grpc.swift @@ -22,6 +22,7 @@ // import GRPC import NIO +import SwiftProtobuf import ModuleB diff --git a/dev/codegen-tests/03-multifile-with-module-map/golden/b.grpc.swift b/dev/codegen-tests/03-multifile-with-module-map/golden/b.grpc.swift index 1c64beb9e..85b3c3514 100644 --- a/dev/codegen-tests/03-multifile-with-module-map/golden/b.grpc.swift +++ b/dev/codegen-tests/03-multifile-with-module-map/golden/b.grpc.swift @@ -22,6 +22,7 @@ // import GRPC import NIO +import SwiftProtobuf /// Usage: instantiate B_ServiceBClient, then call methods of this protocol to make API calls. diff --git a/dev/codegen-tests/04-service-with-message-import/golden/service.grpc.swift b/dev/codegen-tests/04-service-with-message-import/golden/service.grpc.swift index 04e1d1e6f..de32722eb 100644 --- a/dev/codegen-tests/04-service-with-message-import/golden/service.grpc.swift +++ b/dev/codegen-tests/04-service-with-message-import/golden/service.grpc.swift @@ -22,6 +22,7 @@ // import GRPC import NIO +import SwiftProtobuf /// Usage: instantiate Codegentest_FooClient, then call methods of this protocol to make API calls. diff --git a/dev/codegen-tests/05-service-only/golden/test.grpc.swift b/dev/codegen-tests/05-service-only/golden/test.grpc.swift index 31edb4628..86e6168d4 100644 --- a/dev/codegen-tests/05-service-only/golden/test.grpc.swift +++ b/dev/codegen-tests/05-service-only/golden/test.grpc.swift @@ -22,6 +22,7 @@ // import GRPC import NIO +import SwiftProtobuf /// Usage: instantiate Codegentest_FooClient, then call methods of this protocol to make API calls. diff --git a/dev/codegen-tests/06-test-client-only/golden/test.grpc.swift b/dev/codegen-tests/06-test-client-only/golden/test.grpc.swift index f7af8fe23..065e0e70c 100644 --- a/dev/codegen-tests/06-test-client-only/golden/test.grpc.swift +++ b/dev/codegen-tests/06-test-client-only/golden/test.grpc.swift @@ -22,6 +22,7 @@ // import GRPC import NIO +import SwiftProtobuf internal final class Codegentest_FooTestClient: Codegentest_FooClientProtocol {