From 272cb8aee775de65e08b4ab17c485cd678d08266 Mon Sep 17 00:00:00 2001 From: csharptest Date: Tue, 9 Nov 2010 20:49:12 -0600 Subject: Lite feature complete. --- src/ProtoGen/EnumFieldGenerator.cs | 14 +- src/ProtoGen/ExtensionGenerator.cs | 10 + src/ProtoGen/FieldGeneratorBase.cs | 25 +- src/ProtoGen/IFieldSourceGenerator.cs | 4 + src/ProtoGen/MessageFieldGenerator.cs | 13 + src/ProtoGen/MessageGenerator.cs | 47 ++ src/ProtoGen/PrimitiveFieldGenerator.cs | 12 + src/ProtoGen/RepeatedEnumFieldGenerator.cs | 15 + src/ProtoGen/RepeatedMessageFieldGenerator.cs | 17 + src/ProtoGen/RepeatedPrimitiveFieldGenerator.cs | 15 + .../ProtocolBuffers.Test.csproj | 1 - src/ProtocolBuffers.Test/ReflectionTester.cs | 2 +- src/ProtocolBuffers.Test/TestProtos/FIXUP.cs | 14 - .../TestProtos/UnitTestProtoFile.cs | 24 +- src/ProtocolBuffers/AbstractMessage.cs | 4 + src/ProtocolBuffers/AbstractMessageLite.cs | 2 + src/ProtocolBuffers/EnumLite.cs | 12 +- src/ProtocolBuffers/ExtendableMessageLite.cs | 28 + src/ProtocolBuffers/ExtensionInfo.cs | 4 +- src/ProtocolBuffers/FieldSet.cs | 1 + src/ProtocolBuffers/GeneratedExtensionBase.cs | 8 +- src/ProtocolBuffers/GeneratedExtensionLite.cs | 16 +- src/ProtocolBuffers/GeneratedMessageLite.cs | 80 +++ src/ProtocolBuffers/IMessageLite.cs | 5 + src/ProtocolBuffers/TextFormat.cs | 16 +- .../UninitializedMessageException.cs | 14 +- src/ProtocolBuffers/UnknownFieldSet.cs | 12 +- src/ProtocolBuffersLite.Test/InteropLiteTest.cs | 47 ++ .../ProtocolBuffersLiteMixed.Test.csproj | 3 - src/ProtocolBuffersLite.Test/TestLiteByApi.cs | 34 +- .../TestProtos/UnitTestExtrasLiteProtoFile.cs | 141 +++++ .../TestProtos/UnitTestImportLiteProtoFile.cs | 19 + .../UnitTestLiteImportNonLiteProtoFile.cs | 19 + .../TestProtos/UnitTestLiteProtoFile.cs | 662 +++++++++++++++++++++ .../TestProtos/UnitTestProtoFile.cs | 24 +- 35 files changed, 1292 insertions(+), 72 deletions(-) delete mode 100644 src/ProtocolBuffers.Test/TestProtos/FIXUP.cs (limited to 'src') diff --git a/src/ProtoGen/EnumFieldGenerator.cs b/src/ProtoGen/EnumFieldGenerator.cs index cf986303..6cd59869 100644 --- a/src/ProtoGen/EnumFieldGenerator.cs +++ b/src/ProtoGen/EnumFieldGenerator.cs @@ -108,7 +108,19 @@ namespace Google.ProtocolBuffers.ProtoGen { public void GenerateSerializedSizeCode(TextGenerator writer) { writer.WriteLine("if (Has{0}) {{", PropertyName); writer.WriteLine(" size += pb::CodedOutputStream.ComputeEnumSize({0}, (int) {1});", Number, PropertyName); - writer.WriteLine("}"); + writer.WriteLine("}"); + } + + public override void WriteHash(TextGenerator writer) { + writer.WriteLine("if (has{0}) hash ^= {1}_.GetHashCode();", PropertyName, Name); + } + + public override void WriteEquals(TextGenerator writer) { + writer.WriteLine("if (has{0} != other.has{0} || (has{0} && !{1}_.Equals(other.{1}_))) return false;", PropertyName, Name); + } + + public override void WriteToString(TextGenerator writer) { + writer.WriteLine("PrintField(\"{0}\", has{1}, {2}_, writer);", Descriptor.Name, PropertyName, Name); } } } diff --git a/src/ProtoGen/ExtensionGenerator.cs b/src/ProtoGen/ExtensionGenerator.cs index 6e142a66..57713bf7 100644 --- a/src/ProtoGen/ExtensionGenerator.cs +++ b/src/ProtoGen/ExtensionGenerator.cs @@ -97,6 +97,7 @@ namespace Google.ProtocolBuffers.ProtoGen { writer.Indent(); writer.WriteLine("new pb::{0}<{1}, {2}>(", Descriptor.IsRepeated ? "GeneratedRepeatExtensionLite" : "GeneratedExtensionLite", extends, type); writer.Indent(); + writer.WriteLine("\"{0}\",", Descriptor.FullName); writer.WriteLine("{0}.DefaultInstance,", extends); if(!Descriptor.IsRepeated) writer.WriteLine("{0},", Descriptor.HasDefaultValue ? DefaultValue : IsNullableType ? "null" : "default(" + type + ")"); @@ -121,5 +122,14 @@ namespace Google.ProtocolBuffers.ProtoGen { internal void GenerateExtensionRegistrationCode(TextGenerator writer) { writer.WriteLine("registry.Add({0}.{1});", scope, name); } + + public override void WriteHash(TextGenerator writer) { + } + + public override void WriteEquals(TextGenerator writer) { + } + + public override void WriteToString(TextGenerator writer) { + } } } diff --git a/src/ProtoGen/FieldGeneratorBase.cs b/src/ProtoGen/FieldGeneratorBase.cs index 3520dc9e..45a096a0 100644 --- a/src/ProtoGen/FieldGeneratorBase.cs +++ b/src/ProtoGen/FieldGeneratorBase.cs @@ -42,6 +42,10 @@ namespace Google.ProtocolBuffers.ProtoGen { : base(descriptor) { } + public abstract void WriteHash(TextGenerator writer); + public abstract void WriteEquals(TextGenerator writer); + public abstract void WriteToString(TextGenerator writer); + private static bool AllPrintableAscii(string text) { foreach (char c in text) { if (c < 0x20 || c > 0x7e) { @@ -73,11 +77,30 @@ namespace Google.ProtocolBuffers.ProtoGen { case FieldType.UInt32: case FieldType.UInt64: case FieldType.Fixed32: - case FieldType.Fixed64: + case FieldType.Fixed64: + { // The simple Object.ToString converts using the current culture. // We want to always use the invariant culture so it's predictable. IConvertible value = (IConvertible) Descriptor.DefaultValue; + //a few things that must be handled explicitly + if (Descriptor.FieldType == FieldType.Double && value is double) { + if (double.IsNaN((double) value)) + return "double.NaN"; + if (double.IsPositiveInfinity((double) value)) + return "double.PositiveInfinity"; + if (double.IsNegativeInfinity((double) value)) + return "double.NegativeInfinity"; + } + else if (Descriptor.FieldType == FieldType.Float && value is float) { + if (float.IsNaN((float)value)) + return "float.NaN"; + if (float.IsPositiveInfinity((float)value)) + return "float.PositiveInfinity"; + if (float.IsNegativeInfinity((float)value)) + return "float.NegativeInfinity"; + } return value.ToString(CultureInfo.InvariantCulture) + suffix; + } case FieldType.Bool: return (bool) Descriptor.DefaultValue ? "true" : "false"; diff --git a/src/ProtoGen/IFieldSourceGenerator.cs b/src/ProtoGen/IFieldSourceGenerator.cs index 0753c5da..9c71a579 100644 --- a/src/ProtoGen/IFieldSourceGenerator.cs +++ b/src/ProtoGen/IFieldSourceGenerator.cs @@ -41,5 +41,9 @@ namespace Google.ProtocolBuffers.ProtoGen { void GenerateParsingCode(TextGenerator writer); void GenerateSerializationCode(TextGenerator writer); void GenerateSerializedSizeCode(TextGenerator writer); + + void WriteHash(TextGenerator writer); + void WriteEquals(TextGenerator writer); + void WriteToString(TextGenerator writer); } } diff --git a/src/ProtoGen/MessageFieldGenerator.cs b/src/ProtoGen/MessageFieldGenerator.cs index c2b5372e..d952984a 100644 --- a/src/ProtoGen/MessageFieldGenerator.cs +++ b/src/ProtoGen/MessageFieldGenerator.cs @@ -125,5 +125,18 @@ namespace Google.ProtocolBuffers.ProtoGen { MessageOrGroup, Number, PropertyName); writer.WriteLine("}"); } + + public override void WriteHash(TextGenerator writer) { + writer.WriteLine("if (has{0}) hash ^= {1}_.GetHashCode();", PropertyName, Name); + } + + public override void WriteEquals(TextGenerator writer) { + writer.WriteLine("if (has{0} != other.has{0} || (has{0} && !{1}_.Equals(other.{1}_))) return false;", PropertyName, Name); + } + + public override void WriteToString(TextGenerator writer) { + writer.WriteLine("PrintField(\"{2}\", has{0}, {1}_, writer);", PropertyName, Name, + Descriptor.FieldType == FieldType.Group ? Descriptor.MessageType.Name : Descriptor.Name); + } } } diff --git a/src/ProtoGen/MessageGenerator.cs b/src/ProtoGen/MessageGenerator.cs index 47ab318d..43b8b7eb 100644 --- a/src/ProtoGen/MessageGenerator.cs +++ b/src/ProtoGen/MessageGenerator.cs @@ -32,6 +32,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion +using System; using System.Collections.Generic; using Google.ProtocolBuffers.DescriptorProtos; using Google.ProtocolBuffers.Descriptors; @@ -172,6 +173,9 @@ namespace Google.ProtocolBuffers.ProtoGen { GenerateIsInitialized(writer); GenerateMessageSerializationMethods(writer); } + if (UseLiteRuntime) { + GenerateLiteRuntimeMethods(writer); + } GenerateParseFromMethods(writer); GenerateBuilder(writer); @@ -191,6 +195,49 @@ namespace Google.ProtocolBuffers.ProtoGen { writer.WriteLine(); } + private void GenerateLiteRuntimeMethods(TextGenerator writer) { + + bool callbase = Descriptor.Proto.ExtensionRangeCount > 0; + writer.WriteLine("#region Lite runtime methods"); + writer.WriteLine("public override int GetHashCode() {"); + writer.Indent(); + writer.WriteLine("int hash = GetType().GetHashCode();"); + foreach (FieldDescriptor fieldDescriptor in Descriptor.Fields) { + SourceGenerators.CreateFieldGenerator(fieldDescriptor).WriteHash(writer); + } + if (callbase) writer.WriteLine("hash ^= base.GetHashCode();"); + writer.WriteLine("return hash;"); + writer.Outdent(); + writer.WriteLine("}"); + writer.WriteLine(); + + writer.WriteLine("public override bool Equals(object obj) {"); + writer.Indent(); + writer.WriteLine("{0} other = obj as {0};", ClassName); + writer.WriteLine("if (other == null) return false;"); + foreach (FieldDescriptor fieldDescriptor in Descriptor.Fields) { + SourceGenerators.CreateFieldGenerator(fieldDescriptor).WriteEquals(writer); + } + if (callbase) writer.WriteLine("if (!base.Equals(other)) return false;"); + writer.WriteLine("return true;"); + writer.Outdent(); + writer.WriteLine("}"); + writer.WriteLine(); + + writer.WriteLine("public override void PrintTo(global::System.IO.TextWriter writer) {"); + writer.Indent(); + List sorted = new List(Descriptor.Fields); + sorted.Sort(new Comparison(delegate(FieldDescriptor a, FieldDescriptor b) { return a.FieldNumber.CompareTo(b.FieldNumber); })); + foreach (FieldDescriptor fieldDescriptor in sorted) { + SourceGenerators.CreateFieldGenerator(fieldDescriptor).WriteToString(writer); + } + if (callbase) writer.WriteLine("base.PrintTo(writer);"); + writer.Outdent(); + writer.WriteLine("}"); + writer.WriteLine("#endregion"); + writer.WriteLine(); + } + private void GenerateMessageSerializationMethods(TextGenerator writer) { List sortedFields = new List(Descriptor.Fields); sortedFields.Sort((f1, f2) => f1.FieldNumber.CompareTo(f2.FieldNumber)); diff --git a/src/ProtoGen/PrimitiveFieldGenerator.cs b/src/ProtoGen/PrimitiveFieldGenerator.cs index ce3fd238..dbc203d0 100644 --- a/src/ProtoGen/PrimitiveFieldGenerator.cs +++ b/src/ProtoGen/PrimitiveFieldGenerator.cs @@ -103,5 +103,17 @@ namespace Google.ProtocolBuffers.ProtoGen { CapitalizedTypeName, Number, PropertyName); writer.WriteLine("}"); } + + public override void WriteHash(TextGenerator writer) { + writer.WriteLine("if (has{0}) hash ^= {1}_.GetHashCode();", PropertyName, Name); + } + + public override void WriteEquals(TextGenerator writer) { + writer.WriteLine("if (has{0} != other.has{0} || (has{0} && !{1}_.Equals(other.{1}_))) return false;", PropertyName, Name); + } + + public override void WriteToString(TextGenerator writer) { + writer.WriteLine("PrintField(\"{0}\", has{1}, {2}_, writer);", Descriptor.Name, PropertyName, Name); + } } } diff --git a/src/ProtoGen/RepeatedEnumFieldGenerator.cs b/src/ProtoGen/RepeatedEnumFieldGenerator.cs index e30a4c24..c500d38b 100644 --- a/src/ProtoGen/RepeatedEnumFieldGenerator.cs +++ b/src/ProtoGen/RepeatedEnumFieldGenerator.cs @@ -175,5 +175,20 @@ namespace Google.ProtocolBuffers.ProtoGen { writer.Outdent(); writer.WriteLine("}"); } + + public override void WriteHash(TextGenerator writer) { + writer.WriteLine("foreach({0} i in {1}_)", TypeName, Name); + writer.WriteLine(" hash ^= i.GetHashCode();"); + } + + public override void WriteEquals(TextGenerator writer) { + writer.WriteLine("if({0}_.Count != other.{0}_.Count) return false;", Name); + writer.WriteLine("for(int ix=0; ix < {0}_.Count; ix++)", Name); + writer.WriteLine(" if(!{0}_[ix].Equals(other.{0}_[ix])) return false;", Name); + } + + public override void WriteToString(TextGenerator writer) { + writer.WriteLine("PrintField(\"{0}\", {1}_, writer);", Descriptor.Name, Name); + } } } diff --git a/src/ProtoGen/RepeatedMessageFieldGenerator.cs b/src/ProtoGen/RepeatedMessageFieldGenerator.cs index 3eac8090..4461190f 100644 --- a/src/ProtoGen/RepeatedMessageFieldGenerator.cs +++ b/src/ProtoGen/RepeatedMessageFieldGenerator.cs @@ -132,5 +132,22 @@ namespace Google.ProtocolBuffers.ProtoGen { writer.WriteLine(" size += pb::CodedOutputStream.Compute{0}Size({1}, element);", MessageOrGroup, Number); writer.WriteLine("}"); } + + public override void WriteHash(TextGenerator writer) { + writer.WriteLine("foreach({0} i in {1}_)", TypeName, Name); + writer.WriteLine(" hash ^= i.GetHashCode();"); + } + + public override void WriteEquals(TextGenerator writer) { + writer.WriteLine("if({0}_.Count != other.{0}_.Count) return false;", Name); + writer.WriteLine("for(int ix=0; ix < {0}_.Count; ix++)", Name); + writer.WriteLine(" if(!{0}_[ix].Equals(other.{0}_[ix])) return false;", Name); + } + + public override void WriteToString(TextGenerator writer) { + writer.WriteLine("PrintField(\"{0}\", {1}_, writer);", + Descriptor.FieldType == FieldType.Group ? Descriptor.MessageType.Name : Descriptor.Name, Name); + } + } } diff --git a/src/ProtoGen/RepeatedPrimitiveFieldGenerator.cs b/src/ProtoGen/RepeatedPrimitiveFieldGenerator.cs index ebbfe95c..d670c4ce 100644 --- a/src/ProtoGen/RepeatedPrimitiveFieldGenerator.cs +++ b/src/ProtoGen/RepeatedPrimitiveFieldGenerator.cs @@ -168,5 +168,20 @@ namespace Google.ProtocolBuffers.ProtoGen { writer.Outdent(); writer.WriteLine("}"); } + + public override void WriteHash(TextGenerator writer) { + writer.WriteLine("foreach({0} i in {1}_)", TypeName, Name); + writer.WriteLine(" hash ^= i.GetHashCode();"); + } + + public override void WriteEquals(TextGenerator writer) { + writer.WriteLine("if({0}_.Count != other.{0}_.Count) return false;", Name); + writer.WriteLine("for(int ix=0; ix < {0}_.Count; ix++)", Name); + writer.WriteLine(" if(!{0}_[ix].Equals(other.{0}_[ix])) return false;", Name); + } + + public override void WriteToString(TextGenerator writer) { + writer.WriteLine("PrintField(\"{0}\", {1}_, writer);", Descriptor.Name, Name); + } } } diff --git a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj b/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj index 2f1a183c..d64101b6 100644 --- a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj +++ b/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj @@ -73,7 +73,6 @@ - diff --git a/src/ProtocolBuffers.Test/ReflectionTester.cs b/src/ProtocolBuffers.Test/ReflectionTester.cs index 32b64465..3e7ed390 100644 --- a/src/ProtocolBuffers.Test/ReflectionTester.cs +++ b/src/ProtocolBuffers.Test/ReflectionTester.cs @@ -213,7 +213,7 @@ namespace Google.ProtocolBuffers { ExtensionInfo extension = extensionRegistry[field.ContainingType, field.FieldNumber]; Assert.IsNotNull(extension); Assert.IsNotNull(extension.DefaultInstance); - return extension.DefaultInstance.WeakCreateBuilderForType(); + return (IBuilder)extension.DefaultInstance.WeakCreateBuilderForType(); } } diff --git a/src/ProtocolBuffers.Test/TestProtos/FIXUP.cs b/src/ProtocolBuffers.Test/TestProtos/FIXUP.cs deleted file mode 100644 index 39560fb8..00000000 --- a/src/ProtocolBuffers.Test/TestProtos/FIXUP.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Google.ProtocolBuffers.TestProtos { - public sealed partial class TestExtremeDefaultValues { - -#warning ToDo - These values are not currently handled by the generator... - const double InfinityD = double.PositiveInfinity; - const double NaND = double.NaN; - const float InfinityF = float.PositiveInfinity; - const float NaNF = float.NaN; - } -} diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs index 6e6d7c40..5acb333d 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs @@ -12852,7 +12852,7 @@ namespace Google.ProtocolBuffers.TestProtos { public const int InfDoubleFieldNumber = 14; private bool hasInfDouble; - private double infDouble_ = InfinityD; + private double infDouble_ = double.PositiveInfinity; public bool HasInfDouble { get { return hasInfDouble; } } @@ -12862,7 +12862,7 @@ namespace Google.ProtocolBuffers.TestProtos { public const int NegInfDoubleFieldNumber = 15; private bool hasNegInfDouble; - private double negInfDouble_ = -InfinityD; + private double negInfDouble_ = double.NegativeInfinity; public bool HasNegInfDouble { get { return hasNegInfDouble; } } @@ -12872,7 +12872,7 @@ namespace Google.ProtocolBuffers.TestProtos { public const int NanDoubleFieldNumber = 16; private bool hasNanDouble; - private double nanDouble_ = NaND; + private double nanDouble_ = double.NaN; public bool HasNanDouble { get { return hasNanDouble; } } @@ -12882,7 +12882,7 @@ namespace Google.ProtocolBuffers.TestProtos { public const int InfFloatFieldNumber = 17; private bool hasInfFloat; - private float infFloat_ = InfinityF; + private float infFloat_ = float.PositiveInfinity; public bool HasInfFloat { get { return hasInfFloat; } } @@ -12892,7 +12892,7 @@ namespace Google.ProtocolBuffers.TestProtos { public const int NegInfFloatFieldNumber = 18; private bool hasNegInfFloat; - private float negInfFloat_ = -InfinityF; + private float negInfFloat_ = float.NegativeInfinity; public bool HasNegInfFloat { get { return hasNegInfFloat; } } @@ -12902,7 +12902,7 @@ namespace Google.ProtocolBuffers.TestProtos { public const int NanFloatFieldNumber = 19; private bool hasNanFloat; - private float nanFloat_ = NaNF; + private float nanFloat_ = float.NaN; public bool HasNanFloat { get { return hasNanFloat; } } @@ -13558,7 +13558,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder ClearInfDouble() { result.hasInfDouble = false; - result.infDouble_ = InfinityD; + result.infDouble_ = double.PositiveInfinity; return this; } @@ -13576,7 +13576,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder ClearNegInfDouble() { result.hasNegInfDouble = false; - result.negInfDouble_ = -InfinityD; + result.negInfDouble_ = double.NegativeInfinity; return this; } @@ -13594,7 +13594,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder ClearNanDouble() { result.hasNanDouble = false; - result.nanDouble_ = NaND; + result.nanDouble_ = double.NaN; return this; } @@ -13612,7 +13612,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder ClearInfFloat() { result.hasInfFloat = false; - result.infFloat_ = InfinityF; + result.infFloat_ = float.PositiveInfinity; return this; } @@ -13630,7 +13630,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder ClearNegInfFloat() { result.hasNegInfFloat = false; - result.negInfFloat_ = -InfinityF; + result.negInfFloat_ = float.NegativeInfinity; return this; } @@ -13648,7 +13648,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder ClearNanFloat() { result.hasNanFloat = false; - result.nanFloat_ = NaNF; + result.nanFloat_ = float.NaN; return this; } } diff --git a/src/ProtocolBuffers/AbstractMessage.cs b/src/ProtocolBuffers/AbstractMessage.cs index e2cf3827..203b71a4 100644 --- a/src/ProtocolBuffers/AbstractMessage.cs +++ b/src/ProtocolBuffers/AbstractMessage.cs @@ -101,6 +101,10 @@ namespace Google.ProtocolBuffers { return TextFormat.PrintToString(this); } + public sealed override void PrintTo(TextWriter writer) { + TextFormat.Print(this, writer); + } + /// /// Serializes the message and writes it to the given output stream. /// This does not flush or close the stream. diff --git a/src/ProtocolBuffers/AbstractMessageLite.cs b/src/ProtocolBuffers/AbstractMessageLite.cs index 96884753..ee75f3dd 100644 --- a/src/ProtocolBuffers/AbstractMessageLite.cs +++ b/src/ProtocolBuffers/AbstractMessageLite.cs @@ -63,6 +63,8 @@ namespace Google.ProtocolBuffers { //public override int GetHashCode() { //} + public abstract void PrintTo(TextWriter writer); + #region IMessageLite Members /// diff --git a/src/ProtocolBuffers/EnumLite.cs b/src/ProtocolBuffers/EnumLite.cs index ab13c9ab..12497d8e 100644 --- a/src/ProtocolBuffers/EnumLite.cs +++ b/src/ProtocolBuffers/EnumLite.cs @@ -46,6 +46,7 @@ namespace Google.ProtocolBuffers { /// public interface IEnumLite { int Number { get; } + string Name { get; } } /// @@ -69,12 +70,15 @@ namespace Google.ProtocolBuffers { where TEnum : struct, IComparable, IFormattable { struct EnumValue : IEnumLite { - readonly int value; - public EnumValue(int value) { + readonly TEnum value; + public EnumValue(TEnum value) { this.value = value; } int IEnumLite.Number { - get { return value; } + get { return Convert.ToInt32(value); } + } + string IEnumLite.Name { + get { return value.ToString(); } } } @@ -83,7 +87,7 @@ namespace Google.ProtocolBuffers { public EnumLiteMap() { items = new SortedList(); foreach (TEnum evalue in Enum.GetValues(typeof(TEnum))) - items.Add(Convert.ToInt32(evalue), new EnumValue(Convert.ToInt32(evalue))); + items.Add(Convert.ToInt32(evalue), new EnumValue(evalue)); } IEnumLite IEnumLiteMap.FindValueByNumber(int number) { diff --git a/src/ProtocolBuffers/ExtendableMessageLite.cs b/src/ProtocolBuffers/ExtendableMessageLite.cs index fc2ccb6c..aed8545d 100644 --- a/src/ProtocolBuffers/ExtendableMessageLite.cs +++ b/src/ProtocolBuffers/ExtendableMessageLite.cs @@ -33,7 +33,10 @@ #endregion using System; +using System.Collections; using System.Collections.Generic; +using Google.ProtocolBuffers.Collections; + namespace Google.ProtocolBuffers { public abstract class ExtendableMessageLite : GeneratedMessageLite where TMessage : GeneratedMessageLite @@ -49,6 +52,31 @@ namespace Google.ProtocolBuffers { get { return extensions; } } + public override bool Equals(object obj) { + ExtendableMessageLite other = obj as ExtendableMessageLite; + return !ReferenceEquals(null, other) && + Dictionaries.Equals(extensions.AllFields, other.extensions.AllFields); + } + + public override int GetHashCode() { + return Dictionaries.GetHashCode(extensions.AllFields); + } + + /// + /// writes the extensions to the text stream + /// + public override void PrintTo(System.IO.TextWriter writer) { + foreach (KeyValuePair entry in extensions.AllFields) { + string fn = string.Format("[{0}]", entry.Key.FullName); + if (entry.Key.IsRepeated) { + foreach (object o in ((IEnumerable)entry.Value)) + PrintField(fn, true, o, writer); + } else { + PrintField(fn, true, entry.Value, writer); + } + } + } + /// /// Checks if a singular extension is present. /// diff --git a/src/ProtocolBuffers/ExtensionInfo.cs b/src/ProtocolBuffers/ExtensionInfo.cs index 482f006a..5d99b8ff 100644 --- a/src/ProtocolBuffers/ExtensionInfo.cs +++ b/src/ProtocolBuffers/ExtensionInfo.cs @@ -48,12 +48,12 @@ namespace Google.ProtocolBuffers /// A default instance of the extensions's type, if it has a message type, /// or null otherwise. /// - public IMessage DefaultInstance { get; private set; } + public IMessageLite DefaultInstance { get; private set; } internal ExtensionInfo(FieldDescriptor descriptor) : this(descriptor, null) { } - internal ExtensionInfo(FieldDescriptor descriptor, IMessage defaultInstance) { + internal ExtensionInfo(FieldDescriptor descriptor, IMessageLite defaultInstance) { Descriptor = descriptor; DefaultInstance = defaultInstance; } diff --git a/src/ProtocolBuffers/FieldSet.cs b/src/ProtocolBuffers/FieldSet.cs index 838d0568..c3e3d740 100644 --- a/src/ProtocolBuffers/FieldSet.cs +++ b/src/ProtocolBuffers/FieldSet.cs @@ -47,6 +47,7 @@ namespace Google.ProtocolBuffers { bool IsExtension { get; } bool MessageSetWireFormat { get; } //field.ContainingType.Options.MessageSetWireFormat int FieldNumber { get; } + string FullName { get; } IEnumLiteMap EnumType { get; } FieldType FieldType { get; } MappedType MappedType { get; } diff --git a/src/ProtocolBuffers/GeneratedExtensionBase.cs b/src/ProtocolBuffers/GeneratedExtensionBase.cs index 36da58e6..aacc0655 100644 --- a/src/ProtocolBuffers/GeneratedExtensionBase.cs +++ b/src/ProtocolBuffers/GeneratedExtensionBase.cs @@ -66,7 +66,7 @@ namespace Google.ProtocolBuffers { public abstract class GeneratedExtensionBase { private readonly FieldDescriptor descriptor; - private readonly IMessage messageDefaultInstance; + private readonly IMessageLite messageDefaultInstance; protected GeneratedExtensionBase(FieldDescriptor descriptor, Type singularExtensionType) { if (!descriptor.IsExtension) { @@ -80,8 +80,8 @@ namespace Google.ProtocolBuffers { if (defaultInstanceProperty == null) { throw new ArgumentException("No public static DefaultInstance property for type " + typeof(TExtension).Name); } -#warning ToDo - Invalid cast, could be IMessageLite - messageDefaultInstance = (IMessage)defaultInstanceProperty.GetValue(null, null); + + messageDefaultInstance = (IMessageLite)defaultInstanceProperty.GetValue(null, null); } } @@ -96,7 +96,7 @@ namespace Google.ProtocolBuffers { /// /// Returns the default message instance for extensions which are message types. /// - public IMessage MessageDefaultInstance { + public IMessageLite MessageDefaultInstance { get { return messageDefaultInstance; } } diff --git a/src/ProtocolBuffers/GeneratedExtensionLite.cs b/src/ProtocolBuffers/GeneratedExtensionLite.cs index 81d8d41b..33969f4b 100644 --- a/src/ProtocolBuffers/GeneratedExtensionLite.cs +++ b/src/ProtocolBuffers/GeneratedExtensionLite.cs @@ -48,6 +48,7 @@ namespace Google.ProtocolBuffers { } public class ExtensionDescriptorLite : IFieldDescriptorLite { + private readonly string fullName; private readonly IEnumLiteMap enumTypeMap; private readonly int number; private readonly FieldType type; @@ -56,7 +57,8 @@ namespace Google.ProtocolBuffers { private readonly MappedType mapType; private readonly object defaultValue; - public ExtensionDescriptorLite(IEnumLiteMap enumTypeMap, int number, FieldType type, object defaultValue, bool isRepeated, bool isPacked) { + public ExtensionDescriptorLite(string fullName, IEnumLiteMap enumTypeMap, int number, FieldType type, object defaultValue, bool isRepeated, bool isPacked) { + this.fullName = fullName; this.enumTypeMap = enumTypeMap; this.number = number; this.type = type; @@ -66,6 +68,8 @@ namespace Google.ProtocolBuffers { this.defaultValue = defaultValue; } + public string FullName { get { return fullName; } } + public bool IsRepeated { get { return isRepeated; } } @@ -116,9 +120,9 @@ namespace Google.ProtocolBuffers { public class GeneratedRepeatExtensionLite : GeneratedExtensionLite> where TContainingType : IMessageLite { - public GeneratedRepeatExtensionLite(TContainingType containingTypeDefaultInstance, + public GeneratedRepeatExtensionLite(string fullName, TContainingType containingTypeDefaultInstance, IMessageLite messageDefaultInstance, IEnumLiteMap enumTypeMap, int number, FieldType type, bool isPacked) : - base(containingTypeDefaultInstance, new List(), messageDefaultInstance, enumTypeMap, number, type, isPacked) { + base(fullName, containingTypeDefaultInstance, new List(), messageDefaultInstance, enumTypeMap, number, type, isPacked) { } public override object ToReflectionType(object value) { @@ -167,6 +171,7 @@ namespace Google.ProtocolBuffers { /** For use by generated code only. */ public GeneratedExtensionLite( + string fullName, TContainingType containingTypeDefaultInstance, TExtensionType defaultValue, IMessageLite messageDefaultInstance, @@ -174,13 +179,14 @@ namespace Google.ProtocolBuffers { int number, FieldType type) : this(containingTypeDefaultInstance, defaultValue, messageDefaultInstance, - new ExtensionDescriptorLite(enumTypeMap, number, type, defaultValue, + new ExtensionDescriptorLite(fullName, enumTypeMap, number, type, defaultValue, false /* isRepeated */, false /* isPacked */)) { } private static readonly IList Empty = new object[0]; /** Repeating fields: For use by generated code only. */ protected GeneratedExtensionLite( + string fullName, TContainingType containingTypeDefaultInstance, TExtensionType defaultValue, IMessageLite messageDefaultInstance, @@ -189,7 +195,7 @@ namespace Google.ProtocolBuffers { FieldType type, bool isPacked) : this(containingTypeDefaultInstance, defaultValue, messageDefaultInstance, - new ExtensionDescriptorLite(enumTypeMap, number, type, Empty, + new ExtensionDescriptorLite(fullName, enumTypeMap, number, type, Empty, true /* isRepeated */, isPacked)) { } diff --git a/src/ProtocolBuffers/GeneratedMessageLite.cs b/src/ProtocolBuffers/GeneratedMessageLite.cs index fd1c6216..b2a009c4 100644 --- a/src/ProtocolBuffers/GeneratedMessageLite.cs +++ b/src/ProtocolBuffers/GeneratedMessageLite.cs @@ -35,6 +35,8 @@ using System; using System.Collections.Generic; using System.Collections; +using System.Globalization; +using Google.ProtocolBuffers.Descriptors; namespace Google.ProtocolBuffers { @@ -48,5 +50,83 @@ namespace Google.ProtocolBuffers { where TBuilder : GeneratedBuilderLite { protected abstract TMessage ThisMessage { get; } + + public sealed override string ToString() { + using (System.IO.StringWriter wtr = new System.IO.StringWriter()) { + PrintTo(wtr); + return wtr.ToString(); + } + } + + /// + /// PrintTo() helper methods for Lite Runtime + /// + protected static void PrintField(string name, IList value, System.IO.TextWriter writer) { + foreach (T item in value) + PrintField(name, true, (object)item, writer); + } + /// + /// PrintTo() helper methods for Lite Runtime + /// + protected static void PrintField(string name, bool hasValue, object value, System.IO.TextWriter writer) { + if (!hasValue) return; + if (value is IMessageLite) { + writer.WriteLine("{0} {{", name); + ((IMessageLite)value).PrintTo(writer); + writer.WriteLine("}"); + } else if (value is ByteString || value is String) { + writer.Write("{0}: \"", name); + if(value is String) + EscapeBytes( System.Text.Encoding.UTF8.GetBytes((string)value), writer); + else + EscapeBytes(((ByteString)value), writer); + writer.WriteLine("\""); + } else if (value is bool) { + writer.WriteLine("{0}: {1}", name, (bool)value ? "true" : "false"); + } else if (value is IEnumLite) { + writer.WriteLine("{0}: {1}", name, ((IEnumLite)value).Name); + } + else { + writer.WriteLine("{0}: {1}", name, ((IConvertible)value).ToString(CultureInfo.InvariantCulture)); + } + } + + /// + /// COPIED from TextFormat + /// Escapes bytes in the format used in protocol buffer text format, which + /// is the same as the format used for C string literals. All bytes + /// that are not printable 7-bit ASCII characters are escaped, as well as + /// backslash, single-quote, and double-quote characters. Characters for + /// which no defined short-hand escape sequence is defined will be escaped + /// using 3-digit octal sequences. + /// The returned value is guaranteed to be entirely ASCII. + /// + private static void EscapeBytes(IEnumerable input, System.IO.TextWriter writer) { + foreach (byte b in input) { + switch (b) { + // C# does not use \a or \v + case 0x07: writer.Write("\\a"); break; + case (byte)'\b': writer.Write("\\b"); break; + case (byte)'\f': writer.Write("\\f"); break; + case (byte)'\n': writer.Write("\\n"); break; + case (byte)'\r': writer.Write("\\r"); break; + case (byte)'\t': writer.Write("\\t"); break; + case 0x0b: writer.Write("\\v"); break; + case (byte)'\\': writer.Write("\\\\"); break; + case (byte)'\'': writer.Write("\\\'"); break; + case (byte)'"': writer.Write("\\\""); break; + default: + if (b >= 0x20 && b < 128) { + writer.Write((char)b); + } else { + writer.Write('\\'); + writer.Write((char)('0' + ((b >> 6) & 3))); + writer.Write((char)('0' + ((b >> 3) & 7))); + writer.Write((char)('0' + (b & 7))); + } + break; + } + } + } } } diff --git a/src/ProtocolBuffers/IMessageLite.cs b/src/ProtocolBuffers/IMessageLite.cs index cb64e021..48660882 100644 --- a/src/ProtocolBuffers/IMessageLite.cs +++ b/src/ProtocolBuffers/IMessageLite.cs @@ -103,6 +103,11 @@ namespace Google.ProtocolBuffers { /// string ToString(); + /// + /// Converts the message to a string. + /// + void PrintTo(TextWriter writer); + /// /// Serializes the message to a ByteString. This is a trivial wrapper /// around WriteTo(CodedOutputStream). diff --git a/src/ProtocolBuffers/TextFormat.cs b/src/ProtocolBuffers/TextFormat.cs index 81033087..81b3447c 100644 --- a/src/ProtocolBuffers/TextFormat.cs +++ b/src/ProtocolBuffers/TextFormat.cs @@ -170,17 +170,19 @@ namespace Google.ProtocolBuffers { } case FieldType.Enum: { - generator.Print(((EnumValueDescriptor) value).Name); + if (value is IEnumLite && !(value is EnumValueDescriptor)) { + throw new NotSupportedException("Lite enumerations are not supported."); + } + generator.Print(((EnumValueDescriptor)value).Name); break; } case FieldType.Message: case FieldType.Group: - if (value is IMessage) { - Print((IMessage)value, generator); - } else { -#warning ToDo - What do we print for IMessageLite? + if (value is IMessageLite && !(value is IMessage)) { + throw new NotSupportedException("Lite messages are not supported."); } + Print((IMessage)value, generator); break; } } @@ -580,7 +582,9 @@ namespace Google.ProtocolBuffers { if (extension == null) { subBuilder = builder.CreateBuilderForField(field); } else { - subBuilder = extension.DefaultInstance.WeakCreateBuilderForType(); + subBuilder = extension.DefaultInstance.WeakCreateBuilderForType() as IBuilder; + if (subBuilder == null) + throw new NotSupportedException("Lite messages are not supported."); } while (!tokenizer.TryConsume(endToken)) { diff --git a/src/ProtocolBuffers/UninitializedMessageException.cs b/src/ProtocolBuffers/UninitializedMessageException.cs index c5bcd822..d7f58197 100644 --- a/src/ProtocolBuffers/UninitializedMessageException.cs +++ b/src/ProtocolBuffers/UninitializedMessageException.cs @@ -124,16 +124,24 @@ namespace Google.ProtocolBuffers { foreach (KeyValuePair entry in message.AllFields) { FieldDescriptor field = entry.Key; object value = entry.Value; -#warning ToDo - bad assumption, could be IMessageLite + if (field.MappedType == MappedType.Message) { if (field.IsRepeated) { int i = 0; foreach (object element in (IEnumerable) value) { - FindMissingFields((IMessage) element, SubMessagePrefix(prefix, field, i++), results); + if (element is IMessage) { + FindMissingFields((IMessage)element, SubMessagePrefix(prefix, field, i++), results); + } else { + results.Add(prefix + field.Name); + } } } else { if (message.HasField(field)) { - FindMissingFields((IMessage) value, SubMessagePrefix(prefix, field, -1), results); + if (value is IMessage) { + FindMissingFields((IMessage)value, SubMessagePrefix(prefix, field, -1), results); + } else { + results.Add(prefix + field.Name); + } } } } diff --git a/src/ProtocolBuffers/UnknownFieldSet.cs b/src/ProtocolBuffers/UnknownFieldSet.cs index 515637cc..594ae8bd 100644 --- a/src/ProtocolBuffers/UnknownFieldSet.cs +++ b/src/ProtocolBuffers/UnknownFieldSet.cs @@ -138,6 +138,14 @@ namespace Google.ProtocolBuffers { return TextFormat.PrintToString(this); } + /// + /// Converts the set to a string in protocol buffer text format. This + /// is just a trivial wrapper around TextFormat.PrintToString. + /// + public void PrintTo(TextWriter writer) { + TextFormat.Print(this, writer); + } + /// /// Serializes the message to a ByteString and returns it. This is /// just a trivial wrapper around WriteTo(CodedOutputStream). @@ -533,7 +541,7 @@ namespace Google.ProtocolBuffers { int fieldNumber = WireFormat.GetTagFieldNumber(tag); FieldDescriptor field; - IMessage defaultFieldInstance = null; + IMessageLite defaultFieldInstance = null; if (type.IsExtensionNumber(fieldNumber)) { ExtensionInfo extension = extensionRegistry[type, fieldNumber]; @@ -644,7 +652,7 @@ namespace Google.ProtocolBuffers { int typeId = 0; ByteString rawBytes = null; // If we encounter "message" before "typeId" - IBuilder subBuilder = null; + IBuilderLite subBuilder = null; FieldDescriptor field = null; while (true) { diff --git a/src/ProtocolBuffersLite.Test/InteropLiteTest.cs b/src/ProtocolBuffersLite.Test/InteropLiteTest.cs index 30d696da..bd4dba59 100644 --- a/src/ProtocolBuffersLite.Test/InteropLiteTest.cs +++ b/src/ProtocolBuffersLite.Test/InteropLiteTest.cs @@ -111,5 +111,52 @@ namespace Google.ProtocolBuffers { Assert.AreEqual(person.ToByteArray(), copy.ToByteArray()); } + + public ByteString AllBytes { + get { + byte[] bytes = new byte[256]; + for (int i = 0; i < bytes.Length; i++) + bytes[i] = (byte)i; + return ByteString.CopyFrom(bytes); + } + } + + [Test] + public void TestCompareStringValues() { + TestInteropPersonLite person = TestInteropPersonLite.CreateBuilder() + .SetId(123) + .SetName("abc") + .SetEmail("abc@123.com") + .AddRangeCodes(new[] { 1, 2, 3 }) + .AddPhone(TestInteropPersonLite.Types.PhoneNumber.CreateBuilder().SetNumber("555-1234").Build()) + .AddPhone(TestInteropPersonLite.Types.PhoneNumber.CreateBuilder().SetNumber(System.Text.Encoding.ASCII.GetString(AllBytes.ToByteArray())).Build()) + .AddAddresses(TestInteropPersonLite.Types.Addresses.CreateBuilder().SetAddress("123 Seseme").SetCity("Wonderland").SetState("NA").SetZip(12345).Build()) + .SetExtension(UnitTestExtrasLiteProtoFile.EmployeeIdLite, TestInteropEmployeeIdLite.CreateBuilder().SetNumber("123").Build()) + .Build(); + Assert.IsTrue(person.IsInitialized); + + ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); + UnitTestExtrasFullProtoFile.RegisterAllExtensions(registry); + + TestInteropPerson copy = TestInteropPerson.ParseFrom(person.ToByteArray(), registry); + + Assert.AreEqual(person.ToByteArray(), copy.ToByteArray()); + + TestInteropPerson.Builder copyBuilder = TestInteropPerson.CreateBuilder(); + TextFormat.Merge(person.ToString().Replace("[protobuf_unittest_extra.employee_id_lite]", "[protobuf_unittest_extra.employee_id]"), registry, copyBuilder); + + copy = copyBuilder.Build(); + Assert.AreEqual(person.ToByteArray(), copy.ToByteArray()); + + string liteText = person.ToString().TrimEnd().Replace("\r", ""); + string fullText = copy.ToString().TrimEnd().Replace("\r", ""); + //map the extension type + liteText = liteText.Replace("[protobuf_unittest_extra.employee_id_lite]", "[protobuf_unittest_extra.employee_id]"); + //lite version does not indent + while (fullText.IndexOf("\n ") >= 0) + fullText = fullText.Replace("\n ", "\n"); + + Assert.AreEqual(fullText, liteText); + } } } diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj b/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj index 8e8c89e6..9e667e8f 100644 --- a/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj +++ b/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj @@ -57,9 +57,6 @@ Properties\AssemblyInfo.cs - - TestProtos\FIXUP.cs - diff --git a/src/ProtocolBuffersLite.Test/TestLiteByApi.cs b/src/ProtocolBuffersLite.Test/TestLiteByApi.cs index 32dc9506..dfa32221 100644 --- a/src/ProtocolBuffersLite.Test/TestLiteByApi.cs +++ b/src/ProtocolBuffersLite.Test/TestLiteByApi.cs @@ -42,12 +42,44 @@ namespace Google.ProtocolBuffers { [TestFixture] public class TestLiteByApi { - [Test, Ignore("Currently broken as equality/hash is not implemented")] + [Test] public void TestAllTypesEquality() { TestAllTypesLite msg = TestAllTypesLite.DefaultInstance; TestAllTypesLite copy = msg.ToBuilder().Build(); Assert.AreEqual(msg.GetHashCode(), copy.GetHashCode()); Assert.IsTrue(msg.Equals(copy)); + msg = msg.ToBuilder().SetOptionalString("Hi").Build(); + Assert.AreNotEqual(msg.GetHashCode(), copy.GetHashCode()); + Assert.IsFalse(msg.Equals(copy)); + copy = copy.ToBuilder().SetOptionalString("Hi").Build(); + Assert.AreEqual(msg.GetHashCode(), copy.GetHashCode()); + Assert.IsTrue(msg.Equals(copy)); + } + + [Test] + public void TestEqualityOnExtensions() { + TestAllExtensionsLite msg = TestAllExtensionsLite.DefaultInstance; + TestAllExtensionsLite copy = msg.ToBuilder().Build(); + Assert.AreEqual(msg.GetHashCode(), copy.GetHashCode()); + Assert.IsTrue(msg.Equals(copy)); + msg = msg.ToBuilder().SetExtension(UnitTestLiteProtoFile.OptionalStringExtensionLite, "Hi").Build(); + Assert.AreNotEqual(msg.GetHashCode(), copy.GetHashCode()); + Assert.IsFalse(msg.Equals(copy)); + copy = copy.ToBuilder().SetExtension(UnitTestLiteProtoFile.OptionalStringExtensionLite, "Hi").Build(); + Assert.AreEqual(msg.GetHashCode(), copy.GetHashCode()); + Assert.IsTrue(msg.Equals(copy)); + } + + [Test] + public void TestAllTypesToString() { + TestAllTypesLite msg = TestAllTypesLite.DefaultInstance; + TestAllTypesLite copy = msg.ToBuilder().Build(); + Assert.AreEqual(msg.ToString(), copy.ToString()); + Assert.IsEmpty(msg.ToString()); + msg = msg.ToBuilder().SetOptionalInt32(-1).Build(); + Assert.AreEqual("optional_int32: -1", msg.ToString().TrimEnd()); + msg = msg.ToBuilder().SetOptionalString("abc123").Build(); + Assert.AreEqual("optional_int32: -1\noptional_string: \"abc123\"", msg.ToString().Replace("\r", "").TrimEnd()); } [Test] diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs index 07314f8a..82492165 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs @@ -26,6 +26,7 @@ namespace Google.ProtocolBuffers.TestProtos { Descriptor = null; global::Google.ProtocolBuffers.TestProtos.UnitTestExtrasLiteProtoFile.EmployeeIdLite = new pb::GeneratedExtensionLite( + "protobuf_unittest_extra.employee_id_lite", global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.DefaultInstance, null, global::Google.ProtocolBuffers.TestProtos.TestInteropEmployeeIdLite.DefaultInstance, @@ -117,6 +118,28 @@ namespace Google.ProtocolBuffers.TestProtos { } } + #region Lite runtime methods + public override int GetHashCode() { + int hash = GetType().GetHashCode(); + if (hasD) hash ^= d_.GetHashCode(); + if (hasEn) hash ^= en_.GetHashCode(); + return hash; + } + + public override bool Equals(object obj) { + TestRequiredLite other = obj as TestRequiredLite; + if (other == null) return false; + if (hasD != other.hasD || (hasD && !d_.Equals(other.d_))) return false; + if (hasEn != other.hasEn || (hasEn && !en_.Equals(other.en_))) return false; + return true; + } + + public override void PrintTo(global::System.IO.TextWriter writer) { + PrintField("d", hasD, d_, writer); + PrintField("en", hasEn, en_, writer); + } + #endregion + public static TestRequiredLite ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -375,6 +398,28 @@ namespace Google.ProtocolBuffers.TestProtos { } } + #region Lite runtime methods + public override int GetHashCode() { + int hash = GetType().GetHashCode(); + if (hasNumber) hash ^= number_.GetHashCode(); + if (hasType) hash ^= type_.GetHashCode(); + return hash; + } + + public override bool Equals(object obj) { + PhoneNumber other = obj as PhoneNumber; + if (other == null) return false; + if (hasNumber != other.hasNumber || (hasNumber && !number_.Equals(other.number_))) return false; + if (hasType != other.hasType || (hasType && !type_.Equals(other.type_))) return false; + return true; + } + + public override void PrintTo(global::System.IO.TextWriter writer) { + PrintField("number", hasNumber, number_, writer); + PrintField("type", hasType, type_, writer); + } + #endregion + public static PhoneNumber ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -664,6 +709,37 @@ namespace Google.ProtocolBuffers.TestProtos { } } + #region Lite runtime methods + public override int GetHashCode() { + int hash = GetType().GetHashCode(); + if (hasAddress) hash ^= address_.GetHashCode(); + if (hasAddress2) hash ^= address2_.GetHashCode(); + if (hasCity) hash ^= city_.GetHashCode(); + if (hasState) hash ^= state_.GetHashCode(); + if (hasZip) hash ^= zip_.GetHashCode(); + return hash; + } + + public override bool Equals(object obj) { + Addresses other = obj as Addresses; + if (other == null) return false; + if (hasAddress != other.hasAddress || (hasAddress && !address_.Equals(other.address_))) return false; + if (hasAddress2 != other.hasAddress2 || (hasAddress2 && !address2_.Equals(other.address2_))) return false; + if (hasCity != other.hasCity || (hasCity && !city_.Equals(other.city_))) return false; + if (hasState != other.hasState || (hasState && !state_.Equals(other.state_))) return false; + if (hasZip != other.hasZip || (hasZip && !zip_.Equals(other.zip_))) return false; + return true; + } + + public override void PrintTo(global::System.IO.TextWriter writer) { + PrintField("address", hasAddress, address_, writer); + PrintField("address2", hasAddress2, address2_, writer); + PrintField("city", hasCity, city_, writer); + PrintField("state", hasState, state_, writer); + PrintField("zip", hasZip, zip_, writer); + } + #endregion + public static Addresses ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1057,6 +1133,52 @@ namespace Google.ProtocolBuffers.TestProtos { } } + #region Lite runtime methods + public override int GetHashCode() { + int hash = GetType().GetHashCode(); + if (hasName) hash ^= name_.GetHashCode(); + if (hasId) hash ^= id_.GetHashCode(); + if (hasEmail) hash ^= email_.GetHashCode(); + foreach(int i in codes_) + hash ^= i.GetHashCode(); + foreach(global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber i in phone_) + hash ^= i.GetHashCode(); + foreach(global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses i in addresses_) + hash ^= i.GetHashCode(); + hash ^= base.GetHashCode(); + return hash; + } + + public override bool Equals(object obj) { + TestInteropPersonLite other = obj as TestInteropPersonLite; + if (other == null) return false; + if (hasName != other.hasName || (hasName && !name_.Equals(other.name_))) return false; + if (hasId != other.hasId || (hasId && !id_.Equals(other.id_))) return false; + if (hasEmail != other.hasEmail || (hasEmail && !email_.Equals(other.email_))) return false; + if(codes_.Count != other.codes_.Count) return false; + for(int ix=0; ix < codes_.Count; ix++) + if(!codes_[ix].Equals(other.codes_[ix])) return false; + if(phone_.Count != other.phone_.Count) return false; + for(int ix=0; ix < phone_.Count; ix++) + if(!phone_[ix].Equals(other.phone_[ix])) return false; + if(addresses_.Count != other.addresses_.Count) return false; + for(int ix=0; ix < addresses_.Count; ix++) + if(!addresses_[ix].Equals(other.addresses_[ix])) return false; + if (!base.Equals(other)) return false; + return true; + } + + public override void PrintTo(global::System.IO.TextWriter writer) { + PrintField("name", hasName, name_, writer); + PrintField("id", hasId, id_, writer); + PrintField("email", hasEmail, email_, writer); + PrintField("phone", phone_, writer); + PrintField("Addresses", addresses_, writer); + PrintField("codes", codes_, writer); + base.PrintTo(writer); + } + #endregion + public static TestInteropPersonLite ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1436,6 +1558,25 @@ namespace Google.ProtocolBuffers.TestProtos { } } + #region Lite runtime methods + public override int GetHashCode() { + int hash = GetType().GetHashCode(); + if (hasNumber) hash ^= number_.GetHashCode(); + return hash; + } + + public override bool Equals(object obj) { + TestInteropEmployeeIdLite other = obj as TestInteropEmployeeIdLite; + if (other == null) return false; + if (hasNumber != other.hasNumber || (hasNumber && !number_.Equals(other.number_))) return false; + return true; + } + + public override void PrintTo(global::System.IO.TextWriter writer) { + PrintField("number", hasNumber, number_, writer); + } + #endregion + public static TestInteropEmployeeIdLite ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportLiteProtoFile.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportLiteProtoFile.cs index 25a62f50..498d686a 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportLiteProtoFile.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportLiteProtoFile.cs @@ -84,6 +84,25 @@ namespace Google.ProtocolBuffers.TestProtos { } } + #region Lite runtime methods + public override int GetHashCode() { + int hash = GetType().GetHashCode(); + if (hasD) hash ^= d_.GetHashCode(); + return hash; + } + + public override bool Equals(object obj) { + ImportMessageLite other = obj as ImportMessageLite; + if (other == null) return false; + if (hasD != other.hasD || (hasD && !d_.Equals(other.d_))) return false; + return true; + } + + public override void PrintTo(global::System.IO.TextWriter writer) { + PrintField("d", hasD, d_, writer); + } + #endregion + public static ImportMessageLite ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteImportNonLiteProtoFile.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteImportNonLiteProtoFile.cs index f628f2cc..a00d83d3 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteImportNonLiteProtoFile.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteImportNonLiteProtoFile.cs @@ -75,6 +75,25 @@ namespace Google.ProtocolBuffers.TestProtos { } } + #region Lite runtime methods + public override int GetHashCode() { + int hash = GetType().GetHashCode(); + if (hasMessage) hash ^= message_.GetHashCode(); + return hash; + } + + public override bool Equals(object obj) { + TestLiteImportsNonlite other = obj as TestLiteImportsNonlite; + if (other == null) return false; + if (hasMessage != other.hasMessage || (hasMessage && !message_.Equals(other.message_))) return false; + return true; + } + + public override void PrintTo(global::System.IO.TextWriter writer) { + PrintField("message", hasMessage, message_, writer); + } + #endregion + public static TestLiteImportsNonlite ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteProtoFile.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteProtoFile.cs index 4b1a018a..62964944 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteProtoFile.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteProtoFile.cs @@ -286,6 +286,7 @@ namespace Google.ProtocolBuffers.TestProtos { Descriptor = null; global::Google.ProtocolBuffers.TestProtos.TestNestedExtensionLite.NestedExtension = new pb::GeneratedExtensionLite( + "protobuf_unittest.TestNestedExtensionLite.nested_extension", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, default(int), null, @@ -294,6 +295,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Int32); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalInt32ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_int32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, default(int), null, @@ -302,6 +304,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Int32); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalInt64ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_int64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, default(long), null, @@ -310,6 +313,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Int64); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalUint32ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_uint32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, default(uint), null, @@ -318,6 +322,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.UInt32); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalUint64ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_uint64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, default(ulong), null, @@ -326,6 +331,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.UInt64); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalSint32ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_sint32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, default(int), null, @@ -334,6 +340,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.SInt32); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalSint64ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_sint64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, default(long), null, @@ -342,6 +349,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.SInt64); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalFixed32ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_fixed32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, default(uint), null, @@ -350,6 +358,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Fixed32); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalFixed64ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_fixed64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, default(ulong), null, @@ -358,6 +367,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Fixed64); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalSfixed32ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_sfixed32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, default(int), null, @@ -366,6 +376,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.SFixed32); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalSfixed64ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_sfixed64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, default(long), null, @@ -374,6 +385,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.SFixed64); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalFloatExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_float_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, default(float), null, @@ -382,6 +394,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Float); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalDoubleExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_double_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, default(double), null, @@ -390,6 +403,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Double); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalBoolExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_bool_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, default(bool), null, @@ -398,6 +412,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Bool); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalStringExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_string_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -406,6 +421,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.String); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalBytesExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_bytes_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -414,6 +430,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Bytes); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalGroupExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optionalgroup_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, global::Google.ProtocolBuffers.TestProtos.OptionalGroup_extension_lite.DefaultInstance, @@ -422,6 +439,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Group); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalNestedMessageExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_nested_message_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance, @@ -430,6 +448,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Message); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalForeignMessageExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_foreign_message_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.DefaultInstance, @@ -438,6 +457,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Message); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalImportMessageExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_import_message_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.DefaultInstance, @@ -446,6 +466,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Message); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalNestedEnumExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_nested_enum_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, default(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum), null, @@ -454,6 +475,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Enum); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalForeignEnumExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_foreign_enum_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, default(global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite), null, @@ -462,6 +484,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Enum); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalImportEnumExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_import_enum_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, default(global::Google.ProtocolBuffers.TestProtos.ImportEnumLite), null, @@ -470,6 +493,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Enum); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalStringPieceExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_string_piece_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -478,6 +502,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.String); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.OptionalCordExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.optional_cord_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -486,6 +511,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.String); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedInt32ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_int32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -494,6 +520,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedInt64ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_int64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -502,6 +529,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedUint32ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_uint32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -510,6 +538,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedUint64ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_uint64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -518,6 +547,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedSint32ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_sint32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -526,6 +556,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedSint64ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_sint64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -534,6 +565,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedFixed32ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_fixed32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -542,6 +574,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedFixed64ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_fixed64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -550,6 +583,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedSfixed32ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_sfixed32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -558,6 +592,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedSfixed64ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_sfixed64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -566,6 +601,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedFloatExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_float_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -574,6 +610,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedDoubleExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_double_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -582,6 +619,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedBoolExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_bool_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -590,6 +628,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedStringExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_string_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -598,6 +637,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedBytesExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_bytes_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -606,6 +646,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedGroupExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeatedgroup_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, global::Google.ProtocolBuffers.TestProtos.RepeatedGroup_extension_lite.DefaultInstance, null, @@ -614,6 +655,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedNestedMessageExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_nested_message_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance, null, @@ -622,6 +664,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedForeignMessageExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_foreign_message_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.DefaultInstance, null, @@ -630,6 +673,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedImportMessageExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_import_message_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.DefaultInstance, null, @@ -638,6 +682,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedNestedEnumExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_nested_enum_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, new EnumLiteMap(), @@ -646,6 +691,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedForeignEnumExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_foreign_enum_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, new EnumLiteMap(), @@ -654,6 +700,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedImportEnumExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_import_enum_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, new EnumLiteMap(), @@ -662,6 +709,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedStringPieceExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_string_piece_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -670,6 +718,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.RepeatedCordExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.repeated_cord_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, null, null, @@ -678,6 +727,7 @@ namespace Google.ProtocolBuffers.TestProtos { false); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultInt32ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_int32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, 41, null, @@ -686,6 +736,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Int32); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultInt64ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_int64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, 42L, null, @@ -694,6 +745,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Int64); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultUint32ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_uint32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, 43, null, @@ -702,6 +754,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.UInt32); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultUint64ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_uint64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, 44UL, null, @@ -710,6 +763,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.UInt64); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultSint32ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_sint32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, -45, null, @@ -718,6 +772,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.SInt32); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultSint64ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_sint64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, 46, null, @@ -726,6 +781,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.SInt64); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultFixed32ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_fixed32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, 47, null, @@ -734,6 +790,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Fixed32); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultFixed64ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_fixed64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, 48, null, @@ -742,6 +799,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Fixed64); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultSfixed32ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_sfixed32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, 49, null, @@ -750,6 +808,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.SFixed32); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultSfixed64ExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_sfixed64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, -50, null, @@ -758,6 +817,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.SFixed64); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultFloatExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_float_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, 51.5F, null, @@ -766,6 +826,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Float); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultDoubleExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_double_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, 52000D, null, @@ -774,6 +835,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Double); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultBoolExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_bool_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, true, null, @@ -782,6 +844,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Bool); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultStringExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_string_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, "hello", null, @@ -790,6 +853,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.String); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultBytesExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_bytes_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, ByteString.FromBase64("d29ybGQ="), null, @@ -798,6 +862,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Bytes); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultNestedEnumExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_nested_enum_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum.BAR, null, @@ -806,6 +871,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Enum); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultForeignEnumExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_foreign_enum_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite.FOREIGN_LITE_BAR, null, @@ -814,6 +880,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Enum); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultImportEnumExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_import_enum_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, global::Google.ProtocolBuffers.TestProtos.ImportEnumLite.IMPORT_LITE_BAR, null, @@ -822,6 +889,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.Enum); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultStringPieceExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_string_piece_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, "abc", null, @@ -830,6 +898,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.String); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.DefaultCordExtensionLite = new pb::GeneratedExtensionLite( + "protobuf_unittest.default_cord_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, "123", null, @@ -838,6 +907,7 @@ namespace Google.ProtocolBuffers.TestProtos { pbd::FieldType.String); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.PackedInt32ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.packed_int32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, null, null, @@ -846,6 +916,7 @@ namespace Google.ProtocolBuffers.TestProtos { true); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.PackedInt64ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.packed_int64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, null, null, @@ -854,6 +925,7 @@ namespace Google.ProtocolBuffers.TestProtos { true); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.PackedUint32ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.packed_uint32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, null, null, @@ -862,6 +934,7 @@ namespace Google.ProtocolBuffers.TestProtos { true); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.PackedUint64ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.packed_uint64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, null, null, @@ -870,6 +943,7 @@ namespace Google.ProtocolBuffers.TestProtos { true); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.PackedSint32ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.packed_sint32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, null, null, @@ -878,6 +952,7 @@ namespace Google.ProtocolBuffers.TestProtos { true); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.PackedSint64ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.packed_sint64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, null, null, @@ -886,6 +961,7 @@ namespace Google.ProtocolBuffers.TestProtos { true); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.PackedFixed32ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.packed_fixed32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, null, null, @@ -894,6 +970,7 @@ namespace Google.ProtocolBuffers.TestProtos { true); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.PackedFixed64ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.packed_fixed64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, null, null, @@ -902,6 +979,7 @@ namespace Google.ProtocolBuffers.TestProtos { true); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.PackedSfixed32ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.packed_sfixed32_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, null, null, @@ -910,6 +988,7 @@ namespace Google.ProtocolBuffers.TestProtos { true); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.PackedSfixed64ExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.packed_sfixed64_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, null, null, @@ -918,6 +997,7 @@ namespace Google.ProtocolBuffers.TestProtos { true); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.PackedFloatExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.packed_float_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, null, null, @@ -926,6 +1006,7 @@ namespace Google.ProtocolBuffers.TestProtos { true); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.PackedDoubleExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.packed_double_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, null, null, @@ -934,6 +1015,7 @@ namespace Google.ProtocolBuffers.TestProtos { true); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.PackedBoolExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.packed_bool_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, null, null, @@ -942,6 +1024,7 @@ namespace Google.ProtocolBuffers.TestProtos { true); global::Google.ProtocolBuffers.TestProtos.UnitTestLiteProtoFile.PackedEnumExtensionLite = new pb::GeneratedRepeatExtensionLite( + "protobuf_unittest.packed_enum_extension_lite", global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, null, new EnumLiteMap(), @@ -1036,6 +1119,25 @@ namespace Google.ProtocolBuffers.TestProtos { } } + #region Lite runtime methods + public override int GetHashCode() { + int hash = GetType().GetHashCode(); + if (hasBb) hash ^= bb_.GetHashCode(); + return hash; + } + + public override bool Equals(object obj) { + NestedMessage other = obj as NestedMessage; + if (other == null) return false; + if (hasBb != other.hasBb || (hasBb && !bb_.Equals(other.bb_))) return false; + return true; + } + + public override void PrintTo(global::System.IO.TextWriter writer) { + PrintField("bb", hasBb, bb_, writer); + } + #endregion + public static NestedMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1226,6 +1328,25 @@ namespace Google.ProtocolBuffers.TestProtos { } } + #region Lite runtime methods + public override int GetHashCode() { + int hash = GetType().GetHashCode(); + if (hasA) hash ^= a_.GetHashCode(); + return hash; + } + + public override bool Equals(object obj) { + OptionalGroup other = obj as OptionalGroup; + if (other == null) return false; + if (hasA != other.hasA || (hasA && !a_.Equals(other.a_))) return false; + return true; + } + + public override void PrintTo(global::System.IO.TextWriter writer) { + PrintField("a", hasA, a_, writer); + } + #endregion + public static OptionalGroup ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1416,6 +1537,25 @@ namespace Google.ProtocolBuffers.TestProtos { } } + #region Lite runtime methods + public override int GetHashCode() { + int hash = GetType().GetHashCode(); + if (hasA) hash ^= a_.GetHashCode(); + return hash; + } + + public override bool Equals(object obj) { + RepeatedGroup other = obj as RepeatedGroup; + if (other == null) return false; + if (hasA != other.hasA || (hasA && !a_.Equals(other.a_))) return false; + return true; + } + + public override void PrintTo(global::System.IO.TextWriter writer) { + PrintField("a", hasA, a_, writer); + } + #endregion + public static RepeatedGroup ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -2863,6 +3003,298 @@ namespace Google.ProtocolBuffers.TestProtos { } } + #region Lite runtime methods + public override int GetHashCode() { + int hash = GetType().GetHashCode(); + if (hasOptionalInt32) hash ^= optionalInt32_.GetHashCode(); + if (hasOptionalInt64) hash ^= optionalInt64_.GetHashCode(); + if (hasOptionalUint32) hash ^= optionalUint32_.GetHashCode(); + if (hasOptionalUint64) hash ^= optionalUint64_.GetHashCode(); + if (hasOptionalSint32) hash ^= optionalSint32_.GetHashCode(); + if (hasOptionalSint64) hash ^= optionalSint64_.GetHashCode(); + if (hasOptionalFixed32) hash ^= optionalFixed32_.GetHashCode(); + if (hasOptionalFixed64) hash ^= optionalFixed64_.GetHashCode(); + if (hasOptionalSfixed32) hash ^= optionalSfixed32_.GetHashCode(); + if (hasOptionalSfixed64) hash ^= optionalSfixed64_.GetHashCode(); + if (hasOptionalFloat) hash ^= optionalFloat_.GetHashCode(); + if (hasOptionalDouble) hash ^= optionalDouble_.GetHashCode(); + if (hasOptionalBool) hash ^= optionalBool_.GetHashCode(); + if (hasOptionalString) hash ^= optionalString_.GetHashCode(); + if (hasOptionalBytes) hash ^= optionalBytes_.GetHashCode(); + if (hasOptionalGroup) hash ^= optionalGroup_.GetHashCode(); + if (hasOptionalNestedMessage) hash ^= optionalNestedMessage_.GetHashCode(); + if (hasOptionalForeignMessage) hash ^= optionalForeignMessage_.GetHashCode(); + if (hasOptionalImportMessage) hash ^= optionalImportMessage_.GetHashCode(); + if (hasOptionalNestedEnum) hash ^= optionalNestedEnum_.GetHashCode(); + if (hasOptionalForeignEnum) hash ^= optionalForeignEnum_.GetHashCode(); + if (hasOptionalImportEnum) hash ^= optionalImportEnum_.GetHashCode(); + if (hasOptionalStringPiece) hash ^= optionalStringPiece_.GetHashCode(); + if (hasOptionalCord) hash ^= optionalCord_.GetHashCode(); + foreach(int i in repeatedInt32_) + hash ^= i.GetHashCode(); + foreach(long i in repeatedInt64_) + hash ^= i.GetHashCode(); + foreach(uint i in repeatedUint32_) + hash ^= i.GetHashCode(); + foreach(ulong i in repeatedUint64_) + hash ^= i.GetHashCode(); + foreach(int i in repeatedSint32_) + hash ^= i.GetHashCode(); + foreach(long i in repeatedSint64_) + hash ^= i.GetHashCode(); + foreach(uint i in repeatedFixed32_) + hash ^= i.GetHashCode(); + foreach(ulong i in repeatedFixed64_) + hash ^= i.GetHashCode(); + foreach(int i in repeatedSfixed32_) + hash ^= i.GetHashCode(); + foreach(long i in repeatedSfixed64_) + hash ^= i.GetHashCode(); + foreach(float i in repeatedFloat_) + hash ^= i.GetHashCode(); + foreach(double i in repeatedDouble_) + hash ^= i.GetHashCode(); + foreach(bool i in repeatedBool_) + hash ^= i.GetHashCode(); + foreach(string i in repeatedString_) + hash ^= i.GetHashCode(); + foreach(pb::ByteString i in repeatedBytes_) + hash ^= i.GetHashCode(); + foreach(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.RepeatedGroup i in repeatedGroup_) + hash ^= i.GetHashCode(); + foreach(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage i in repeatedNestedMessage_) + hash ^= i.GetHashCode(); + foreach(global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite i in repeatedForeignMessage_) + hash ^= i.GetHashCode(); + foreach(global::Google.ProtocolBuffers.TestProtos.ImportMessageLite i in repeatedImportMessage_) + hash ^= i.GetHashCode(); + foreach(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum i in repeatedNestedEnum_) + hash ^= i.GetHashCode(); + foreach(global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite i in repeatedForeignEnum_) + hash ^= i.GetHashCode(); + foreach(global::Google.ProtocolBuffers.TestProtos.ImportEnumLite i in repeatedImportEnum_) + hash ^= i.GetHashCode(); + foreach(string i in repeatedStringPiece_) + hash ^= i.GetHashCode(); + foreach(string i in repeatedCord_) + hash ^= i.GetHashCode(); + if (hasDefaultInt32) hash ^= defaultInt32_.GetHashCode(); + if (hasDefaultInt64) hash ^= defaultInt64_.GetHashCode(); + if (hasDefaultUint32) hash ^= defaultUint32_.GetHashCode(); + if (hasDefaultUint64) hash ^= defaultUint64_.GetHashCode(); + if (hasDefaultSint32) hash ^= defaultSint32_.GetHashCode(); + if (hasDefaultSint64) hash ^= defaultSint64_.GetHashCode(); + if (hasDefaultFixed32) hash ^= defaultFixed32_.GetHashCode(); + if (hasDefaultFixed64) hash ^= defaultFixed64_.GetHashCode(); + if (hasDefaultSfixed32) hash ^= defaultSfixed32_.GetHashCode(); + if (hasDefaultSfixed64) hash ^= defaultSfixed64_.GetHashCode(); + if (hasDefaultFloat) hash ^= defaultFloat_.GetHashCode(); + if (hasDefaultDouble) hash ^= defaultDouble_.GetHashCode(); + if (hasDefaultBool) hash ^= defaultBool_.GetHashCode(); + if (hasDefaultString) hash ^= defaultString_.GetHashCode(); + if (hasDefaultBytes) hash ^= defaultBytes_.GetHashCode(); + if (hasDefaultNestedEnum) hash ^= defaultNestedEnum_.GetHashCode(); + if (hasDefaultForeignEnum) hash ^= defaultForeignEnum_.GetHashCode(); + if (hasDefaultImportEnum) hash ^= defaultImportEnum_.GetHashCode(); + if (hasDefaultStringPiece) hash ^= defaultStringPiece_.GetHashCode(); + if (hasDefaultCord) hash ^= defaultCord_.GetHashCode(); + return hash; + } + + public override bool Equals(object obj) { + TestAllTypesLite other = obj as TestAllTypesLite; + if (other == null) return false; + if (hasOptionalInt32 != other.hasOptionalInt32 || (hasOptionalInt32 && !optionalInt32_.Equals(other.optionalInt32_))) return false; + if (hasOptionalInt64 != other.hasOptionalInt64 || (hasOptionalInt64 && !optionalInt64_.Equals(other.optionalInt64_))) return false; + if (hasOptionalUint32 != other.hasOptionalUint32 || (hasOptionalUint32 && !optionalUint32_.Equals(other.optionalUint32_))) return false; + if (hasOptionalUint64 != other.hasOptionalUint64 || (hasOptionalUint64 && !optionalUint64_.Equals(other.optionalUint64_))) return false; + if (hasOptionalSint32 != other.hasOptionalSint32 || (hasOptionalSint32 && !optionalSint32_.Equals(other.optionalSint32_))) return false; + if (hasOptionalSint64 != other.hasOptionalSint64 || (hasOptionalSint64 && !optionalSint64_.Equals(other.optionalSint64_))) return false; + if (hasOptionalFixed32 != other.hasOptionalFixed32 || (hasOptionalFixed32 && !optionalFixed32_.Equals(other.optionalFixed32_))) return false; + if (hasOptionalFixed64 != other.hasOptionalFixed64 || (hasOptionalFixed64 && !optionalFixed64_.Equals(other.optionalFixed64_))) return false; + if (hasOptionalSfixed32 != other.hasOptionalSfixed32 || (hasOptionalSfixed32 && !optionalSfixed32_.Equals(other.optionalSfixed32_))) return false; + if (hasOptionalSfixed64 != other.hasOptionalSfixed64 || (hasOptionalSfixed64 && !optionalSfixed64_.Equals(other.optionalSfixed64_))) return false; + if (hasOptionalFloat != other.hasOptionalFloat || (hasOptionalFloat && !optionalFloat_.Equals(other.optionalFloat_))) return false; + if (hasOptionalDouble != other.hasOptionalDouble || (hasOptionalDouble && !optionalDouble_.Equals(other.optionalDouble_))) return false; + if (hasOptionalBool != other.hasOptionalBool || (hasOptionalBool && !optionalBool_.Equals(other.optionalBool_))) return false; + if (hasOptionalString != other.hasOptionalString || (hasOptionalString && !optionalString_.Equals(other.optionalString_))) return false; + if (hasOptionalBytes != other.hasOptionalBytes || (hasOptionalBytes && !optionalBytes_.Equals(other.optionalBytes_))) return false; + if (hasOptionalGroup != other.hasOptionalGroup || (hasOptionalGroup && !optionalGroup_.Equals(other.optionalGroup_))) return false; + if (hasOptionalNestedMessage != other.hasOptionalNestedMessage || (hasOptionalNestedMessage && !optionalNestedMessage_.Equals(other.optionalNestedMessage_))) return false; + if (hasOptionalForeignMessage != other.hasOptionalForeignMessage || (hasOptionalForeignMessage && !optionalForeignMessage_.Equals(other.optionalForeignMessage_))) return false; + if (hasOptionalImportMessage != other.hasOptionalImportMessage || (hasOptionalImportMessage && !optionalImportMessage_.Equals(other.optionalImportMessage_))) return false; + if (hasOptionalNestedEnum != other.hasOptionalNestedEnum || (hasOptionalNestedEnum && !optionalNestedEnum_.Equals(other.optionalNestedEnum_))) return false; + if (hasOptionalForeignEnum != other.hasOptionalForeignEnum || (hasOptionalForeignEnum && !optionalForeignEnum_.Equals(other.optionalForeignEnum_))) return false; + if (hasOptionalImportEnum != other.hasOptionalImportEnum || (hasOptionalImportEnum && !optionalImportEnum_.Equals(other.optionalImportEnum_))) return false; + if (hasOptionalStringPiece != other.hasOptionalStringPiece || (hasOptionalStringPiece && !optionalStringPiece_.Equals(other.optionalStringPiece_))) return false; + if (hasOptionalCord != other.hasOptionalCord || (hasOptionalCord && !optionalCord_.Equals(other.optionalCord_))) return false; + if(repeatedInt32_.Count != other.repeatedInt32_.Count) return false; + for(int ix=0; ix < repeatedInt32_.Count; ix++) + if(!repeatedInt32_[ix].Equals(other.repeatedInt32_[ix])) return false; + if(repeatedInt64_.Count != other.repeatedInt64_.Count) return false; + for(int ix=0; ix < repeatedInt64_.Count; ix++) + if(!repeatedInt64_[ix].Equals(other.repeatedInt64_[ix])) return false; + if(repeatedUint32_.Count != other.repeatedUint32_.Count) return false; + for(int ix=0; ix < repeatedUint32_.Count; ix++) + if(!repeatedUint32_[ix].Equals(other.repeatedUint32_[ix])) return false; + if(repeatedUint64_.Count != other.repeatedUint64_.Count) return false; + for(int ix=0; ix < repeatedUint64_.Count; ix++) + if(!repeatedUint64_[ix].Equals(other.repeatedUint64_[ix])) return false; + if(repeatedSint32_.Count != other.repeatedSint32_.Count) return false; + for(int ix=0; ix < repeatedSint32_.Count; ix++) + if(!repeatedSint32_[ix].Equals(other.repeatedSint32_[ix])) return false; + if(repeatedSint64_.Count != other.repeatedSint64_.Count) return false; + for(int ix=0; ix < repeatedSint64_.Count; ix++) + if(!repeatedSint64_[ix].Equals(other.repeatedSint64_[ix])) return false; + if(repeatedFixed32_.Count != other.repeatedFixed32_.Count) return false; + for(int ix=0; ix < repeatedFixed32_.Count; ix++) + if(!repeatedFixed32_[ix].Equals(other.repeatedFixed32_[ix])) return false; + if(repeatedFixed64_.Count != other.repeatedFixed64_.Count) return false; + for(int ix=0; ix < repeatedFixed64_.Count; ix++) + if(!repeatedFixed64_[ix].Equals(other.repeatedFixed64_[ix])) return false; + if(repeatedSfixed32_.Count != other.repeatedSfixed32_.Count) return false; + for(int ix=0; ix < repeatedSfixed32_.Count; ix++) + if(!repeatedSfixed32_[ix].Equals(other.repeatedSfixed32_[ix])) return false; + if(repeatedSfixed64_.Count != other.repeatedSfixed64_.Count) return false; + for(int ix=0; ix < repeatedSfixed64_.Count; ix++) + if(!repeatedSfixed64_[ix].Equals(other.repeatedSfixed64_[ix])) return false; + if(repeatedFloat_.Count != other.repeatedFloat_.Count) return false; + for(int ix=0; ix < repeatedFloat_.Count; ix++) + if(!repeatedFloat_[ix].Equals(other.repeatedFloat_[ix])) return false; + if(repeatedDouble_.Count != other.repeatedDouble_.Count) return false; + for(int ix=0; ix < repeatedDouble_.Count; ix++) + if(!repeatedDouble_[ix].Equals(other.repeatedDouble_[ix])) return false; + if(repeatedBool_.Count != other.repeatedBool_.Count) return false; + for(int ix=0; ix < repeatedBool_.Count; ix++) + if(!repeatedBool_[ix].Equals(other.repeatedBool_[ix])) return false; + if(repeatedString_.Count != other.repeatedString_.Count) return false; + for(int ix=0; ix < repeatedString_.Count; ix++) + if(!repeatedString_[ix].Equals(other.repeatedString_[ix])) return false; + if(repeatedBytes_.Count != other.repeatedBytes_.Count) return false; + for(int ix=0; ix < repeatedBytes_.Count; ix++) + if(!repeatedBytes_[ix].Equals(other.repeatedBytes_[ix])) return false; + if(repeatedGroup_.Count != other.repeatedGroup_.Count) return false; + for(int ix=0; ix < repeatedGroup_.Count; ix++) + if(!repeatedGroup_[ix].Equals(other.repeatedGroup_[ix])) return false; + if(repeatedNestedMessage_.Count != other.repeatedNestedMessage_.Count) return false; + for(int ix=0; ix < repeatedNestedMessage_.Count; ix++) + if(!repeatedNestedMessage_[ix].Equals(other.repeatedNestedMessage_[ix])) return false; + if(repeatedForeignMessage_.Count != other.repeatedForeignMessage_.Count) return false; + for(int ix=0; ix < repeatedForeignMessage_.Count; ix++) + if(!repeatedForeignMessage_[ix].Equals(other.repeatedForeignMessage_[ix])) return false; + if(repeatedImportMessage_.Count != other.repeatedImportMessage_.Count) return false; + for(int ix=0; ix < repeatedImportMessage_.Count; ix++) + if(!repeatedImportMessage_[ix].Equals(other.repeatedImportMessage_[ix])) return false; + if(repeatedNestedEnum_.Count != other.repeatedNestedEnum_.Count) return false; + for(int ix=0; ix < repeatedNestedEnum_.Count; ix++) + if(!repeatedNestedEnum_[ix].Equals(other.repeatedNestedEnum_[ix])) return false; + if(repeatedForeignEnum_.Count != other.repeatedForeignEnum_.Count) return false; + for(int ix=0; ix < repeatedForeignEnum_.Count; ix++) + if(!repeatedForeignEnum_[ix].Equals(other.repeatedForeignEnum_[ix])) return false; + if(repeatedImportEnum_.Count != other.repeatedImportEnum_.Count) return false; + for(int ix=0; ix < repeatedImportEnum_.Count; ix++) + if(!repeatedImportEnum_[ix].Equals(other.repeatedImportEnum_[ix])) return false; + if(repeatedStringPiece_.Count != other.repeatedStringPiece_.Count) return false; + for(int ix=0; ix < repeatedStringPiece_.Count; ix++) + if(!repeatedStringPiece_[ix].Equals(other.repeatedStringPiece_[ix])) return false; + if(repeatedCord_.Count != other.repeatedCord_.Count) return false; + for(int ix=0; ix < repeatedCord_.Count; ix++) + if(!repeatedCord_[ix].Equals(other.repeatedCord_[ix])) return false; + if (hasDefaultInt32 != other.hasDefaultInt32 || (hasDefaultInt32 && !defaultInt32_.Equals(other.defaultInt32_))) return false; + if (hasDefaultInt64 != other.hasDefaultInt64 || (hasDefaultInt64 && !defaultInt64_.Equals(other.defaultInt64_))) return false; + if (hasDefaultUint32 != other.hasDefaultUint32 || (hasDefaultUint32 && !defaultUint32_.Equals(other.defaultUint32_))) return false; + if (hasDefaultUint64 != other.hasDefaultUint64 || (hasDefaultUint64 && !defaultUint64_.Equals(other.defaultUint64_))) return false; + if (hasDefaultSint32 != other.hasDefaultSint32 || (hasDefaultSint32 && !defaultSint32_.Equals(other.defaultSint32_))) return false; + if (hasDefaultSint64 != other.hasDefaultSint64 || (hasDefaultSint64 && !defaultSint64_.Equals(other.defaultSint64_))) return false; + if (hasDefaultFixed32 != other.hasDefaultFixed32 || (hasDefaultFixed32 && !defaultFixed32_.Equals(other.defaultFixed32_))) return false; + if (hasDefaultFixed64 != other.hasDefaultFixed64 || (hasDefaultFixed64 && !defaultFixed64_.Equals(other.defaultFixed64_))) return false; + if (hasDefaultSfixed32 != other.hasDefaultSfixed32 || (hasDefaultSfixed32 && !defaultSfixed32_.Equals(other.defaultSfixed32_))) return false; + if (hasDefaultSfixed64 != other.hasDefaultSfixed64 || (hasDefaultSfixed64 && !defaultSfixed64_.Equals(other.defaultSfixed64_))) return false; + if (hasDefaultFloat != other.hasDefaultFloat || (hasDefaultFloat && !defaultFloat_.Equals(other.defaultFloat_))) return false; + if (hasDefaultDouble != other.hasDefaultDouble || (hasDefaultDouble && !defaultDouble_.Equals(other.defaultDouble_))) return false; + if (hasDefaultBool != other.hasDefaultBool || (hasDefaultBool && !defaultBool_.Equals(other.defaultBool_))) return false; + if (hasDefaultString != other.hasDefaultString || (hasDefaultString && !defaultString_.Equals(other.defaultString_))) return false; + if (hasDefaultBytes != other.hasDefaultBytes || (hasDefaultBytes && !defaultBytes_.Equals(other.defaultBytes_))) return false; + if (hasDefaultNestedEnum != other.hasDefaultNestedEnum || (hasDefaultNestedEnum && !defaultNestedEnum_.Equals(other.defaultNestedEnum_))) return false; + if (hasDefaultForeignEnum != other.hasDefaultForeignEnum || (hasDefaultForeignEnum && !defaultForeignEnum_.Equals(other.defaultForeignEnum_))) return false; + if (hasDefaultImportEnum != other.hasDefaultImportEnum || (hasDefaultImportEnum && !defaultImportEnum_.Equals(other.defaultImportEnum_))) return false; + if (hasDefaultStringPiece != other.hasDefaultStringPiece || (hasDefaultStringPiece && !defaultStringPiece_.Equals(other.defaultStringPiece_))) return false; + if (hasDefaultCord != other.hasDefaultCord || (hasDefaultCord && !defaultCord_.Equals(other.defaultCord_))) return false; + return true; + } + + public override void PrintTo(global::System.IO.TextWriter writer) { + PrintField("optional_int32", hasOptionalInt32, optionalInt32_, writer); + PrintField("optional_int64", hasOptionalInt64, optionalInt64_, writer); + PrintField("optional_uint32", hasOptionalUint32, optionalUint32_, writer); + PrintField("optional_uint64", hasOptionalUint64, optionalUint64_, writer); + PrintField("optional_sint32", hasOptionalSint32, optionalSint32_, writer); + PrintField("optional_sint64", hasOptionalSint64, optionalSint64_, writer); + PrintField("optional_fixed32", hasOptionalFixed32, optionalFixed32_, writer); + PrintField("optional_fixed64", hasOptionalFixed64, optionalFixed64_, writer); + PrintField("optional_sfixed32", hasOptionalSfixed32, optionalSfixed32_, writer); + PrintField("optional_sfixed64", hasOptionalSfixed64, optionalSfixed64_, writer); + PrintField("optional_float", hasOptionalFloat, optionalFloat_, writer); + PrintField("optional_double", hasOptionalDouble, optionalDouble_, writer); + PrintField("optional_bool", hasOptionalBool, optionalBool_, writer); + PrintField("optional_string", hasOptionalString, optionalString_, writer); + PrintField("optional_bytes", hasOptionalBytes, optionalBytes_, writer); + PrintField("OptionalGroup", hasOptionalGroup, optionalGroup_, writer); + PrintField("optional_nested_message", hasOptionalNestedMessage, optionalNestedMessage_, writer); + PrintField("optional_foreign_message", hasOptionalForeignMessage, optionalForeignMessage_, writer); + PrintField("optional_import_message", hasOptionalImportMessage, optionalImportMessage_, writer); + PrintField("optional_nested_enum", hasOptionalNestedEnum, optionalNestedEnum_, writer); + PrintField("optional_foreign_enum", hasOptionalForeignEnum, optionalForeignEnum_, writer); + PrintField("optional_import_enum", hasOptionalImportEnum, optionalImportEnum_, writer); + PrintField("optional_string_piece", hasOptionalStringPiece, optionalStringPiece_, writer); + PrintField("optional_cord", hasOptionalCord, optionalCord_, writer); + PrintField("repeated_int32", repeatedInt32_, writer); + PrintField("repeated_int64", repeatedInt64_, writer); + PrintField("repeated_uint32", repeatedUint32_, writer); + PrintField("repeated_uint64", repeatedUint64_, writer); + PrintField("repeated_sint32", repeatedSint32_, writer); + PrintField("repeated_sint64", repeatedSint64_, writer); + PrintField("repeated_fixed32", repeatedFixed32_, writer); + PrintField("repeated_fixed64", repeatedFixed64_, writer); + PrintField("repeated_sfixed32", repeatedSfixed32_, writer); + PrintField("repeated_sfixed64", repeatedSfixed64_, writer); + PrintField("repeated_float", repeatedFloat_, writer); + PrintField("repeated_double", repeatedDouble_, writer); + PrintField("repeated_bool", repeatedBool_, writer); + PrintField("repeated_string", repeatedString_, writer); + PrintField("repeated_bytes", repeatedBytes_, writer); + PrintField("RepeatedGroup", repeatedGroup_, writer); + PrintField("repeated_nested_message", repeatedNestedMessage_, writer); + PrintField("repeated_foreign_message", repeatedForeignMessage_, writer); + PrintField("repeated_import_message", repeatedImportMessage_, writer); + PrintField("repeated_nested_enum", repeatedNestedEnum_, writer); + PrintField("repeated_foreign_enum", repeatedForeignEnum_, writer); + PrintField("repeated_import_enum", repeatedImportEnum_, writer); + PrintField("repeated_string_piece", repeatedStringPiece_, writer); + PrintField("repeated_cord", repeatedCord_, writer); + PrintField("default_int32", hasDefaultInt32, defaultInt32_, writer); + PrintField("default_int64", hasDefaultInt64, defaultInt64_, writer); + PrintField("default_uint32", hasDefaultUint32, defaultUint32_, writer); + PrintField("default_uint64", hasDefaultUint64, defaultUint64_, writer); + PrintField("default_sint32", hasDefaultSint32, defaultSint32_, writer); + PrintField("default_sint64", hasDefaultSint64, defaultSint64_, writer); + PrintField("default_fixed32", hasDefaultFixed32, defaultFixed32_, writer); + PrintField("default_fixed64", hasDefaultFixed64, defaultFixed64_, writer); + PrintField("default_sfixed32", hasDefaultSfixed32, defaultSfixed32_, writer); + PrintField("default_sfixed64", hasDefaultSfixed64, defaultSfixed64_, writer); + PrintField("default_float", hasDefaultFloat, defaultFloat_, writer); + PrintField("default_double", hasDefaultDouble, defaultDouble_, writer); + PrintField("default_bool", hasDefaultBool, defaultBool_, writer); + PrintField("default_string", hasDefaultString, defaultString_, writer); + PrintField("default_bytes", hasDefaultBytes, defaultBytes_, writer); + PrintField("default_nested_enum", hasDefaultNestedEnum, defaultNestedEnum_, writer); + PrintField("default_foreign_enum", hasDefaultForeignEnum, defaultForeignEnum_, writer); + PrintField("default_import_enum", hasDefaultImportEnum, defaultImportEnum_, writer); + PrintField("default_string_piece", hasDefaultStringPiece, defaultStringPiece_, writer); + PrintField("default_cord", hasDefaultCord, defaultCord_, writer); + } + #endregion + public static TestAllTypesLite ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -5180,6 +5612,25 @@ namespace Google.ProtocolBuffers.TestProtos { } } + #region Lite runtime methods + public override int GetHashCode() { + int hash = GetType().GetHashCode(); + if (hasC) hash ^= c_.GetHashCode(); + return hash; + } + + public override bool Equals(object obj) { + ForeignMessageLite other = obj as ForeignMessageLite; + if (other == null) return false; + if (hasC != other.hasC || (hasC && !c_.Equals(other.c_))) return false; + return true; + } + + public override void PrintTo(global::System.IO.TextWriter writer) { + PrintField("c", hasC, c_, writer); + } + #endregion + public static ForeignMessageLite ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -5783,6 +6234,106 @@ namespace Google.ProtocolBuffers.TestProtos { } } + #region Lite runtime methods + public override int GetHashCode() { + int hash = GetType().GetHashCode(); + foreach(int i in packedInt32_) + hash ^= i.GetHashCode(); + foreach(long i in packedInt64_) + hash ^= i.GetHashCode(); + foreach(uint i in packedUint32_) + hash ^= i.GetHashCode(); + foreach(ulong i in packedUint64_) + hash ^= i.GetHashCode(); + foreach(int i in packedSint32_) + hash ^= i.GetHashCode(); + foreach(long i in packedSint64_) + hash ^= i.GetHashCode(); + foreach(uint i in packedFixed32_) + hash ^= i.GetHashCode(); + foreach(ulong i in packedFixed64_) + hash ^= i.GetHashCode(); + foreach(int i in packedSfixed32_) + hash ^= i.GetHashCode(); + foreach(long i in packedSfixed64_) + hash ^= i.GetHashCode(); + foreach(float i in packedFloat_) + hash ^= i.GetHashCode(); + foreach(double i in packedDouble_) + hash ^= i.GetHashCode(); + foreach(bool i in packedBool_) + hash ^= i.GetHashCode(); + foreach(global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite i in packedEnum_) + hash ^= i.GetHashCode(); + return hash; + } + + public override bool Equals(object obj) { + TestPackedTypesLite other = obj as TestPackedTypesLite; + if (other == null) return false; + if(packedInt32_.Count != other.packedInt32_.Count) return false; + for(int ix=0; ix < packedInt32_.Count; ix++) + if(!packedInt32_[ix].Equals(other.packedInt32_[ix])) return false; + if(packedInt64_.Count != other.packedInt64_.Count) return false; + for(int ix=0; ix < packedInt64_.Count; ix++) + if(!packedInt64_[ix].Equals(other.packedInt64_[ix])) return false; + if(packedUint32_.Count != other.packedUint32_.Count) return false; + for(int ix=0; ix < packedUint32_.Count; ix++) + if(!packedUint32_[ix].Equals(other.packedUint32_[ix])) return false; + if(packedUint64_.Count != other.packedUint64_.Count) return false; + for(int ix=0; ix < packedUint64_.Count; ix++) + if(!packedUint64_[ix].Equals(other.packedUint64_[ix])) return false; + if(packedSint32_.Count != other.packedSint32_.Count) return false; + for(int ix=0; ix < packedSint32_.Count; ix++) + if(!packedSint32_[ix].Equals(other.packedSint32_[ix])) return false; + if(packedSint64_.Count != other.packedSint64_.Count) return false; + for(int ix=0; ix < packedSint64_.Count; ix++) + if(!packedSint64_[ix].Equals(other.packedSint64_[ix])) return false; + if(packedFixed32_.Count != other.packedFixed32_.Count) return false; + for(int ix=0; ix < packedFixed32_.Count; ix++) + if(!packedFixed32_[ix].Equals(other.packedFixed32_[ix])) return false; + if(packedFixed64_.Count != other.packedFixed64_.Count) return false; + for(int ix=0; ix < packedFixed64_.Count; ix++) + if(!packedFixed64_[ix].Equals(other.packedFixed64_[ix])) return false; + if(packedSfixed32_.Count != other.packedSfixed32_.Count) return false; + for(int ix=0; ix < packedSfixed32_.Count; ix++) + if(!packedSfixed32_[ix].Equals(other.packedSfixed32_[ix])) return false; + if(packedSfixed64_.Count != other.packedSfixed64_.Count) return false; + for(int ix=0; ix < packedSfixed64_.Count; ix++) + if(!packedSfixed64_[ix].Equals(other.packedSfixed64_[ix])) return false; + if(packedFloat_.Count != other.packedFloat_.Count) return false; + for(int ix=0; ix < packedFloat_.Count; ix++) + if(!packedFloat_[ix].Equals(other.packedFloat_[ix])) return false; + if(packedDouble_.Count != other.packedDouble_.Count) return false; + for(int ix=0; ix < packedDouble_.Count; ix++) + if(!packedDouble_[ix].Equals(other.packedDouble_[ix])) return false; + if(packedBool_.Count != other.packedBool_.Count) return false; + for(int ix=0; ix < packedBool_.Count; ix++) + if(!packedBool_[ix].Equals(other.packedBool_[ix])) return false; + if(packedEnum_.Count != other.packedEnum_.Count) return false; + for(int ix=0; ix < packedEnum_.Count; ix++) + if(!packedEnum_[ix].Equals(other.packedEnum_[ix])) return false; + return true; + } + + public override void PrintTo(global::System.IO.TextWriter writer) { + PrintField("packed_int32", packedInt32_, writer); + PrintField("packed_int64", packedInt64_, writer); + PrintField("packed_uint32", packedUint32_, writer); + PrintField("packed_uint64", packedUint64_, writer); + PrintField("packed_sint32", packedSint32_, writer); + PrintField("packed_sint64", packedSint64_, writer); + PrintField("packed_fixed32", packedFixed32_, writer); + PrintField("packed_fixed64", packedFixed64_, writer); + PrintField("packed_sfixed32", packedSfixed32_, writer); + PrintField("packed_sfixed64", packedSfixed64_, writer); + PrintField("packed_float", packedFloat_, writer); + PrintField("packed_double", packedDouble_, writer); + PrintField("packed_bool", packedBool_, writer); + PrintField("packed_enum", packedEnum_, writer); + } + #endregion + public static TestPackedTypesLite ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6506,6 +7057,25 @@ namespace Google.ProtocolBuffers.TestProtos { } } + #region Lite runtime methods + public override int GetHashCode() { + int hash = GetType().GetHashCode(); + hash ^= base.GetHashCode(); + return hash; + } + + public override bool Equals(object obj) { + TestAllExtensionsLite other = obj as TestAllExtensionsLite; + if (other == null) return false; + if (!base.Equals(other)) return false; + return true; + } + + public override void PrintTo(global::System.IO.TextWriter writer) { + base.PrintTo(writer); + } + #endregion + public static TestAllExtensionsLite ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6672,6 +7242,25 @@ namespace Google.ProtocolBuffers.TestProtos { } } + #region Lite runtime methods + public override int GetHashCode() { + int hash = GetType().GetHashCode(); + if (hasA) hash ^= a_.GetHashCode(); + return hash; + } + + public override bool Equals(object obj) { + OptionalGroup_extension_lite other = obj as OptionalGroup_extension_lite; + if (other == null) return false; + if (hasA != other.hasA || (hasA && !a_.Equals(other.a_))) return false; + return true; + } + + public override void PrintTo(global::System.IO.TextWriter writer) { + PrintField("a", hasA, a_, writer); + } + #endregion + public static OptionalGroup_extension_lite ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6862,6 +7451,25 @@ namespace Google.ProtocolBuffers.TestProtos { } } + #region Lite runtime methods + public override int GetHashCode() { + int hash = GetType().GetHashCode(); + if (hasA) hash ^= a_.GetHashCode(); + return hash; + } + + public override bool Equals(object obj) { + RepeatedGroup_extension_lite other = obj as RepeatedGroup_extension_lite; + if (other == null) return false; + if (hasA != other.hasA || (hasA && !a_.Equals(other.a_))) return false; + return true; + } + + public override void PrintTo(global::System.IO.TextWriter writer) { + PrintField("a", hasA, a_, writer); + } + #endregion + public static RepeatedGroup_extension_lite ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -7040,6 +7648,25 @@ namespace Google.ProtocolBuffers.TestProtos { } } + #region Lite runtime methods + public override int GetHashCode() { + int hash = GetType().GetHashCode(); + hash ^= base.GetHashCode(); + return hash; + } + + public override bool Equals(object obj) { + TestPackedExtensionsLite other = obj as TestPackedExtensionsLite; + if (other == null) return false; + if (!base.Equals(other)) return false; + return true; + } + + public override void PrintTo(global::System.IO.TextWriter writer) { + base.PrintTo(writer); + } + #endregion + public static TestPackedExtensionsLite ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -7192,6 +7819,22 @@ namespace Google.ProtocolBuffers.TestProtos { } } + #region Lite runtime methods + public override int GetHashCode() { + int hash = GetType().GetHashCode(); + return hash; + } + + public override bool Equals(object obj) { + TestNestedExtensionLite other = obj as TestNestedExtensionLite; + if (other == null) return false; + return true; + } + + public override void PrintTo(global::System.IO.TextWriter writer) { + } + #endregion + public static TestNestedExtensionLite ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -7357,6 +8000,25 @@ namespace Google.ProtocolBuffers.TestProtos { } } + #region Lite runtime methods + public override int GetHashCode() { + int hash = GetType().GetHashCode(); + if (hasDeprecatedField) hash ^= deprecatedField_.GetHashCode(); + return hash; + } + + public override bool Equals(object obj) { + TestDeprecatedLite other = obj as TestDeprecatedLite; + if (other == null) return false; + if (hasDeprecatedField != other.hasDeprecatedField || (hasDeprecatedField && !deprecatedField_.Equals(other.deprecatedField_))) return false; + return true; + } + + public override void PrintTo(global::System.IO.TextWriter writer) { + PrintField("deprecated_field", hasDeprecatedField, deprecatedField_, writer); + } + #endregion + public static TestDeprecatedLite ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestProtoFile.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestProtoFile.cs index 6e6d7c40..5acb333d 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestProtoFile.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestProtoFile.cs @@ -12852,7 +12852,7 @@ namespace Google.ProtocolBuffers.TestProtos { public const int InfDoubleFieldNumber = 14; private bool hasInfDouble; - private double infDouble_ = InfinityD; + private double infDouble_ = double.PositiveInfinity; public bool HasInfDouble { get { return hasInfDouble; } } @@ -12862,7 +12862,7 @@ namespace Google.ProtocolBuffers.TestProtos { public const int NegInfDoubleFieldNumber = 15; private bool hasNegInfDouble; - private double negInfDouble_ = -InfinityD; + private double negInfDouble_ = double.NegativeInfinity; public bool HasNegInfDouble { get { return hasNegInfDouble; } } @@ -12872,7 +12872,7 @@ namespace Google.ProtocolBuffers.TestProtos { public const int NanDoubleFieldNumber = 16; private bool hasNanDouble; - private double nanDouble_ = NaND; + private double nanDouble_ = double.NaN; public bool HasNanDouble { get { return hasNanDouble; } } @@ -12882,7 +12882,7 @@ namespace Google.ProtocolBuffers.TestProtos { public const int InfFloatFieldNumber = 17; private bool hasInfFloat; - private float infFloat_ = InfinityF; + private float infFloat_ = float.PositiveInfinity; public bool HasInfFloat { get { return hasInfFloat; } } @@ -12892,7 +12892,7 @@ namespace Google.ProtocolBuffers.TestProtos { public const int NegInfFloatFieldNumber = 18; private bool hasNegInfFloat; - private float negInfFloat_ = -InfinityF; + private float negInfFloat_ = float.NegativeInfinity; public bool HasNegInfFloat { get { return hasNegInfFloat; } } @@ -12902,7 +12902,7 @@ namespace Google.ProtocolBuffers.TestProtos { public const int NanFloatFieldNumber = 19; private bool hasNanFloat; - private float nanFloat_ = NaNF; + private float nanFloat_ = float.NaN; public bool HasNanFloat { get { return hasNanFloat; } } @@ -13558,7 +13558,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder ClearInfDouble() { result.hasInfDouble = false; - result.infDouble_ = InfinityD; + result.infDouble_ = double.PositiveInfinity; return this; } @@ -13576,7 +13576,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder ClearNegInfDouble() { result.hasNegInfDouble = false; - result.negInfDouble_ = -InfinityD; + result.negInfDouble_ = double.NegativeInfinity; return this; } @@ -13594,7 +13594,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder ClearNanDouble() { result.hasNanDouble = false; - result.nanDouble_ = NaND; + result.nanDouble_ = double.NaN; return this; } @@ -13612,7 +13612,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder ClearInfFloat() { result.hasInfFloat = false; - result.infFloat_ = InfinityF; + result.infFloat_ = float.PositiveInfinity; return this; } @@ -13630,7 +13630,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder ClearNegInfFloat() { result.hasNegInfFloat = false; - result.negInfFloat_ = -InfinityF; + result.negInfFloat_ = float.NegativeInfinity; return this; } @@ -13648,7 +13648,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public Builder ClearNanFloat() { result.hasNanFloat = false; - result.nanFloat_ = NaNF; + result.nanFloat_ = float.NaN; return this; } } -- cgit v1.2.3