Skip to content

Commit 10a904a

Browse files
committed
Rename nullable message to nrt message
1 parent 1e35b60 commit 10a904a

File tree

5 files changed

+60
-49
lines changed

5 files changed

+60
-49
lines changed

csharp/generate_protos.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ $PROTOC -Isrc -I. \
8484
--descriptor_set_out=csharp/src/Google.Protobuf.Test/testprotos.pb \
8585
--include_source_info \
8686
--include_imports \
87-
csharp/protos/unittest_nullable_proto3.proto
87+
csharp/protos/unittest_nrt_proto3.proto
8888

8989
# AddressBook sample protos
9090
$PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \

csharp/protos/unittest_nullable_proto3.proto renamed to csharp/protos/unittest_nrt_proto3.proto

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ option csharp_namespace = "Google.Protobuf.TestProtos";
3636

3737
package protobuf_unittest3;
3838

39-
message TestNullableMessage {
40-
message TestNullableNestedMessage {
39+
message TestNrtMessage {
40+
message TestNrtNestedMessage {
4141
int32 int32_field = 1;
4242
string string_field = 2;
4343
}
4444

45-
TestNullableNestedMessage reference_field = 1;
45+
TestNrtNestedMessage reference_field = 1;
4646
}

csharp/src/Google.Protobuf.Test.TestProtos/UnittestNullableProto3.pb.cs renamed to csharp/src/Google.Protobuf.Test.TestProtos/UnittestNrtProto3.pb.cs

+40-41
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// <auto-generated>
22
// Generated by the protocol buffer compiler. DO NOT EDIT!
3-
// source: csharp/protos/unittest_nullable_proto3.proto
3+
// source: csharp/protos/unittest_nrt_proto3.proto
44
// </auto-generated>
55
#nullable enable
66
#pragma warning disable 1591, 0612, 3021, 8981
@@ -12,51 +12,50 @@
1212
using scg = global::System.Collections.Generic;
1313
namespace Google.Protobuf.TestProtos {
1414

15-
/// <summary>Holder for reflection information generated from csharp/protos/unittest_nullable_proto3.proto</summary>
16-
public static partial class UnittestNullableProto3Reflection {
15+
/// <summary>Holder for reflection information generated from csharp/protos/unittest_nrt_proto3.proto</summary>
16+
public static partial class UnittestNrtProto3Reflection {
1717

1818
#region Descriptor
19-
/// <summary>File descriptor for csharp/protos/unittest_nullable_proto3.proto</summary>
19+
/// <summary>File descriptor for csharp/protos/unittest_nrt_proto3.proto</summary>
2020
public static pbr::FileDescriptor Descriptor {
2121
get { return descriptor; }
2222
}
2323
private static pbr::FileDescriptor descriptor;
2424

25-
static UnittestNullableProto3Reflection() {
25+
static UnittestNrtProto3Reflection() {
2626
byte[] descriptorData = global::System.Convert.FromBase64String(
2727
string.Concat(
28-
"Cixjc2hhcnAvcHJvdG9zL3VuaXR0ZXN0X251bGxhYmxlX3Byb3RvMy5wcm90",
29-
"bxIScHJvdG9idWZfdW5pdHRlc3QzIrkBChNUZXN0TnVsbGFibGVNZXNzYWdl",
30-
"EloKD3JlZmVyZW5jZV9maWVsZBgBIAEoCzJBLnByb3RvYnVmX3VuaXR0ZXN0",
31-
"My5UZXN0TnVsbGFibGVNZXNzYWdlLlRlc3ROdWxsYWJsZU5lc3RlZE1lc3Nh",
32-
"Z2UaRgoZVGVzdE51bGxhYmxlTmVzdGVkTWVzc2FnZRITCgtpbnQzMl9maWVs",
33-
"ZBgBIAEoBRIUCgxzdHJpbmdfZmllbGQYAiABKAlCHaoCGkdvb2dsZS5Qcm90",
34-
"b2J1Zi5UZXN0UHJvdG9zYgZwcm90bzM="));
28+
"Cidjc2hhcnAvcHJvdG9zL3VuaXR0ZXN0X25ydF9wcm90bzMucHJvdG8SEnBy",
29+
"b3RvYnVmX3VuaXR0ZXN0MyKlAQoOVGVzdE5ydE1lc3NhZ2USUAoPcmVmZXJl",
30+
"bmNlX2ZpZWxkGAEgASgLMjcucHJvdG9idWZfdW5pdHRlc3QzLlRlc3ROcnRN",
31+
"ZXNzYWdlLlRlc3ROcnROZXN0ZWRNZXNzYWdlGkEKFFRlc3ROcnROZXN0ZWRN",
32+
"ZXNzYWdlEhMKC2ludDMyX2ZpZWxkGAEgASgFEhQKDHN0cmluZ19maWVsZBgC",
33+
"IAEoCUIdqgIaR29vZ2xlLlByb3RvYnVmLlRlc3RQcm90b3NiBnByb3RvMw=="));
3534
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
3635
new pbr::FileDescriptor[] { },
3736
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
38-
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestNullableMessage), global::Google.Protobuf.TestProtos.TestNullableMessage.Parser, new[]{ "ReferenceField" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestNullableMessage.Types.TestNullableNestedMessage), global::Google.Protobuf.TestProtos.TestNullableMessage.Types.TestNullableNestedMessage.Parser, new[]{ "Int32Field", "StringField" }, null, null, null, null)})
37+
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestNrtMessage), global::Google.Protobuf.TestProtos.TestNrtMessage.Parser, new[]{ "ReferenceField" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.TestNrtMessage.Types.TestNrtNestedMessage), global::Google.Protobuf.TestProtos.TestNrtMessage.Types.TestNrtNestedMessage.Parser, new[]{ "Int32Field", "StringField" }, null, null, null, null)})
3938
}));
4039
}
4140
#endregion
4241

4342
}
4443
#region Messages
45-
public sealed partial class TestNullableMessage : pb::IMessage<TestNullableMessage>
44+
public sealed partial class TestNrtMessage : pb::IMessage<TestNrtMessage>
4645
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
4746
, pb::IBufferMessage
4847
#endif
4948
{
50-
private static readonly pb::MessageParser<TestNullableMessage> _parser = new pb::MessageParser<TestNullableMessage>(() => new TestNullableMessage());
49+
private static readonly pb::MessageParser<TestNrtMessage> _parser = new pb::MessageParser<TestNrtMessage>(() => new TestNrtMessage());
5150
private pb::UnknownFieldSet _unknownFields;
5251
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
5352
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
54-
public static pb::MessageParser<TestNullableMessage> Parser { get { return _parser; } }
53+
public static pb::MessageParser<TestNrtMessage> Parser { get { return _parser; } }
5554

5655
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
5756
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
5857
public static pbr::MessageDescriptor Descriptor {
59-
get { return global::Google.Protobuf.TestProtos.UnittestNullableProto3Reflection.Descriptor.MessageTypes[0]; }
58+
get { return global::Google.Protobuf.TestProtos.UnittestNrtProto3Reflection.Descriptor.MessageTypes[0]; }
6059
}
6160

6261
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -67,31 +66,31 @@ public sealed partial class TestNullableMessage : pb::IMessage<TestNullableMessa
6766

6867
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
6968
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
70-
public TestNullableMessage() {
69+
public TestNrtMessage() {
7170
OnConstruction();
7271
}
7372

7473
partial void OnConstruction();
7574

7675
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
7776
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
78-
public TestNullableMessage(TestNullableMessage other) : this() {
77+
public TestNrtMessage(TestNrtMessage other) : this() {
7978
referenceField_ = other.referenceField_ != null ? other.referenceField_.Clone() : null;
8079
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
8180
}
8281

8382
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
8483
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
85-
public TestNullableMessage Clone() {
86-
return new TestNullableMessage(this);
84+
public TestNrtMessage Clone() {
85+
return new TestNrtMessage(this);
8786
}
8887

8988
/// <summary>Field number for the "reference_field" field.</summary>
9089
public const int ReferenceFieldFieldNumber = 1;
91-
private global::Google.Protobuf.TestProtos.TestNullableMessage.Types.TestNullableNestedMessage referenceField_;
90+
private global::Google.Protobuf.TestProtos.TestNrtMessage.Types.TestNrtNestedMessage referenceField_;
9291
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
9392
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
94-
public global::Google.Protobuf.TestProtos.TestNullableMessage.Types.TestNullableNestedMessage ReferenceField {
93+
public global::Google.Protobuf.TestProtos.TestNrtMessage.Types.TestNrtNestedMessage ReferenceField {
9594
get { return referenceField_; }
9695
set {
9796
referenceField_ = value;
@@ -101,12 +100,12 @@ public TestNullableMessage Clone() {
101100
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
102101
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
103102
public override bool Equals(object other) {
104-
return Equals(other as TestNullableMessage);
103+
return Equals(other as TestNrtMessage);
105104
}
106105

107106
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
108107
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
109-
public bool Equals(TestNullableMessage other) {
108+
public bool Equals(TestNrtMessage other) {
110109
if (ReferenceEquals(other, null)) {
111110
return false;
112111
}
@@ -179,13 +178,13 @@ public int CalculateSize() {
179178

180179
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
181180
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
182-
public void MergeFrom(TestNullableMessage other) {
181+
public void MergeFrom(TestNrtMessage other) {
183182
if (other == null) {
184183
return;
185184
}
186185
if (other.referenceField_ != null) {
187186
if (referenceField_ == null) {
188-
ReferenceField = new global::Google.Protobuf.TestProtos.TestNullableMessage.Types.TestNullableNestedMessage();
187+
ReferenceField = new global::Google.Protobuf.TestProtos.TestNrtMessage.Types.TestNrtNestedMessage();
189188
}
190189
ReferenceField.MergeFrom(other.ReferenceField);
191190
}
@@ -206,7 +205,7 @@ public void MergeFrom(pb::CodedInputStream input) {
206205
break;
207206
case 10: {
208207
if (referenceField_ == null) {
209-
ReferenceField = new global::Google.Protobuf.TestProtos.TestNullableMessage.Types.TestNullableNestedMessage();
208+
ReferenceField = new global::Google.Protobuf.TestProtos.TestNrtMessage.Types.TestNrtNestedMessage();
210209
}
211210
input.ReadMessage(ReferenceField);
212211
break;
@@ -228,7 +227,7 @@ public void MergeFrom(pb::CodedInputStream input) {
228227
break;
229228
case 10: {
230229
if (referenceField_ == null) {
231-
ReferenceField = new global::Google.Protobuf.TestProtos.TestNullableMessage.Types.TestNullableNestedMessage();
230+
ReferenceField = new global::Google.Protobuf.TestProtos.TestNrtMessage.Types.TestNrtNestedMessage();
232231
}
233232
input.ReadMessage(ReferenceField);
234233
break;
@@ -239,25 +238,25 @@ public void MergeFrom(pb::CodedInputStream input) {
239238
#endif
240239

241240
#region Nested types
242-
/// <summary>Container for nested types declared in the TestNullableMessage message type.</summary>
241+
/// <summary>Container for nested types declared in the TestNrtMessage message type.</summary>
243242
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
244243
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
245244
public static partial class Types {
246-
public sealed partial class TestNullableNestedMessage : pb::IMessage<TestNullableNestedMessage>
245+
public sealed partial class TestNrtNestedMessage : pb::IMessage<TestNrtNestedMessage>
247246
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
248247
, pb::IBufferMessage
249248
#endif
250249
{
251-
private static readonly pb::MessageParser<TestNullableNestedMessage> _parser = new pb::MessageParser<TestNullableNestedMessage>(() => new TestNullableNestedMessage());
250+
private static readonly pb::MessageParser<TestNrtNestedMessage> _parser = new pb::MessageParser<TestNrtNestedMessage>(() => new TestNrtNestedMessage());
252251
private pb::UnknownFieldSet _unknownFields;
253252
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
254253
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
255-
public static pb::MessageParser<TestNullableNestedMessage> Parser { get { return _parser; } }
254+
public static pb::MessageParser<TestNrtNestedMessage> Parser { get { return _parser; } }
256255

257256
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
258257
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
259258
public static pbr::MessageDescriptor Descriptor {
260-
get { return global::Google.Protobuf.TestProtos.TestNullableMessage.Descriptor.NestedTypes[0]; }
259+
get { return global::Google.Protobuf.TestProtos.TestNrtMessage.Descriptor.NestedTypes[0]; }
261260
}
262261

263262
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -268,24 +267,24 @@ public sealed partial class TestNullableNestedMessage : pb::IMessage<TestNullabl
268267

269268
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
270269
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
271-
public TestNullableNestedMessage() {
270+
public TestNrtNestedMessage() {
272271
OnConstruction();
273272
}
274273

275274
partial void OnConstruction();
276275

277276
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
278277
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
279-
public TestNullableNestedMessage(TestNullableNestedMessage other) : this() {
278+
public TestNrtNestedMessage(TestNrtNestedMessage other) : this() {
280279
int32Field_ = other.int32Field_;
281280
stringField_ = other.stringField_;
282281
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
283282
}
284283

285284
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
286285
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
287-
public TestNullableNestedMessage Clone() {
288-
return new TestNullableNestedMessage(this);
286+
public TestNrtNestedMessage Clone() {
287+
return new TestNrtNestedMessage(this);
289288
}
290289

291290
/// <summary>Field number for the "int32_field" field.</summary>
@@ -315,12 +314,12 @@ public string StringField {
315314
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
316315
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
317316
public override bool Equals(object other) {
318-
return Equals(other as TestNullableNestedMessage);
317+
return Equals(other as TestNrtNestedMessage);
319318
}
320319

321320
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
322321
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
323-
public bool Equals(TestNullableNestedMessage other) {
322+
public bool Equals(TestNrtNestedMessage other) {
324323
if (ReferenceEquals(other, null)) {
325324
return false;
326325
}
@@ -406,7 +405,7 @@ public int CalculateSize() {
406405

407406
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
408407
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
409-
public void MergeFrom(TestNullableNestedMessage other) {
408+
public void MergeFrom(TestNrtNestedMessage other) {
410409
if (other == null) {
411410
return;
412411
}

csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs

+16-4
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public void MapIgnoresExtraFieldsWithinEntryMessages()
335335

336336
output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited);
337337

338-
var key = 10; // Field 1
338+
var key = 10; // Field 1
339339
var value = 20; // Field 2
340340
var extra = 30; // Field 3
341341

@@ -857,7 +857,7 @@ public void NullableReferenceTypes_IsDisabled()
857857
}
858858

859859
/// <summary>
860-
/// unittest_nullable_proto3.proto is generated with enable_nullable_reference_types flag.
860+
/// unittest_nrt_proto3.proto is generated with enable_nullable_reference_types flag.
861861
/// This allows retreivable nullability information for reference types, which is otherwise
862862
/// ignored because of the &lt;auto-generated&gt; attribute.
863863
/// </summary>
@@ -866,13 +866,25 @@ public void NullableReferenceTypes_IsEnabled()
866866
{
867867
NullabilityInfoContext context = new();
868868

869-
PropertyInfo referenceProperty = typeof(TestNullableMessage).GetProperty("ReferenceField", BindingFlags.Instance | BindingFlags.Public)!;
869+
PropertyInfo referenceProperty = typeof(TestNrtMessage).GetProperty("ReferenceField", BindingFlags.Instance | BindingFlags.Public)!;
870870
Assert.NotNull(referenceProperty);
871871
NullabilityInfo referenceNullabilityInfo = context.Create(referenceProperty);
872872
Assert.AreEqual(NullabilityState.NotNull, referenceNullabilityInfo.ReadState);
873873
Assert.AreEqual(NullabilityState.NotNull, referenceNullabilityInfo.WriteState);
874874

875-
PropertyInfo stringProperty = typeof(TestNullableMessage.Types.TestNullableNestedMessage).GetProperty("StringField", BindingFlags.Instance | BindingFlags.Public)!;
875+
// Message generated without enable_nullable_reference_types flag.
876+
TestAllTypes messageNoNrt = new() {
877+
SingleString = null
878+
};
879+
880+
// Message generated with enable_nullable_reference_types flag.
881+
TestNrtMessage messageNrt = new() {
882+
ReferenceField = null
883+
};
884+
885+
886+
887+
PropertyInfo stringProperty = typeof(TestNrtMessage.Types.TestNrtNestedMessage).GetProperty("StringField", BindingFlags.Instance | BindingFlags.Public)!;
876888
Assert.NotNull(referenceProperty);
877889
NullabilityInfo stringNullabilityInfo = context.Create(stringProperty);
878890
Assert.AreEqual(NullabilityState.NotNull, stringNullabilityInfo.ReadState);
-25 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)