Browse Source

Several performance tweaks
- Removed default value assingment when default is equal to default(T)
- Added Benchmarks for most types and repeated/packed arrays
- Left PopsicleList's list fields uninitialized util needed
- Changed CodedInputStream's repated/packed reader
- Changed Enum writers to simply cast to int
- Changed the WriteEnum to use object rawValue that provides .ToString() if needed
- Should be fully on par with original library for performance, gaining 2x-3x in some cases

csharptest 14 years ago
parent
commit
ced18e10ae
31 changed files with 889 additions and 448 deletions
  1. 2 2
      src/AddressBook/AddressBookProtos.cs
  2. 146 21
      src/ProtoBench/Program.cs
  3. 6 0
      src/ProtoBench/ProtoBench.csproj
  4. 1 1
      src/ProtoGen/EnumFieldGenerator.cs
  5. 30 0
      src/ProtoGen/FieldGeneratorBase.cs
  6. 1 1
      src/ProtoGen/PrimitiveFieldGenerator.cs
  7. 7 0
      src/ProtocolBuffers.Test/AbstractMessageTest.cs
  8. 8 8
      src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs
  9. 76 76
      src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSizeProtoFile.cs
  10. 76 76
      src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSpeedProtoFile.cs
  11. 1 1
      src/ProtocolBuffers.Test/TestProtos/UnitTestImportLiteProtoFile.cs
  12. 1 1
      src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs
  13. 2 2
      src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs
  14. 1 1
      src/ProtocolBuffers.Test/TestProtos/UnitTestNoGenericServicesProtoFile.cs
  15. 2 2
      src/ProtocolBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs
  16. 76 76
      src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs
  17. 3 3
      src/ProtocolBuffers.Test/TestProtos/UnitTestXmlSerializerTestProtoFile.cs
  18. 246 9
      src/ProtocolBuffers/CodedInputStream.cs
  19. 18 11
      src/ProtocolBuffers/CodedOutputStream.cs
  20. 8 0
      src/ProtocolBuffers/Collections/IPopsicleList.cs
  21. 32 18
      src/ProtocolBuffers/Collections/PopsicleList.cs
  22. 7 7
      src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs
  23. 17 17
      src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
  24. 7 0
      src/ProtocolBuffers/ICodedInputStream.cs
  25. 1 1
      src/ProtocolBuffers/ICodedOutputStream.cs
  26. 5 5
      src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasFullProtoFile.cs
  27. 5 5
      src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs
  28. 1 1
      src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportLiteProtoFile.cs
  29. 1 1
      src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportProtoFile.cs
  30. 26 26
      src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteProtoFile.cs
  31. 76 76
      src/ProtocolBuffersLite.Test/TestProtos/UnitTestProtoFile.cs

+ 2 - 2
src/AddressBook/AddressBookProtos.cs

@@ -163,7 +163,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
             output.WriteString(1, field_names[0], Number);
           }
           if (hasType) {
-            output.WriteEnum(2, field_names[1], (int) Type, Type.ToString());
+            output.WriteEnum(2, field_names[1], (int) Type, Type);
           }
           UnknownFields.WriteTo(output);
         }
@@ -407,7 +407,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
     
     public const int IdFieldNumber = 2;
     private bool hasId;
-    private int id_ = 0;
+    private int id_;
     public bool HasId {
       get { return hasId; }
     }

+ 146 - 21
src/ProtoBench/Program.cs

@@ -39,6 +39,7 @@ using System.Collections.Generic;
 using System.Diagnostics;
 using System.IO;
 using System.Threading;
+using Google.ProtocolBuffers.TestProtos;
 
 namespace Google.ProtocolBuffers.ProtoBench
 {
@@ -49,8 +50,7 @@ namespace Google.ProtocolBuffers.ProtoBench
     {
         private static TimeSpan MinSampleTime = TimeSpan.FromSeconds(2);
         private static TimeSpan TargetTime = TimeSpan.FromSeconds(30);
-        private static bool FastTest = false;
-        private static bool Verbose = false;
+        private static bool Verbose = false, FastTest = false;
         // Avoid a .NET 3.5 dependency
         private delegate void Action();
 
@@ -63,21 +63,27 @@ namespace Google.ProtocolBuffers.ProtoBench
         {
             List<string> temp = new List<string>(args);
 
-            FastTest = temp.Remove("/fast") || temp.Remove("-fast");
             Verbose = temp.Remove("/verbose") || temp.Remove("-verbose");
 
+            if (true == (FastTest = (temp.Remove("/fast") || temp.Remove("-fast"))))
+                TargetTime = TimeSpan.FromSeconds(10);
+
             RunBenchmark = BenchmarkV1;
             if (temp.Remove("/v2") || temp.Remove("-v2"))
             {
-                string cpu = temp.Find(x => x.StartsWith("-cpu:"));
-                int cpuIx = 1;
-                if (cpu != null) cpuIx = 1 << Math.Max(0, int.Parse(cpu.Substring(5)));
-
-                //pin the entire process to a single CPU
-                Process.GetCurrentProcess().ProcessorAffinity = new IntPtr(cpuIx);
                 Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
                 RunBenchmark = BenchmarkV2;
             }
+            if (temp.Remove("/all") || temp.Remove("-all"))
+            {
+                if(FastTest)
+                    TargetTime = TimeSpan.FromSeconds(5);
+                foreach (KeyValuePair<string, string> item in MakeTests())
+                {
+                    temp.Add(item.Key);
+                    temp.Add(item.Value);
+                }
+            }
             args = temp.ToArray();
 
             if (args.Length < 2 || (args.Length%2) != 0)
@@ -92,16 +98,16 @@ namespace Google.ProtocolBuffers.ProtoBench
             bool success = true;
             for (int i = 0; i < args.Length; i += 2)
             {
-                success &= RunTest(args[i], args[i + 1]);
+                success &= RunTest(args[i], args[i + 1], null);
             }
             return success ? 0 : 1;
         }
-        
+
         /// <summary>
         /// Runs a single test. Error messages are displayed to Console.Error, and the return value indicates
         /// general success/failure.
         /// </summary>
-        public static bool RunTest(string typeName, string file)
+        public static bool RunTest(string typeName, string file, byte[] inputData)
         {
             Console.WriteLine("Benchmarking {0} with file {1}", typeName, file);
             IMessage defaultMessage;
@@ -116,30 +122,32 @@ namespace Google.ProtocolBuffers.ProtoBench
             }
             try
             {
-                byte[] inputData = File.ReadAllBytes(file);
+                ExtensionRegistry registry = ExtensionRegistry.Empty;
+                inputData = inputData ?? File.ReadAllBytes(file);
                 MemoryStream inputStream = new MemoryStream(inputData);
                 ByteString inputString = ByteString.CopyFrom(inputData);
                 IMessage sampleMessage =
-                    defaultMessage.WeakCreateBuilderForType().WeakMergeFrom(inputString).WeakBuild();
+                    defaultMessage.WeakCreateBuilderForType().WeakMergeFrom(inputString, registry).WeakBuild();
                 if(!FastTest) RunBenchmark("Serialize to byte string", inputData.Length, () => sampleMessage.ToByteString());
                 RunBenchmark("Serialize to byte array", inputData.Length, () => sampleMessage.ToByteArray());
                 if (!FastTest) RunBenchmark("Serialize to memory stream", inputData.Length,
                           () => sampleMessage.WriteTo(new MemoryStream()));
                 if (!FastTest) RunBenchmark("Deserialize from byte string", inputData.Length,
                           () => defaultMessage.WeakCreateBuilderForType()
-                                    .WeakMergeFrom(inputString)
+                                    .WeakMergeFrom(inputString, registry)
                                     .WeakBuild()
                     );
+
                 RunBenchmark("Deserialize from byte array", inputData.Length,
                           () => defaultMessage.WeakCreateBuilderForType()
-                                    .WeakMergeFrom(CodedInputStream.CreateInstance(inputData))
+                                    .WeakMergeFrom(CodedInputStream.CreateInstance(inputData), registry)
                                     .WeakBuild()
                     );
                 if (!FastTest) RunBenchmark("Deserialize from memory stream", inputData.Length, 
                     () => {
                       inputStream.Position = 0;
                       defaultMessage.WeakCreateBuilderForType().WeakMergeFrom(
-                              CodedInputStream.CreateInstance(inputStream))
+                              CodedInputStream.CreateInstance(inputStream), registry)
                           .WeakBuild();
                   });
                 Console.WriteLine();
@@ -156,6 +164,7 @@ namespace Google.ProtocolBuffers.ProtoBench
 
         private static void BenchmarkV2(string name, long dataSize, Action action)
         {
+            Thread.BeginThreadAffinity();
             TimeSpan elapsed = TimeSpan.Zero;
             long runs = 0;
             long totalCount = 0;
@@ -184,7 +193,7 @@ namespace Google.ProtocolBuffers.ProtoBench
             double first = (iterations * dataSize) / (elapsed.TotalSeconds * 1024 * 1024);
             if (Verbose) Console.WriteLine("Round ---: Count = {1,6}, Bps = {2,8:f3}", 0, iterations, first);
             elapsed = TimeSpan.Zero;
-            int max = FastTest ? 10 : 30;
+            int max = (int)TargetTime.TotalSeconds;
 
             while (runs < max)
             {
@@ -192,7 +201,8 @@ namespace Google.ProtocolBuffers.ProtoBench
                 // Accumulate and scale for next cycle.
                 
                 double bps = (iterations * dataSize) / (cycle.TotalSeconds * 1024 * 1024);
-                if (Verbose) Console.WriteLine("Round {0,3}: Count = {1,6}, Bps = {2,8:f3}", runs, iterations, bps);
+                if (Verbose) Console.WriteLine("Round {1,3}: Count = {2,6}, Bps = {3,8:f3}",
+                    0, runs, iterations, bps);
 
                 best = Math.Max(best, bps);
                 worst = Math.Min(worst, bps);
@@ -203,8 +213,9 @@ namespace Google.ProtocolBuffers.ProtoBench
                 iterations = (int) ((target.Ticks*totalCount)/(double) elapsed.Ticks);
             }
 
-            Console.WriteLine("{0}: averages {1} per {2:f3}s for {3} runs; avg: {4:f3}mbps; best: {5:f3}mbps; worst: {6:f3}mbps",
-                              name, totalCount / runs, elapsed.TotalSeconds / runs, runs,
+            Thread.EndThreadAffinity();
+            Console.WriteLine("{1}: averages {2} per {3:f3}s for {4} runs; avg: {5:f3}mbps; best: {6:f3}mbps; worst: {7:f3}mbps",
+                              0, name, totalCount / runs, elapsed.TotalSeconds / runs, runs,
                               (totalCount * dataSize) / (elapsed.TotalSeconds * 1024 * 1024), best, worst);
         }
 
@@ -244,5 +255,119 @@ namespace Google.ProtocolBuffers.ProtoBench
             sw.Stop();
             return sw.Elapsed;
         }
+
+        private static IEnumerable<KeyValuePair<string, string>> MakeTests()
+        {
+            //Aggregate Tests
+            yield return MakeWorkItem("all-types", MakeTestAllTypes());
+            yield return MakeWorkItem("repeated-100", MakeRepeatedTestAllTypes(100));
+            yield return MakeWorkItem("packed-100", MakeTestPackedTypes(100));
+
+            //Discrete Tests
+            foreach (KeyValuePair<string, Action<TestAllTypes.Builder>> item in MakeTestAllTypes())
+                yield return MakeWorkItem(item.Key, new[] { item });
+
+            foreach (KeyValuePair<string, Action<TestAllTypes.Builder>> item in MakeRepeatedTestAllTypes(100))
+                yield return MakeWorkItem(item.Key, new[] { item });
+
+            foreach (KeyValuePair<string, Action<TestPackedTypes.Builder>> item in MakeTestPackedTypes(100))
+                yield return MakeWorkItem(item.Key, new[] { item });
+        }
+
+        private static IEnumerable<KeyValuePair<string, Action<TestAllTypes.Builder>>> MakeTestAllTypes()
+        {
+            // Many of the raw type serializers below perform poorly due to the numerous fields defined
+            // in TestAllTypes.
+
+            //single values
+            yield return MakeItem<TestAllTypes.Builder>("int32", 1, x => x.SetOptionalInt32(1001));
+            yield return MakeItem<TestAllTypes.Builder>("int64", 1, x => x.SetOptionalInt64(1001));
+            yield return MakeItem<TestAllTypes.Builder>("uint32", 1, x => x.SetOptionalUint32(1001));
+            yield return MakeItem<TestAllTypes.Builder>("uint64", 1, x => x.SetOptionalUint64(1001));
+            yield return MakeItem<TestAllTypes.Builder>("sint32", 1, x => x.SetOptionalSint32(-1001));
+            yield return MakeItem<TestAllTypes.Builder>("sint64", 1, x => x.SetOptionalSint64(-1001));
+            yield return MakeItem<TestAllTypes.Builder>("fixed32", 1, x => x.SetOptionalFixed32(1001));
+            yield return MakeItem<TestAllTypes.Builder>("fixed64", 1, x => x.SetOptionalFixed64(1001));
+            yield return MakeItem<TestAllTypes.Builder>("sfixed32", 1, x => x.SetOptionalSfixed32(-1001));
+            yield return MakeItem<TestAllTypes.Builder>("sfixed64", 1, x => x.SetOptionalSfixed64(-1001));
+            yield return MakeItem<TestAllTypes.Builder>("float", 1, x => x.SetOptionalFloat(1001.1001f));
+            yield return MakeItem<TestAllTypes.Builder>("double", 1, x => x.SetOptionalDouble(1001.1001));
+            yield return MakeItem<TestAllTypes.Builder>("bool", 1, x => x.SetOptionalBool(true));
+            yield return MakeItem<TestAllTypes.Builder>("string", 1, x => x.SetOptionalString("this is a string value"));
+            yield return MakeItem<TestAllTypes.Builder>("bytes", 1, x => x.SetOptionalBytes(ByteString.CopyFromUtf8("this is an array of bytes")));
+            yield return MakeItem<TestAllTypes.Builder>("group", 1, x => x.SetOptionalGroup(new TestAllTypes.Types.OptionalGroup.Builder().SetA(1001)));
+            yield return MakeItem<TestAllTypes.Builder>("message", 1, x => x.SetOptionalNestedMessage(new TestAllTypes.Types.NestedMessage.Builder().SetBb(1001)));
+            yield return MakeItem<TestAllTypes.Builder>("enum", 1, x => x.SetOptionalNestedEnum(TestAllTypes.Types.NestedEnum.FOO));
+        }
+
+        private static IEnumerable<KeyValuePair<string, Action<TestAllTypes.Builder>>> MakeRepeatedTestAllTypes(int size)
+        {
+            //repeated values
+            yield return MakeItem<TestAllTypes.Builder>("repeated-int32", size, x => x.AddRepeatedInt32(1001));
+            yield return MakeItem<TestAllTypes.Builder>("repeated-int64", size, x => x.AddRepeatedInt64(1001));
+            yield return MakeItem<TestAllTypes.Builder>("repeated-uint32", size, x => x.AddRepeatedUint32(1001));
+            yield return MakeItem<TestAllTypes.Builder>("repeated-uint64", size, x => x.AddRepeatedUint64(1001));
+            yield return MakeItem<TestAllTypes.Builder>("repeated-sint32", size, x => x.AddRepeatedSint32(-1001));
+            yield return MakeItem<TestAllTypes.Builder>("repeated-sint64", size, x => x.AddRepeatedSint64(-1001));
+            yield return MakeItem<TestAllTypes.Builder>("repeated-fixed32", size, x => x.AddRepeatedFixed32(1001));
+            yield return MakeItem<TestAllTypes.Builder>("repeated-fixed64", size, x => x.AddRepeatedFixed64(1001));
+            yield return MakeItem<TestAllTypes.Builder>("repeated-sfixed32", size, x => x.AddRepeatedSfixed32(-1001));
+            yield return MakeItem<TestAllTypes.Builder>("repeated-sfixed64", size, x => x.AddRepeatedSfixed64(-1001));
+            yield return MakeItem<TestAllTypes.Builder>("repeated-float", size, x => x.AddRepeatedFloat(1001.1001f));
+            yield return MakeItem<TestAllTypes.Builder>("repeated-double", size, x => x.AddRepeatedDouble(1001.1001));
+            yield return MakeItem<TestAllTypes.Builder>("repeated-bool", size, x => x.AddRepeatedBool(true));
+            yield return MakeItem<TestAllTypes.Builder>("repeated-string", size, x => x.AddRepeatedString("this is a string value"));
+            yield return MakeItem<TestAllTypes.Builder>("repeated-bytes", size, x => x.AddRepeatedBytes(ByteString.CopyFromUtf8("this is an array of bytes")));
+            yield return MakeItem<TestAllTypes.Builder>("repeated-group", size, x => x.AddRepeatedGroup(new TestAllTypes.Types.RepeatedGroup.Builder().SetA(1001)));
+            yield return MakeItem<TestAllTypes.Builder>("repeated-message", size, x => x.AddRepeatedNestedMessage(new TestAllTypes.Types.NestedMessage.Builder().SetBb(1001)));
+            yield return MakeItem<TestAllTypes.Builder>("repeated-enum", size, x => x.AddRepeatedNestedEnum(TestAllTypes.Types.NestedEnum.FOO));
+        }
+
+        private static IEnumerable<KeyValuePair<string, Action<TestPackedTypes.Builder>>> MakeTestPackedTypes(int size)
+        {
+            //packed values
+            yield return MakeItem<TestPackedTypes.Builder>("packed-int32", size, x => x.AddPackedInt32(1001));
+            yield return MakeItem<TestPackedTypes.Builder>("packed-int64", size, x => x.AddPackedInt64(1001));
+            yield return MakeItem<TestPackedTypes.Builder>("packed-uint32", size, x => x.AddPackedUint32(1001));
+            yield return MakeItem<TestPackedTypes.Builder>("packed-uint64", size, x => x.AddPackedUint64(1001));
+            yield return MakeItem<TestPackedTypes.Builder>("packed-sint32", size, x => x.AddPackedSint32(-1001));
+            yield return MakeItem<TestPackedTypes.Builder>("packed-sint64", size, x => x.AddPackedSint64(-1001));
+            yield return MakeItem<TestPackedTypes.Builder>("packed-fixed32", size, x => x.AddPackedFixed32(1001));
+            yield return MakeItem<TestPackedTypes.Builder>("packed-fixed64", size, x => x.AddPackedFixed64(1001));
+            yield return MakeItem<TestPackedTypes.Builder>("packed-sfixed32", size, x => x.AddPackedSfixed32(-1001));
+            yield return MakeItem<TestPackedTypes.Builder>("packed-sfixed64", size, x => x.AddPackedSfixed64(-1001));
+            yield return MakeItem<TestPackedTypes.Builder>("packed-float", size, x => x.AddPackedFloat(1001.1001f));
+            yield return MakeItem<TestPackedTypes.Builder>("packed-double", size, x => x.AddPackedDouble(1001.1001));
+            yield return MakeItem<TestPackedTypes.Builder>("packed-bool", size, x => x.AddPackedBool(true));
+            yield return MakeItem<TestPackedTypes.Builder>("packed-enum", size, x => x.AddPackedEnum(ForeignEnum.FOREIGN_FOO));
+        }
+
+        private static KeyValuePair<string, Action<T>> MakeItem<T>(string name, int repeated, Action<T> build) where T : IBuilderLite, new()
+        {
+            if (repeated == 1)
+                return new KeyValuePair<string, Action<T>>(name, build);
+
+            return new KeyValuePair<string, Action<T>>(
+                String.Format("{0}[{1}]", name, repeated),
+                x =>
+                {
+                    for (int i = 0; i < repeated; i++)
+                        build(x);
+                }
+            );
+        }
+
+        private static KeyValuePair<string, string> MakeWorkItem<T>(string name, IEnumerable<KeyValuePair<string, Action<T>>> builders) where T : IBuilderLite, new()
+        {
+            T builder = new T();
+
+            foreach (KeyValuePair<string, Action<T>> item in builders)
+                item.Value(builder);
+
+            IMessageLite msg = builder.WeakBuild();
+            string fname = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "unittest_" + name + ".dat");
+            File.WriteAllBytes(fname, msg.ToByteArray());
+            return new KeyValuePair<string, string>(String.Format("{0},{1}", msg.GetType().FullName, msg.GetType().Assembly.GetName().Name), fname);
+        }
     }
 }

+ 6 - 0
src/ProtoBench/ProtoBench.csproj

@@ -59,6 +59,12 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="..\ProtocolBuffers.Test\TestProtos\UnitTestImportProtoFile.cs">
+      <Link>UnitTestImportProtoFile.cs</Link>
+    </Compile>
+    <Compile Include="..\ProtocolBuffers.Test\TestProtos\UnitTestProtoFile.cs">
+      <Link>UnitTestProtoFile.cs</Link>
+    </Compile>
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>

+ 1 - 1
src/ProtoGen/EnumFieldGenerator.cs

@@ -112,7 +112,7 @@ namespace Google.ProtocolBuffers.ProtoGen
         public void GenerateSerializationCode(TextGenerator writer)
         {
             writer.WriteLine("if (has{0}) {{", PropertyName);
-            writer.WriteLine("  output.WriteEnum({0}, field_names[{2}], (int) {1}, {1}.ToString());", Number, PropertyName, FieldOrdinal);
+            writer.WriteLine("  output.WriteEnum({0}, field_names[{2}], (int) {1}, {1});", Number, PropertyName, FieldOrdinal);
             writer.WriteLine("}");
         }
 

+ 30 - 0
src/ProtoGen/FieldGeneratorBase.cs

@@ -68,6 +68,36 @@ namespace Google.ProtocolBuffers.ProtoGen
             return true;
         }
 
+        protected bool HasDefaultValue
+        {
+            get 
+            {
+                switch (Descriptor.FieldType)
+                {
+                    case FieldType.Float:
+                    case FieldType.Double:
+                    case FieldType.Int32:
+                    case FieldType.Int64:
+                    case FieldType.SInt32:
+                    case FieldType.SInt64:
+                    case FieldType.SFixed32:
+                    case FieldType.SFixed64:
+                    case FieldType.UInt32:
+                    case FieldType.UInt64:
+                    case FieldType.Fixed32:
+                    case FieldType.Fixed64:
+                        {
+                            IConvertible value = (IConvertible) Descriptor.DefaultValue;
+                            return value.ToString(CultureInfo.InvariantCulture) != "0";
+                        }
+                    case FieldType.Bool:
+                        return ((bool) Descriptor.DefaultValue) == true;
+                    default:
+                        return true;
+                }
+            }
+        }
+
         /// <remarks>Copy exists in ExtensionGenerator.cs</remarks>
         protected string DefaultValue
         {

+ 1 - 1
src/ProtoGen/PrimitiveFieldGenerator.cs

@@ -49,7 +49,7 @@ namespace Google.ProtocolBuffers.ProtoGen
         public void GenerateMembers(TextGenerator writer)
         {
             writer.WriteLine("private bool has{0};", PropertyName);
-            writer.WriteLine("private {0} {1}_ = {2};", TypeName, Name, DefaultValue);
+            writer.WriteLine("private {0} {1}_{2};", TypeName, Name, HasDefaultValue ? " = " + DefaultValue : "");
             writer.WriteLine("public bool Has{0} {{", PropertyName);
             writer.WriteLine("  get {{ return has{0}; }}", PropertyName);
             writer.WriteLine("}");

+ 7 - 0
src/ProtocolBuffers.Test/AbstractMessageTest.cs

@@ -62,6 +62,13 @@ namespace Google.ProtocolBuffers
             TestUtil.AssertAllFieldsSet((TestAllTypes) message.WrappedMessage);
         }
 
+        [Test]
+        public void CreateAndBuild()
+        {
+            TestAllTypes.CreateBuilder()
+                .Build();
+        }
+
         [Test]
         public void SerializedSize()
         {

+ 8 - 8
src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs

@@ -2475,7 +2475,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int FooFieldNumber = 1;
     private bool hasFoo;
-    private int foo_ = 0;
+    private int foo_;
     public bool HasFoo {
       get { return hasFoo; }
     }
@@ -2485,7 +2485,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Foo2FieldNumber = 2;
     private bool hasFoo2;
-    private int foo2_ = 0;
+    private int foo2_;
     public bool HasFoo2 {
       get { return hasFoo2; }
     }
@@ -2495,7 +2495,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Foo3FieldNumber = 3;
     private bool hasFoo3;
-    private int foo3_ = 0;
+    private int foo3_;
     public bool HasFoo3 {
       get { return hasFoo3; }
     }
@@ -2835,7 +2835,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         public static pb::GeneratedExtensionBase<global::Google.ProtocolBuffers.TestProtos.ComplexOptionType2.Types.ComplexOptionType4> ComplexOpt4;
         public const int WaldoFieldNumber = 1;
         private bool hasWaldo;
-        private int waldo_ = 0;
+        private int waldo_;
         public bool HasWaldo {
           get { return hasWaldo; }
         }
@@ -3060,7 +3060,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int BazFieldNumber = 2;
     private bool hasBaz;
-    private int baz_ = 0;
+    private int baz_;
     public bool HasBaz {
       get { return hasBaz; }
     }
@@ -3457,7 +3457,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int PlughFieldNumber = 3;
         private bool hasPlugh;
-        private int plugh_ = 0;
+        private int plugh_;
         public bool HasPlugh {
           get { return hasPlugh; }
         }
@@ -3672,7 +3672,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int QuxFieldNumber = 1;
     private bool hasQux;
-    private int qux_ = 0;
+    private int qux_;
     public bool HasQux {
       get { return hasQux; }
     }
@@ -3975,7 +3975,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int XyzzyFieldNumber = 7593951;
     private bool hasXyzzy;
-    private int xyzzy_ = 0;
+    private int xyzzy_;
     public bool HasXyzzy {
       get { return hasXyzzy; }
     }

+ 76 - 76
src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSizeProtoFile.cs

@@ -188,7 +188,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field80FieldNumber = 80;
     private bool hasField80;
-    private bool field80_ = false;
+    private bool field80_;
     public bool HasField80 {
       get { return hasField80; }
     }
@@ -208,7 +208,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field2FieldNumber = 2;
     private bool hasField2;
-    private int field2_ = 0;
+    private int field2_;
     public bool HasField2 {
       get { return hasField2; }
     }
@@ -218,7 +218,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field3FieldNumber = 3;
     private bool hasField3;
-    private int field3_ = 0;
+    private int field3_;
     public bool HasField3 {
       get { return hasField3; }
     }
@@ -228,7 +228,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field280FieldNumber = 280;
     private bool hasField280;
-    private int field280_ = 0;
+    private int field280_;
     public bool HasField280 {
       get { return hasField280; }
     }
@@ -238,7 +238,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field6FieldNumber = 6;
     private bool hasField6;
-    private int field6_ = 0;
+    private int field6_;
     public bool HasField6 {
       get { return hasField6; }
     }
@@ -248,7 +248,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field22FieldNumber = 22;
     private bool hasField22;
-    private long field22_ = 0L;
+    private long field22_;
     public bool HasField22 {
       get { return hasField22; }
     }
@@ -282,7 +282,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field59FieldNumber = 59;
     private bool hasField59;
-    private bool field59_ = false;
+    private bool field59_;
     public bool HasField59 {
       get { return hasField59; }
     }
@@ -302,7 +302,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field16FieldNumber = 16;
     private bool hasField16;
-    private int field16_ = 0;
+    private int field16_;
     public bool HasField16 {
       get { return hasField16; }
     }
@@ -312,7 +312,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field130FieldNumber = 130;
     private bool hasField130;
-    private int field130_ = 0;
+    private int field130_;
     public bool HasField130 {
       get { return hasField130; }
     }
@@ -362,7 +362,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field104FieldNumber = 104;
     private bool hasField104;
-    private int field104_ = 0;
+    private int field104_;
     public bool HasField104 {
       get { return hasField104; }
     }
@@ -372,7 +372,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field100FieldNumber = 100;
     private bool hasField100;
-    private int field100_ = 0;
+    private int field100_;
     public bool HasField100 {
       get { return hasField100; }
     }
@@ -382,7 +382,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field101FieldNumber = 101;
     private bool hasField101;
-    private int field101_ = 0;
+    private int field101_;
     public bool HasField101 {
       get { return hasField101; }
     }
@@ -412,7 +412,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field29FieldNumber = 29;
     private bool hasField29;
-    private int field29_ = 0;
+    private int field29_;
     public bool HasField29 {
       get { return hasField29; }
     }
@@ -422,7 +422,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field30FieldNumber = 30;
     private bool hasField30;
-    private bool field30_ = false;
+    private bool field30_;
     public bool HasField30 {
       get { return hasField30; }
     }
@@ -462,7 +462,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field150FieldNumber = 150;
     private bool hasField150;
-    private int field150_ = 0;
+    private int field150_;
     public bool HasField150 {
       get { return hasField150; }
     }
@@ -472,7 +472,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field23FieldNumber = 23;
     private bool hasField23;
-    private int field23_ = 0;
+    private int field23_;
     public bool HasField23 {
       get { return hasField23; }
     }
@@ -482,7 +482,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field24FieldNumber = 24;
     private bool hasField24;
-    private bool field24_ = false;
+    private bool field24_;
     public bool HasField24 {
       get { return hasField24; }
     }
@@ -492,7 +492,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field25FieldNumber = 25;
     private bool hasField25;
-    private int field25_ = 0;
+    private int field25_;
     public bool HasField25 {
       get { return hasField25; }
     }
@@ -512,7 +512,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field78FieldNumber = 78;
     private bool hasField78;
-    private bool field78_ = false;
+    private bool field78_;
     public bool HasField78 {
       get { return hasField78; }
     }
@@ -522,7 +522,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field67FieldNumber = 67;
     private bool hasField67;
-    private int field67_ = 0;
+    private int field67_;
     public bool HasField67 {
       get { return hasField67; }
     }
@@ -532,7 +532,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field68FieldNumber = 68;
     private bool hasField68;
-    private int field68_ = 0;
+    private int field68_;
     public bool HasField68 {
       get { return hasField68; }
     }
@@ -542,7 +542,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field128FieldNumber = 128;
     private bool hasField128;
-    private int field128_ = 0;
+    private int field128_;
     public bool HasField128 {
       get { return hasField128; }
     }
@@ -562,7 +562,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field131FieldNumber = 131;
     private bool hasField131;
-    private int field131_ = 0;
+    private int field131_;
     public bool HasField131 {
       get { return hasField131; }
     }
@@ -1459,7 +1459,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field1FieldNumber = 1;
     private bool hasField1;
-    private int field1_ = 0;
+    private int field1_;
     public bool HasField1 {
       get { return hasField1; }
     }
@@ -1469,7 +1469,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field2FieldNumber = 2;
     private bool hasField2;
-    private int field2_ = 0;
+    private int field2_;
     public bool HasField2 {
       get { return hasField2; }
     }
@@ -1479,7 +1479,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field3FieldNumber = 3;
     private bool hasField3;
-    private int field3_ = 0;
+    private int field3_;
     public bool HasField3 {
       get { return hasField3; }
     }
@@ -1509,7 +1509,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field13FieldNumber = 13;
     private bool hasField13;
-    private long field13_ = 0L;
+    private long field13_;
     public bool HasField13 {
       get { return hasField13; }
     }
@@ -1519,7 +1519,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field14FieldNumber = 14;
     private bool hasField14;
-    private long field14_ = 0L;
+    private long field14_;
     public bool HasField14 {
       get { return hasField14; }
     }
@@ -1529,7 +1529,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field16FieldNumber = 16;
     private bool hasField16;
-    private int field16_ = 0;
+    private int field16_;
     public bool HasField16 {
       get { return hasField16; }
     }
@@ -1569,7 +1569,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field21FieldNumber = 21;
     private bool hasField21;
-    private ulong field21_ = 0;
+    private ulong field21_;
     public bool HasField21 {
       get { return hasField21; }
     }
@@ -1580,7 +1580,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field22FieldNumber = 22;
     private bool hasField22;
-    private int field22_ = 0;
+    private int field22_;
     public bool HasField22 {
       get { return hasField22; }
     }
@@ -1590,7 +1590,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field23FieldNumber = 23;
     private bool hasField23;
-    private bool field23_ = false;
+    private bool field23_;
     public bool HasField23 {
       get { return hasField23; }
     }
@@ -1600,7 +1600,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field206FieldNumber = 206;
     private bool hasField206;
-    private bool field206_ = false;
+    private bool field206_;
     public bool HasField206 {
       get { return hasField206; }
     }
@@ -1610,7 +1610,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field203FieldNumber = 203;
     private bool hasField203;
-    private uint field203_ = 0;
+    private uint field203_;
     public bool HasField203 {
       get { return hasField203; }
     }
@@ -1621,7 +1621,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field204FieldNumber = 204;
     private bool hasField204;
-    private int field204_ = 0;
+    private int field204_;
     public bool HasField204 {
       get { return hasField204; }
     }
@@ -1641,7 +1641,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field207FieldNumber = 207;
     private bool hasField207;
-    private ulong field207_ = 0UL;
+    private ulong field207_;
     public bool HasField207 {
       get { return hasField207; }
     }
@@ -1652,7 +1652,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field300FieldNumber = 300;
     private bool hasField300;
-    private ulong field300_ = 0UL;
+    private ulong field300_;
     public bool HasField300 {
       get { return hasField300; }
     }
@@ -2172,7 +2172,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int Field11FieldNumber = 11;
         private bool hasField11;
-        private float field11_ = 0F;
+        private float field11_;
         public bool HasField11 {
           get { return hasField11; }
         }
@@ -2182,7 +2182,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int Field26FieldNumber = 26;
         private bool hasField26;
-        private float field26_ = 0F;
+        private float field26_;
         public bool HasField26 {
           get { return hasField26; }
         }
@@ -2224,7 +2224,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int Field15FieldNumber = 15;
         private bool hasField15;
-        private ulong field15_ = 0UL;
+        private ulong field15_;
         public bool HasField15 {
           get { return hasField15; }
         }
@@ -2235,7 +2235,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int Field5FieldNumber = 5;
         private bool hasField5;
-        private int field5_ = 0;
+        private int field5_;
         public bool HasField5 {
           get { return hasField5; }
         }
@@ -2255,7 +2255,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int Field28FieldNumber = 28;
         private bool hasField28;
-        private int field28_ = 0;
+        private int field28_;
         public bool HasField28 {
           get { return hasField28; }
         }
@@ -2309,7 +2309,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int Field20FieldNumber = 20;
         private bool hasField20;
-        private int field20_ = 0;
+        private int field20_;
         public bool HasField20 {
           get { return hasField20; }
         }
@@ -2781,7 +2781,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field3FieldNumber = 3;
     private bool hasField3;
-    private long field3_ = 0L;
+    private long field3_;
     public bool HasField3 {
       get { return hasField3; }
     }
@@ -2791,7 +2791,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field4FieldNumber = 4;
     private bool hasField4;
-    private long field4_ = 0L;
+    private long field4_;
     public bool HasField4 {
       get { return hasField4; }
     }
@@ -2801,7 +2801,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field30FieldNumber = 30;
     private bool hasField30;
-    private long field30_ = 0L;
+    private long field30_;
     public bool HasField30 {
       get { return hasField30; }
     }
@@ -2811,7 +2811,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field75FieldNumber = 75;
     private bool hasField75;
-    private bool field75_ = false;
+    private bool field75_;
     public bool HasField75 {
       get { return hasField75; }
     }
@@ -2841,7 +2841,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field21FieldNumber = 21;
     private bool hasField21;
-    private int field21_ = 0;
+    private int field21_;
     public bool HasField21 {
       get { return hasField21; }
     }
@@ -2851,7 +2851,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field71FieldNumber = 71;
     private bool hasField71;
-    private int field71_ = 0;
+    private int field71_;
     public bool HasField71 {
       get { return hasField71; }
     }
@@ -2861,7 +2861,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field25FieldNumber = 25;
     private bool hasField25;
-    private float field25_ = 0F;
+    private float field25_;
     public bool HasField25 {
       get { return hasField25; }
     }
@@ -2871,7 +2871,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field109FieldNumber = 109;
     private bool hasField109;
-    private int field109_ = 0;
+    private int field109_;
     public bool HasField109 {
       get { return hasField109; }
     }
@@ -2881,7 +2881,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field210FieldNumber = 210;
     private bool hasField210;
-    private int field210_ = 0;
+    private int field210_;
     public bool HasField210 {
       get { return hasField210; }
     }
@@ -2891,7 +2891,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field211FieldNumber = 211;
     private bool hasField211;
-    private int field211_ = 0;
+    private int field211_;
     public bool HasField211 {
       get { return hasField211; }
     }
@@ -2901,7 +2901,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field212FieldNumber = 212;
     private bool hasField212;
-    private int field212_ = 0;
+    private int field212_;
     public bool HasField212 {
       get { return hasField212; }
     }
@@ -2911,7 +2911,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field213FieldNumber = 213;
     private bool hasField213;
-    private int field213_ = 0;
+    private int field213_;
     public bool HasField213 {
       get { return hasField213; }
     }
@@ -2921,7 +2921,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field216FieldNumber = 216;
     private bool hasField216;
-    private int field216_ = 0;
+    private int field216_;
     public bool HasField216 {
       get { return hasField216; }
     }
@@ -2931,7 +2931,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field217FieldNumber = 217;
     private bool hasField217;
-    private int field217_ = 0;
+    private int field217_;
     public bool HasField217 {
       get { return hasField217; }
     }
@@ -2941,7 +2941,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field218FieldNumber = 218;
     private bool hasField218;
-    private int field218_ = 0;
+    private int field218_;
     public bool HasField218 {
       get { return hasField218; }
     }
@@ -2951,7 +2951,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field220FieldNumber = 220;
     private bool hasField220;
-    private int field220_ = 0;
+    private int field220_;
     public bool HasField220 {
       get { return hasField220; }
     }
@@ -2961,7 +2961,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field221FieldNumber = 221;
     private bool hasField221;
-    private int field221_ = 0;
+    private int field221_;
     public bool HasField221 {
       get { return hasField221; }
     }
@@ -2971,7 +2971,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field222FieldNumber = 222;
     private bool hasField222;
-    private float field222_ = 0F;
+    private float field222_;
     public bool HasField222 {
       get { return hasField222; }
     }
@@ -2981,7 +2981,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field63FieldNumber = 63;
     private bool hasField63;
-    private int field63_ = 0;
+    private int field63_;
     public bool HasField63 {
       get { return hasField63; }
     }
@@ -3015,7 +3015,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field131FieldNumber = 131;
     private bool hasField131;
-    private long field131_ = 0L;
+    private long field131_;
     public bool HasField131 {
       get { return hasField131; }
     }
@@ -3037,7 +3037,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field129FieldNumber = 129;
     private bool hasField129;
-    private int field129_ = 0;
+    private int field129_;
     public bool HasField129 {
       get { return hasField129; }
     }
@@ -3059,7 +3059,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field205FieldNumber = 205;
     private bool hasField205;
-    private bool field205_ = false;
+    private bool field205_;
     public bool HasField205 {
       get { return hasField205; }
     }
@@ -3069,7 +3069,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field206FieldNumber = 206;
     private bool hasField206;
-    private bool field206_ = false;
+    private bool field206_;
     public bool HasField206 {
       get { return hasField206; }
     }
@@ -3783,7 +3783,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field1FieldNumber = 1;
     private bool hasField1;
-    private float field1_ = 0F;
+    private float field1_;
     public bool HasField1 {
       get { return hasField1; }
     }
@@ -3793,7 +3793,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field2FieldNumber = 2;
     private bool hasField2;
-    private float field2_ = 0F;
+    private float field2_;
     public bool HasField2 {
       get { return hasField2; }
     }
@@ -3803,7 +3803,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field3FieldNumber = 3;
     private bool hasField3;
-    private float field3_ = 0F;
+    private float field3_;
     public bool HasField3 {
       get { return hasField3; }
     }
@@ -3813,7 +3813,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field4FieldNumber = 4;
     private bool hasField4;
-    private bool field4_ = false;
+    private bool field4_;
     public bool HasField4 {
       get { return hasField4; }
     }
@@ -3823,7 +3823,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field5FieldNumber = 5;
     private bool hasField5;
-    private bool field5_ = false;
+    private bool field5_;
     public bool HasField5 {
       get { return hasField5; }
     }
@@ -3843,7 +3843,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field7FieldNumber = 7;
     private bool hasField7;
-    private bool field7_ = false;
+    private bool field7_;
     public bool HasField7 {
       get { return hasField7; }
     }
@@ -3853,7 +3853,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field8FieldNumber = 8;
     private bool hasField8;
-    private float field8_ = 0F;
+    private float field8_;
     public bool HasField8 {
       get { return hasField8; }
     }
@@ -3863,7 +3863,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field9FieldNumber = 9;
     private bool hasField9;
-    private bool field9_ = false;
+    private bool field9_;
     public bool HasField9 {
       get { return hasField9; }
     }
@@ -3873,7 +3873,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field10FieldNumber = 10;
     private bool hasField10;
-    private float field10_ = 0F;
+    private float field10_;
     public bool HasField10 {
       get { return hasField10; }
     }
@@ -3883,7 +3883,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field11FieldNumber = 11;
     private bool hasField11;
-    private long field11_ = 0L;
+    private long field11_;
     public bool HasField11 {
       get { return hasField11; }
     }

+ 76 - 76
src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSpeedProtoFile.cs

@@ -190,7 +190,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field80FieldNumber = 80;
     private bool hasField80;
-    private bool field80_ = false;
+    private bool field80_;
     public bool HasField80 {
       get { return hasField80; }
     }
@@ -210,7 +210,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field2FieldNumber = 2;
     private bool hasField2;
-    private int field2_ = 0;
+    private int field2_;
     public bool HasField2 {
       get { return hasField2; }
     }
@@ -220,7 +220,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field3FieldNumber = 3;
     private bool hasField3;
-    private int field3_ = 0;
+    private int field3_;
     public bool HasField3 {
       get { return hasField3; }
     }
@@ -230,7 +230,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field280FieldNumber = 280;
     private bool hasField280;
-    private int field280_ = 0;
+    private int field280_;
     public bool HasField280 {
       get { return hasField280; }
     }
@@ -240,7 +240,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field6FieldNumber = 6;
     private bool hasField6;
-    private int field6_ = 0;
+    private int field6_;
     public bool HasField6 {
       get { return hasField6; }
     }
@@ -250,7 +250,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field22FieldNumber = 22;
     private bool hasField22;
-    private long field22_ = 0L;
+    private long field22_;
     public bool HasField22 {
       get { return hasField22; }
     }
@@ -284,7 +284,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field59FieldNumber = 59;
     private bool hasField59;
-    private bool field59_ = false;
+    private bool field59_;
     public bool HasField59 {
       get { return hasField59; }
     }
@@ -304,7 +304,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field16FieldNumber = 16;
     private bool hasField16;
-    private int field16_ = 0;
+    private int field16_;
     public bool HasField16 {
       get { return hasField16; }
     }
@@ -314,7 +314,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field130FieldNumber = 130;
     private bool hasField130;
-    private int field130_ = 0;
+    private int field130_;
     public bool HasField130 {
       get { return hasField130; }
     }
@@ -364,7 +364,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field104FieldNumber = 104;
     private bool hasField104;
-    private int field104_ = 0;
+    private int field104_;
     public bool HasField104 {
       get { return hasField104; }
     }
@@ -374,7 +374,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field100FieldNumber = 100;
     private bool hasField100;
-    private int field100_ = 0;
+    private int field100_;
     public bool HasField100 {
       get { return hasField100; }
     }
@@ -384,7 +384,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field101FieldNumber = 101;
     private bool hasField101;
-    private int field101_ = 0;
+    private int field101_;
     public bool HasField101 {
       get { return hasField101; }
     }
@@ -414,7 +414,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field29FieldNumber = 29;
     private bool hasField29;
-    private int field29_ = 0;
+    private int field29_;
     public bool HasField29 {
       get { return hasField29; }
     }
@@ -424,7 +424,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field30FieldNumber = 30;
     private bool hasField30;
-    private bool field30_ = false;
+    private bool field30_;
     public bool HasField30 {
       get { return hasField30; }
     }
@@ -464,7 +464,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field150FieldNumber = 150;
     private bool hasField150;
-    private int field150_ = 0;
+    private int field150_;
     public bool HasField150 {
       get { return hasField150; }
     }
@@ -474,7 +474,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field23FieldNumber = 23;
     private bool hasField23;
-    private int field23_ = 0;
+    private int field23_;
     public bool HasField23 {
       get { return hasField23; }
     }
@@ -484,7 +484,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field24FieldNumber = 24;
     private bool hasField24;
-    private bool field24_ = false;
+    private bool field24_;
     public bool HasField24 {
       get { return hasField24; }
     }
@@ -494,7 +494,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field25FieldNumber = 25;
     private bool hasField25;
-    private int field25_ = 0;
+    private int field25_;
     public bool HasField25 {
       get { return hasField25; }
     }
@@ -514,7 +514,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field78FieldNumber = 78;
     private bool hasField78;
-    private bool field78_ = false;
+    private bool field78_;
     public bool HasField78 {
       get { return hasField78; }
     }
@@ -524,7 +524,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field67FieldNumber = 67;
     private bool hasField67;
-    private int field67_ = 0;
+    private int field67_;
     public bool HasField67 {
       get { return hasField67; }
     }
@@ -534,7 +534,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field68FieldNumber = 68;
     private bool hasField68;
-    private int field68_ = 0;
+    private int field68_;
     public bool HasField68 {
       get { return hasField68; }
     }
@@ -544,7 +544,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field128FieldNumber = 128;
     private bool hasField128;
-    private int field128_ = 0;
+    private int field128_;
     public bool HasField128 {
       get { return hasField128; }
     }
@@ -564,7 +564,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field131FieldNumber = 131;
     private bool hasField131;
-    private int field131_ = 0;
+    private int field131_;
     public bool HasField131 {
       get { return hasField131; }
     }
@@ -2095,7 +2095,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field1FieldNumber = 1;
     private bool hasField1;
-    private int field1_ = 0;
+    private int field1_;
     public bool HasField1 {
       get { return hasField1; }
     }
@@ -2105,7 +2105,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field2FieldNumber = 2;
     private bool hasField2;
-    private int field2_ = 0;
+    private int field2_;
     public bool HasField2 {
       get { return hasField2; }
     }
@@ -2115,7 +2115,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field3FieldNumber = 3;
     private bool hasField3;
-    private int field3_ = 0;
+    private int field3_;
     public bool HasField3 {
       get { return hasField3; }
     }
@@ -2145,7 +2145,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field13FieldNumber = 13;
     private bool hasField13;
-    private long field13_ = 0L;
+    private long field13_;
     public bool HasField13 {
       get { return hasField13; }
     }
@@ -2155,7 +2155,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field14FieldNumber = 14;
     private bool hasField14;
-    private long field14_ = 0L;
+    private long field14_;
     public bool HasField14 {
       get { return hasField14; }
     }
@@ -2165,7 +2165,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field16FieldNumber = 16;
     private bool hasField16;
-    private int field16_ = 0;
+    private int field16_;
     public bool HasField16 {
       get { return hasField16; }
     }
@@ -2205,7 +2205,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field21FieldNumber = 21;
     private bool hasField21;
-    private ulong field21_ = 0;
+    private ulong field21_;
     public bool HasField21 {
       get { return hasField21; }
     }
@@ -2216,7 +2216,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field22FieldNumber = 22;
     private bool hasField22;
-    private int field22_ = 0;
+    private int field22_;
     public bool HasField22 {
       get { return hasField22; }
     }
@@ -2226,7 +2226,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field23FieldNumber = 23;
     private bool hasField23;
-    private bool field23_ = false;
+    private bool field23_;
     public bool HasField23 {
       get { return hasField23; }
     }
@@ -2236,7 +2236,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field206FieldNumber = 206;
     private bool hasField206;
-    private bool field206_ = false;
+    private bool field206_;
     public bool HasField206 {
       get { return hasField206; }
     }
@@ -2246,7 +2246,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field203FieldNumber = 203;
     private bool hasField203;
-    private uint field203_ = 0;
+    private uint field203_;
     public bool HasField203 {
       get { return hasField203; }
     }
@@ -2257,7 +2257,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field204FieldNumber = 204;
     private bool hasField204;
-    private int field204_ = 0;
+    private int field204_;
     public bool HasField204 {
       get { return hasField204; }
     }
@@ -2277,7 +2277,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field207FieldNumber = 207;
     private bool hasField207;
-    private ulong field207_ = 0UL;
+    private ulong field207_;
     public bool HasField207 {
       get { return hasField207; }
     }
@@ -2288,7 +2288,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field300FieldNumber = 300;
     private bool hasField300;
-    private ulong field300_ = 0UL;
+    private ulong field300_;
     public bool HasField300 {
       get { return hasField300; }
     }
@@ -3159,7 +3159,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int Field11FieldNumber = 11;
         private bool hasField11;
-        private float field11_ = 0F;
+        private float field11_;
         public bool HasField11 {
           get { return hasField11; }
         }
@@ -3169,7 +3169,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int Field26FieldNumber = 26;
         private bool hasField26;
-        private float field26_ = 0F;
+        private float field26_;
         public bool HasField26 {
           get { return hasField26; }
         }
@@ -3211,7 +3211,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int Field15FieldNumber = 15;
         private bool hasField15;
-        private ulong field15_ = 0UL;
+        private ulong field15_;
         public bool HasField15 {
           get { return hasField15; }
         }
@@ -3222,7 +3222,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int Field5FieldNumber = 5;
         private bool hasField5;
-        private int field5_ = 0;
+        private int field5_;
         public bool HasField5 {
           get { return hasField5; }
         }
@@ -3242,7 +3242,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int Field28FieldNumber = 28;
         private bool hasField28;
-        private int field28_ = 0;
+        private int field28_;
         public bool HasField28 {
           get { return hasField28; }
         }
@@ -3296,7 +3296,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int Field20FieldNumber = 20;
         private bool hasField20;
-        private int field20_ = 0;
+        private int field20_;
         public bool HasField20 {
           get { return hasField20; }
         }
@@ -4086,7 +4086,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field3FieldNumber = 3;
     private bool hasField3;
-    private long field3_ = 0L;
+    private long field3_;
     public bool HasField3 {
       get { return hasField3; }
     }
@@ -4096,7 +4096,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field4FieldNumber = 4;
     private bool hasField4;
-    private long field4_ = 0L;
+    private long field4_;
     public bool HasField4 {
       get { return hasField4; }
     }
@@ -4106,7 +4106,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field30FieldNumber = 30;
     private bool hasField30;
-    private long field30_ = 0L;
+    private long field30_;
     public bool HasField30 {
       get { return hasField30; }
     }
@@ -4116,7 +4116,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field75FieldNumber = 75;
     private bool hasField75;
-    private bool field75_ = false;
+    private bool field75_;
     public bool HasField75 {
       get { return hasField75; }
     }
@@ -4146,7 +4146,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field21FieldNumber = 21;
     private bool hasField21;
-    private int field21_ = 0;
+    private int field21_;
     public bool HasField21 {
       get { return hasField21; }
     }
@@ -4156,7 +4156,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field71FieldNumber = 71;
     private bool hasField71;
-    private int field71_ = 0;
+    private int field71_;
     public bool HasField71 {
       get { return hasField71; }
     }
@@ -4166,7 +4166,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field25FieldNumber = 25;
     private bool hasField25;
-    private float field25_ = 0F;
+    private float field25_;
     public bool HasField25 {
       get { return hasField25; }
     }
@@ -4176,7 +4176,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field109FieldNumber = 109;
     private bool hasField109;
-    private int field109_ = 0;
+    private int field109_;
     public bool HasField109 {
       get { return hasField109; }
     }
@@ -4186,7 +4186,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field210FieldNumber = 210;
     private bool hasField210;
-    private int field210_ = 0;
+    private int field210_;
     public bool HasField210 {
       get { return hasField210; }
     }
@@ -4196,7 +4196,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field211FieldNumber = 211;
     private bool hasField211;
-    private int field211_ = 0;
+    private int field211_;
     public bool HasField211 {
       get { return hasField211; }
     }
@@ -4206,7 +4206,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field212FieldNumber = 212;
     private bool hasField212;
-    private int field212_ = 0;
+    private int field212_;
     public bool HasField212 {
       get { return hasField212; }
     }
@@ -4216,7 +4216,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field213FieldNumber = 213;
     private bool hasField213;
-    private int field213_ = 0;
+    private int field213_;
     public bool HasField213 {
       get { return hasField213; }
     }
@@ -4226,7 +4226,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field216FieldNumber = 216;
     private bool hasField216;
-    private int field216_ = 0;
+    private int field216_;
     public bool HasField216 {
       get { return hasField216; }
     }
@@ -4236,7 +4236,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field217FieldNumber = 217;
     private bool hasField217;
-    private int field217_ = 0;
+    private int field217_;
     public bool HasField217 {
       get { return hasField217; }
     }
@@ -4246,7 +4246,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field218FieldNumber = 218;
     private bool hasField218;
-    private int field218_ = 0;
+    private int field218_;
     public bool HasField218 {
       get { return hasField218; }
     }
@@ -4256,7 +4256,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field220FieldNumber = 220;
     private bool hasField220;
-    private int field220_ = 0;
+    private int field220_;
     public bool HasField220 {
       get { return hasField220; }
     }
@@ -4266,7 +4266,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field221FieldNumber = 221;
     private bool hasField221;
-    private int field221_ = 0;
+    private int field221_;
     public bool HasField221 {
       get { return hasField221; }
     }
@@ -4276,7 +4276,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field222FieldNumber = 222;
     private bool hasField222;
-    private float field222_ = 0F;
+    private float field222_;
     public bool HasField222 {
       get { return hasField222; }
     }
@@ -4286,7 +4286,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field63FieldNumber = 63;
     private bool hasField63;
-    private int field63_ = 0;
+    private int field63_;
     public bool HasField63 {
       get { return hasField63; }
     }
@@ -4320,7 +4320,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field131FieldNumber = 131;
     private bool hasField131;
-    private long field131_ = 0L;
+    private long field131_;
     public bool HasField131 {
       get { return hasField131; }
     }
@@ -4342,7 +4342,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field129FieldNumber = 129;
     private bool hasField129;
-    private int field129_ = 0;
+    private int field129_;
     public bool HasField129 {
       get { return hasField129; }
     }
@@ -4364,7 +4364,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field205FieldNumber = 205;
     private bool hasField205;
-    private bool field205_ = false;
+    private bool field205_;
     public bool HasField205 {
       get { return hasField205; }
     }
@@ -4374,7 +4374,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field206FieldNumber = 206;
     private bool hasField206;
-    private bool field206_ = false;
+    private bool field206_;
     public bool HasField206 {
       get { return hasField206; }
     }
@@ -5583,7 +5583,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field1FieldNumber = 1;
     private bool hasField1;
-    private float field1_ = 0F;
+    private float field1_;
     public bool HasField1 {
       get { return hasField1; }
     }
@@ -5593,7 +5593,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field2FieldNumber = 2;
     private bool hasField2;
-    private float field2_ = 0F;
+    private float field2_;
     public bool HasField2 {
       get { return hasField2; }
     }
@@ -5603,7 +5603,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field3FieldNumber = 3;
     private bool hasField3;
-    private float field3_ = 0F;
+    private float field3_;
     public bool HasField3 {
       get { return hasField3; }
     }
@@ -5613,7 +5613,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field4FieldNumber = 4;
     private bool hasField4;
-    private bool field4_ = false;
+    private bool field4_;
     public bool HasField4 {
       get { return hasField4; }
     }
@@ -5623,7 +5623,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field5FieldNumber = 5;
     private bool hasField5;
-    private bool field5_ = false;
+    private bool field5_;
     public bool HasField5 {
       get { return hasField5; }
     }
@@ -5643,7 +5643,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field7FieldNumber = 7;
     private bool hasField7;
-    private bool field7_ = false;
+    private bool field7_;
     public bool HasField7 {
       get { return hasField7; }
     }
@@ -5653,7 +5653,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field8FieldNumber = 8;
     private bool hasField8;
-    private float field8_ = 0F;
+    private float field8_;
     public bool HasField8 {
       get { return hasField8; }
     }
@@ -5663,7 +5663,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field9FieldNumber = 9;
     private bool hasField9;
-    private bool field9_ = false;
+    private bool field9_;
     public bool HasField9 {
       get { return hasField9; }
     }
@@ -5673,7 +5673,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field10FieldNumber = 10;
     private bool hasField10;
-    private float field10_ = 0F;
+    private float field10_;
     public bool HasField10 {
       get { return hasField10; }
     }
@@ -5683,7 +5683,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Field11FieldNumber = 11;
     private bool hasField11;
-    private long field11_ = 0L;
+    private long field11_;
     public bool HasField11 {
       get { return hasField11; }
     }

+ 1 - 1
src/ProtocolBuffers.Test/TestProtos/UnitTestImportLiteProtoFile.cs

@@ -58,7 +58,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int DFieldNumber = 1;
     private bool hasD;
-    private int d_ = 0;
+    private int d_;
     public bool HasD {
       get { return hasD; }
     }

+ 1 - 1
src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs

@@ -94,7 +94,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int DFieldNumber = 1;
     private bool hasD;
-    private int d_ = 0;
+    private int d_;
     public bool HasD {
       get { return hasD; }
     }

+ 2 - 2
src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs

@@ -593,7 +593,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     public static pb::GeneratedExtensionBase<global::Google.ProtocolBuffers.TestProtos.TestMessageSetExtension1> MessageSetExtension;
     public const int IFieldNumber = 15;
     private bool hasI;
-    private int i_ = 0;
+    private int i_;
     public bool HasI {
       get { return hasI; }
     }
@@ -1106,7 +1106,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int TypeIdFieldNumber = 2;
         private bool hasTypeId;
-        private int typeId_ = 0;
+        private int typeId_;
         public bool HasTypeId {
           get { return hasTypeId; }
         }

+ 1 - 1
src/ProtocolBuffers.Test/TestProtos/UnitTestNoGenericServicesProtoFile.cs

@@ -104,7 +104,7 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService {
     
     public const int AFieldNumber = 1;
     private bool hasA;
-    private int a_ = 0;
+    private int a_;
     public bool HasA {
       get { return hasA; }
     }

+ 2 - 2
src/ProtocolBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs

@@ -110,7 +110,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     public static pb::GeneratedExtensionBase<global::Google.ProtocolBuffers.TestProtos.TestRequiredOptimizedForSize> TestExtension2;
     public const int IFieldNumber = 1;
     private bool hasI;
-    private int i_ = 0;
+    private int i_;
     public bool HasI {
       get { return hasI; }
     }
@@ -293,7 +293,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int XFieldNumber = 1;
     private bool hasX;
-    private int x_ = 0;
+    private int x_;
     public bool HasX {
       get { return hasX; }
     }

+ 76 - 76
src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs

@@ -1185,7 +1185,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int BbFieldNumber = 1;
         private bool hasBb;
-        private int bb_ = 0;
+        private int bb_;
         public bool HasBb {
           get { return hasBb; }
         }
@@ -1424,7 +1424,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int AFieldNumber = 17;
         private bool hasA;
-        private int a_ = 0;
+        private int a_;
         public bool HasA {
           get { return hasA; }
         }
@@ -1663,7 +1663,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int AFieldNumber = 47;
         private bool hasA;
-        private int a_ = 0;
+        private int a_;
         public bool HasA {
           get { return hasA; }
         }
@@ -1878,7 +1878,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalInt32FieldNumber = 1;
     private bool hasOptionalInt32;
-    private int optionalInt32_ = 0;
+    private int optionalInt32_;
     public bool HasOptionalInt32 {
       get { return hasOptionalInt32; }
     }
@@ -1888,7 +1888,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalInt64FieldNumber = 2;
     private bool hasOptionalInt64;
-    private long optionalInt64_ = 0L;
+    private long optionalInt64_;
     public bool HasOptionalInt64 {
       get { return hasOptionalInt64; }
     }
@@ -1898,7 +1898,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalUint32FieldNumber = 3;
     private bool hasOptionalUint32;
-    private uint optionalUint32_ = 0;
+    private uint optionalUint32_;
     public bool HasOptionalUint32 {
       get { return hasOptionalUint32; }
     }
@@ -1909,7 +1909,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalUint64FieldNumber = 4;
     private bool hasOptionalUint64;
-    private ulong optionalUint64_ = 0UL;
+    private ulong optionalUint64_;
     public bool HasOptionalUint64 {
       get { return hasOptionalUint64; }
     }
@@ -1920,7 +1920,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalSint32FieldNumber = 5;
     private bool hasOptionalSint32;
-    private int optionalSint32_ = 0;
+    private int optionalSint32_;
     public bool HasOptionalSint32 {
       get { return hasOptionalSint32; }
     }
@@ -1930,7 +1930,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalSint64FieldNumber = 6;
     private bool hasOptionalSint64;
-    private long optionalSint64_ = 0;
+    private long optionalSint64_;
     public bool HasOptionalSint64 {
       get { return hasOptionalSint64; }
     }
@@ -1940,7 +1940,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalFixed32FieldNumber = 7;
     private bool hasOptionalFixed32;
-    private uint optionalFixed32_ = 0;
+    private uint optionalFixed32_;
     public bool HasOptionalFixed32 {
       get { return hasOptionalFixed32; }
     }
@@ -1951,7 +1951,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalFixed64FieldNumber = 8;
     private bool hasOptionalFixed64;
-    private ulong optionalFixed64_ = 0;
+    private ulong optionalFixed64_;
     public bool HasOptionalFixed64 {
       get { return hasOptionalFixed64; }
     }
@@ -1962,7 +1962,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalSfixed32FieldNumber = 9;
     private bool hasOptionalSfixed32;
-    private int optionalSfixed32_ = 0;
+    private int optionalSfixed32_;
     public bool HasOptionalSfixed32 {
       get { return hasOptionalSfixed32; }
     }
@@ -1972,7 +1972,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalSfixed64FieldNumber = 10;
     private bool hasOptionalSfixed64;
-    private long optionalSfixed64_ = 0;
+    private long optionalSfixed64_;
     public bool HasOptionalSfixed64 {
       get { return hasOptionalSfixed64; }
     }
@@ -1982,7 +1982,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalFloatFieldNumber = 11;
     private bool hasOptionalFloat;
-    private float optionalFloat_ = 0F;
+    private float optionalFloat_;
     public bool HasOptionalFloat {
       get { return hasOptionalFloat; }
     }
@@ -1992,7 +1992,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalDoubleFieldNumber = 12;
     private bool hasOptionalDouble;
-    private double optionalDouble_ = 0D;
+    private double optionalDouble_;
     public bool HasOptionalDouble {
       get { return hasOptionalDouble; }
     }
@@ -2002,7 +2002,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalBoolFieldNumber = 13;
     private bool hasOptionalBool;
-    private bool optionalBool_ = false;
+    private bool optionalBool_;
     public bool HasOptionalBool {
       get { return hasOptionalBool; }
     }
@@ -2687,13 +2687,13 @@ namespace Google.ProtocolBuffers.TestProtos {
         output.WriteMessage(20, field_names[30], OptionalImportMessage);
       }
       if (hasOptionalNestedEnum) {
-        output.WriteEnum(21, field_names[33], (int) OptionalNestedEnum, OptionalNestedEnum.ToString());
+        output.WriteEnum(21, field_names[33], (int) OptionalNestedEnum, OptionalNestedEnum);
       }
       if (hasOptionalForeignEnum) {
-        output.WriteEnum(22, field_names[27], (int) OptionalForeignEnum, OptionalForeignEnum.ToString());
+        output.WriteEnum(22, field_names[27], (int) OptionalForeignEnum, OptionalForeignEnum);
       }
       if (hasOptionalImportEnum) {
-        output.WriteEnum(23, field_names[29], (int) OptionalImportEnum, OptionalImportEnum.ToString());
+        output.WriteEnum(23, field_names[29], (int) OptionalImportEnum, OptionalImportEnum);
       }
       if (hasOptionalStringPiece) {
         output.WriteString(24, field_names[40], OptionalStringPiece);
@@ -2819,13 +2819,13 @@ namespace Google.ProtocolBuffers.TestProtos {
         output.WriteBytes(75, field_names[1], DefaultBytes);
       }
       if (hasDefaultNestedEnum) {
-        output.WriteEnum(81, field_names[11], (int) DefaultNestedEnum, DefaultNestedEnum.ToString());
+        output.WriteEnum(81, field_names[11], (int) DefaultNestedEnum, DefaultNestedEnum);
       }
       if (hasDefaultForeignEnum) {
-        output.WriteEnum(82, field_names[7], (int) DefaultForeignEnum, DefaultForeignEnum.ToString());
+        output.WriteEnum(82, field_names[7], (int) DefaultForeignEnum, DefaultForeignEnum);
       }
       if (hasDefaultImportEnum) {
-        output.WriteEnum(83, field_names[8], (int) DefaultImportEnum, DefaultImportEnum.ToString());
+        output.WriteEnum(83, field_names[8], (int) DefaultImportEnum, DefaultImportEnum);
       }
       if (hasDefaultStringPiece) {
         output.WriteString(84, field_names[17], DefaultStringPiece);
@@ -5519,7 +5519,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int DeprecatedInt32FieldNumber = 1;
     private bool hasDeprecatedInt32;
-    private int deprecatedInt32_ = 0;
+    private int deprecatedInt32_;
     public bool HasDeprecatedInt32 {
       get { return hasDeprecatedInt32; }
     }
@@ -5758,7 +5758,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int CFieldNumber = 1;
     private bool hasC;
-    private int c_ = 0;
+    private int c_;
     public bool HasC {
       get { return hasC; }
     }
@@ -6200,7 +6200,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int AFieldNumber = 17;
     private bool hasA;
-    private int a_ = 0;
+    private int a_;
     public bool HasA {
       get { return hasA; }
     }
@@ -6439,7 +6439,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int AFieldNumber = 47;
     private bool hasA;
-    private int a_ = 0;
+    private int a_;
     public bool HasA {
       get { return hasA; }
     }
@@ -6882,7 +6882,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     public static pb::GeneratedExtensionBase<scg::IList<global::Google.ProtocolBuffers.TestProtos.TestRequired>> Multi;
     public const int AFieldNumber = 1;
     private bool hasA;
-    private int a_ = 0;
+    private int a_;
     public bool HasA {
       get { return hasA; }
     }
@@ -6892,7 +6892,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy2FieldNumber = 2;
     private bool hasDummy2;
-    private int dummy2_ = 0;
+    private int dummy2_;
     public bool HasDummy2 {
       get { return hasDummy2; }
     }
@@ -6902,7 +6902,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int BFieldNumber = 3;
     private bool hasB;
-    private int b_ = 0;
+    private int b_;
     public bool HasB {
       get { return hasB; }
     }
@@ -6912,7 +6912,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy4FieldNumber = 4;
     private bool hasDummy4;
-    private int dummy4_ = 0;
+    private int dummy4_;
     public bool HasDummy4 {
       get { return hasDummy4; }
     }
@@ -6922,7 +6922,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy5FieldNumber = 5;
     private bool hasDummy5;
-    private int dummy5_ = 0;
+    private int dummy5_;
     public bool HasDummy5 {
       get { return hasDummy5; }
     }
@@ -6932,7 +6932,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy6FieldNumber = 6;
     private bool hasDummy6;
-    private int dummy6_ = 0;
+    private int dummy6_;
     public bool HasDummy6 {
       get { return hasDummy6; }
     }
@@ -6942,7 +6942,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy7FieldNumber = 7;
     private bool hasDummy7;
-    private int dummy7_ = 0;
+    private int dummy7_;
     public bool HasDummy7 {
       get { return hasDummy7; }
     }
@@ -6952,7 +6952,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy8FieldNumber = 8;
     private bool hasDummy8;
-    private int dummy8_ = 0;
+    private int dummy8_;
     public bool HasDummy8 {
       get { return hasDummy8; }
     }
@@ -6962,7 +6962,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy9FieldNumber = 9;
     private bool hasDummy9;
-    private int dummy9_ = 0;
+    private int dummy9_;
     public bool HasDummy9 {
       get { return hasDummy9; }
     }
@@ -6972,7 +6972,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy10FieldNumber = 10;
     private bool hasDummy10;
-    private int dummy10_ = 0;
+    private int dummy10_;
     public bool HasDummy10 {
       get { return hasDummy10; }
     }
@@ -6982,7 +6982,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy11FieldNumber = 11;
     private bool hasDummy11;
-    private int dummy11_ = 0;
+    private int dummy11_;
     public bool HasDummy11 {
       get { return hasDummy11; }
     }
@@ -6992,7 +6992,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy12FieldNumber = 12;
     private bool hasDummy12;
-    private int dummy12_ = 0;
+    private int dummy12_;
     public bool HasDummy12 {
       get { return hasDummy12; }
     }
@@ -7002,7 +7002,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy13FieldNumber = 13;
     private bool hasDummy13;
-    private int dummy13_ = 0;
+    private int dummy13_;
     public bool HasDummy13 {
       get { return hasDummy13; }
     }
@@ -7012,7 +7012,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy14FieldNumber = 14;
     private bool hasDummy14;
-    private int dummy14_ = 0;
+    private int dummy14_;
     public bool HasDummy14 {
       get { return hasDummy14; }
     }
@@ -7022,7 +7022,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy15FieldNumber = 15;
     private bool hasDummy15;
-    private int dummy15_ = 0;
+    private int dummy15_;
     public bool HasDummy15 {
       get { return hasDummy15; }
     }
@@ -7032,7 +7032,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy16FieldNumber = 16;
     private bool hasDummy16;
-    private int dummy16_ = 0;
+    private int dummy16_;
     public bool HasDummy16 {
       get { return hasDummy16; }
     }
@@ -7042,7 +7042,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy17FieldNumber = 17;
     private bool hasDummy17;
-    private int dummy17_ = 0;
+    private int dummy17_;
     public bool HasDummy17 {
       get { return hasDummy17; }
     }
@@ -7052,7 +7052,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy18FieldNumber = 18;
     private bool hasDummy18;
-    private int dummy18_ = 0;
+    private int dummy18_;
     public bool HasDummy18 {
       get { return hasDummy18; }
     }
@@ -7062,7 +7062,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy19FieldNumber = 19;
     private bool hasDummy19;
-    private int dummy19_ = 0;
+    private int dummy19_;
     public bool HasDummy19 {
       get { return hasDummy19; }
     }
@@ -7072,7 +7072,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy20FieldNumber = 20;
     private bool hasDummy20;
-    private int dummy20_ = 0;
+    private int dummy20_;
     public bool HasDummy20 {
       get { return hasDummy20; }
     }
@@ -7082,7 +7082,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy21FieldNumber = 21;
     private bool hasDummy21;
-    private int dummy21_ = 0;
+    private int dummy21_;
     public bool HasDummy21 {
       get { return hasDummy21; }
     }
@@ -7092,7 +7092,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy22FieldNumber = 22;
     private bool hasDummy22;
-    private int dummy22_ = 0;
+    private int dummy22_;
     public bool HasDummy22 {
       get { return hasDummy22; }
     }
@@ -7102,7 +7102,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy23FieldNumber = 23;
     private bool hasDummy23;
-    private int dummy23_ = 0;
+    private int dummy23_;
     public bool HasDummy23 {
       get { return hasDummy23; }
     }
@@ -7112,7 +7112,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy24FieldNumber = 24;
     private bool hasDummy24;
-    private int dummy24_ = 0;
+    private int dummy24_;
     public bool HasDummy24 {
       get { return hasDummy24; }
     }
@@ -7122,7 +7122,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy25FieldNumber = 25;
     private bool hasDummy25;
-    private int dummy25_ = 0;
+    private int dummy25_;
     public bool HasDummy25 {
       get { return hasDummy25; }
     }
@@ -7132,7 +7132,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy26FieldNumber = 26;
     private bool hasDummy26;
-    private int dummy26_ = 0;
+    private int dummy26_;
     public bool HasDummy26 {
       get { return hasDummy26; }
     }
@@ -7142,7 +7142,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy27FieldNumber = 27;
     private bool hasDummy27;
-    private int dummy27_ = 0;
+    private int dummy27_;
     public bool HasDummy27 {
       get { return hasDummy27; }
     }
@@ -7152,7 +7152,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy28FieldNumber = 28;
     private bool hasDummy28;
-    private int dummy28_ = 0;
+    private int dummy28_;
     public bool HasDummy28 {
       get { return hasDummy28; }
     }
@@ -7162,7 +7162,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy29FieldNumber = 29;
     private bool hasDummy29;
-    private int dummy29_ = 0;
+    private int dummy29_;
     public bool HasDummy29 {
       get { return hasDummy29; }
     }
@@ -7172,7 +7172,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy30FieldNumber = 30;
     private bool hasDummy30;
-    private int dummy30_ = 0;
+    private int dummy30_;
     public bool HasDummy30 {
       get { return hasDummy30; }
     }
@@ -7182,7 +7182,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy31FieldNumber = 31;
     private bool hasDummy31;
-    private int dummy31_ = 0;
+    private int dummy31_;
     public bool HasDummy31 {
       get { return hasDummy31; }
     }
@@ -7192,7 +7192,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy32FieldNumber = 32;
     private bool hasDummy32;
-    private int dummy32_ = 0;
+    private int dummy32_;
     public bool HasDummy32 {
       get { return hasDummy32; }
     }
@@ -7202,7 +7202,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int CFieldNumber = 33;
     private bool hasC;
-    private int c_ = 0;
+    private int c_;
     public bool HasC {
       get { return hasC; }
     }
@@ -8458,7 +8458,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int DummyFieldNumber = 3;
     private bool hasDummy;
-    private int dummy_ = 0;
+    private int dummy_;
     public bool HasDummy {
       get { return hasDummy; }
     }
@@ -9677,7 +9677,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int AFieldNumber = 1;
     private bool hasA;
-    private int a_ = 0;
+    private int a_;
     public bool HasA {
       get { return hasA; }
     }
@@ -9687,7 +9687,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int BbFieldNumber = 268435455;
     private bool hasBb;
-    private int bb_ = 0;
+    private int bb_;
     public bool HasBb {
       get { return hasBb; }
     }
@@ -9967,7 +9967,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int IFieldNumber = 2;
     private bool hasI;
-    private int i_ = 0;
+    private int i_;
     public bool HasI {
       get { return hasI; }
     }
@@ -10532,7 +10532,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalInt32FieldNumber = 2;
     private bool hasOptionalInt32;
-    private int optionalInt32_ = 0;
+    private int optionalInt32_;
     public bool HasOptionalInt32 {
       get { return hasOptionalInt32; }
     }
@@ -10857,7 +10857,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int AFieldNumber = 1;
         private bool hasA;
-        private int a_ = 0;
+        private int a_;
         public bool HasA {
           get { return hasA; }
         }
@@ -11096,7 +11096,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int AFieldNumber = 1;
         private bool hasA;
-        private int a_ = 0;
+        private int a_;
         public bool HasA {
           get { return hasA; }
         }
@@ -11311,7 +11311,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int AFieldNumber = 1;
     private bool hasA;
-    private int a_ = 0;
+    private int a_;
     public bool HasA {
       get { return hasA; }
     }
@@ -12268,7 +12268,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int PrimitiveFieldFieldNumber = 1;
     private bool hasPrimitiveField;
-    private int primitiveField_ = 0;
+    private int primitiveField_;
     public bool HasPrimitiveField {
       get { return hasPrimitiveField; }
     }
@@ -12414,7 +12414,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         output.WriteString(2, field_names[10], StringField);
       }
       if (hasEnumField) {
-        output.WriteEnum(3, field_names[1], (int) EnumField, EnumField.ToString());
+        output.WriteEnum(3, field_names[1], (int) EnumField, EnumField);
       }
       if (hasMessageField) {
         output.WriteMessage(4, field_names[2], MessageField);
@@ -13124,7 +13124,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int MyIntFieldNumber = 1;
     private bool hasMyInt;
-    private long myInt_ = 0L;
+    private long myInt_;
     public bool HasMyInt {
       get { return hasMyInt; }
     }
@@ -13134,7 +13134,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int MyFloatFieldNumber = 101;
     private bool hasMyFloat;
-    private float myFloat_ = 0F;
+    private float myFloat_;
     public bool HasMyFloat {
       get { return hasMyFloat; }
     }
@@ -13504,7 +13504,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int ZeroFloatFieldNumber = 7;
     private bool hasZeroFloat;
-    private float zeroFloat_ = 0F;
+    private float zeroFloat_;
     public bool HasZeroFloat {
       get { return hasZeroFloat; }
     }
@@ -17478,7 +17478,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int DynamicFieldFieldNumber = 2100;
         private bool hasDynamicField;
-        private int dynamicField_ = 0;
+        private int dynamicField_;
         public bool HasDynamicField {
           get { return hasDynamicField; }
         }
@@ -17693,7 +17693,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int ScalarExtensionFieldNumber = 2000;
     private bool hasScalarExtension;
-    private uint scalarExtension_ = 0;
+    private uint scalarExtension_;
     public bool HasScalarExtension {
       get { return hasScalarExtension; }
     }
@@ -17780,10 +17780,10 @@ namespace Google.ProtocolBuffers.TestProtos {
         output.WriteFixed32(2000, field_names[6], ScalarExtension);
       }
       if (hasEnumExtension) {
-        output.WriteEnum(2001, field_names[2], (int) EnumExtension, EnumExtension.ToString());
+        output.WriteEnum(2001, field_names[2], (int) EnumExtension, EnumExtension);
       }
       if (hasDynamicEnumExtension) {
-        output.WriteEnum(2002, field_names[0], (int) DynamicEnumExtension, DynamicEnumExtension.ToString());
+        output.WriteEnum(2002, field_names[0], (int) DynamicEnumExtension, DynamicEnumExtension);
       }
       if (hasMessageExtension) {
         output.WriteMessage(2003, field_names[3], MessageExtension);

+ 3 - 3
src/ProtocolBuffers.Test/TestProtos/UnitTestXmlSerializerTestProtoFile.cs

@@ -977,7 +977,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int NumberFieldNumber = 6;
     private bool hasNumber;
-    private long number_ = 0L;
+    private long number_;
     public bool HasNumber {
       get { return hasNumber; }
     }
@@ -1021,7 +1021,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int ValidFieldNumber = 5;
     private bool hasValid;
-    private bool valid_ = false;
+    private bool valid_;
     public bool HasValid {
       get { return hasValid; }
     }
@@ -1549,7 +1549,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int NumberFieldNumber = 1;
     private bool hasNumber;
-    private int number_ = 0;
+    private int number_;
     public bool HasNumber {
       get { return hasNumber; }
     }

+ 246 - 9
src/ProtocolBuffers/CodedInputStream.cs

@@ -516,8 +516,13 @@ namespace Google.ProtocolBuffers
         /// <summary>
         /// Returns true if the next tag is also part of the same unpacked array
         /// </summary>
-        private bool ContinueArray(uint currentTag)
+        private bool ContinueArray(uint currentTag, bool packed)
         {
+            if (packed)
+            {
+                return !ReachedLimit;
+            }
+
             string ignore;
             uint next;
             if (PeekNextTag(out next, out ignore))
@@ -532,7 +537,7 @@ namespace Google.ProtocolBuffers
         }
 
         [CLSCompliant(false)]
-        public void ReadPrimitiveArray<T>(FieldType fieldType, uint fieldTag, string fieldName, ICollection<T> list)
+        public void ReadPrimitiveArray(FieldType fieldType, uint fieldTag, string fieldName, ICollection<object> list)
         {
             WireFormat.WireType normal = WireFormat.GetWireType(fieldType);
             WireFormat.WireType wformat = WireFormat.GetTagWireType(fieldTag);
@@ -546,7 +551,7 @@ namespace Google.ProtocolBuffers
                 {
                     Object value = null;
                     if(ReadPrimitiveField(fieldType, ref value))
-                        list.Add((T)value);
+                        list.Add(value);
                 }
                 PopLimit(limit);
             }
@@ -556,9 +561,241 @@ namespace Google.ProtocolBuffers
                 do
                 {
                     if (ReadPrimitiveField(fieldType, ref value))
-                        list.Add((T)value);
+                        list.Add(value);
                 }
-                while (ContinueArray(fieldTag));
+                while (ContinueArray(fieldTag, false));
+            }
+        }
+
+        [CLSCompliant(false)]
+        public void ReadPrimitiveArray<T>(FieldType fieldType, uint fieldTag, string fieldName, ICollection<T> list)
+        {
+            WireFormat.WireType normal = WireFormat.GetWireType(fieldType);
+            WireFormat.WireType wformat = WireFormat.GetTagWireType(fieldTag);
+
+            // 2.3 allows packed form even if the field is not declared packed.
+            if (normal != wformat && wformat == WireFormat.WireType.LengthDelimited)
+            {
+                int length = (int)(ReadRawVarint32() & int.MaxValue);
+                int limit = PushLimit(length);
+                //while (!ReachedLimit)
+                //{
+                //    Object value = null;
+                //    if (ReadPrimitiveField(fieldType, ref value))
+                //        list.Add((T)value);
+                //}
+                if (!ReachedLimit)
+                    ReadPrimitiveArrayItems(fieldType, fieldTag, list, true);
+
+                PopLimit(limit);
+            }
+            else
+            {
+                ReadPrimitiveArrayItems(fieldType, fieldTag, list, false);
+                //Object value = null;
+                //do
+                //{
+                //    if (ReadPrimitiveField(fieldType, ref value))
+                //        list.Add((T)value);
+                //}
+                //while (ContinueArray(fieldTag, false));
+            }
+        }
+
+        void ReadPrimitiveArrayItems<T>(FieldType fieldType, uint fieldTag, ICollection<T> list, bool packed)
+        {
+            switch (fieldType)
+            {
+                case FieldType.Double:
+                    {
+                        ICollection<double> output = (ICollection<double>)list;
+                        double tmp = 0;
+                        do
+                        {
+                            ReadDouble(ref tmp);
+                            output.Add(tmp);
+                        }
+                        while (ContinueArray(fieldTag, packed));
+                    }
+                    break;
+                case FieldType.Float:
+                    {
+                        ICollection<float> output = (ICollection<float>)list;
+                        float tmp = 0;
+                        do
+                        {
+                            ReadFloat(ref tmp);
+                            output.Add(tmp);
+                        }
+                        while (ContinueArray(fieldTag, packed));
+                    }
+                    break;
+                case FieldType.Int64:
+                    {
+                        ICollection<long> output = (ICollection<long>)list;
+                        long tmp = 0;
+                        do
+                        {
+                            ReadInt64(ref tmp);
+                            output.Add(tmp);
+                        }
+                        while (ContinueArray(fieldTag, packed));
+                    }
+                    break;
+                case FieldType.UInt64:
+                    {
+                        ICollection<ulong> output = (ICollection<ulong>)list;
+                        ulong tmp = 0;
+                        do
+                        {
+                            ReadUInt64(ref tmp);
+                            output.Add(tmp);
+                        }
+                        while (ContinueArray(fieldTag, packed));
+                    }
+                    break;
+                case FieldType.Int32:
+                    {
+                        ICollection<int> output = (ICollection<int>)list;
+                        int tmp = 0;
+                        do
+                        {
+                            ReadInt32(ref tmp);
+                            output.Add(tmp);
+                        }
+                        while (ContinueArray(fieldTag, packed));
+                    }
+                    break;
+                case FieldType.Fixed64:
+                    {
+                        ICollection<ulong> output = (ICollection<ulong>)list;
+                        ulong tmp = 0;
+                        do
+                        {
+                            ReadFixed64(ref tmp);
+                            output.Add(tmp);
+                        }
+                        while (ContinueArray(fieldTag, packed));
+                    }
+                    break;
+                case FieldType.Fixed32:
+                    {
+                        ICollection<uint> output = (ICollection<uint>)list;
+                        uint tmp = 0;
+                        do
+                        {
+                            ReadFixed32(ref tmp);
+                            output.Add(tmp);
+                        }
+                        while (ContinueArray(fieldTag, packed));
+                    }
+                    break;
+                case FieldType.Bool:
+                    {
+                        ICollection<bool> output = (ICollection<bool>)list;
+                        bool tmp = false;
+                        do
+                        {
+                            ReadBool(ref tmp);
+                            output.Add(tmp);
+                        }
+                        while (ContinueArray(fieldTag, packed));
+                    }
+                    break;
+                case FieldType.String:
+                    {
+                        ICollection<string> output = (ICollection<string>)list;
+                        string tmp = null;
+                        do
+                        {
+                            ReadString(ref tmp);
+                            output.Add(tmp);
+                        }
+                        while (ContinueArray(fieldTag, packed));
+                    }
+                    break;
+                case FieldType.Bytes:
+                    {
+                        ICollection<ByteString> output = (ICollection<ByteString>)list;
+                        ByteString tmp = null;
+                        do
+                        {
+                            ReadBytes(ref tmp);
+                            output.Add(tmp);
+                        }
+                        while (ContinueArray(fieldTag, packed));
+                    }
+                    break;
+                case FieldType.UInt32:
+                    {
+                        ICollection<uint> output = (ICollection<uint>)list;
+                        uint tmp = 0;
+                        do
+                        {
+                            ReadUInt32(ref tmp);
+                            output.Add(tmp);
+                        }
+                        while (ContinueArray(fieldTag, packed));
+                    }
+                    break;
+                case FieldType.SFixed32:
+                    {
+                        ICollection<int> output = (ICollection<int>)list;
+                        int tmp = 0;
+                        do
+                        {
+                            ReadSFixed32(ref tmp);
+                            output.Add(tmp);
+                        }
+                        while (ContinueArray(fieldTag, packed));
+                    }
+                    break;
+                case FieldType.SFixed64:
+                    {
+                        ICollection<long> output = (ICollection<long>)list;
+                        long tmp = 0;
+                        do
+                        {
+                            ReadSFixed64(ref tmp);
+                            output.Add(tmp);
+                        }
+                        while (ContinueArray(fieldTag, packed));
+                    }
+                    break;
+                case FieldType.SInt32:
+                    {
+                        ICollection<int> output = (ICollection<int>)list;
+                        int tmp = 0;
+                        do
+                        {
+                            ReadSInt32(ref tmp);
+                            output.Add(tmp);
+                        }
+                        while (ContinueArray(fieldTag, packed));
+                    }
+                    break;
+                case FieldType.SInt64:
+                    {
+                        ICollection<long> output = (ICollection<long>)list;
+                        long tmp = 0;
+                        do
+                        {
+                            ReadSInt64(ref tmp);
+                            output.Add(tmp);
+                        }
+                        while (ContinueArray(fieldTag, packed));
+                    }
+                    break;
+                case FieldType.Group:
+                    throw new ArgumentException("ReadPrimitiveField() cannot handle nested groups.");
+                case FieldType.Message:
+                    throw new ArgumentException("ReadPrimitiveField() cannot handle embedded messages.");
+                // We don't handle enums because we don't know what to do if the
+                // value is not recognized.
+                case FieldType.Enum:
+                    throw new ArgumentException("ReadPrimitiveField() cannot handle enums.");
+                default:
+                    throw new ArgumentOutOfRangeException("Invalid field type " + fieldType);
             }
         }
 
@@ -601,7 +838,7 @@ namespace Google.ProtocolBuffers
                         unknown.Add(unkval);
                     }
                 }
-                while (ContinueArray(fieldTag));
+                while (ContinueArray(fieldTag, false));
             }
         }
 
@@ -645,7 +882,7 @@ namespace Google.ProtocolBuffers
                         unknown.Add(unkval);
                     }
                 }
-                while (ContinueArray(fieldTag));
+                while (ContinueArray(fieldTag, false));
             }
         }
 
@@ -658,7 +895,7 @@ namespace Google.ProtocolBuffers
                 ReadMessage(builder, registry);
                 list.Add((T)builder.WeakBuildPartial());
             }
-            while (ContinueArray(fieldTag));
+            while (ContinueArray(fieldTag, false));
         }
 
         [CLSCompliant(false)]
@@ -670,7 +907,7 @@ namespace Google.ProtocolBuffers
                 ReadGroup(WireFormat.GetTagFieldNumber(fieldTag), builder, registry);
                 list.Add((T)builder.WeakBuildPartial());
             }
-            while (ContinueArray(fieldTag));
+            while (ContinueArray(fieldTag, false));
         }
 
         /// <summary>

+ 18 - 11
src/ProtocolBuffers/CodedOutputStream.cs

@@ -40,6 +40,7 @@ using System.Globalization;
 using System.IO;
 using System.Runtime.InteropServices;
 using System.Text;
+using Google.ProtocolBuffers.Collections;
 using Google.ProtocolBuffers.Descriptors;
 
 namespace Google.ProtocolBuffers
@@ -272,7 +273,7 @@ namespace Google.ProtocolBuffers
             WriteRawVarint32(value);
         }
 
-        public void WriteEnum(int fieldNumber, string fieldName, int value, string textValue)
+        public void WriteEnum(int fieldNumber, string fieldName, int value, object textValue)
         {
             WriteTag(fieldNumber, WireFormat.WireType.Varint);
             WriteRawVarint32((uint) value);
@@ -349,11 +350,14 @@ namespace Google.ProtocolBuffers
                         WriteBool(fieldNumber, fieldName, value);
                     break;
                 case FieldType.Enum:
-                    foreach (T value in list)
+                    if (default(T) is System.Enum)
+                    {
+                        foreach (int value in ((ICastArray)list).CastArray<int>())
+                            WriteEnum(fieldNumber, fieldName, value, null/*not used*/);
+                    }
+                    else
                     {
-                        if (value is System.Enum)
-                            WriteEnum(fieldNumber, fieldName, ((IConvertible)value).ToInt32(CultureInfo.InvariantCulture), null/*not used*/);
-                        else
+                        foreach (T value in list)
                             WriteEnum(fieldNumber, fieldName, ((IEnumLite)value).Number, null/*not used*/);
                     }
                     break;
@@ -449,11 +453,14 @@ namespace Google.ProtocolBuffers
                         WriteBoolNoTag(value);
                     break;
                 case FieldType.Enum:
-                    foreach (T value in list)
+                    if (default(T) is System.Enum)
+                    {
+                        foreach (int value in ((ICastArray)list).CastArray<int>())
+                            WriteEnumNoTag(value);
+                    }
+                    else
                     {
-                        if (value is System.Enum)
-                            WriteEnumNoTag(((IConvertible)value).ToInt32(CultureInfo.InvariantCulture));
-                        else
+                        foreach (T value in list)
                             WriteEnumNoTag(((IEnumLite)value).Number);
                     }
                     break;
@@ -529,7 +536,7 @@ namespace Google.ProtocolBuffers
                     break;
                 case FieldType.Enum:
                     if (value is System.Enum)
-                        WriteEnum(fieldNumber, fieldName, ((IConvertible)value).ToInt32(CultureInfo.InvariantCulture), null/*not used*/);
+                        WriteEnum(fieldNumber, fieldName, (int)value, null/*not used*/);
                     else
                         WriteEnum(fieldNumber, fieldName, ((IEnumLite)value).Number, null/*not used*/);
                     break;
@@ -593,7 +600,7 @@ namespace Google.ProtocolBuffers
                     break;
                 case FieldType.Enum:
                     if (value is System.Enum)
-                        WriteEnumNoTag(((IConvertible)value).ToInt32(CultureInfo.InvariantCulture));
+                        WriteEnumNoTag((int)value);
                     else
                         WriteEnumNoTag(((IEnumLite)value).Number);
                     break;

+ 8 - 0
src/ProtocolBuffers/Collections/IPopsicleList.cs

@@ -47,4 +47,12 @@ namespace Google.ProtocolBuffers.Collections
     {
         void Add(IEnumerable<T> collection);
     }
+
+    /// <summary>
+    /// Used to efficiently cast the elements of enumerations
+    /// </summary>
+    internal interface ICastArray
+    {
+        IEnumerable<TItemType> CastArray<TItemType>();
+    }
 }

+ 32 - 18
src/ProtocolBuffers/Collections/PopsicleList.cs

@@ -40,10 +40,12 @@ namespace Google.ProtocolBuffers.Collections
     /// to be made read-only (with the <see cref="MakeReadOnly" /> method), 
     /// after which any modifying methods throw <see cref="NotSupportedException" />.
     /// </summary>
-    public sealed class PopsicleList<T> : IPopsicleList<T>
+    public sealed class PopsicleList<T> : IPopsicleList<T>, ICastArray
     {
-        private readonly List<T> items = new List<T>();
-        private bool readOnly = false;
+        private static readonly IEnumerable<T> EmptySet = new T[0];
+
+        private List<T> items;
+        private bool readOnly;
 
         /// <summary>
         /// Makes this list read-only ("freezes the popsicle"). From this
@@ -57,7 +59,7 @@ namespace Google.ProtocolBuffers.Collections
 
         public int IndexOf(T item)
         {
-            return items.IndexOf(item);
+            return items == null ? -1 : items.IndexOf(item);
         }
 
         public void Insert(int index, T item)
@@ -74,7 +76,7 @@ namespace Google.ProtocolBuffers.Collections
 
         public T this[int index]
         {
-            get { return items[index]; }
+            get { if (items == null) throw new ArgumentOutOfRangeException(); return items[index]; }
             set
             {
                 ValidateModification();
@@ -96,17 +98,18 @@ namespace Google.ProtocolBuffers.Collections
 
         public bool Contains(T item)
         {
-            return items.Contains(item);
+            return items == null ? false : items.Contains(item);
         }
 
         public void CopyTo(T[] array, int arrayIndex)
         {
-            items.CopyTo(array, arrayIndex);
+            if (items != null)
+                items.CopyTo(array, arrayIndex);
         }
 
         public int Count
         {
-            get { return items.Count; }
+            get { return items == null ? 0 : items.Count; }
         }
 
         public bool IsReadOnly
@@ -120,18 +123,9 @@ namespace Google.ProtocolBuffers.Collections
             return items.Remove(item);
         }
 
-        public void Add(IEnumerable<T> collection)
-        {
-            if (readOnly)
-            {
-                throw new NotSupportedException("List is read-only");
-            }
-            items.AddRange(collection);
-        }
-
         public IEnumerator<T> GetEnumerator()
         {
-            return items.GetEnumerator();
+            return items == null ? EmptySet.GetEnumerator() : items.GetEnumerator();
         }
 
         IEnumerator IEnumerable.GetEnumerator()
@@ -139,12 +133,32 @@ namespace Google.ProtocolBuffers.Collections
             return GetEnumerator();
         }
 
+        public void Add(IEnumerable<T> collection)
+        {
+            if (readOnly)
+            {
+                throw new NotSupportedException("List is read-only");
+            }
+            if (items == null)
+                items = new List<T>();
+            items.AddRange(collection);
+        }
+
         private void ValidateModification()
         {
             if (readOnly)
             {
                 throw new NotSupportedException("List is read-only");
             }
+            if (items == null)
+                items = new List<T>();
+        }
+
+        IEnumerable<TItemType> ICastArray.CastArray<TItemType>()
+        {
+            if (items == null)
+                return new TItemType[0];
+            return (TItemType[])(object)items.ToArray();
         }
     }
 }

+ 7 - 7
src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs

@@ -178,7 +178,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
     
     public const int MultipleFilesFieldNumber = 4;
     private bool hasMultipleFiles;
-    private bool multipleFiles_ = false;
+    private bool multipleFiles_;
     public bool HasMultipleFiles {
       get { return hasMultipleFiles; }
     }
@@ -188,7 +188,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
     
     public const int NestClassesFieldNumber = 5;
     private bool hasNestClasses;
-    private bool nestClasses_ = false;
+    private bool nestClasses_;
     public bool HasNestClasses {
       get { return hasNestClasses; }
     }
@@ -198,7 +198,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
     
     public const int CodeContractsFieldNumber = 6;
     private bool hasCodeContracts;
-    private bool codeContracts_ = false;
+    private bool codeContracts_;
     public bool HasCodeContracts {
       get { return hasCodeContracts; }
     }
@@ -208,7 +208,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
     
     public const int ExpandNamespaceDirectoriesFieldNumber = 7;
     private bool hasExpandNamespaceDirectories;
-    private bool expandNamespaceDirectories_ = false;
+    private bool expandNamespaceDirectories_;
     public bool HasExpandNamespaceDirectories {
       get { return hasExpandNamespaceDirectories; }
     }
@@ -258,7 +258,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
     
     public const int IgnoreGoogleProtobufFieldNumber = 224;
     private bool hasIgnoreGoogleProtobuf;
-    private bool ignoreGoogleProtobuf_ = false;
+    private bool ignoreGoogleProtobuf_;
     public bool HasIgnoreGoogleProtobuf {
       get { return hasIgnoreGoogleProtobuf; }
     }
@@ -322,7 +322,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
         output.WriteBool(224, field_names[4], IgnoreGoogleProtobuf);
       }
       if (hasServiceGeneratorType) {
-        output.WriteEnum(225, field_names[10], (int) ServiceGeneratorType, ServiceGeneratorType.ToString());
+        output.WriteEnum(225, field_names[10], (int) ServiceGeneratorType, ServiceGeneratorType);
       }
       UnknownFields.WriteTo(output);
     }
@@ -1372,7 +1372,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
     
     public const int DispatchIdFieldNumber = 1;
     private bool hasDispatchId;
-    private int dispatchId_ = 0;
+    private int dispatchId_;
     public bool HasDispatchId {
       get { return hasDispatchId; }
     }

+ 17 - 17
src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs

@@ -1229,7 +1229,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
         
         public const int StartFieldNumber = 1;
         private bool hasStart;
-        private int start_ = 0;
+        private int start_;
         public bool HasStart {
           get { return hasStart; }
         }
@@ -1239,7 +1239,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
         
         public const int EndFieldNumber = 2;
         private bool hasEnd;
-        private int end_ = 0;
+        private int end_;
         public bool HasEnd {
           get { return hasEnd; }
         }
@@ -2173,7 +2173,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
     
     public const int NumberFieldNumber = 3;
     private bool hasNumber;
-    private int number_ = 0;
+    private int number_;
     public bool HasNumber {
       get { return hasNumber; }
     }
@@ -2263,10 +2263,10 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
         output.WriteInt32(3, field_names[4], Number);
       }
       if (hasLabel) {
-        output.WriteEnum(4, field_names[2], (int) Label, Label.ToString());
+        output.WriteEnum(4, field_names[2], (int) Label, Label);
       }
       if (hasType) {
-        output.WriteEnum(5, field_names[6], (int) Type, Type.ToString());
+        output.WriteEnum(5, field_names[6], (int) Type, Type);
       }
       if (hasTypeName) {
         output.WriteString(6, field_names[7], TypeName);
@@ -3119,7 +3119,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
     
     public const int NumberFieldNumber = 2;
     private bool hasNumber;
-    private int number_ = 0;
+    private int number_;
     public bool HasNumber {
       get { return hasNumber; }
     }
@@ -4258,7 +4258,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
     
     public const int JavaMultipleFilesFieldNumber = 10;
     private bool hasJavaMultipleFiles;
-    private bool javaMultipleFiles_ = false;
+    private bool javaMultipleFiles_;
     public bool HasJavaMultipleFiles {
       get { return hasJavaMultipleFiles; }
     }
@@ -4339,7 +4339,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
         output.WriteString(8, field_names[3], JavaOuterClassname);
       }
       if (hasOptimizeFor) {
-        output.WriteEnum(9, field_names[5], (int) OptimizeFor, OptimizeFor.ToString());
+        output.WriteEnum(9, field_names[5], (int) OptimizeFor, OptimizeFor);
       }
       if (hasJavaMultipleFiles) {
         output.WriteBool(10, field_names[2], JavaMultipleFiles);
@@ -4805,7 +4805,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
     
     public const int MessageSetWireFormatFieldNumber = 1;
     private bool hasMessageSetWireFormat;
-    private bool messageSetWireFormat_ = false;
+    private bool messageSetWireFormat_;
     public bool HasMessageSetWireFormat {
       get { return hasMessageSetWireFormat; }
     }
@@ -4815,7 +4815,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
     
     public const int NoStandardDescriptorAccessorFieldNumber = 2;
     private bool hasNoStandardDescriptorAccessor;
-    private bool noStandardDescriptorAccessor_ = false;
+    private bool noStandardDescriptorAccessor_;
     public bool HasNoStandardDescriptorAccessor {
       get { return hasNoStandardDescriptorAccessor; }
     }
@@ -5183,7 +5183,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
     
     public const int PackedFieldNumber = 2;
     private bool hasPacked;
-    private bool packed_ = false;
+    private bool packed_;
     public bool HasPacked {
       get { return hasPacked; }
     }
@@ -5193,7 +5193,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
     
     public const int DeprecatedFieldNumber = 3;
     private bool hasDeprecated;
-    private bool deprecated_ = false;
+    private bool deprecated_;
     public bool HasDeprecated {
       get { return hasDeprecated; }
     }
@@ -5238,7 +5238,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
       string[] field_names = _fieldOptionsFieldNames;
       pb::ExtendableMessage<FieldOptions, FieldOptions.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this);
       if (hasCtype) {
-        output.WriteEnum(1, field_names[0], (int) Ctype, Ctype.ToString());
+        output.WriteEnum(1, field_names[0], (int) Ctype, Ctype);
       }
       if (hasPacked) {
         output.WriteBool(2, field_names[3], Packed);
@@ -6738,7 +6738,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
         
         public const int IsExtensionFieldNumber = 2;
         private bool hasIsExtension;
-        private bool isExtension_ = false;
+        private bool isExtension_;
         public bool HasIsExtension {
           get { return hasIsExtension; }
         }
@@ -7009,7 +7009,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
     
     public const int PositiveIntValueFieldNumber = 4;
     private bool hasPositiveIntValue;
-    private ulong positiveIntValue_ = 0UL;
+    private ulong positiveIntValue_;
     public bool HasPositiveIntValue {
       get { return hasPositiveIntValue; }
     }
@@ -7020,7 +7020,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
     
     public const int NegativeIntValueFieldNumber = 5;
     private bool hasNegativeIntValue;
-    private long negativeIntValue_ = 0L;
+    private long negativeIntValue_;
     public bool HasNegativeIntValue {
       get { return hasNegativeIntValue; }
     }
@@ -7030,7 +7030,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
     
     public const int DoubleValueFieldNumber = 6;
     private bool hasDoubleValue;
-    private double doubleValue_ = 0D;
+    private double doubleValue_;
     public bool HasDoubleValue {
       get { return hasDoubleValue; }
     }

+ 7 - 0
src/ProtocolBuffers/ICodedInputStream.cs

@@ -139,6 +139,13 @@ namespace Google.ProtocolBuffers
         /// </summary>   
         bool ReadSInt64(ref long value);
 
+        /// <summary>
+        /// Reads an array of primitive values into the list, if the wire-type of fieldTag is length-prefixed and the 
+        /// type is numberic, it will read a packed array.
+        /// </summary>
+        [CLSCompliant(false)]
+        void ReadPrimitiveArray(FieldType fieldType, uint fieldTag, string fieldName, ICollection<object> list);
+
         /// <summary>
         /// Reads an array of primitive values into the list, if the wire-type of fieldTag is length-prefixed and the 
         /// type is numberic, it will read a packed array.

+ 1 - 1
src/ProtocolBuffers/ICodedOutputStream.cs

@@ -70,7 +70,7 @@ namespace Google.ProtocolBuffers
         [CLSCompliant(false)]
         void WriteUInt32(int fieldNumber, string fieldName, uint value);
 
-        void WriteEnum(int fieldNumber, string fieldName, int value, string textValue);
+        void WriteEnum(int fieldNumber, string fieldName, int value, object rawValue);
         void WriteSFixed32(int fieldNumber, string fieldName, int value);
         void WriteSFixed64(int fieldNumber, string fieldName, long value);
         void WriteSInt32(int fieldNumber, string fieldName, int value);

+ 5 - 5
src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasFullProtoFile.cs

@@ -393,7 +393,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int ZipFieldNumber = 5;
         private bool hasZip;
-        private uint zip_ = 0;
+        private uint zip_;
         public bool HasZip {
           get { return hasZip; }
         }
@@ -597,7 +597,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int IdFieldNumber = 2;
     private bool hasId;
-    private int id_ = 0;
+    private int id_;
     public bool HasId {
       get { return hasId; }
     }
@@ -1091,7 +1091,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int CountFieldNumber = 5;
         private bool hasCount;
-        private int count_ = 0;
+        private int count_;
         public bool HasCount {
           get { return hasCount; }
         }
@@ -1257,7 +1257,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int IdFieldNumber = 2;
     private bool hasId;
-    private int id_ = 0;
+    private int id_;
     public bool HasId {
       get { return hasId; }
     }
@@ -1656,7 +1656,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int IdFieldNumber = 2;
     private bool hasId;
-    private int id_ = 0;
+    private int id_;
     public bool HasId {
       get { return hasId; }
     }

+ 5 - 5
src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs

@@ -74,7 +74,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int DFieldNumber = 1;
     private bool hasD;
-    private int d_ = 0;
+    private int d_;
     public bool HasD {
       get { return hasD; }
     }
@@ -107,7 +107,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         output.WriteInt32(1, field_names[0], D);
       }
       if (hasEn) {
-        output.WriteEnum(2, field_names[1], (int) En, En.ToString());
+        output.WriteEnum(2, field_names[1], (int) En, En);
       }
     }
     
@@ -418,7 +418,7 @@ namespace Google.ProtocolBuffers.TestProtos {
             output.WriteString(1, field_names[0], Number);
           }
           if (hasType) {
-            output.WriteEnum(2, field_names[1], (int) Type, Type.ToString());
+            output.WriteEnum(2, field_names[1], (int) Type, Type);
           }
         }
         
@@ -706,7 +706,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int ZipFieldNumber = 5;
         private bool hasZip;
-        private uint zip_ = 0;
+        private uint zip_;
         public bool HasZip {
           get { return hasZip; }
         }
@@ -1077,7 +1077,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int IdFieldNumber = 2;
     private bool hasId;
-    private int id_ = 0;
+    private int id_;
     public bool HasId {
       get { return hasId; }
     }

+ 1 - 1
src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportLiteProtoFile.cs

@@ -58,7 +58,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int DFieldNumber = 1;
     private bool hasD;
-    private int d_ = 0;
+    private int d_;
     public bool HasD {
       get { return hasD; }
     }

+ 1 - 1
src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportProtoFile.cs

@@ -94,7 +94,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int DFieldNumber = 1;
     private bool hasD;
-    private int d_ = 0;
+    private int d_;
     public bool HasD {
       get { return hasD; }
     }

+ 26 - 26
src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteProtoFile.cs

@@ -1275,7 +1275,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int BbFieldNumber = 1;
         private bool hasBb;
-        private int bb_ = 0;
+        private int bb_;
         public bool HasBb {
           get { return hasBb; }
         }
@@ -1505,7 +1505,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int AFieldNumber = 17;
         private bool hasA;
-        private int a_ = 0;
+        private int a_;
         public bool HasA {
           get { return hasA; }
         }
@@ -1735,7 +1735,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int AFieldNumber = 47;
         private bool hasA;
-        private int a_ = 0;
+        private int a_;
         public bool HasA {
           get { return hasA; }
         }
@@ -1949,7 +1949,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalInt32FieldNumber = 1;
     private bool hasOptionalInt32;
-    private int optionalInt32_ = 0;
+    private int optionalInt32_;
     public bool HasOptionalInt32 {
       get { return hasOptionalInt32; }
     }
@@ -1959,7 +1959,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalInt64FieldNumber = 2;
     private bool hasOptionalInt64;
-    private long optionalInt64_ = 0L;
+    private long optionalInt64_;
     public bool HasOptionalInt64 {
       get { return hasOptionalInt64; }
     }
@@ -1969,7 +1969,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalUint32FieldNumber = 3;
     private bool hasOptionalUint32;
-    private uint optionalUint32_ = 0;
+    private uint optionalUint32_;
     public bool HasOptionalUint32 {
       get { return hasOptionalUint32; }
     }
@@ -1980,7 +1980,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalUint64FieldNumber = 4;
     private bool hasOptionalUint64;
-    private ulong optionalUint64_ = 0UL;
+    private ulong optionalUint64_;
     public bool HasOptionalUint64 {
       get { return hasOptionalUint64; }
     }
@@ -1991,7 +1991,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalSint32FieldNumber = 5;
     private bool hasOptionalSint32;
-    private int optionalSint32_ = 0;
+    private int optionalSint32_;
     public bool HasOptionalSint32 {
       get { return hasOptionalSint32; }
     }
@@ -2001,7 +2001,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalSint64FieldNumber = 6;
     private bool hasOptionalSint64;
-    private long optionalSint64_ = 0;
+    private long optionalSint64_;
     public bool HasOptionalSint64 {
       get { return hasOptionalSint64; }
     }
@@ -2011,7 +2011,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalFixed32FieldNumber = 7;
     private bool hasOptionalFixed32;
-    private uint optionalFixed32_ = 0;
+    private uint optionalFixed32_;
     public bool HasOptionalFixed32 {
       get { return hasOptionalFixed32; }
     }
@@ -2022,7 +2022,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalFixed64FieldNumber = 8;
     private bool hasOptionalFixed64;
-    private ulong optionalFixed64_ = 0;
+    private ulong optionalFixed64_;
     public bool HasOptionalFixed64 {
       get { return hasOptionalFixed64; }
     }
@@ -2033,7 +2033,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalSfixed32FieldNumber = 9;
     private bool hasOptionalSfixed32;
-    private int optionalSfixed32_ = 0;
+    private int optionalSfixed32_;
     public bool HasOptionalSfixed32 {
       get { return hasOptionalSfixed32; }
     }
@@ -2043,7 +2043,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalSfixed64FieldNumber = 10;
     private bool hasOptionalSfixed64;
-    private long optionalSfixed64_ = 0;
+    private long optionalSfixed64_;
     public bool HasOptionalSfixed64 {
       get { return hasOptionalSfixed64; }
     }
@@ -2053,7 +2053,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalFloatFieldNumber = 11;
     private bool hasOptionalFloat;
-    private float optionalFloat_ = 0F;
+    private float optionalFloat_;
     public bool HasOptionalFloat {
       get { return hasOptionalFloat; }
     }
@@ -2063,7 +2063,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalDoubleFieldNumber = 12;
     private bool hasOptionalDouble;
-    private double optionalDouble_ = 0D;
+    private double optionalDouble_;
     public bool HasOptionalDouble {
       get { return hasOptionalDouble; }
     }
@@ -2073,7 +2073,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalBoolFieldNumber = 13;
     private bool hasOptionalBool;
-    private bool optionalBool_ = false;
+    private bool optionalBool_;
     public bool HasOptionalBool {
       get { return hasOptionalBool; }
     }
@@ -2758,13 +2758,13 @@ namespace Google.ProtocolBuffers.TestProtos {
         output.WriteMessage(20, field_names[30], OptionalImportMessage);
       }
       if (hasOptionalNestedEnum) {
-        output.WriteEnum(21, field_names[33], (int) OptionalNestedEnum, OptionalNestedEnum.ToString());
+        output.WriteEnum(21, field_names[33], (int) OptionalNestedEnum, OptionalNestedEnum);
       }
       if (hasOptionalForeignEnum) {
-        output.WriteEnum(22, field_names[27], (int) OptionalForeignEnum, OptionalForeignEnum.ToString());
+        output.WriteEnum(22, field_names[27], (int) OptionalForeignEnum, OptionalForeignEnum);
       }
       if (hasOptionalImportEnum) {
-        output.WriteEnum(23, field_names[29], (int) OptionalImportEnum, OptionalImportEnum.ToString());
+        output.WriteEnum(23, field_names[29], (int) OptionalImportEnum, OptionalImportEnum);
       }
       if (hasOptionalStringPiece) {
         output.WriteString(24, field_names[40], OptionalStringPiece);
@@ -2890,13 +2890,13 @@ namespace Google.ProtocolBuffers.TestProtos {
         output.WriteBytes(75, field_names[1], DefaultBytes);
       }
       if (hasDefaultNestedEnum) {
-        output.WriteEnum(81, field_names[11], (int) DefaultNestedEnum, DefaultNestedEnum.ToString());
+        output.WriteEnum(81, field_names[11], (int) DefaultNestedEnum, DefaultNestedEnum);
       }
       if (hasDefaultForeignEnum) {
-        output.WriteEnum(82, field_names[7], (int) DefaultForeignEnum, DefaultForeignEnum.ToString());
+        output.WriteEnum(82, field_names[7], (int) DefaultForeignEnum, DefaultForeignEnum);
       }
       if (hasDefaultImportEnum) {
-        output.WriteEnum(83, field_names[8], (int) DefaultImportEnum, DefaultImportEnum.ToString());
+        output.WriteEnum(83, field_names[8], (int) DefaultImportEnum, DefaultImportEnum);
       }
       if (hasDefaultStringPiece) {
         output.WriteString(84, field_names[17], DefaultStringPiece);
@@ -5806,7 +5806,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int CFieldNumber = 1;
     private bool hasC;
-    private int c_ = 0;
+    private int c_;
     public bool HasC {
       get { return hasC; }
     }
@@ -8483,7 +8483,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int AFieldNumber = 17;
     private bool hasA;
-    private int a_ = 0;
+    private int a_;
     public bool HasA {
       get { return hasA; }
     }
@@ -8713,7 +8713,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int AFieldNumber = 47;
     private bool hasA;
-    private int a_ = 0;
+    private int a_;
     public bool HasA {
       get { return hasA; }
     }
@@ -9519,7 +9519,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int DeprecatedFieldFieldNumber = 1;
     private bool hasDeprecatedField;
-    private int deprecatedField_ = 0;
+    private int deprecatedField_;
     public bool HasDeprecatedField {
       get { return hasDeprecatedField; }
     }

+ 76 - 76
src/ProtocolBuffersLite.Test/TestProtos/UnitTestProtoFile.cs

@@ -1185,7 +1185,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int BbFieldNumber = 1;
         private bool hasBb;
-        private int bb_ = 0;
+        private int bb_;
         public bool HasBb {
           get { return hasBb; }
         }
@@ -1424,7 +1424,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int AFieldNumber = 17;
         private bool hasA;
-        private int a_ = 0;
+        private int a_;
         public bool HasA {
           get { return hasA; }
         }
@@ -1663,7 +1663,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int AFieldNumber = 47;
         private bool hasA;
-        private int a_ = 0;
+        private int a_;
         public bool HasA {
           get { return hasA; }
         }
@@ -1878,7 +1878,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalInt32FieldNumber = 1;
     private bool hasOptionalInt32;
-    private int optionalInt32_ = 0;
+    private int optionalInt32_;
     public bool HasOptionalInt32 {
       get { return hasOptionalInt32; }
     }
@@ -1888,7 +1888,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalInt64FieldNumber = 2;
     private bool hasOptionalInt64;
-    private long optionalInt64_ = 0L;
+    private long optionalInt64_;
     public bool HasOptionalInt64 {
       get { return hasOptionalInt64; }
     }
@@ -1898,7 +1898,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalUint32FieldNumber = 3;
     private bool hasOptionalUint32;
-    private uint optionalUint32_ = 0;
+    private uint optionalUint32_;
     public bool HasOptionalUint32 {
       get { return hasOptionalUint32; }
     }
@@ -1909,7 +1909,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalUint64FieldNumber = 4;
     private bool hasOptionalUint64;
-    private ulong optionalUint64_ = 0UL;
+    private ulong optionalUint64_;
     public bool HasOptionalUint64 {
       get { return hasOptionalUint64; }
     }
@@ -1920,7 +1920,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalSint32FieldNumber = 5;
     private bool hasOptionalSint32;
-    private int optionalSint32_ = 0;
+    private int optionalSint32_;
     public bool HasOptionalSint32 {
       get { return hasOptionalSint32; }
     }
@@ -1930,7 +1930,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalSint64FieldNumber = 6;
     private bool hasOptionalSint64;
-    private long optionalSint64_ = 0;
+    private long optionalSint64_;
     public bool HasOptionalSint64 {
       get { return hasOptionalSint64; }
     }
@@ -1940,7 +1940,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalFixed32FieldNumber = 7;
     private bool hasOptionalFixed32;
-    private uint optionalFixed32_ = 0;
+    private uint optionalFixed32_;
     public bool HasOptionalFixed32 {
       get { return hasOptionalFixed32; }
     }
@@ -1951,7 +1951,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalFixed64FieldNumber = 8;
     private bool hasOptionalFixed64;
-    private ulong optionalFixed64_ = 0;
+    private ulong optionalFixed64_;
     public bool HasOptionalFixed64 {
       get { return hasOptionalFixed64; }
     }
@@ -1962,7 +1962,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalSfixed32FieldNumber = 9;
     private bool hasOptionalSfixed32;
-    private int optionalSfixed32_ = 0;
+    private int optionalSfixed32_;
     public bool HasOptionalSfixed32 {
       get { return hasOptionalSfixed32; }
     }
@@ -1972,7 +1972,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalSfixed64FieldNumber = 10;
     private bool hasOptionalSfixed64;
-    private long optionalSfixed64_ = 0;
+    private long optionalSfixed64_;
     public bool HasOptionalSfixed64 {
       get { return hasOptionalSfixed64; }
     }
@@ -1982,7 +1982,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalFloatFieldNumber = 11;
     private bool hasOptionalFloat;
-    private float optionalFloat_ = 0F;
+    private float optionalFloat_;
     public bool HasOptionalFloat {
       get { return hasOptionalFloat; }
     }
@@ -1992,7 +1992,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalDoubleFieldNumber = 12;
     private bool hasOptionalDouble;
-    private double optionalDouble_ = 0D;
+    private double optionalDouble_;
     public bool HasOptionalDouble {
       get { return hasOptionalDouble; }
     }
@@ -2002,7 +2002,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalBoolFieldNumber = 13;
     private bool hasOptionalBool;
-    private bool optionalBool_ = false;
+    private bool optionalBool_;
     public bool HasOptionalBool {
       get { return hasOptionalBool; }
     }
@@ -2687,13 +2687,13 @@ namespace Google.ProtocolBuffers.TestProtos {
         output.WriteMessage(20, field_names[30], OptionalImportMessage);
       }
       if (hasOptionalNestedEnum) {
-        output.WriteEnum(21, field_names[33], (int) OptionalNestedEnum, OptionalNestedEnum.ToString());
+        output.WriteEnum(21, field_names[33], (int) OptionalNestedEnum, OptionalNestedEnum);
       }
       if (hasOptionalForeignEnum) {
-        output.WriteEnum(22, field_names[27], (int) OptionalForeignEnum, OptionalForeignEnum.ToString());
+        output.WriteEnum(22, field_names[27], (int) OptionalForeignEnum, OptionalForeignEnum);
       }
       if (hasOptionalImportEnum) {
-        output.WriteEnum(23, field_names[29], (int) OptionalImportEnum, OptionalImportEnum.ToString());
+        output.WriteEnum(23, field_names[29], (int) OptionalImportEnum, OptionalImportEnum);
       }
       if (hasOptionalStringPiece) {
         output.WriteString(24, field_names[40], OptionalStringPiece);
@@ -2819,13 +2819,13 @@ namespace Google.ProtocolBuffers.TestProtos {
         output.WriteBytes(75, field_names[1], DefaultBytes);
       }
       if (hasDefaultNestedEnum) {
-        output.WriteEnum(81, field_names[11], (int) DefaultNestedEnum, DefaultNestedEnum.ToString());
+        output.WriteEnum(81, field_names[11], (int) DefaultNestedEnum, DefaultNestedEnum);
       }
       if (hasDefaultForeignEnum) {
-        output.WriteEnum(82, field_names[7], (int) DefaultForeignEnum, DefaultForeignEnum.ToString());
+        output.WriteEnum(82, field_names[7], (int) DefaultForeignEnum, DefaultForeignEnum);
       }
       if (hasDefaultImportEnum) {
-        output.WriteEnum(83, field_names[8], (int) DefaultImportEnum, DefaultImportEnum.ToString());
+        output.WriteEnum(83, field_names[8], (int) DefaultImportEnum, DefaultImportEnum);
       }
       if (hasDefaultStringPiece) {
         output.WriteString(84, field_names[17], DefaultStringPiece);
@@ -5519,7 +5519,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int DeprecatedInt32FieldNumber = 1;
     private bool hasDeprecatedInt32;
-    private int deprecatedInt32_ = 0;
+    private int deprecatedInt32_;
     public bool HasDeprecatedInt32 {
       get { return hasDeprecatedInt32; }
     }
@@ -5758,7 +5758,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int CFieldNumber = 1;
     private bool hasC;
-    private int c_ = 0;
+    private int c_;
     public bool HasC {
       get { return hasC; }
     }
@@ -6200,7 +6200,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int AFieldNumber = 17;
     private bool hasA;
-    private int a_ = 0;
+    private int a_;
     public bool HasA {
       get { return hasA; }
     }
@@ -6439,7 +6439,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int AFieldNumber = 47;
     private bool hasA;
-    private int a_ = 0;
+    private int a_;
     public bool HasA {
       get { return hasA; }
     }
@@ -6882,7 +6882,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     public static pb::GeneratedExtensionBase<scg::IList<global::Google.ProtocolBuffers.TestProtos.TestRequired>> Multi;
     public const int AFieldNumber = 1;
     private bool hasA;
-    private int a_ = 0;
+    private int a_;
     public bool HasA {
       get { return hasA; }
     }
@@ -6892,7 +6892,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy2FieldNumber = 2;
     private bool hasDummy2;
-    private int dummy2_ = 0;
+    private int dummy2_;
     public bool HasDummy2 {
       get { return hasDummy2; }
     }
@@ -6902,7 +6902,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int BFieldNumber = 3;
     private bool hasB;
-    private int b_ = 0;
+    private int b_;
     public bool HasB {
       get { return hasB; }
     }
@@ -6912,7 +6912,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy4FieldNumber = 4;
     private bool hasDummy4;
-    private int dummy4_ = 0;
+    private int dummy4_;
     public bool HasDummy4 {
       get { return hasDummy4; }
     }
@@ -6922,7 +6922,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy5FieldNumber = 5;
     private bool hasDummy5;
-    private int dummy5_ = 0;
+    private int dummy5_;
     public bool HasDummy5 {
       get { return hasDummy5; }
     }
@@ -6932,7 +6932,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy6FieldNumber = 6;
     private bool hasDummy6;
-    private int dummy6_ = 0;
+    private int dummy6_;
     public bool HasDummy6 {
       get { return hasDummy6; }
     }
@@ -6942,7 +6942,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy7FieldNumber = 7;
     private bool hasDummy7;
-    private int dummy7_ = 0;
+    private int dummy7_;
     public bool HasDummy7 {
       get { return hasDummy7; }
     }
@@ -6952,7 +6952,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy8FieldNumber = 8;
     private bool hasDummy8;
-    private int dummy8_ = 0;
+    private int dummy8_;
     public bool HasDummy8 {
       get { return hasDummy8; }
     }
@@ -6962,7 +6962,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy9FieldNumber = 9;
     private bool hasDummy9;
-    private int dummy9_ = 0;
+    private int dummy9_;
     public bool HasDummy9 {
       get { return hasDummy9; }
     }
@@ -6972,7 +6972,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy10FieldNumber = 10;
     private bool hasDummy10;
-    private int dummy10_ = 0;
+    private int dummy10_;
     public bool HasDummy10 {
       get { return hasDummy10; }
     }
@@ -6982,7 +6982,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy11FieldNumber = 11;
     private bool hasDummy11;
-    private int dummy11_ = 0;
+    private int dummy11_;
     public bool HasDummy11 {
       get { return hasDummy11; }
     }
@@ -6992,7 +6992,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy12FieldNumber = 12;
     private bool hasDummy12;
-    private int dummy12_ = 0;
+    private int dummy12_;
     public bool HasDummy12 {
       get { return hasDummy12; }
     }
@@ -7002,7 +7002,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy13FieldNumber = 13;
     private bool hasDummy13;
-    private int dummy13_ = 0;
+    private int dummy13_;
     public bool HasDummy13 {
       get { return hasDummy13; }
     }
@@ -7012,7 +7012,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy14FieldNumber = 14;
     private bool hasDummy14;
-    private int dummy14_ = 0;
+    private int dummy14_;
     public bool HasDummy14 {
       get { return hasDummy14; }
     }
@@ -7022,7 +7022,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy15FieldNumber = 15;
     private bool hasDummy15;
-    private int dummy15_ = 0;
+    private int dummy15_;
     public bool HasDummy15 {
       get { return hasDummy15; }
     }
@@ -7032,7 +7032,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy16FieldNumber = 16;
     private bool hasDummy16;
-    private int dummy16_ = 0;
+    private int dummy16_;
     public bool HasDummy16 {
       get { return hasDummy16; }
     }
@@ -7042,7 +7042,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy17FieldNumber = 17;
     private bool hasDummy17;
-    private int dummy17_ = 0;
+    private int dummy17_;
     public bool HasDummy17 {
       get { return hasDummy17; }
     }
@@ -7052,7 +7052,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy18FieldNumber = 18;
     private bool hasDummy18;
-    private int dummy18_ = 0;
+    private int dummy18_;
     public bool HasDummy18 {
       get { return hasDummy18; }
     }
@@ -7062,7 +7062,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy19FieldNumber = 19;
     private bool hasDummy19;
-    private int dummy19_ = 0;
+    private int dummy19_;
     public bool HasDummy19 {
       get { return hasDummy19; }
     }
@@ -7072,7 +7072,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy20FieldNumber = 20;
     private bool hasDummy20;
-    private int dummy20_ = 0;
+    private int dummy20_;
     public bool HasDummy20 {
       get { return hasDummy20; }
     }
@@ -7082,7 +7082,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy21FieldNumber = 21;
     private bool hasDummy21;
-    private int dummy21_ = 0;
+    private int dummy21_;
     public bool HasDummy21 {
       get { return hasDummy21; }
     }
@@ -7092,7 +7092,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy22FieldNumber = 22;
     private bool hasDummy22;
-    private int dummy22_ = 0;
+    private int dummy22_;
     public bool HasDummy22 {
       get { return hasDummy22; }
     }
@@ -7102,7 +7102,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy23FieldNumber = 23;
     private bool hasDummy23;
-    private int dummy23_ = 0;
+    private int dummy23_;
     public bool HasDummy23 {
       get { return hasDummy23; }
     }
@@ -7112,7 +7112,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy24FieldNumber = 24;
     private bool hasDummy24;
-    private int dummy24_ = 0;
+    private int dummy24_;
     public bool HasDummy24 {
       get { return hasDummy24; }
     }
@@ -7122,7 +7122,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy25FieldNumber = 25;
     private bool hasDummy25;
-    private int dummy25_ = 0;
+    private int dummy25_;
     public bool HasDummy25 {
       get { return hasDummy25; }
     }
@@ -7132,7 +7132,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy26FieldNumber = 26;
     private bool hasDummy26;
-    private int dummy26_ = 0;
+    private int dummy26_;
     public bool HasDummy26 {
       get { return hasDummy26; }
     }
@@ -7142,7 +7142,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy27FieldNumber = 27;
     private bool hasDummy27;
-    private int dummy27_ = 0;
+    private int dummy27_;
     public bool HasDummy27 {
       get { return hasDummy27; }
     }
@@ -7152,7 +7152,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy28FieldNumber = 28;
     private bool hasDummy28;
-    private int dummy28_ = 0;
+    private int dummy28_;
     public bool HasDummy28 {
       get { return hasDummy28; }
     }
@@ -7162,7 +7162,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy29FieldNumber = 29;
     private bool hasDummy29;
-    private int dummy29_ = 0;
+    private int dummy29_;
     public bool HasDummy29 {
       get { return hasDummy29; }
     }
@@ -7172,7 +7172,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy30FieldNumber = 30;
     private bool hasDummy30;
-    private int dummy30_ = 0;
+    private int dummy30_;
     public bool HasDummy30 {
       get { return hasDummy30; }
     }
@@ -7182,7 +7182,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy31FieldNumber = 31;
     private bool hasDummy31;
-    private int dummy31_ = 0;
+    private int dummy31_;
     public bool HasDummy31 {
       get { return hasDummy31; }
     }
@@ -7192,7 +7192,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int Dummy32FieldNumber = 32;
     private bool hasDummy32;
-    private int dummy32_ = 0;
+    private int dummy32_;
     public bool HasDummy32 {
       get { return hasDummy32; }
     }
@@ -7202,7 +7202,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int CFieldNumber = 33;
     private bool hasC;
-    private int c_ = 0;
+    private int c_;
     public bool HasC {
       get { return hasC; }
     }
@@ -8458,7 +8458,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int DummyFieldNumber = 3;
     private bool hasDummy;
-    private int dummy_ = 0;
+    private int dummy_;
     public bool HasDummy {
       get { return hasDummy; }
     }
@@ -9677,7 +9677,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int AFieldNumber = 1;
     private bool hasA;
-    private int a_ = 0;
+    private int a_;
     public bool HasA {
       get { return hasA; }
     }
@@ -9687,7 +9687,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int BbFieldNumber = 268435455;
     private bool hasBb;
-    private int bb_ = 0;
+    private int bb_;
     public bool HasBb {
       get { return hasBb; }
     }
@@ -9967,7 +9967,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int IFieldNumber = 2;
     private bool hasI;
-    private int i_ = 0;
+    private int i_;
     public bool HasI {
       get { return hasI; }
     }
@@ -10532,7 +10532,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int OptionalInt32FieldNumber = 2;
     private bool hasOptionalInt32;
-    private int optionalInt32_ = 0;
+    private int optionalInt32_;
     public bool HasOptionalInt32 {
       get { return hasOptionalInt32; }
     }
@@ -10857,7 +10857,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int AFieldNumber = 1;
         private bool hasA;
-        private int a_ = 0;
+        private int a_;
         public bool HasA {
           get { return hasA; }
         }
@@ -11096,7 +11096,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int AFieldNumber = 1;
         private bool hasA;
-        private int a_ = 0;
+        private int a_;
         public bool HasA {
           get { return hasA; }
         }
@@ -11311,7 +11311,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int AFieldNumber = 1;
     private bool hasA;
-    private int a_ = 0;
+    private int a_;
     public bool HasA {
       get { return hasA; }
     }
@@ -12268,7 +12268,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int PrimitiveFieldFieldNumber = 1;
     private bool hasPrimitiveField;
-    private int primitiveField_ = 0;
+    private int primitiveField_;
     public bool HasPrimitiveField {
       get { return hasPrimitiveField; }
     }
@@ -12414,7 +12414,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         output.WriteString(2, field_names[10], StringField);
       }
       if (hasEnumField) {
-        output.WriteEnum(3, field_names[1], (int) EnumField, EnumField.ToString());
+        output.WriteEnum(3, field_names[1], (int) EnumField, EnumField);
       }
       if (hasMessageField) {
         output.WriteMessage(4, field_names[2], MessageField);
@@ -13124,7 +13124,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int MyIntFieldNumber = 1;
     private bool hasMyInt;
-    private long myInt_ = 0L;
+    private long myInt_;
     public bool HasMyInt {
       get { return hasMyInt; }
     }
@@ -13134,7 +13134,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int MyFloatFieldNumber = 101;
     private bool hasMyFloat;
-    private float myFloat_ = 0F;
+    private float myFloat_;
     public bool HasMyFloat {
       get { return hasMyFloat; }
     }
@@ -13504,7 +13504,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int ZeroFloatFieldNumber = 7;
     private bool hasZeroFloat;
-    private float zeroFloat_ = 0F;
+    private float zeroFloat_;
     public bool HasZeroFloat {
       get { return hasZeroFloat; }
     }
@@ -17478,7 +17478,7 @@ namespace Google.ProtocolBuffers.TestProtos {
         
         public const int DynamicFieldFieldNumber = 2100;
         private bool hasDynamicField;
-        private int dynamicField_ = 0;
+        private int dynamicField_;
         public bool HasDynamicField {
           get { return hasDynamicField; }
         }
@@ -17693,7 +17693,7 @@ namespace Google.ProtocolBuffers.TestProtos {
     
     public const int ScalarExtensionFieldNumber = 2000;
     private bool hasScalarExtension;
-    private uint scalarExtension_ = 0;
+    private uint scalarExtension_;
     public bool HasScalarExtension {
       get { return hasScalarExtension; }
     }
@@ -17780,10 +17780,10 @@ namespace Google.ProtocolBuffers.TestProtos {
         output.WriteFixed32(2000, field_names[6], ScalarExtension);
       }
       if (hasEnumExtension) {
-        output.WriteEnum(2001, field_names[2], (int) EnumExtension, EnumExtension.ToString());
+        output.WriteEnum(2001, field_names[2], (int) EnumExtension, EnumExtension);
       }
       if (hasDynamicEnumExtension) {
-        output.WriteEnum(2002, field_names[0], (int) DynamicEnumExtension, DynamicEnumExtension.ToString());
+        output.WriteEnum(2002, field_names[0], (int) DynamicEnumExtension, DynamicEnumExtension);
       }
       if (hasMessageExtension) {
         output.WriteMessage(2003, field_names[3], MessageExtension);