Skip to content

Commit

Permalink
Adjust based on review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ObsidianMinor committed Nov 27, 2019
1 parent cd11d54 commit 145033c
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 88 deletions.
8 changes: 4 additions & 4 deletions csharp/generate_protos.sh
Expand Up @@ -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 \
Expand All @@ -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
Expand Down
12 changes: 0 additions & 12 deletions csharp/protos/extensions/extensions_a.proto

This file was deleted.

12 changes: 0 additions & 12 deletions csharp/protos/extensions/extensions_b.proto

This file was deleted.

14 changes: 0 additions & 14 deletions csharp/protos/extensions/extensions_c.proto

This file was deleted.

15 changes: 15 additions & 0 deletions csharp/protos/extensions_issue6936_a.proto
@@ -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;
}
14 changes: 14 additions & 0 deletions csharp/protos/extensions_issue6936_b.proto
@@ -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";
}
16 changes: 16 additions & 0 deletions csharp/protos/extensions_issue6936_c.proto
@@ -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
Expand All @@ -9,34 +9,34 @@
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, ""));
}
Expand Down
@@ -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
Expand All @@ -9,28 +9,28 @@
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
Expand All @@ -45,7 +45,7 @@ public sealed partial class Foo : pb::IMessage<Foo> {

[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]
Expand Down
@@ -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
Expand All @@ -9,29 +9,30 @@
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
Expand All @@ -46,7 +47,7 @@ public sealed partial class Bar : pb::IMessage<Bar> {

[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]
Expand Down Expand Up @@ -74,9 +75,9 @@ public sealed partial class Bar : pb::IMessage<Bar> {

/// <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;
Expand Down Expand Up @@ -145,7 +146,7 @@ public sealed partial class Bar : pb::IMessage<Bar> {
}
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);
}
Expand All @@ -162,7 +163,7 @@ public sealed partial class Bar : pb::IMessage<Bar> {
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;
Expand Down
Expand Up @@ -42,7 +42,6 @@
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

Expand Down Expand Up @@ -197,11 +196,11 @@ public void NoOptions()
[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>
Expand Down
Binary file modified csharp/src/Google.Protobuf.Test/testprotos.pb
Binary file not shown.

0 comments on commit 145033c

Please sign in to comment.