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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs \
csharp/src/Google.Protobuf.Test/JsonParserTest.cs \
csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs \
csharp/src/Google.Protobuf.Test/Proto3OptionalTest.cs \
csharp/src/Google.Protobuf.Test/Reflection/CustomOptionsTest.cs \
csharp/src/Google.Protobuf.Test/Reflection/DescriptorDeclarationTest.cs \
csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs \
Expand All @@ -148,6 +149,7 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf.Test.TestProtos/UnittestImport.cs \
csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.cs \
csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3.cs \
csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.cs \
csharp/src/Google.Protobuf.Test.TestProtos/UnittestWellKnownTypes.cs \
csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs \
csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs \
Expand Down
3 changes: 2 additions & 1 deletion csharp/generate_protos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ $PROTOC -Isrc -Icsharp/protos \
csharp/protos/unittest_issue6936_c.proto \
src/google/protobuf/unittest_well_known_types.proto \
src/google/protobuf/test_messages_proto3.proto \
src/google/protobuf/test_messages_proto2.proto
src/google/protobuf/test_messages_proto2.proto \
src/google/protobuf/unittest_proto3_optional.proto

# AddressBook sample protos
$PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \
Expand Down
144 changes: 72 additions & 72 deletions csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto2.cs

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15521,7 +15521,6 @@ public void MergeFrom(pb::CodedInputStream input) {
public sealed partial class TestOneof : pb::IMessage<TestOneof> {
private static readonly pb::MessageParser<TestOneof> _parser = new pb::MessageParser<TestOneof>(() => new TestOneof());
private pb::UnknownFieldSet _unknownFields;
private int _hasBits0;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<TestOneof> Parser { get { return _parser; } }

Expand All @@ -15544,7 +15543,6 @@ public TestOneof() {

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public TestOneof(TestOneof other) : this() {
_hasBits0 = other._hasBits0;
switch (other.FooCase) {
case FooOneofCase.FooInt:
FooInt = other.FooInt;
Expand Down Expand Up @@ -16934,21 +16932,21 @@ public void ClearBarEnum() {
private int bazInt_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int BazInt {
get { if ((_hasBits0 & 16) != 0) { return bazInt_; } else { return BazIntDefaultValue; } }
get { if ((_hasBits0 & 1) != 0) { return bazInt_; } else { return BazIntDefaultValue; } }
set {
_hasBits0 |= 16;
_hasBits0 |= 1;
bazInt_ = value;
}
}
/// <summary>Gets whether the "baz_int" field is set</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool HasBazInt {
get { return (_hasBits0 & 16) != 0; }
get { return (_hasBits0 & 1) != 0; }
}
/// <summary>Clears the value of the "baz_int" field</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void ClearBazInt() {
_hasBits0 &= ~16;
_hasBits0 &= ~1;
}

/// <summary>Field number for the "baz_string" field.</summary>
Expand Down Expand Up @@ -17767,7 +17765,6 @@ public void MergeFrom(pb::CodedInputStream input) {
public sealed partial class TestRequiredOneof : pb::IMessage<TestRequiredOneof> {
private static readonly pb::MessageParser<TestRequiredOneof> _parser = new pb::MessageParser<TestRequiredOneof>(() => new TestRequiredOneof());
private pb::UnknownFieldSet _unknownFields;
private int _hasBits0;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<TestRequiredOneof> Parser { get { return _parser; } }

Expand All @@ -17790,7 +17787,6 @@ public TestRequiredOneof() {

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public TestRequiredOneof(TestRequiredOneof other) : this() {
_hasBits0 = other._hasBits0;
switch (other.FooCase) {
case FooOneofCase.FooInt:
FooInt = other.FooInt;
Expand Down
Loading