Skip to content

[C#] Adding Clear mechanism to IMessage #21472

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
34 changes: 34 additions & 0 deletions csharp/src/AddressBook/Addressbook.pb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ public Person Clone() {
return new Person(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void Clear() {
name_ = "";
id_ = 0;
email_ = "";
phones_.Clear();
if (lastUpdated_ != null) {
lastUpdated_.Clear();
}
if (_unknownFields != null) {
_unknownFields.Clear();
}
}

/// <summary>Field number for the "name" field.</summary>
public const int NameFieldNumber = 1;
private string name_ = "";
Expand Down Expand Up @@ -452,6 +467,16 @@ public PhoneNumber Clone() {
return new PhoneNumber(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void Clear() {
number_ = "";
type_ = global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.Mobile;
if (_unknownFields != null) {
_unknownFields.Clear();
}
}

/// <summary>Field number for the "number" field.</summary>
public const int NumberFieldNumber = 1;
private string number_ = "";
Expand Down Expand Up @@ -694,6 +719,15 @@ public AddressBook Clone() {
return new AddressBook(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void Clear() {
people_.Clear();
if (_unknownFields != null) {
_unknownFields.Clear();
}
}

/// <summary>Field number for the "people" field.</summary>
public const int PeopleFieldNumber = 1;
private static readonly pb::FieldCodec<global::Google.Protobuf.Examples.AddressBook.Person> _repeated_people_codec
Expand Down
56 changes: 56 additions & 0 deletions csharp/src/Google.Protobuf.Conformance/Conformance.pb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,17 @@ public TestStatus Clone() {
return new TestStatus(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void Clear() {
name_ = "";
failureMessage_ = "";
matchedName_ = "";
if (_unknownFields != null) {
_unknownFields.Clear();
}
}

/// <summary>Field number for the "name" field.</summary>
public const int NameFieldNumber = 1;
private string name_ = "";
Expand Down Expand Up @@ -439,6 +450,15 @@ public FailureSet Clone() {
return new FailureSet(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void Clear() {
test_.Clear();
if (_unknownFields != null) {
_unknownFields.Clear();
}
}

/// <summary>Field number for the "test" field.</summary>
public const int TestFieldNumber = 2;
private static readonly pb::FieldCodec<global::Conformance.TestStatus> _repeated_test_codec
Expand Down Expand Up @@ -652,6 +672,23 @@ public ConformanceRequest Clone() {
return new ConformanceRequest(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void Clear() {
requestedOutputFormat_ = global::Conformance.WireFormat.Unspecified;
messageType_ = "";
testCategory_ = global::Conformance.TestCategory.UnspecifiedTest;
if (jspbEncodingOptions_ != null) {
jspbEncodingOptions_.Clear();
}
printUnknownFields_ = false;
payloadCase_ = PayloadOneofCase.None;
payload_ = null;
if (_unknownFields != null) {
_unknownFields.Clear();
}
}

/// <summary>Field number for the "protobuf_payload" field.</summary>
public const int ProtobufPayloadFieldNumber = 1;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
Expand Down Expand Up @@ -1289,6 +1326,16 @@ public ConformanceResponse Clone() {
return new ConformanceResponse(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void Clear() {
resultCase_ = ResultOneofCase.None;
result_ = null;
if (_unknownFields != null) {
_unknownFields.Clear();
}
}

/// <summary>Field number for the "parse_error" field.</summary>
public const int ParseErrorFieldNumber = 1;
/// <summary>
Expand Down Expand Up @@ -1980,6 +2027,15 @@ public JspbEncodingConfig Clone() {
return new JspbEncodingConfig(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void Clear() {
useJspbArrayAnyFormat_ = false;
if (_unknownFields != null) {
_unknownFields.Clear();
}
}

/// <summary>Field number for the "use_jspb_array_any_format" field.</summary>
public const int UseJspbArrayAnyFormatFieldNumber = 1;
private bool useJspbArrayAnyFormat_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,31 @@ public TestMap Clone() {
return new TestMap(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void Clear() {
mapInt32Int32_.Clear();
mapInt64Int64_.Clear();
mapUint32Uint32_.Clear();
mapUint64Uint64_.Clear();
mapSint32Sint32_.Clear();
mapSint64Sint64_.Clear();
mapFixed32Fixed32_.Clear();
mapFixed64Fixed64_.Clear();
mapSfixed32Sfixed32_.Clear();
mapSfixed64Sfixed64_.Clear();
mapInt32Float_.Clear();
mapInt32Double_.Clear();
mapBoolBool_.Clear();
mapStringString_.Clear();
mapInt32Bytes_.Clear();
mapInt32Enum_.Clear();
mapInt32ForeignMessage_.Clear();
if (_unknownFields != null) {
_unknownFields.Clear();
}
}

/// <summary>Field number for the "map_int32_int32" field.</summary>
public const int MapInt32Int32FieldNumber = 1;
private static readonly pbc::MapField<int, int>.Codec _map_mapInt32Int32_codec
Expand Down Expand Up @@ -825,6 +850,17 @@ public TestMapSubmessage Clone() {
return new TestMapSubmessage(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void Clear() {
if (testMap_ != null) {
testMap_.Clear();
}
if (_unknownFields != null) {
_unknownFields.Clear();
}
}

/// <summary>Field number for the "test_map" field.</summary>
public const int TestMapFieldNumber = 1;
private global::Google.Protobuf.TestProtos.TestMap testMap_;
Expand Down Expand Up @@ -1032,6 +1068,15 @@ public TestMessageMap Clone() {
return new TestMessageMap(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void Clear() {
mapInt32Message_.Clear();
if (_unknownFields != null) {
_unknownFields.Clear();
}
}

/// <summary>Field number for the "map_int32_message" field.</summary>
public const int MapInt32MessageFieldNumber = 1;
private static readonly pbc::MapField<int, global::Google.Protobuf.TestProtos.TestAllTypes>.Codec _map_mapInt32Message_codec
Expand Down Expand Up @@ -1223,6 +1268,16 @@ public TestSameTypeMap Clone() {
return new TestSameTypeMap(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void Clear() {
map1_.Clear();
map2_.Clear();
if (_unknownFields != null) {
_unknownFields.Clear();
}
}

/// <summary>Field number for the "map1" field.</summary>
public const int Map1FieldNumber = 1;
private static readonly pbc::MapField<int, int>.Codec _map_map1_codec
Expand Down Expand Up @@ -1449,6 +1504,29 @@ public TestArenaMap Clone() {
return new TestArenaMap(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void Clear() {
mapInt32Int32_.Clear();
mapInt64Int64_.Clear();
mapUint32Uint32_.Clear();
mapUint64Uint64_.Clear();
mapSint32Sint32_.Clear();
mapSint64Sint64_.Clear();
mapFixed32Fixed32_.Clear();
mapFixed64Fixed64_.Clear();
mapSfixed32Sfixed32_.Clear();
mapSfixed64Sfixed64_.Clear();
mapInt32Float_.Clear();
mapInt32Double_.Clear();
mapBoolBool_.Clear();
mapInt32Enum_.Clear();
mapInt32ForeignMessage_.Clear();
if (_unknownFields != null) {
_unknownFields.Clear();
}
}

/// <summary>Field number for the "map_int32_int32" field.</summary>
public const int MapInt32Int32FieldNumber = 1;
private static readonly pbc::MapField<int, int>.Codec _map_mapInt32Int32_codec
Expand Down Expand Up @@ -1990,6 +2068,15 @@ public MessageContainingEnumCalledType Clone() {
return new MessageContainingEnumCalledType(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void Clear() {
type_.Clear();
if (_unknownFields != null) {
_unknownFields.Clear();
}
}

/// <summary>Field number for the "type" field.</summary>
public const int TypeFieldNumber = 1;
private static readonly pbc::MapField<int, global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType>.Codec _map_type_codec
Expand Down Expand Up @@ -2192,6 +2279,15 @@ public MessageContainingMapCalledEntry Clone() {
return new MessageContainingMapCalledEntry(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void Clear() {
entry_.Clear();
if (_unknownFields != null) {
_unknownFields.Clear();
}
}

/// <summary>Field number for the "entry" field.</summary>
public const int EntryFieldNumber = 1;
private static readonly pbc::MapField<int, int>.Codec _map_entry_codec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ public TestMessage Clone() {
return new TestMessage(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void Clear() {
if(_unknownFields != null) {
_unknownFields.Clear();
}
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as TestMessage);
Expand Down
Loading
Loading