Slight refactoring of Extensions to support lookup by name, added compatibility tests for text and binary formats.
parent
45a93fad4d
commit
27bfcc5e1a
28 changed files with 13109 additions and 248 deletions
@ -0,0 +1,53 @@ |
||||
// Additional options required for C# generation. File from copyright |
||||
// line onwards is as per original distribution. |
||||
import "google/protobuf/csharp_options.proto"; |
||||
option (google.protobuf.csharp_file_options).namespace = "Google.ProtocolBuffers.TestProtos"; |
||||
option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestXmlSerializerTestProtoFile"; |
||||
|
||||
package protobuf_unittest_extra; |
||||
|
||||
option optimize_for = SPEED; |
||||
|
||||
enum EnumOptions { |
||||
ONE = 0; |
||||
TWO = 1; |
||||
THREE = 2; |
||||
} |
||||
|
||||
message TestXmlChild |
||||
{ |
||||
repeated EnumOptions options = 3; |
||||
optional bytes binary = 4; |
||||
} |
||||
|
||||
message TestXmlNoFields { |
||||
} |
||||
|
||||
message TestXmlMessage { |
||||
|
||||
optional int64 number = 6; |
||||
repeated int32 numbers = 2; |
||||
optional string text = 3; |
||||
repeated string textlines = 700; |
||||
optional bool valid = 5; |
||||
|
||||
optional TestXmlChild child = 1; |
||||
repeated group Children = 401 |
||||
{ |
||||
repeated EnumOptions options = 3; |
||||
optional bytes binary = 4; |
||||
} |
||||
|
||||
extensions 100 to 199; |
||||
} |
||||
|
||||
message TestXmlExtension { |
||||
required int32 number = 1; |
||||
} |
||||
|
||||
extend TestXmlMessage { |
||||
optional EnumOptions extension_enum = 101; |
||||
optional string extension_text = 102; |
||||
repeated int32 extension_number = 103 [packed = true]; |
||||
optional TestXmlExtension extension_message = 199; |
||||
} |
@ -0,0 +1,140 @@ |
||||
package benchmarks; |
||||
|
||||
import "google/protobuf/csharp_options.proto"; |
||||
option (google.protobuf.csharp_file_options).namespace = "Google.ProtocolBuffers.TestProtos"; |
||||
option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestGoogleSizeProtoFile"; |
||||
|
||||
option java_outer_classname = "GoogleSize"; |
||||
option optimize_for = CODE_SIZE; |
||||
|
||||
message SizeMessage1 { |
||||
required string field1 = 1; |
||||
optional string field9 = 9; |
||||
optional string field18 = 18; |
||||
optional bool field80 = 80 [default=false]; |
||||
optional bool field81 = 81 [default=true]; |
||||
required int32 field2 = 2; |
||||
required int32 field3 = 3; |
||||
optional int32 field280 = 280; |
||||
optional int32 field6 = 6 [default=0]; |
||||
optional int64 field22 = 22; |
||||
optional string field4 = 4; |
||||
repeated fixed64 field5 = 5; |
||||
optional bool field59 = 59 [default=false]; |
||||
optional string field7 = 7; |
||||
optional int32 field16 = 16; |
||||
optional int32 field130 = 130 [default=0]; |
||||
optional bool field12 = 12 [default=true]; |
||||
optional bool field17 = 17 [default=true]; |
||||
optional bool field13 = 13 [default=true]; |
||||
optional bool field14 = 14 [default=true]; |
||||
optional int32 field104 = 104 [default=0]; |
||||
optional int32 field100 = 100 [default=0]; |
||||
optional int32 field101 = 101 [default=0]; |
||||
optional string field102 = 102; |
||||
optional string field103 = 103; |
||||
optional int32 field29 = 29 [default=0]; |
||||
optional bool field30 = 30 [default=false]; |
||||
optional int32 field60 = 60 [default=-1]; |
||||
optional int32 field271 = 271 [default=-1]; |
||||
optional int32 field272 = 272 [default=-1]; |
||||
optional int32 field150 = 150; |
||||
optional int32 field23 = 23 [default=0]; |
||||
optional bool field24 = 24 [default=false]; |
||||
optional int32 field25 = 25 [default=0]; |
||||
optional SizeMessage1SubMessage field15 = 15; |
||||
optional bool field78 = 78; |
||||
optional int32 field67 = 67 [default=0]; |
||||
optional int32 field68 = 68; |
||||
optional int32 field128 = 128 [default=0]; |
||||
optional string field129 = 129 [default="xxxxxxxxxxxxxxxxxxxxx"]; |
||||
optional int32 field131 = 131 [default=0]; |
||||
} |
||||
|
||||
message SizeMessage1SubMessage { |
||||
optional int32 field1 = 1 [default=0]; |
||||
optional int32 field2 = 2 [default=0]; |
||||
optional int32 field3 = 3 [default=0]; |
||||
optional string field15 = 15; |
||||
optional bool field12 = 12 [default=true]; |
||||
optional int64 field13 = 13; |
||||
optional int64 field14 = 14; |
||||
optional int32 field16 = 16; |
||||
optional int32 field19 = 19 [default=2]; |
||||
optional bool field20 = 20 [default=true]; |
||||
optional bool field28 = 28 [default=true]; |
||||
optional fixed64 field21 = 21; |
||||
optional int32 field22 = 22; |
||||
optional bool field23 = 23 [ default=false ]; |
||||
optional bool field206 = 206 [default=false]; |
||||
optional fixed32 field203 = 203; |
||||
optional int32 field204 = 204; |
||||
optional string field205 = 205; |
||||
optional uint64 field207 = 207; |
||||
optional uint64 field300 = 300; |
||||
} |
||||
|
||||
message SizeMessage2 { |
||||
optional string field1 = 1; |
||||
optional int64 field3 = 3; |
||||
optional int64 field4 = 4; |
||||
optional int64 field30 = 30; |
||||
optional bool field75 = 75 [default=false]; |
||||
optional string field6 = 6; |
||||
optional bytes field2 = 2; |
||||
optional int32 field21 = 21 [default=0]; |
||||
optional int32 field71 = 71; |
||||
optional float field25 = 25; |
||||
optional int32 field109 = 109 [default=0]; |
||||
optional int32 field210 = 210 [default=0]; |
||||
optional int32 field211 = 211 [default=0]; |
||||
optional int32 field212 = 212 [default=0]; |
||||
optional int32 field213 = 213 [default=0]; |
||||
optional int32 field216 = 216 [default=0]; |
||||
optional int32 field217 = 217 [default=0]; |
||||
optional int32 field218 = 218 [default=0]; |
||||
optional int32 field220 = 220 [default=0]; |
||||
optional int32 field221 = 221 [default=0]; |
||||
optional float field222 = 222 [default=0.0]; |
||||
optional int32 field63 = 63; |
||||
|
||||
repeated group Group1 = 10 { |
||||
required float field11 = 11; |
||||
optional float field26 = 26; |
||||
optional string field12 = 12; |
||||
optional string field13 = 13; |
||||
repeated string field14 = 14; |
||||
required uint64 field15 = 15; |
||||
optional int32 field5 = 5; |
||||
optional string field27 = 27; |
||||
optional int32 field28 = 28; |
||||
optional string field29 = 29; |
||||
optional string field16 = 16; |
||||
repeated string field22 = 22; |
||||
repeated int32 field73 = 73; |
||||
optional int32 field20 = 20 [default=0]; |
||||
optional string field24 = 24; |
||||
optional SizeMessage2GroupedMessage field31 = 31; |
||||
} |
||||
repeated string field128 = 128; |
||||
optional int64 field131 = 131; |
||||
repeated string field127 = 127; |
||||
optional int32 field129 = 129; |
||||
repeated int64 field130 = 130; |
||||
optional bool field205 = 205 [default=false]; |
||||
optional bool field206 = 206 [default=false]; |
||||
} |
||||
|
||||
message SizeMessage2GroupedMessage { |
||||
optional float field1 = 1; |
||||
optional float field2 = 2; |
||||
optional float field3 = 3 [default=0.0]; |
||||
optional bool field4 = 4; |
||||
optional bool field5 = 5; |
||||
optional bool field6 = 6 [default=true]; |
||||
optional bool field7 = 7 [default=false]; |
||||
optional float field8 = 8; |
||||
optional bool field9 = 9; |
||||
optional float field10 = 10; |
||||
optional int64 field11 = 11; |
||||
} |
@ -0,0 +1,140 @@ |
||||
package benchmarks; |
||||
|
||||
import "google/protobuf/csharp_options.proto"; |
||||
option (google.protobuf.csharp_file_options).namespace = "Google.ProtocolBuffers.TestProtos"; |
||||
option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestGoogleSpeedProtoFile"; |
||||
|
||||
option java_outer_classname = "GoogleSpeed"; |
||||
option optimize_for = SPEED; |
||||
|
||||
message SpeedMessage1 { |
||||
required string field1 = 1; |
||||
optional string field9 = 9; |
||||
optional string field18 = 18; |
||||
optional bool field80 = 80 [default=false]; |
||||
optional bool field81 = 81 [default=true]; |
||||
required int32 field2 = 2; |
||||
required int32 field3 = 3; |
||||
optional int32 field280 = 280; |
||||
optional int32 field6 = 6 [default=0]; |
||||
optional int64 field22 = 22; |
||||
optional string field4 = 4; |
||||
repeated fixed64 field5 = 5; |
||||
optional bool field59 = 59 [default=false]; |
||||
optional string field7 = 7; |
||||
optional int32 field16 = 16; |
||||
optional int32 field130 = 130 [default=0]; |
||||
optional bool field12 = 12 [default=true]; |
||||
optional bool field17 = 17 [default=true]; |
||||
optional bool field13 = 13 [default=true]; |
||||
optional bool field14 = 14 [default=true]; |
||||
optional int32 field104 = 104 [default=0]; |
||||
optional int32 field100 = 100 [default=0]; |
||||
optional int32 field101 = 101 [default=0]; |
||||
optional string field102 = 102; |
||||
optional string field103 = 103; |
||||
optional int32 field29 = 29 [default=0]; |
||||
optional bool field30 = 30 [default=false]; |
||||
optional int32 field60 = 60 [default=-1]; |
||||
optional int32 field271 = 271 [default=-1]; |
||||
optional int32 field272 = 272 [default=-1]; |
||||
optional int32 field150 = 150; |
||||
optional int32 field23 = 23 [default=0]; |
||||
optional bool field24 = 24 [default=false]; |
||||
optional int32 field25 = 25 [default=0]; |
||||
optional SpeedMessage1SubMessage field15 = 15; |
||||
optional bool field78 = 78; |
||||
optional int32 field67 = 67 [default=0]; |
||||
optional int32 field68 = 68; |
||||
optional int32 field128 = 128 [default=0]; |
||||
optional string field129 = 129 [default="xxxxxxxxxxxxxxxxxxxxx"]; |
||||
optional int32 field131 = 131 [default=0]; |
||||
} |
||||
|
||||
message SpeedMessage1SubMessage { |
||||
optional int32 field1 = 1 [default=0]; |
||||
optional int32 field2 = 2 [default=0]; |
||||
optional int32 field3 = 3 [default=0]; |
||||
optional string field15 = 15; |
||||
optional bool field12 = 12 [default=true]; |
||||
optional int64 field13 = 13; |
||||
optional int64 field14 = 14; |
||||
optional int32 field16 = 16; |
||||
optional int32 field19 = 19 [default=2]; |
||||
optional bool field20 = 20 [default=true]; |
||||
optional bool field28 = 28 [default=true]; |
||||
optional fixed64 field21 = 21; |
||||
optional int32 field22 = 22; |
||||
optional bool field23 = 23 [ default=false ]; |
||||
optional bool field206 = 206 [default=false]; |
||||
optional fixed32 field203 = 203; |
||||
optional int32 field204 = 204; |
||||
optional string field205 = 205; |
||||
optional uint64 field207 = 207; |
||||
optional uint64 field300 = 300; |
||||
} |
||||
|
||||
message SpeedMessage2 { |
||||
optional string field1 = 1; |
||||
optional int64 field3 = 3; |
||||
optional int64 field4 = 4; |
||||
optional int64 field30 = 30; |
||||
optional bool field75 = 75 [default=false]; |
||||
optional string field6 = 6; |
||||
optional bytes field2 = 2; |
||||
optional int32 field21 = 21 [default=0]; |
||||
optional int32 field71 = 71; |
||||
optional float field25 = 25; |
||||
optional int32 field109 = 109 [default=0]; |
||||
optional int32 field210 = 210 [default=0]; |
||||
optional int32 field211 = 211 [default=0]; |
||||
optional int32 field212 = 212 [default=0]; |
||||
optional int32 field213 = 213 [default=0]; |
||||
optional int32 field216 = 216 [default=0]; |
||||
optional int32 field217 = 217 [default=0]; |
||||
optional int32 field218 = 218 [default=0]; |
||||
optional int32 field220 = 220 [default=0]; |
||||
optional int32 field221 = 221 [default=0]; |
||||
optional float field222 = 222 [default=0.0]; |
||||
optional int32 field63 = 63; |
||||
|
||||
repeated group Group1 = 10 { |
||||
required float field11 = 11; |
||||
optional float field26 = 26; |
||||
optional string field12 = 12; |
||||
optional string field13 = 13; |
||||
repeated string field14 = 14; |
||||
required uint64 field15 = 15; |
||||
optional int32 field5 = 5; |
||||
optional string field27 = 27; |
||||
optional int32 field28 = 28; |
||||
optional string field29 = 29; |
||||
optional string field16 = 16; |
||||
repeated string field22 = 22; |
||||
repeated int32 field73 = 73; |
||||
optional int32 field20 = 20 [default=0]; |
||||
optional string field24 = 24; |
||||
optional SpeedMessage2GroupedMessage field31 = 31; |
||||
} |
||||
repeated string field128 = 128; |
||||
optional int64 field131 = 131; |
||||
repeated string field127 = 127; |
||||
optional int32 field129 = 129; |
||||
repeated int64 field130 = 130; |
||||
optional bool field205 = 205 [default=false]; |
||||
optional bool field206 = 206 [default=false]; |
||||
} |
||||
|
||||
message SpeedMessage2GroupedMessage { |
||||
optional float field1 = 1; |
||||
optional float field2 = 2; |
||||
optional float field3 = 3 [default=0.0]; |
||||
optional bool field4 = 4; |
||||
optional bool field5 = 5; |
||||
optional bool field6 = 6 [default=true]; |
||||
optional bool field7 = 7 [default=false]; |
||||
optional float field8 = 8; |
||||
optional bool field9 = 9; |
||||
optional float field10 = 10; |
||||
optional int64 field11 = 11; |
||||
} |
@ -0,0 +1,60 @@ |
||||
using System.ComponentModel; |
||||
using System.IO; |
||||
using NUnit.Framework; |
||||
|
||||
namespace Google.ProtocolBuffers.CompatTests |
||||
{ |
||||
[TestFixture] |
||||
public class TextCompatibilityTests : CompatibilityTests |
||||
{ |
||||
protected override string TestName { get { return "text"; } } |
||||
|
||||
protected override object SerializeMessage<TMessage, TBuilder>(TMessage message) |
||||
{ |
||||
StringWriter text = new StringWriter(); |
||||
message.PrintTo(text); |
||||
return text.ToString(); |
||||
} |
||||
|
||||
protected override TBuilder DeerializeMessage<TMessage, TBuilder>(object message, TBuilder builder, ExtensionRegistry registry) |
||||
{ |
||||
TextFormat.Merge(new StringReader((string)message), registry, (IBuilder)builder); |
||||
return builder; |
||||
} |
||||
|
||||
[Test, Explicit, Description("This test can take a very long time to run.")] |
||||
public override void Message2OptimizeSizeReadPerf() |
||||
{ |
||||
base.Message2OptimizeSizeReadPerf(); |
||||
} |
||||
[Test, Explicit, Description("This test can take a very long time to run.")] |
||||
public override void Message2OptimizeSpeedReadPerf() |
||||
{ |
||||
base.Message2OptimizeSpeedReadPerf(); |
||||
} |
||||
|
||||
[Test, Explicit, Description("This test can take a very long time to run.")] |
||||
public override void RoundTripMessage2OptimizeSize() |
||||
{ |
||||
base.RoundTripMessage2OptimizeSize(); |
||||
} |
||||
|
||||
[Test, Explicit, Description("This test can take a very long time to run.")] |
||||
public override void RoundTripMessage2OptimizeSpeed() |
||||
{ |
||||
base.RoundTripMessage2OptimizeSpeed(); |
||||
} |
||||
|
||||
[Test, Explicit, Description("This test can take a very long time to run.")] |
||||
public override void Message2OptimizeSizeWriterPerf() |
||||
{ |
||||
base.Message2OptimizeSizeWriterPerf(); |
||||
} |
||||
[Test, Explicit, Description("This test can take a very long time to run.")] |
||||
public override void Message2OptimizeSpeedWriterPerf() |
||||
{ |
||||
base.Message2OptimizeSpeedWriterPerf(); |
||||
} |
||||
|
||||
} |
||||
} |
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue