Commit 03872044 authored by ObsidianMinor's avatar ObsidianMinor Committed by Sydney Acksman

Make extension container classes public and modify conformance to test proto2 messages

parent 05712c67
...@@ -53,7 +53,8 @@ $PROTOC -Isrc -Icsharp/protos \ ...@@ -53,7 +53,8 @@ $PROTOC -Isrc -Icsharp/protos \
csharp/protos/unittest_import_proto3.proto \ csharp/protos/unittest_import_proto3.proto \
csharp/protos/unittest_import_public_proto3.proto \ csharp/protos/unittest_import_public_proto3.proto \
src/google/protobuf/unittest_well_known_types.proto \ src/google/protobuf/unittest_well_known_types.proto \
src/google/protobuf/test_messages_proto3.proto src/google/protobuf/test_messages_proto3.proto \
src/google/protobuf/test_messages_proto2.proto
# AddressBook sample protos # AddressBook sample protos
$PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \ $PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \
......
...@@ -48,7 +48,9 @@ namespace Google.Protobuf.Conformance ...@@ -48,7 +48,9 @@ namespace Google.Protobuf.Conformance
// This way we get the binary streams instead of readers/writers. // This way we get the binary streams instead of readers/writers.
var input = new BinaryReader(Console.OpenStandardInput()); var input = new BinaryReader(Console.OpenStandardInput());
var output = new BinaryWriter(Console.OpenStandardOutput()); var output = new BinaryWriter(Console.OpenStandardOutput());
var typeRegistry = TypeRegistry.FromMessages(ProtobufTestMessages.Proto3.TestAllTypesProto3.Descriptor); var typeRegistry = TypeRegistry.FromMessages(
ProtobufTestMessages.Proto3.TestAllTypesProto3.Descriptor,
ProtobufTestMessages.Proto2.TestAllTypesProto2.Descriptor);
int count = 0; int count = 0;
while (RunTest(input, output, typeRegistry)) while (RunTest(input, output, typeRegistry))
...@@ -81,7 +83,7 @@ namespace Google.Protobuf.Conformance ...@@ -81,7 +83,7 @@ namespace Google.Protobuf.Conformance
private static ConformanceResponse PerformRequest(ConformanceRequest request, TypeRegistry typeRegistry) private static ConformanceResponse PerformRequest(ConformanceRequest request, TypeRegistry typeRegistry)
{ {
ProtobufTestMessages.Proto3.TestAllTypesProto3 message; IMessage message;
try try
{ {
switch (request.PayloadCase) switch (request.PayloadCase)
...@@ -101,7 +103,13 @@ namespace Google.Protobuf.Conformance ...@@ -101,7 +103,13 @@ namespace Google.Protobuf.Conformance
} }
else if (request.MessageType.Equals("protobuf_test_messages.proto2.TestAllTypesProto2")) else if (request.MessageType.Equals("protobuf_test_messages.proto2.TestAllTypesProto2"))
{ {
return new ConformanceResponse { Skipped = "CSharp doesn't support proto2" }; ExtensionRegistry registry = new ExtensionRegistry()
{
ProtobufTestMessages.Proto2.TestMessagesProto2Extensions.ExtensionInt32,
ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.MessageSetCorrectExtension1.Extensions.MessageSetExtension,
ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.MessageSetCorrectExtension2.Extensions.MessageSetExtension
};
message = ProtobufTestMessages.Proto2.TestAllTypesProto2.Parser.WithExtensionRegistry(registry).ParseFrom(request.ProtobufPayload);
} }
else else
{ {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -165,7 +165,7 @@ namespace UnitTest.Issues.TestProtos { ...@@ -165,7 +165,7 @@ namespace UnitTest.Issues.TestProtos {
} }
/// <summary>Holder for extension identifiers generated from the top level of unittest_custom_options_proto3.proto</summary> /// <summary>Holder for extension identifiers generated from the top level of unittest_custom_options_proto3.proto</summary>
internal static partial class UnittestCustomOptionsProto3Extensions { public static partial class UnittestCustomOptionsProto3Extensions {
public static readonly pb::Extension<global::Google.Protobuf.Reflection.FileOptions, ulong> FileOpt1 = public static readonly pb::Extension<global::Google.Protobuf.Reflection.FileOptions, ulong> FileOpt1 =
new pb::Extension<global::Google.Protobuf.Reflection.FileOptions, ulong>(7736974, pb::FieldCodec.ForUInt64(61895792, 0UL)); new pb::Extension<global::Google.Protobuf.Reflection.FileOptions, ulong>(7736974, pb::FieldCodec.ForUInt64(61895792, 0UL));
public static readonly pb::Extension<global::Google.Protobuf.Reflection.MessageOptions, int> MessageOpt1 = public static readonly pb::Extension<global::Google.Protobuf.Reflection.MessageOptions, int> MessageOpt1 =
...@@ -2138,7 +2138,7 @@ namespace UnitTest.Issues.TestProtos { ...@@ -2138,7 +2138,7 @@ namespace UnitTest.Issues.TestProtos {
#region Extensions #region Extensions
/// <summary>Container for extensions for other messages declared in the ComplexOptionType4 message type.</summary> /// <summary>Container for extensions for other messages declared in the ComplexOptionType4 message type.</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
internal static partial class Extensions { public static partial class Extensions {
public static readonly pb::Extension<global::Google.Protobuf.Reflection.MessageOptions, global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4> ComplexOpt4 = public static readonly pb::Extension<global::Google.Protobuf.Reflection.MessageOptions, global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4> ComplexOpt4 =
new pb::Extension<global::Google.Protobuf.Reflection.MessageOptions, global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4>(7633546, pb::FieldCodec.ForMessage(61068370, global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4.Parser)); new pb::Extension<global::Google.Protobuf.Reflection.MessageOptions, global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4>(7633546, pb::FieldCodec.ForMessage(61068370, global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4.Parser));
} }
......
...@@ -320,7 +320,7 @@ void MessageGenerator::Generate(io::Printer* printer) { ...@@ -320,7 +320,7 @@ void MessageGenerator::Generate(io::Printer* printer) {
"#region Extensions\n" "#region Extensions\n"
"/// <summary>Container for extensions for other messages declared in the $class_name$ message type.</summary>\n"); "/// <summary>Container for extensions for other messages declared in the $class_name$ message type.</summary>\n");
WriteGeneratedCodeAttributes(printer); WriteGeneratedCodeAttributes(printer);
printer->Print("internal static partial class Extensions {\n"); printer->Print("public static partial class Extensions {\n");
printer->Indent(); printer->Indent();
for (int i = 0; i < descriptor_->extension_count(); i++) { for (int i = 0; i < descriptor_->extension_count(); i++) {
std::unique_ptr<FieldGeneratorBase> generator( std::unique_ptr<FieldGeneratorBase> generator(
......
...@@ -74,7 +74,7 @@ void ReflectionClassGenerator::Generate(io::Printer* printer) { ...@@ -74,7 +74,7 @@ void ReflectionClassGenerator::Generate(io::Printer* printer) {
if (file_->extension_count() > 0) { if (file_->extension_count() > 0) {
printer->Print( printer->Print(
"/// <summary>Holder for extension identifiers generated from the top level of $file_name$</summary>\n" "/// <summary>Holder for extension identifiers generated from the top level of $file_name$</summary>\n"
"internal static partial class $class_name$ {\n", "$access_level$ static partial class $class_name$ {\n",
"access_level", class_access_level(), "access_level", class_access_level(),
"class_name", extensionClassname_, "class_name", extensionClassname_,
"file_name", file_->name()); "file_name", file_->name());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment