-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add deprecation annotations for RPCs marked "deprecated=true" #316
Conversation
Signed-off-by: Eddie Seay <[email protected]>
6be74d8
to
4ee7dcb
Compare
Signed-off-by: Eddie Seay <[email protected]>
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.
A couple in-context notes for y'all to look at as well @rebello95 @jhump. Thanks!
|
||
func callbackAvailabilityAnnotation() -> String? { | ||
if self.options.deprecated { | ||
// swiftlint:disable line_length |
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.
@rebello95 @jhump Let me know if this is acceptable. I use SwiftLint in my own repos as well, so I know the rules exist for a purpose; however, I may propose disabling this specific rule in this specific context to improve legibility in the editor and to more closely mimic what will actually be output at the time of generation.
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.
This seems fine to me, doing additional gymnastics would be a bit excessive 😉
func asyncAwaitAvailabilityAnnotation() -> String? { | ||
if self.options.deprecated { | ||
// swiftlint:disable:next line_length | ||
return "@available(iOS, introduced: 13, deprecated: 13, message: \"This function has been marked deprecated.\")" | ||
} else { | ||
return nil | ||
} | ||
} |
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.
This function signature and behavior differs from its sibling defined in ConnectClientGenerator
since the entire type is already annotated with an @available(iOS 13, *)
in the generated mock. Because of that existing annotation, we only need to produce something if in the case that it's more restrictive than the availability rules defined at the higher scope.
Yes, I think that would be great 👍🏽 thanks for flagging. |
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.
Thanks for implementing this!
|
||
func callbackAvailabilityAnnotation() -> String? { | ||
if self.options.deprecated { | ||
// swiftlint:disable line_length |
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.
This seems fine to me, doing additional gymnastics would be a bit excessive 😉
if self.options.deprecated { | ||
// swiftlint:disable line_length | ||
return """ | ||
@available(iOS, introduced: 12, deprecated: 12, message: "This function has been marked deprecated.") |
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.
Thoughts on changing these messages to "This RPC has been marked as deprecated in its .proto
file."?
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.
Even clearer - a good move in my book!
@@ -201,6 +207,30 @@ private extension MethodDescriptor { | |||
} | |||
} | |||
|
|||
func callbackAvailabilityAnnotation() -> String? { |
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.
I think all these helper functions can be private
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.
I left them without explicit access to align with the functions that were already there; however, I think we're good on not needing to specify access level since the enclosing extension private extension MethodDescriptor
is already marked.
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.
Ah didn't realize these were inside a private extension 👍🏽
Signed-off-by: Eddie Seay <[email protected]>
This enhances the
ConnectClientGenerator
to inspect thedeprecated
option and annotate the generated service functions accordingly.@available
annotation, which only exists for iOS, is adjusted accordingly to introduce and deprecate the function at v13, since that is when concurrency was first made available.@available
annotations for all supported platforms. The "introduced" and "deprecated" versions for those platforms were determined by the minimum supported version of the respective platform defined inPackage.swift
.Adding the following RPC...
...to the ElizaService defined in the examples-go repository, from which the Eliza sample app sources are generated, and regenerating the Swift service (setting
GenerateCallbackMethods=true
to also demonstrate callback behavior) yields the following result:The generated code for the existing
Say
RPC remains unchanged:The same additions have been made to the
ConnectMockGenerator
.Closes #305