-
Notifications
You must be signed in to change notification settings - Fork 15.7k
C#: add option and code generation for null reference types #16240
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
base: main
Are you sure you want to change the base?
Conversation
The code generated by this PR may be good enough - however to be able to change
|
@tonydnewell Sorry for not reviewing this for a while - is this now done and complete, ready for review and possible merging? |
It is ready. However my contract has now ended so I'll only be able to fix any problems on an ad hoc basis. |
Righto - if I spot anything, I could quite possibly fix it myself instead. Will attempt to find headspace to review this soon. Thanks! |
(It's actually much shorter than I'd have expected, so it might not be too hard to review after all...) |
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 this looks mostly fine - but I don't see anything to handle the wrapper types for string
and ByteString
. I think those properties would need to be nullable as well.
@tonydnewell is that a change you think you'd be able to get to in spare time, or would you like me to try to get this merged and then do a fast-follow change for that?
if (this->options()->enable_nullable_reference_types) { | ||
printer->Print( | ||
"#nullable enable annotations\n", | ||
"file_name", file_->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.
I don't think we need this line, as we're not using the file_name
variable anywhere. (It doesn't do any harm though, so we could merge and then fix.)
@@ -50,6 +51,9 @@ struct Options { | |||
bool serializable; | |||
// If true, strip out nonfunctional codegen. | |||
bool strip_nonfunctional_codegen; | |||
// Whether the generated files support null reference types. |
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.
Nit: extra space at start (could fix after merging).
@tonydnewell Is there anything I can do to help get traction on this? |
I suspect the next step is mine - it's a matter of finding the time. |
@JasonLunn I think we can close this one in favor of the extended one. If you want to keep it until the other is handled, I added close-keywords to my PR instead :) |
Yes let's keep this one open until the other merges. |
Marking this |
This replaces the abandoned #16240 and should address the open points mentioned. This will fix #6632 and close #16240 Closes #20242 COPYBARA_INTEGRATE_REVIEW=#20242 from Falco20019:csharp-nrt-option 538f02f FUTURE_COPYBARA_INTEGRATE_REVIEW=#20242 from Falco20019:csharp-nrt-option 538f02f PiperOrigin-RevId: 733464986
This replaces the closed PR #13218
It adds an option for generating C# code that handles null reference types.
See https://github.com/grpc/proposal/blob/master/L110-csharp-nullable-reference-types.md
Further work could be done to:
#nullable enable annotations
to#nullable enable
- but this requires further codegen changesGoogle.Protobuf.Reflection
API that doesn't yet handle null reference typesstring
andbytes
that use null to indicate presence