Skip to content
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 support for proto3 optional fields in C# #7382

Merged
merged 6 commits into from Apr 24, 2020

Commits on Apr 22, 2020

  1. Register that the C# compiler supports proto3 presence.

    (It doesn't yet, but will in the next commits...)
    jskeet committed Apr 22, 2020
    Copy the full SHA
    9f9b43e View commit details
    Browse the repository at this point in the history
  2. Support proto3 optional fields in the C# generator

    Most changes are:
    
    - Introducing new helpers of SupportsPresenceApi and RequiresPresenceBit. This allows calling code to be a lot clearer about what it's interested in.
    - Changing most previous IsProto2 calls to use one of the two new helper methods
    - Avoiding treating synthetic oneofs as regular ones
    - Some slight refactoring in csharp_primitive_field to avoid code duplication
    - Comments explaining what we want when, so the next maintainer doesn't need to do the detective work I did!
    
    This change deliberately doesn't modify the API surface of any
    existing code. The only change to previously-generated C# should be
    making presence bits more efficient in proto2.
    
    Once proto3 optional fields are supported, we can consider further
    changes to make the proto2 and proto3 generated API surface more
    consistent (e.g. adding presence API for message fields and oneofs).
    jskeet committed Apr 22, 2020
    Copy the full SHA
    d45e9f5 View commit details
    Browse the repository at this point in the history
  3. Regenerate C# code with the new generator, adding unittest_proto3_opt…

    …ional.proto
    
    The changes in the existing proto2 code are solely around presence bits. The new generator allocated presence bits more efficiently. (Previously bits were sometimes allocated but never used.)
    jskeet committed Apr 22, 2020
    Copy the full SHA
    1ec9f85 View commit details
    Browse the repository at this point in the history
  4. Add unit tests for proto3 optional fields

    (This isn't as exhaustive as it might be, but the behavior is basically the same as proto2 optional fields.)
    jskeet committed Apr 22, 2020
    Copy the full SHA
    c48cd64 View commit details
    Browse the repository at this point in the history

Commits on Apr 24, 2020

  1. Add reflection support for proto3 optional fields

    This is more involved than might be expected because the synthetic oneofs don't generate the properties we would usually expect to see.
    jskeet committed Apr 24, 2020
    Copy the full SHA
    00c7efa View commit details
    Browse the repository at this point in the history
  2. Add new files into Makefile.am

    jskeet committed Apr 24, 2020
    Copy the full SHA
    452a851 View commit details
    Browse the repository at this point in the history