Lite feature complete.

pull/288/head
csharptest 14 years ago
parent e495477358
commit 272cb8aee7
  1. 14
      src/ProtoGen/EnumFieldGenerator.cs
  2. 10
      src/ProtoGen/ExtensionGenerator.cs
  3. 25
      src/ProtoGen/FieldGeneratorBase.cs
  4. 4
      src/ProtoGen/IFieldSourceGenerator.cs
  5. 13
      src/ProtoGen/MessageFieldGenerator.cs
  6. 47
      src/ProtoGen/MessageGenerator.cs
  7. 12
      src/ProtoGen/PrimitiveFieldGenerator.cs
  8. 15
      src/ProtoGen/RepeatedEnumFieldGenerator.cs
  9. 17
      src/ProtoGen/RepeatedMessageFieldGenerator.cs
  10. 15
      src/ProtoGen/RepeatedPrimitiveFieldGenerator.cs
  11. 1
      src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj
  12. 2
      src/ProtocolBuffers.Test/ReflectionTester.cs
  13. 14
      src/ProtocolBuffers.Test/TestProtos/FIXUP.cs
  14. 24
      src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs
  15. 4
      src/ProtocolBuffers/AbstractMessage.cs
  16. 2
      src/ProtocolBuffers/AbstractMessageLite.cs
  17. 12
      src/ProtocolBuffers/EnumLite.cs
  18. 28
      src/ProtocolBuffers/ExtendableMessageLite.cs
  19. 4
      src/ProtocolBuffers/ExtensionInfo.cs
  20. 1
      src/ProtocolBuffers/FieldSet.cs
  21. 8
      src/ProtocolBuffers/GeneratedExtensionBase.cs
  22. 16
      src/ProtocolBuffers/GeneratedExtensionLite.cs
  23. 80
      src/ProtocolBuffers/GeneratedMessageLite.cs
  24. 5
      src/ProtocolBuffers/IMessageLite.cs
  25. 16
      src/ProtocolBuffers/TextFormat.cs
  26. 14
      src/ProtocolBuffers/UninitializedMessageException.cs
  27. 12
      src/ProtocolBuffers/UnknownFieldSet.cs
  28. 47
      src/ProtocolBuffersLite.Test/InteropLiteTest.cs
  29. 3
      src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj
  30. 34
      src/ProtocolBuffersLite.Test/TestLiteByApi.cs
  31. 141
      src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs
  32. 19
      src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportLiteProtoFile.cs
  33. 19
      src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteImportNonLiteProtoFile.cs
  34. 662
      src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteProtoFile.cs
  35. 24
      src/ProtocolBuffersLite.Test/TestProtos/UnitTestProtoFile.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);
}
}
}

@ -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) {
}
}
}

@ -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";

@ -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);
}
}

@ -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);
}
}
}

@ -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<FieldDescriptor> sorted = new List<FieldDescriptor>(Descriptor.Fields);
sorted.Sort(new Comparison<FieldDescriptor>(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<FieldDescriptor> sortedFields = new List<FieldDescriptor>(Descriptor.Fields);
sortedFields.Sort((f1, f2) => f1.FieldNumber.CompareTo(f2.FieldNumber));

@ -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);
}
}
}

@ -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);
}
}
}

@ -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);
}
}
}

@ -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);
}
}
}

@ -73,7 +73,6 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReflectionTester.cs" />
<Compile Include="ServiceTest.cs" />
<Compile Include="TestProtos\FIXUP.cs" />
<Compile Include="TestProtos\UnitTestCSharpOptionsProtoFile.cs" />
<Compile Include="TestProtos\UnitTestCustomOptionsProtoFile.cs" />
<Compile Include="TestProtos\UnitTestEmbedOptimizeForProtoFile.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();
}
}

@ -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;
}
}

@ -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;
}
}

@ -101,6 +101,10 @@ namespace Google.ProtocolBuffers {
return TextFormat.PrintToString(this);
}
public sealed override void PrintTo(TextWriter writer) {
TextFormat.Print(this, writer);
}
/// <summary>
/// Serializes the message and writes it to the given output stream.
/// This does not flush or close the stream.

@ -63,6 +63,8 @@ namespace Google.ProtocolBuffers {
//public override int GetHashCode() {
//}
public abstract void PrintTo(TextWriter writer);
#region IMessageLite<TMessage,TBuilder> Members
/// <summary>

@ -46,6 +46,7 @@ namespace Google.ProtocolBuffers {
///</summary>
public interface IEnumLite {
int Number { get; }
string Name { get; }
}
///<summary>
@ -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<int, IEnumLite>();
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) {

@ -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<TMessage, TBuilder> : GeneratedMessageLite<TMessage, TBuilder>
where TMessage : GeneratedMessageLite<TMessage, TBuilder>
@ -49,6 +52,31 @@ namespace Google.ProtocolBuffers {
get { return extensions; }
}
public override bool Equals(object obj) {
ExtendableMessageLite<TMessage, TBuilder> other = obj as ExtendableMessageLite<TMessage, TBuilder>;
return !ReferenceEquals(null, other) &&
Dictionaries.Equals(extensions.AllFields, other.extensions.AllFields);
}
public override int GetHashCode() {
return Dictionaries.GetHashCode(extensions.AllFields);
}
/// <summary>
/// writes the extensions to the text stream
/// </summary>
public override void PrintTo(System.IO.TextWriter writer) {
foreach (KeyValuePair<IFieldDescriptorLite, object> 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);
}
}
}
/// <summary>
/// Checks if a singular extension is present.
/// </summary>

@ -48,12 +48,12 @@ namespace Google.ProtocolBuffers
/// A default instance of the extensions's type, if it has a message type,
/// or null otherwise.
/// </summary>
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;
}

@ -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; }

@ -66,7 +66,7 @@ namespace Google.ProtocolBuffers {
public abstract class GeneratedExtensionBase<TExtension> {
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 {
/// <summary>
/// Returns the default message instance for extensions which are message types.
/// </summary>
public IMessage MessageDefaultInstance {
public IMessageLite MessageDefaultInstance {
get { return messageDefaultInstance; }
}

@ -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<TContainingType, TExtensionType> : GeneratedExtensionLite<TContainingType, IList<TExtensionType>>
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<TExtensionType>(), messageDefaultInstance, enumTypeMap, number, type, isPacked) {
base(fullName, containingTypeDefaultInstance, new List<TExtensionType>(), 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<object> 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)) {
}

@ -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<TMessage, TBuilder> {
protected abstract TMessage ThisMessage { get; }
public sealed override string ToString() {
using (System.IO.StringWriter wtr = new System.IO.StringWriter()) {
PrintTo(wtr);
return wtr.ToString();
}
}
/// <summary>
/// PrintTo() helper methods for Lite Runtime
/// </summary>
protected static void PrintField<T>(string name, IList<T> value, System.IO.TextWriter writer) {
foreach (T item in value)
PrintField(name, true, (object)item, writer);
}
/// <summary>
/// PrintTo() helper methods for Lite Runtime
/// </summary>
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));
}
}
/// <summary>
/// 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.
/// </summary>
private static void EscapeBytes(IEnumerable<byte> 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;
}
}
}
}
}

@ -103,6 +103,11 @@ namespace Google.ProtocolBuffers {
/// </summary>
string ToString();
/// <summary>
/// Converts the message to a string.
/// </summary>
void PrintTo(TextWriter writer);
/// <summary>
/// Serializes the message to a ByteString. This is a trivial wrapper
/// around WriteTo(CodedOutputStream).

@ -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)) {

@ -124,16 +124,24 @@ namespace Google.ProtocolBuffers {
foreach (KeyValuePair<FieldDescriptor, object> 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);
}
}
}
}

@ -138,6 +138,14 @@ namespace Google.ProtocolBuffers {
return TextFormat.PrintToString(this);
}
/// <summary>
/// Converts the set to a string in protocol buffer text format. This
/// is just a trivial wrapper around TextFormat.PrintToString.
/// </summary>
public void PrintTo(TextWriter writer) {
TextFormat.Print(this, writer);
}
/// <summary>
/// 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) {

@ -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);
}
}
}

@ -57,9 +57,6 @@
<Compile Include="..\ProtocolBuffers.Test\Properties\AssemblyInfo.cs">
<Link>Properties\AssemblyInfo.cs</Link>
</Compile>
<Compile Include="..\ProtocolBuffers.Test\TestProtos\FIXUP.cs">
<Link>TestProtos\FIXUP.cs</Link>
</Compile>
<Compile Include="AbstractBuilderLiteTest.cs" />
<Compile Include="AbstractMessageLiteTest.cs" />
<Compile Include="ExtendableBuilderLiteTest.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]

@ -26,6 +26,7 @@ namespace Google.ProtocolBuffers.TestProtos {
Descriptor = null;
global::Google.ProtocolBuffers.TestProtos.UnitTestExtrasLiteProtoFile.EmployeeIdLite =
new pb::GeneratedExtensionLite<global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite, global::Google.ProtocolBuffers.TestProtos.TestInteropEmployeeIdLite>(
"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();
}

@ -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();
}

@ -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();
}

@ -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;
}
}

Loading…
Cancel
Save