Adjust based on review feedback

pull/6938/head
Sydney Acksman 5 years ago
parent cd11d5414f
commit 145033c056
  1. 8
      csharp/generate_protos.sh
  2. 12
      csharp/protos/extensions/extensions_a.proto
  3. 12
      csharp/protos/extensions/extensions_b.proto
  4. 14
      csharp/protos/extensions/extensions_c.proto
  5. 15
      csharp/protos/extensions_issue6936_a.proto
  6. 14
      csharp/protos/extensions_issue6936_b.proto
  7. 16
      csharp/protos/extensions_issue6936_c.proto
  8. 26
      csharp/src/Google.Protobuf.Test.TestProtos/ExtensionsIssue6936A.cs
  9. 24
      csharp/src/Google.Protobuf.Test.TestProtos/ExtensionsIssue6936B.cs
  10. 35
      csharp/src/Google.Protobuf.Test.TestProtos/ExtensionsIssue6936C.cs
  11. 7
      csharp/src/Google.Protobuf.Test/Reflection/CustomOptionsTest.cs
  12. BIN
      csharp/src/Google.Protobuf.Test/testprotos.pb

@ -44,7 +44,7 @@ $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \
# Note that this deliberately does *not* include old_extensions1.proto
# and old_extensions2.proto, which are generated with an older version
# of protoc.
$PROTOC -Isrc -Icsharp/protos -Icsharp/protos/extensions \
$PROTOC -Isrc -Icsharp/protos \
--csharp_out=csharp/src/Google.Protobuf.Test.TestProtos \
--descriptor_set_out=csharp/src/Google.Protobuf.Test/testprotos.pb \
--include_source_info \
@ -58,9 +58,9 @@ $PROTOC -Isrc -Icsharp/protos -Icsharp/protos/extensions \
unittest.proto \
unittest_import.proto \
unittest_import_public.proto \
extensions_a.proto \
extensions_b.proto \
extensions_c.proto \
extensions_issue6936_a.proto \
extensions_issue6936_b.proto \
extensions_issue6936_c.proto \
google/protobuf/unittest_well_known_types.proto \
google/protobuf/test_messages_proto3.proto \
google/protobuf/test_messages_proto2.proto

@ -1,12 +0,0 @@
syntax = "proto3";
option csharp_namespace = "Google.Protobuf.TestProtos.Extensions";
// This file is used as part of a unit test for issue 6936
// We don't need to use it, we just have to import it in both b and c
import "google/protobuf/descriptor.proto";
extend google.protobuf.MessageOptions {
string opt = 50000;
}

@ -1,12 +0,0 @@
syntax = "proto3";
import "extensions_a.proto";
option csharp_namespace = "Google.Protobuf.TestProtos.Extensions";
// This file is used as part of a unit test for issue 6936
// We don't need to use it, we just have to import it in c
message Foo {
option (opt) = "bar";
}

@ -1,14 +0,0 @@
syntax = "proto3";
import "extensions_a.proto";
import "extensions_b.proto";
option csharp_namespace = "Google.Protobuf.TestProtos.Extensions";
// This file is used as part of a unit test for issue 6936
// We don't need to use it, we just have to load it at runtime
message Bar {
option (opt) = "foo";
Foo foo = 1;
}

@ -0,0 +1,15 @@
syntax = "proto3";
package unittest_issues;
option csharp_namespace = "UnitTest.Issues.TestProtos";
// This file is used as part of a unit test for issue 6936
// We don't need to use it, we just have to import it in both
// "extensions_issue6936_b.proto" and "extensions_issue6936_c.proto"
import "google/protobuf/descriptor.proto";
extend google.protobuf.MessageOptions {
string opt = 50000;
}

@ -0,0 +1,14 @@
syntax = "proto3";
import "extensions_issue6936_a.proto";
package unittest_issues;
option csharp_namespace = "UnitTest.Issues.TestProtos";
// This file is used as part of a unit test for issue 6936
// We don't need to use it, we just have to import it in "extensions_issue6936_c.proto"
message Foo {
option (opt) = "foo";
}

@ -0,0 +1,16 @@
syntax = "proto3";
import "extensions_issue6936_a.proto";
import "extensions_issue6936_b.proto";
package unittest_issues;
option csharp_namespace = "UnitTest.Issues.TestProtos";
// This file is used as part of a unit test for issue 6936
// We don't need to use it, we just have to load it at runtime
message Bar {
option (opt) = "bar";
Foo foo = 1;
}

@ -1,6 +1,6 @@
// <auto-generated>
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: extensions_a.proto
// source: extensions_issue6936_a.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#region Designer generated code
@ -9,34 +9,34 @@ using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections;
using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace Google.Protobuf.TestProtos.Extensions {
namespace UnitTest.Issues.TestProtos {
/// <summary>Holder for reflection information generated from extensions_a.proto</summary>
public static partial class ExtensionsAReflection {
/// <summary>Holder for reflection information generated from extensions_issue6936_a.proto</summary>
public static partial class ExtensionsIssue6936AReflection {
#region Descriptor
/// <summary>File descriptor for extensions_a.proto</summary>
/// <summary>File descriptor for extensions_issue6936_a.proto</summary>
public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
}
private static pbr::FileDescriptor descriptor;
static ExtensionsAReflection() {
static ExtensionsIssue6936AReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"ChJleHRlbnNpb25zX2EucHJvdG8aIGdvb2dsZS9wcm90b2J1Zi9kZXNjcmlw",
"dG9yLnByb3RvOi4KA29wdBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0",
"aW9ucxjQhgMgASgJQiiqAiVHb29nbGUuUHJvdG9idWYuVGVzdFByb3Rvcy5F",
"eHRlbnNpb25zYgZwcm90bzM="));
"ChxleHRlbnNpb25zX2lzc3VlNjkzNl9hLnByb3RvEg91bml0dGVzdF9pc3N1",
"ZXMaIGdvb2dsZS9wcm90b2J1Zi9kZXNjcmlwdG9yLnByb3RvOi4KA29wdBIf",
"Lmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxjQhgMgASgJQh2qAhpV",
"bml0VGVzdC5Jc3N1ZXMuVGVzdFByb3Rvc2IGcHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(null, new pb::Extension[] { ExtensionsAExtensions.Opt }, null));
new pbr::GeneratedClrTypeInfo(null, new pb::Extension[] { ExtensionsIssue6936AExtensions.Opt }, null));
}
#endregion
}
/// <summary>Holder for extension identifiers generated from the top level of extensions_a.proto</summary>
public static partial class ExtensionsAExtensions {
/// <summary>Holder for extension identifiers generated from the top level of extensions_issue6936_a.proto</summary>
public static partial class ExtensionsIssue6936AExtensions {
public static readonly pb::Extension<global::Google.Protobuf.Reflection.MessageOptions, string> Opt =
new pb::Extension<global::Google.Protobuf.Reflection.MessageOptions, string>(50000, pb::FieldCodec.ForString(400002, ""));
}

@ -1,6 +1,6 @@
// <auto-generated>
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: extensions_b.proto
// source: extensions_issue6936_b.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#region Designer generated code
@ -9,28 +9,28 @@ using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections;
using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace Google.Protobuf.TestProtos.Extensions {
namespace UnitTest.Issues.TestProtos {
/// <summary>Holder for reflection information generated from extensions_b.proto</summary>
public static partial class ExtensionsBReflection {
/// <summary>Holder for reflection information generated from extensions_issue6936_b.proto</summary>
public static partial class ExtensionsIssue6936BReflection {
#region Descriptor
/// <summary>File descriptor for extensions_b.proto</summary>
/// <summary>File descriptor for extensions_issue6936_b.proto</summary>
public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
}
private static pbr::FileDescriptor descriptor;
static ExtensionsBReflection() {
static ExtensionsIssue6936BReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"ChJleHRlbnNpb25zX2IucHJvdG8aEmV4dGVuc2lvbnNfYS5wcm90byIOCgNG",
"b286B4K1GANiYXJCKKoCJUdvb2dsZS5Qcm90b2J1Zi5UZXN0UHJvdG9zLkV4",
"dGVuc2lvbnNiBnByb3RvMw=="));
"ChxleHRlbnNpb25zX2lzc3VlNjkzNl9iLnByb3RvEg91bml0dGVzdF9pc3N1",
"ZXMaHGV4dGVuc2lvbnNfaXNzdWU2OTM2X2EucHJvdG8iDgoDRm9vOgeCtRgD",
"Zm9vQh2qAhpVbml0VGVzdC5Jc3N1ZXMuVGVzdFByb3Rvc2IGcHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Protobuf.TestProtos.Extensions.ExtensionsAReflection.Descriptor, },
new pbr::FileDescriptor[] { global::UnitTest.Issues.TestProtos.ExtensionsIssue6936AReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.Extensions.Foo), global::Google.Protobuf.TestProtos.Extensions.Foo.Parser, null, null, null, null, null)
new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.Foo), global::UnitTest.Issues.TestProtos.Foo.Parser, null, null, null, null, null)
}));
}
#endregion
@ -45,7 +45,7 @@ namespace Google.Protobuf.TestProtos.Extensions {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.TestProtos.Extensions.ExtensionsBReflection.Descriptor.MessageTypes[0]; }
get { return global::UnitTest.Issues.TestProtos.ExtensionsIssue6936BReflection.Descriptor.MessageTypes[0]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]

@ -1,6 +1,6 @@
// <auto-generated>
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: extensions_c.proto
// source: extensions_issue6936_c.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#region Designer generated code
@ -9,29 +9,30 @@ using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections;
using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace Google.Protobuf.TestProtos.Extensions {
namespace UnitTest.Issues.TestProtos {
/// <summary>Holder for reflection information generated from extensions_c.proto</summary>
public static partial class ExtensionsCReflection {
/// <summary>Holder for reflection information generated from extensions_issue6936_c.proto</summary>
public static partial class ExtensionsIssue6936CReflection {
#region Descriptor
/// <summary>File descriptor for extensions_c.proto</summary>
/// <summary>File descriptor for extensions_issue6936_c.proto</summary>
public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
}
private static pbr::FileDescriptor descriptor;
static ExtensionsCReflection() {
static ExtensionsIssue6936CReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"ChJleHRlbnNpb25zX2MucHJvdG8aEmV4dGVuc2lvbnNfYS5wcm90bxoSZXh0",
"ZW5zaW9uc19iLnByb3RvIiEKA0JhchIRCgNmb28YASABKAsyBC5Gb286B4K1",
"GANmb29CKKoCJUdvb2dsZS5Qcm90b2J1Zi5UZXN0UHJvdG9zLkV4dGVuc2lv",
"bnNiBnByb3RvMw=="));
"ChxleHRlbnNpb25zX2lzc3VlNjkzNl9jLnByb3RvEg91bml0dGVzdF9pc3N1",
"ZXMaHGV4dGVuc2lvbnNfaXNzdWU2OTM2X2EucHJvdG8aHGV4dGVuc2lvbnNf",
"aXNzdWU2OTM2X2IucHJvdG8iMQoDQmFyEiEKA2ZvbxgBIAEoCzIULnVuaXR0",
"ZXN0X2lzc3Vlcy5Gb286B4K1GANiYXJCHaoCGlVuaXRUZXN0Lklzc3Vlcy5U",
"ZXN0UHJvdG9zYgZwcm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Protobuf.TestProtos.Extensions.ExtensionsAReflection.Descriptor, global::Google.Protobuf.TestProtos.Extensions.ExtensionsBReflection.Descriptor, },
new pbr::FileDescriptor[] { global::UnitTest.Issues.TestProtos.ExtensionsIssue6936AReflection.Descriptor, global::UnitTest.Issues.TestProtos.ExtensionsIssue6936BReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.TestProtos.Extensions.Bar), global::Google.Protobuf.TestProtos.Extensions.Bar.Parser, new[]{ "Foo" }, null, null, null, null)
new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.Bar), global::UnitTest.Issues.TestProtos.Bar.Parser, new[]{ "Foo" }, null, null, null, null)
}));
}
#endregion
@ -46,7 +47,7 @@ namespace Google.Protobuf.TestProtos.Extensions {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor {
get { return global::Google.Protobuf.TestProtos.Extensions.ExtensionsCReflection.Descriptor.MessageTypes[0]; }
get { return global::UnitTest.Issues.TestProtos.ExtensionsIssue6936CReflection.Descriptor.MessageTypes[0]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@ -74,9 +75,9 @@ namespace Google.Protobuf.TestProtos.Extensions {
/// <summary>Field number for the "foo" field.</summary>
public const int FooFieldNumber = 1;
private global::Google.Protobuf.TestProtos.Extensions.Foo foo_;
private global::UnitTest.Issues.TestProtos.Foo foo_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.TestProtos.Extensions.Foo Foo {
public global::UnitTest.Issues.TestProtos.Foo Foo {
get { return foo_; }
set {
foo_ = value;
@ -145,7 +146,7 @@ namespace Google.Protobuf.TestProtos.Extensions {
}
if (other.foo_ != null) {
if (foo_ == null) {
Foo = new global::Google.Protobuf.TestProtos.Extensions.Foo();
Foo = new global::UnitTest.Issues.TestProtos.Foo();
}
Foo.MergeFrom(other.Foo);
}
@ -162,7 +163,7 @@ namespace Google.Protobuf.TestProtos.Extensions {
break;
case 10: {
if (foo_ == null) {
Foo = new global::Google.Protobuf.TestProtos.Extensions.Foo();
Foo = new global::UnitTest.Issues.TestProtos.Foo();
}
input.ReadMessage(Foo);
break;

@ -42,7 +42,6 @@ using static UnitTest.Issues.TestProtos.ComplexOptionType2.Types;
using static UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Extensions;
using static UnitTest.Issues.TestProtos.DummyMessageContainingEnum.Types;
using Google.Protobuf.TestProtos;
using Google.Protobuf.TestProtos.Extensions;
#pragma warning disable CS0618
@ -197,11 +196,11 @@ namespace Google.Protobuf.Test.Reflection
[Test]
public void MultipleImportOfSameFileWithExtension()
{
var descriptor = ExtensionsCReflection.Descriptor;
var descriptor = ExtensionsIssue6936CReflection.Descriptor;
var foo = Foo.Descriptor;
var bar = Bar.Descriptor;
AssertOption("bar", foo.CustomOptions.TryGetString, ExtensionsAExtensions.Opt, foo.GetOption);
AssertOption("foo", bar.CustomOptions.TryGetString, ExtensionsAExtensions.Opt, bar.GetOption);
AssertOption("foo", foo.CustomOptions.TryGetString, ExtensionsIssue6936AExtensions.Opt, foo.GetOption);
AssertOption("bar", bar.CustomOptions.TryGetString, ExtensionsIssue6936AExtensions.Opt, bar.GetOption);
}
private void AssertOption<T, D>(T expected, OptionFetcher<T> fetcher, Extension<D, T> extension, Func<Extension<D, T>, T> descriptorOptionFetcher) where D : IExtendableMessage<D>

Loading…
Cancel
Save