-
Notifications
You must be signed in to change notification settings - Fork 435
[CodeGenLib] Typealias translator configuration for client and server #1750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CodeGenLib] Typealias translator configuration for client and server #1750
Conversation
… typealiases Motivation: The typealias translator should generate typealias for the client and server protocols only if the associated code (client/server code) will be generated as well. Also, at the moment the Typealias translator doesn't generate the ClientProtocol typealias. Modifications: - added a new initialiser for the TypealiasTranslator that sets the client and server property. - Based on the client and server properties' values the typealias translator generates or not the protocol typealiases. - created method gor client protocol typalias generation. - modified tests, so they include the client code. - added new tests for generating only client or server code. Result: The typealias translator will generate typealiases for client and server protocols only when the associated code is also generated, getting rid of the possibility of an error (when the protocol doesn't exist).
| let namespacedPrefix: String | ||
| if service.namespace.isEmpty { | ||
| namespacedPrefix = service.name | ||
| } else { | ||
| namespacedPrefix = "\(service.namespace)_\(service.name)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After merging the server code translator PR, I will use the service property from the extension to get the namespacedPrefix
| static let methods: [MethodDescriptor] = [] | ||
| typealias StreamingServiceProtocol = namespaceA_ServiceAServiceStreamingProtocol | ||
| typealias ServiceProtocol = namespaceA_ServiceAServiceProtocol | ||
| typealias ClientProtocol = namespaceA_ServiceAClientProtocol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add a typealias for the Client as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the struct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
…grpc#1750) Motivation: The typealias translator should generate typealias for the client and server protocols only if the associated code (client/server code) will be generated as well. Also, at the moment the Typealias translator doesn't generate the ClientProtocol typealias. Modifications: - added a new initialiser for the TypealiasTranslator that sets the client and server property. - Based on the client and server properties' values the typealias translator generates or not the protocol typealiases. - created method gor client protocol typalias generation. - modified tests, so they include the client code. - added new tests for generating only client or server code. Result: The typealias translator will generate typealiases for client and server protocols only when the associated code is also generated, getting rid of the possibility of an error (when the protocol doesn't exist).
Typealias translator configuration for client and server type aliases
Motivation:
The typealias translator should generate typealiases for the client and server protocols only if the associated code (client/server code) will be generated. Also, at the moment the typealias translator doesn't generate the
ClientProtocoltypealias.Modifications:
TypealiasTranslatorthat sets the client and server property.Result:
The typealias translator will generate typealiases for client and server protocols only when the associated code is also generated, getting rid of the possibility of an error (when the protocol doesn't exist).