diff --git a/build/build.csproj b/build/build.csproj index a0fcefa2d8..ccd39ce23f 100644 --- a/build/build.csproj +++ b/build/build.csproj @@ -38,6 +38,7 @@ + @@ -54,6 +55,8 @@ + + @@ -68,6 +71,9 @@ $(SourceDirectory)\AddressBook + + $(SourceDirectory)\ProtocolBuffers.Test\TestProtos + $(SourceDirectory)\ProtocolBuffers.Test\TestProtos @@ -108,6 +114,9 @@ $(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos + + $(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos + $(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos @@ -123,7 +132,13 @@ $(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos - + + $(SourceDirectory)\ProtocolBuffers.Test\TestProtos + + + $(SourceDirectory)\ProtocolBuffers.Test\TestProtos + + diff --git a/protos/extest/unittest_extras_xmltest.proto b/protos/extest/unittest_extras_xmltest.proto new file mode 100644 index 0000000000..4a3b881047 --- /dev/null +++ b/protos/extest/unittest_extras_xmltest.proto @@ -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; +} diff --git a/protos/google/test/google_size.proto b/protos/google/test/google_size.proto new file mode 100644 index 0000000000..a38d1388e5 --- /dev/null +++ b/protos/google/test/google_size.proto @@ -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; +} diff --git a/protos/google/test/google_speed.proto b/protos/google/test/google_speed.proto new file mode 100644 index 0000000000..3123b5ce56 --- /dev/null +++ b/protos/google/test/google_speed.proto @@ -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; +} diff --git a/src/ProtoGen/FieldGeneratorBase.cs b/src/ProtoGen/FieldGeneratorBase.cs index c4f5dbf47d..4d2ec43846 100644 --- a/src/ProtoGen/FieldGeneratorBase.cs +++ b/src/ProtoGen/FieldGeneratorBase.cs @@ -133,7 +133,7 @@ namespace Google.ProtocolBuffers.ProtoGen } if (UseLiteRuntime && Descriptor.DefaultValue is ByteString) { - string temp = Convert.ToBase64String(((ByteString) Descriptor.DefaultValue).ToByteArray()); + string temp = (((ByteString) Descriptor.DefaultValue).ToBase64()); return String.Format("ByteString.FromBase64(\"{0}\")", temp); } return string.Format("(pb::ByteString) {0}.Descriptor.Fields[{1}].DefaultValue", diff --git a/src/ProtocolBuffers.Test/CompatTests/BinaryCompatibilityTests.cs b/src/ProtocolBuffers.Test/CompatTests/BinaryCompatibilityTests.cs new file mode 100644 index 0000000000..fe8a1e37d6 --- /dev/null +++ b/src/ProtocolBuffers.Test/CompatTests/BinaryCompatibilityTests.cs @@ -0,0 +1,22 @@ +using System; +using NUnit.Framework; + +namespace Google.ProtocolBuffers.CompatTests +{ + [TestFixture] + public class BinaryCompatibilityTests : CompatibilityTests + { + protected override string TestName { get { return "binary"; } } + + protected override object SerializeMessage(TMessage message) + { + byte[] bresult = message.ToByteArray(); + return bresult; + } + + protected override TBuilder DeerializeMessage(object message, TBuilder builder, ExtensionRegistry registry) + { + return builder.MergeFrom((byte[])message, registry); + } + } +} \ No newline at end of file diff --git a/src/ProtocolBuffers.Test/CompatTests/CompatibilityTests.cs b/src/ProtocolBuffers.Test/CompatTests/CompatibilityTests.cs new file mode 100644 index 0000000000..e74f2b0814 --- /dev/null +++ b/src/ProtocolBuffers.Test/CompatTests/CompatibilityTests.cs @@ -0,0 +1,172 @@ +using System; +using Google.ProtocolBuffers.TestProtos; +using NUnit.Framework; + +namespace Google.ProtocolBuffers.CompatTests +{ + public abstract class CompatibilityTests + { + protected abstract string TestName { get; } + protected abstract object SerializeMessage(TMessage message) + where TMessage : IMessageLite + where TBuilder : IBuilderLite; + + protected abstract TBuilder DeerializeMessage(object message, TBuilder builder, ExtensionRegistry registry) + where TMessage : IMessageLite + where TBuilder : IBuilderLite; + + #region RunBenchmark + + protected void RunBenchmark(byte[] buffer, bool write) + where TMessage : IMessageLite + where TBuilder : IBuilderLite, new() + { + TBuilder builder = new TBuilder(); + TMessage message = new TBuilder().MergeFrom(buffer).Build(); + System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); + //simple warm-up + object content = SerializeMessage(message); + Assert.AreEqual(message, DeerializeMessage(content, new TBuilder(), ExtensionRegistry.Empty).Build()); + //timming + long time = 0, sample = 1; + while (time < 100) + { + sample *= 10; + watch.Reset(); + watch.Start(); + if (write) + { + for (int i = 0; i < sample; i++) + SerializeMessage(message); + } + else + { + for (int i = 0; i < sample; i++) + DeerializeMessage(content, builder, ExtensionRegistry.Empty); + } + watch.Stop(); + time = watch.ElapsedMilliseconds; + } + + ulong rounds = (ulong)((100.0 / watch.ElapsedMilliseconds) * sample); + //test + watch.Reset(); + watch.Start(); + + if (write) + { + for (ulong i = 0; i < rounds; i++) + SerializeMessage(message); + } + else + { + for (ulong i = 0; i < rounds; i++) + DeerializeMessage(content, builder, ExtensionRegistry.Empty); + } + + watch.Stop(); + System.Diagnostics.Trace.TraceInformation( + "\r\n{0} {4} {5} {3:n0} rps ({1:n0} rounds in {2:n0} ms)", typeof(TMessage).Name, rounds, + watch.ElapsedMilliseconds, (1000.0 / watch.ElapsedMilliseconds) * (double)rounds, TestName, write ? " write" : " read"); + GC.GetTotalMemory(true); + GC.WaitForPendingFinalizers(); + } + + [Test] + public virtual void Message1OptimizeSizeWriterPerf() + { + RunBenchmark(TestResources.google_message1, true); + } + [Test] + public virtual void Message1OptimizeSpeedWriterPerf() + { + RunBenchmark(TestResources.google_message1, true); + } + [Test] + public virtual void Message2OptimizeSizeWriterPerf() + { + RunBenchmark(TestResources.google_message2, true); + } + [Test] + public virtual void Message2OptimizeSpeedWriterPerf() + { + RunBenchmark(TestResources.google_message2, true); + } + + [Test] + public virtual void Message1OptimizeSizeReadPerf() + { + RunBenchmark(TestResources.google_message1, false); + } + [Test] + public virtual void Message1OptimizeSpeedReadPerf() + { + RunBenchmark(TestResources.google_message1, false); + } + [Test] + public virtual void Message2OptimizeSizeReadPerf() + { + RunBenchmark(TestResources.google_message2, false); + } + [Test] + public virtual void Message2OptimizeSpeedReadPerf() + { + RunBenchmark(TestResources.google_message2, false); + } + + #endregion + + [Test] + public virtual void RoundTripMessage1OptimizeSize() + { + SizeMessage1 msg = SizeMessage1.CreateBuilder().MergeFrom(TestResources.google_message1).Build(); + object content = SerializeMessage(msg); + + SizeMessage1 copy = DeerializeMessage(content, SizeMessage1.CreateBuilder(), ExtensionRegistry.Empty).Build(); + + Assert.AreEqual(msg, copy); + Assert.AreEqual(content, SerializeMessage(copy)); + Assert.AreEqual(TestResources.google_message1, copy.ToByteArray()); + } + + [Test] + public virtual void RoundTripMessage2OptimizeSize() + { + SizeMessage2 msg = SizeMessage2.CreateBuilder().MergeFrom(TestResources.google_message2).Build(); + object content = SerializeMessage(msg); + + SizeMessage2 copy = DeerializeMessage(content, SizeMessage2.CreateBuilder(), ExtensionRegistry.Empty).Build(); + + Assert.AreEqual(msg, copy); + Assert.AreEqual(content, SerializeMessage(copy)); + Assert.AreEqual(TestResources.google_message2, copy.ToByteArray()); + } + + [Test] + public virtual void RoundTripMessage1OptimizeSpeed() + { + SpeedMessage1 msg = SpeedMessage1.CreateBuilder().MergeFrom(TestResources.google_message1).Build(); + object content = SerializeMessage(msg); + + SpeedMessage1 copy = DeerializeMessage(content, SpeedMessage1.CreateBuilder(), ExtensionRegistry.Empty).Build(); + + Assert.AreEqual(msg, copy); + Assert.AreEqual(content, SerializeMessage(copy)); + Assert.AreEqual(TestResources.google_message1, copy.ToByteArray()); + } + + [Test] + public virtual void RoundTripMessage2OptimizeSpeed() + { + SpeedMessage2 msg = SpeedMessage2.CreateBuilder().MergeFrom(TestResources.google_message2).Build(); + object content = SerializeMessage(msg); + + SpeedMessage2 copy = DeerializeMessage(content, SpeedMessage2.CreateBuilder(), ExtensionRegistry.Empty).Build(); + + Assert.AreEqual(msg, copy); + Assert.AreEqual(content, SerializeMessage(copy)); + Assert.AreEqual(TestResources.google_message2, copy.ToByteArray()); + } + + } +} diff --git a/src/ProtocolBuffers.Test/CompatTests/TestResources.Designer.cs b/src/ProtocolBuffers.Test/CompatTests/TestResources.Designer.cs new file mode 100644 index 0000000000..8565ee80dd --- /dev/null +++ b/src/ProtocolBuffers.Test/CompatTests/TestResources.Designer.cs @@ -0,0 +1,77 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.5444 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Google.ProtocolBuffers.CompatTests { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class TestResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal TestResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Google.ProtocolBuffers.CompatTests.TestResources", typeof(TestResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + internal static byte[] google_message1 { + get { + object obj = ResourceManager.GetObject("google_message1", resourceCulture); + return ((byte[])(obj)); + } + } + + internal static byte[] google_message2 { + get { + object obj = ResourceManager.GetObject("google_message2", resourceCulture); + return ((byte[])(obj)); + } + } + } +} diff --git a/src/ProtocolBuffers.Test/CompatTests/TestResources.resx b/src/ProtocolBuffers.Test/CompatTests/TestResources.resx new file mode 100644 index 0000000000..0481d38805 --- /dev/null +++ b/src/ProtocolBuffers.Test/CompatTests/TestResources.resx @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + google_message1.dat;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + google_message2.dat;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/ProtocolBuffers.Test/CompatTests/TextCompatibilityTests.cs b/src/ProtocolBuffers.Test/CompatTests/TextCompatibilityTests.cs new file mode 100644 index 0000000000..5eba0d3370 --- /dev/null +++ b/src/ProtocolBuffers.Test/CompatTests/TextCompatibilityTests.cs @@ -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 message) + { + StringWriter text = new StringWriter(); + message.PrintTo(text); + return text.ToString(); + } + + protected override TBuilder DeerializeMessage(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(); + } + + } +} \ No newline at end of file diff --git a/src/ProtocolBuffers.Test/CompatTests/google_message1.dat b/src/ProtocolBuffers.Test/CompatTests/google_message1.dat new file mode 100644 index 0000000000..bc0f064cc2 Binary files /dev/null and b/src/ProtocolBuffers.Test/CompatTests/google_message1.dat differ diff --git a/src/ProtocolBuffers.Test/CompatTests/google_message2.dat b/src/ProtocolBuffers.Test/CompatTests/google_message2.dat new file mode 100644 index 0000000000..06c09441b9 Binary files /dev/null and b/src/ProtocolBuffers.Test/CompatTests/google_message2.dat differ diff --git a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj b/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj index 4e07a89aa1..06dda010fa 100644 --- a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj +++ b/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj @@ -34,6 +34,7 @@ false false true + false true @@ -74,6 +75,14 @@ + + + + True + True + TestResources.resx + + @@ -93,6 +102,8 @@ + + @@ -100,6 +111,7 @@ + @@ -129,6 +141,16 @@ true + + + + + + + ResXFileCodeGenerator + TestResources.Designer.cs + +