Эх сурвалжийг харах

Merge pull request #4072 from google/jieluo

Cherrypick for csharp, including:
Jisi Liu 7 жил өмнө
parent
commit
d106399d39
55 өөрчлөгдсөн 3781 нэмэгдсэн , 679 устгасан
  1. 13 1
      Makefile.am
  2. 0 1
      conformance/failure_list_csharp.txt
  3. 7 5
      csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/GeneratedMessageTest.cs
  4. 11 19
      csharp/generate_protos.sh
  5. 3 0
      csharp/protos/README.md
  6. 116 0
      csharp/protos/map_unittest_proto3.proto
  7. 56 0
      csharp/protos/unittest_import_proto3.proto
  8. 41 0
      csharp/protos/unittest_import_public_proto3.proto
  9. 0 1
      csharp/protos/unittest_issues.proto
  10. 380 0
      csharp/protos/unittest_proto3.proto
  11. 46 8
      csharp/src/AddressBook/Addressbook.cs
  12. 32 6
      csharp/src/Google.Protobuf.Conformance/Conformance.cs
  13. 43 0
      csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
  14. 124 0
      csharp/src/Google.Protobuf.Test/Collections/ProtobufEqualityComparersTest.cs
  15. 13 0
      csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs
  16. 17 4
      csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs
  17. 3 3
      csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
  18. 2 2
      csharp/src/Google.Protobuf.Test/JsonParserTest.cs
  19. 22 12
      csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs
  20. 53 0
      csharp/src/Google.Protobuf.Test/SampleNaNs.cs
  21. 228 142
      csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs
  22. 68 27
      csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs
  23. 206 31
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs
  24. 26 14
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs
  25. 24 10
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs
  26. 188 30
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs
  27. 277 158
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs
  28. 104 27
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs
  29. 128 0
      csharp/src/Google.Protobuf.Test/UnknownFieldSetTest.cs
  30. 3 3
      csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs
  31. 11 0
      csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs
  32. 4 2
      csharp/src/Google.Protobuf/CodedInputStream.cs
  33. 89 0
      csharp/src/Google.Protobuf/Collections/Lists.cs
  34. 11 11
      csharp/src/Google.Protobuf/Collections/MapField.cs
  35. 130 0
      csharp/src/Google.Protobuf/Collections/ProtobufEqualityComparers.cs
  36. 3 2
      csharp/src/Google.Protobuf/Collections/RepeatedField.cs
  37. 3 1
      csharp/src/Google.Protobuf/FieldCodec.cs
  38. 1 1
      csharp/src/Google.Protobuf/JsonTokenizer.cs
  39. 199 29
      csharp/src/Google.Protobuf/Reflection/Descriptor.cs
  40. 263 0
      csharp/src/Google.Protobuf/UnknownField.cs
  41. 324 0
      csharp/src/Google.Protobuf/UnknownFieldSet.cs
  42. 18 4
      csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
  43. 46 8
      csharp/src/Google.Protobuf/WellKnownTypes/Api.cs
  44. 18 4
      csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs
  45. 18 4
      csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs
  46. 18 4
      csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs
  47. 18 4
      csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs
  48. 48 10
      csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs
  49. 18 4
      csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
  50. 74 12
      csharp/src/Google.Protobuf/WellKnownTypes/Type.cs
  51. 134 24
      csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs
  52. 65 37
      src/google/protobuf/compiler/csharp/csharp_message.cc
  53. 14 6
      src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
  54. 4 2
      src/google/protobuf/compiler/csharp/csharp_reflection_class.cc
  55. 16 6
      src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc

+ 13 - 1
Makefile.am

@@ -61,8 +61,13 @@ csharp_EXTRA_DIST=                                                           \
   csharp/keys/Google.Protobuf.public.snk                                     \
   csharp/keys/Google.Protobuf.public.snk                                     \
   csharp/keys/Google.Protobuf.snk                                            \
   csharp/keys/Google.Protobuf.snk                                            \
   csharp/keys/README.md                                                      \
   csharp/keys/README.md                                                      \
+  csharp/protos/README.md                                                    \
+  csharp/protos/map_unittest_proto3.proto                                    \
   csharp/protos/unittest_custom_options_proto3.proto                         \
   csharp/protos/unittest_custom_options_proto3.proto                         \
+  csharp/protos/unittest_import_public_proto3.proto                          \
+  csharp/protos/unittest_import_proto3.proto                                 \
   csharp/protos/unittest_issues.proto                                        \
   csharp/protos/unittest_issues.proto                                        \
+  csharp/protos/unittest_proto3.proto                                        \
   csharp/src/AddressBook/AddPerson.cs                                        \
   csharp/src/AddressBook/AddPerson.cs                                        \
   csharp/src/AddressBook/Addressbook.cs                                      \
   csharp/src/AddressBook/Addressbook.cs                                      \
   csharp/src/AddressBook/AddressBook.csproj                                  \
   csharp/src/AddressBook/AddressBook.csproj                                  \
@@ -79,6 +84,7 @@ csharp_EXTRA_DIST=                                                           \
   csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs                    \
   csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs                    \
   csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs                   \
   csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs                   \
   csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs                \
   csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs                \
+  csharp/src/Google.Protobuf.Test/Collections/ProtobufEqualityComparersTest.cs \
   csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs           \
   csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs           \
   csharp/src/Google.Protobuf.Test/Compatibility/PropertyInfoExtensionsTest.cs \
   csharp/src/Google.Protobuf.Test/Compatibility/PropertyInfoExtensionsTest.cs \
   csharp/src/Google.Protobuf.Test/Compatibility/StreamExtensionsTest.cs      \
   csharp/src/Google.Protobuf.Test/Compatibility/StreamExtensionsTest.cs      \
@@ -99,6 +105,7 @@ csharp_EXTRA_DIST=                                                           \
   csharp/src/Google.Protobuf.Test/Reflection/TypeRegistryTest.cs             \
   csharp/src/Google.Protobuf.Test/Reflection/TypeRegistryTest.cs             \
   csharp/src/Google.Protobuf.Test/SampleEnum.cs                              \
   csharp/src/Google.Protobuf.Test/SampleEnum.cs                              \
   csharp/src/Google.Protobuf.Test/SampleMessages.cs                          \
   csharp/src/Google.Protobuf.Test/SampleMessages.cs                          \
+  csharp/src/Google.Protobuf.Test/SampleNaNs.cs                              \
   csharp/src/Google.Protobuf.Test/TestCornerCases.cs                         \
   csharp/src/Google.Protobuf.Test/TestCornerCases.cs                         \
   csharp/src/Google.Protobuf.Test/TestProtos/ForeignMessagePartial.cs        \
   csharp/src/Google.Protobuf.Test/TestProtos/ForeignMessagePartial.cs        \
   csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs            \
   csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs            \
@@ -114,13 +121,16 @@ csharp_EXTRA_DIST=                                                           \
   csharp/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs            \
   csharp/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs            \
   csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs            \
   csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs            \
   csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs             \
   csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs             \
+  csharp/src/Google.Protobuf.Test/UnknownFieldSetTest.cs                     \
   csharp/src/Google.Protobuf.sln                                             \
   csharp/src/Google.Protobuf.sln                                             \
   csharp/src/Google.Protobuf/ByteArray.cs                                    \
   csharp/src/Google.Protobuf/ByteArray.cs                                    \
   csharp/src/Google.Protobuf/ByteString.cs                                   \
   csharp/src/Google.Protobuf/ByteString.cs                                   \
   csharp/src/Google.Protobuf/CodedInputStream.cs                             \
   csharp/src/Google.Protobuf/CodedInputStream.cs                             \
   csharp/src/Google.Protobuf/CodedOutputStream.ComputeSize.cs                \
   csharp/src/Google.Protobuf/CodedOutputStream.ComputeSize.cs                \
   csharp/src/Google.Protobuf/CodedOutputStream.cs                            \
   csharp/src/Google.Protobuf/CodedOutputStream.cs                            \
+  csharp/src/Google.Protobuf/Collections/Lists.cs                            \
   csharp/src/Google.Protobuf/Collections/MapField.cs                         \
   csharp/src/Google.Protobuf/Collections/MapField.cs                         \
+  csharp/src/Google.Protobuf/Collections/ProtobufEqualityComparers.cs        \
   csharp/src/Google.Protobuf/Collections/ReadOnlyDictionary.cs               \
   csharp/src/Google.Protobuf/Collections/ReadOnlyDictionary.cs               \
   csharp/src/Google.Protobuf/Collections/RepeatedField.cs                    \
   csharp/src/Google.Protobuf/Collections/RepeatedField.cs                    \
   csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs         \
   csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs         \
@@ -188,7 +198,9 @@ csharp_EXTRA_DIST=                                                           \
   csharp/src/Google.Protobuf/WellKnownTypes/ValuePartial.cs                  \
   csharp/src/Google.Protobuf/WellKnownTypes/ValuePartial.cs                  \
   csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs                      \
   csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs                      \
   csharp/src/Google.Protobuf/WellKnownTypes/WrappersPartial.cs               \
   csharp/src/Google.Protobuf/WellKnownTypes/WrappersPartial.cs               \
-  csharp/src/Google.Protobuf/WireFormat.cs
+  csharp/src/Google.Protobuf/WireFormat.cs                                   \
+  csharp/src/Google.Protobuf/UnknownField.cs                                 \
+  csharp/src/Google.Protobuf/UnknownFieldSet.cs
 
 
 java_EXTRA_DIST=                                                                   \
 java_EXTRA_DIST=                                                                   \
   java/README.md                                                                   \
   java/README.md                                                                   \

+ 0 - 1
conformance/failure_list_csharp.txt

@@ -1,3 +1,2 @@
 Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput
 Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput
 Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput
 Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput
-Required.Proto3.ProtobufInput.UnknownVarint.ProtobufOutput

+ 7 - 5
csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/GeneratedMessageTest.cs

@@ -638,7 +638,7 @@ namespace Google.Protobuf
         }
         }
 
 
         [Test]
         [Test]
-        public void IgnoreUnknownFields_RealDataStillRead()
+        public void DiscardUnknownFields_RealDataStillRead()
         {
         {
             var message = SampleMessages.CreateFullTestAllTypes();
             var message = SampleMessages.CreateFullTestAllTypes();
             var stream = new MemoryStream();
             var stream = new MemoryStream();
@@ -652,16 +652,18 @@ namespace Google.Protobuf
 
 
             stream.Position = 0;
             stream.Position = 0;
             var parsed = TestAllTypes.Parser.ParseFrom(stream);
             var parsed = TestAllTypes.Parser.ParseFrom(stream);
-            Assert.AreEqual(message, parsed);
+	    // TODO(jieluo): Add test back after DiscardUnknownFields is supported
+            // Assert.AreEqual(message, parsed);
         }
         }
 
 
         [Test]
         [Test]
-        public void IgnoreUnknownFields_AllTypes()
+        public void DiscardUnknownFields_AllTypes()
         {
         {
             // Simple way of ensuring we can skip all kinds of fields.
             // Simple way of ensuring we can skip all kinds of fields.
             var data = SampleMessages.CreateFullTestAllTypes().ToByteArray();
             var data = SampleMessages.CreateFullTestAllTypes().ToByteArray();
             var empty = Empty.Parser.ParseFrom(data);
             var empty = Empty.Parser.ParseFrom(data);
-            Assert.AreEqual(new Empty(), empty);
+	    // TODO(jieluo): Add test back after DiscardUnknownField is supported.
+            // Assert.AreEqual(new Empty(), empty);
         }
         }
 
 
         // This was originally seen as a conformance test failure.
         // This was originally seen as a conformance test failure.
@@ -720,4 +722,4 @@ namespace Google.Protobuf
             Assert.AreEqual("{ \"c\": 31 }", writer.ToString());
             Assert.AreEqual("{ \"c\": 31 }", writer.ToString());
         }
         }
     }
     }
-}
+}

+ 11 - 19
csharp/generate_protos.sh

@@ -3,7 +3,7 @@
 # You first need to make sure protoc has been built (see instructions on
 # You first need to make sure protoc has been built (see instructions on
 # building protoc in root of this repository)
 # building protoc in root of this repository)
 
 
-set -ex
+set -e
 
 
 # cd to repository root
 # cd to repository root
 pushd $(dirname $0)/..
 pushd $(dirname $0)/..
@@ -40,28 +40,20 @@ $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \
     src/google/protobuf/type.proto \
     src/google/protobuf/type.proto \
     src/google/protobuf/wrappers.proto
     src/google/protobuf/wrappers.proto
 
 
-# Test protos where the namespace matches the target location
-$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf.Test \
-    --csharp_opt=base_namespace=Google.Protobuf \
-    src/google/protobuf/map_unittest_proto3.proto \
-    src/google/protobuf/unittest_proto3.proto \
-    src/google/protobuf/unittest_import_proto3.proto \
-    src/google/protobuf/unittest_import_public_proto3.proto \
-    src/google/protobuf/unittest_well_known_types.proto
-
-# Different base namespace to the protos above
-$PROTOC -Isrc -Icsharp/protos --csharp_out=csharp/src/Google.Protobuf.Test \
-    --csharp_opt=base_namespace=UnitTest.Issues \
+# Test protos
+$PROTOC -Isrc -Icsharp/protos \
+    --csharp_out=csharp/src/Google.Protobuf.Test/TestProtos \
+    csharp/protos/map_unittest_proto3.proto \
     csharp/protos/unittest_issues.proto \
     csharp/protos/unittest_issues.proto \
-    csharp/protos/unittest_custom_options_proto3.proto
-
-# Don't specify a base namespace at all; we just want to make sure the
-# results end up in TestProtos.
-$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf.Test/TestProtos \
+    csharp/protos/unittest_custom_options_proto3.proto \
+    csharp/protos/unittest_proto3.proto \
+    csharp/protos/unittest_import_proto3.proto \
+    csharp/protos/unittest_import_public_proto3.proto \
+    src/google/protobuf/unittest_well_known_types.proto \
     src/google/protobuf/test_messages_proto3.proto
     src/google/protobuf/test_messages_proto3.proto
 
 
 # AddressBook sample protos
 # AddressBook sample protos
-$PROTOC -Iexamples --csharp_out=csharp/src/AddressBook \
+$PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \
     examples/addressbook.proto
     examples/addressbook.proto
 
 
 $PROTOC -Iconformance -Isrc --csharp_out=csharp/src/Google.Protobuf.Conformance \
 $PROTOC -Iconformance -Isrc --csharp_out=csharp/src/Google.Protobuf.Conformance \

+ 3 - 0
csharp/protos/README.md

@@ -0,0 +1,3 @@
+This directory contains unit test protos adapted from those in
+src/google/protobuf, and C#-specific test protos for regression
+tests against bugs found in the C# codegen or library.

+ 116 - 0
csharp/protos/map_unittest_proto3.proto

@@ -0,0 +1,116 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc.  All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// This file is mostly equivalent to map_unittest.proto, but imports
+// unittest_proto3.proto instead of unittest.proto, so that it only
+// uses proto3 messages. This makes it suitable for testing
+// implementations which only support proto3.
+// The TestRequiredMessageMap message has been removed as there are no
+// required fields in proto3.
+syntax = "proto3";
+
+option csharp_namespace = "Google.Protobuf.TestProtos";
+
+import "unittest_proto3.proto";
+
+package protobuf_unittest3;
+
+// Tests maps.
+message TestMap {
+  map<int32   , int32   > map_int32_int32       = 1;
+  map<int64   , int64   > map_int64_int64       = 2;
+  map<uint32  , uint32  > map_uint32_uint32     = 3;
+  map<uint64  , uint64  > map_uint64_uint64     = 4;
+  map<sint32  , sint32  > map_sint32_sint32     = 5;
+  map<sint64  , sint64  > map_sint64_sint64     = 6;
+  map<fixed32 , fixed32 > map_fixed32_fixed32   = 7;
+  map<fixed64 , fixed64 > map_fixed64_fixed64   = 8;
+  map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
+  map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
+  map<int32   , float   > map_int32_float       = 11;
+  map<int32   , double  > map_int32_double      = 12;
+  map<bool    , bool    > map_bool_bool         = 13;
+  map<string  , string  > map_string_string     = 14;
+  map<int32   , bytes   > map_int32_bytes       = 15;
+  map<int32   , MapEnum > map_int32_enum        = 16;
+  map<int32   , ForeignMessage> map_int32_foreign_message = 17;
+}
+
+message TestMapSubmessage {
+  TestMap test_map = 1;
+}
+
+message TestMessageMap {
+  map<int32, TestAllTypes> map_int32_message = 1;
+}
+
+// Two map fields share the same entry default instance.
+message TestSameTypeMap {
+  map<int32, int32> map1 = 1;
+  map<int32, int32> map2 = 2;
+}
+
+enum MapEnum {
+  MAP_ENUM_FOO = 0;
+  MAP_ENUM_BAR = 1;
+  MAP_ENUM_BAZ = 2;
+}
+
+message TestArenaMap {
+  map<int32   , int32   > map_int32_int32       = 1;
+  map<int64   , int64   > map_int64_int64       = 2;
+  map<uint32  , uint32  > map_uint32_uint32     = 3;
+  map<uint64  , uint64  > map_uint64_uint64     = 4;
+  map<sint32  , sint32  > map_sint32_sint32     = 5;
+  map<sint64  , sint64  > map_sint64_sint64     = 6;
+  map<fixed32 , fixed32 > map_fixed32_fixed32   = 7;
+  map<fixed64 , fixed64 > map_fixed64_fixed64   = 8;
+  map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
+  map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
+  map<int32   , float   > map_int32_float       = 11;
+  map<int32   , double  > map_int32_double      = 12;
+  map<bool    , bool    > map_bool_bool         = 13;
+  map<int32   , MapEnum > map_int32_enum        = 14;
+  map<int32   , ForeignMessage> map_int32_foreign_message = 15;
+}
+
+// Previously, message containing enum called Type cannot be used as value of
+// map field.
+message MessageContainingEnumCalledType {
+  enum Type {
+    TYPE_FOO = 0;
+  }
+  map<int32, MessageContainingEnumCalledType> type = 1;
+}
+
+// Previously, message cannot contain map field called "entry".
+message MessageContainingMapCalledEntry {
+  map<int32, int32> entry = 1;
+}

+ 56 - 0
csharp/protos/unittest_import_proto3.proto

@@ -0,0 +1,56 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc.  All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: kenton@google.com (Kenton Varda)
+//  Based on original Protocol Buffers design by
+//  Sanjay Ghemawat, Jeff Dean, and others.
+//
+// A proto file which is imported by unittest_proto3.proto to test importing.
+
+syntax = "proto3";
+
+package protobuf_unittest_import;
+
+option csharp_namespace = "Google.Protobuf.TestProtos";
+
+// Test public import
+import public "unittest_import_public_proto3.proto";
+
+message ImportMessage {
+  int32 d = 1;
+}
+
+enum ImportEnum {
+  IMPORT_ENUM_UNSPECIFIED = 0;
+  IMPORT_FOO = 7;
+  IMPORT_BAR = 8;
+  IMPORT_BAZ = 9;
+}
+

+ 41 - 0
csharp/protos/unittest_import_public_proto3.proto

@@ -0,0 +1,41 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc.  All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: liujisi@google.com (Pherl Liu)
+
+syntax = "proto3";
+
+package protobuf_unittest_import;
+
+option csharp_namespace = "Google.Protobuf.TestProtos";
+
+message PublicImportMessage {
+ int32 e = 1;
+}

+ 0 - 1
csharp/protos/unittest_issues.proto

@@ -7,7 +7,6 @@ syntax = "proto3";
 option csharp_namespace = "UnitTest.Issues.TestProtos";
 option csharp_namespace = "UnitTest.Issues.TestProtos";
 
 
 package unittest_issues;
 package unittest_issues;
-option optimize_for = SPEED;
 
 
 // Issue 307: when generating doubly-nested types, any references
 // Issue 307: when generating doubly-nested types, any references
 // should be of the form A.Types.B.Types.C.
 // should be of the form A.Types.B.Types.C.

+ 380 - 0
csharp/protos/unittest_proto3.proto

@@ -0,0 +1,380 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc.  All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: kenton@google.com (Kenton Varda)
+//  Based on original Protocol Buffers design by
+//  Sanjay Ghemawat, Jeff Dean, and others.
+//
+// A proto file we will use for unit testing.
+
+syntax = "proto3";
+
+option csharp_namespace = "Google.Protobuf.TestProtos";
+
+// Only present so we can test that we can read it (as an example
+// of a non-C# option)
+option java_outer_classname = "UnittestProto";
+
+import "unittest_import_proto3.proto";
+
+package protobuf_unittest3;
+
+// This proto includes every type of field in both singular and repeated
+// forms.
+message TestAllTypes {
+  message NestedMessage {
+    // The field name "b" fails to compile in proto1 because it conflicts with
+    // a local variable named "b" in one of the generated methods.  Doh.
+    // This file needs to compile in proto1 to test backwards-compatibility.
+    int32 bb = 1;
+  }
+
+  enum NestedEnum {
+    NESTED_ENUM_UNSPECIFIED = 0;
+    FOO = 1;
+    BAR = 2;
+    BAZ = 3;
+    NEG = -1;  // Intentionally negative.
+  }
+
+  // Singular
+  int32 single_int32 = 1;
+  int64 single_int64 = 2;
+  uint32 single_uint32 = 3;
+  uint64 single_uint64 = 4;
+  sint32 single_sint32 = 5;
+  sint64 single_sint64 = 6;
+  fixed32 single_fixed32 = 7;
+  fixed64 single_fixed64 = 8;
+  sfixed32 single_sfixed32 = 9;
+  sfixed64 single_sfixed64 = 10;
+  float single_float = 11;
+  double single_double = 12;
+  bool single_bool = 13;
+  string single_string = 14;
+  bytes single_bytes = 15;
+
+  NestedMessage single_nested_message = 18;
+  ForeignMessage single_foreign_message = 19;
+  protobuf_unittest_import.ImportMessage single_import_message = 20;
+
+  NestedEnum single_nested_enum = 21;
+  ForeignEnum single_foreign_enum = 22;
+  protobuf_unittest_import.ImportEnum single_import_enum = 23;
+
+  // Defined in unittest_import_public.proto
+  protobuf_unittest_import.PublicImportMessage
+      single_public_import_message = 26;
+
+  // Repeated
+  repeated    int32 repeated_int32    = 31;
+  repeated    int64 repeated_int64    = 32;
+  repeated   uint32 repeated_uint32   = 33;
+  repeated   uint64 repeated_uint64   = 34;
+  repeated   sint32 repeated_sint32   = 35;
+  repeated   sint64 repeated_sint64   = 36;
+  repeated  fixed32 repeated_fixed32  = 37;
+  repeated  fixed64 repeated_fixed64  = 38;
+  repeated sfixed32 repeated_sfixed32 = 39;
+  repeated sfixed64 repeated_sfixed64 = 40;
+  repeated    float repeated_float    = 41;
+  repeated   double repeated_double   = 42;
+  repeated     bool repeated_bool     = 43;
+  repeated   string repeated_string   = 44;
+  repeated    bytes repeated_bytes    = 45;
+
+  repeated NestedMessage                        repeated_nested_message  = 48;
+  repeated ForeignMessage                       repeated_foreign_message = 49;
+  repeated protobuf_unittest_import.ImportMessage repeated_import_message  = 50;
+
+  repeated NestedEnum                           repeated_nested_enum     = 51;
+  repeated ForeignEnum                          repeated_foreign_enum    = 52;
+  repeated protobuf_unittest_import.ImportEnum    repeated_import_enum     = 53;
+  // Defined in unittest_import_public.proto
+  repeated protobuf_unittest_import.PublicImportMessage
+      repeated_public_import_message = 54;
+
+  // For oneof test
+  oneof oneof_field {
+    uint32 oneof_uint32 = 111;
+    NestedMessage oneof_nested_message = 112;
+    string oneof_string = 113;
+    bytes oneof_bytes = 114;
+  }
+}
+
+// This proto includes a recusively nested message.
+message NestedTestAllTypes {
+  NestedTestAllTypes child = 1;
+  TestAllTypes payload = 2;
+  repeated NestedTestAllTypes repeated_child = 3;
+}
+
+message TestDeprecatedFields {
+  int32 deprecated_int32 = 1 [deprecated=true];
+}
+
+// Define these after TestAllTypes to make sure the compiler can handle
+// that.
+message ForeignMessage {
+  int32 c = 1;
+}
+
+enum ForeignEnum {
+  FOREIGN_UNSPECIFIED = 0;
+  FOREIGN_FOO = 4;
+  FOREIGN_BAR = 5;
+  FOREIGN_BAZ = 6;
+}
+
+message TestReservedFields {
+  reserved 2, 15, 9 to 11;
+  reserved "bar", "baz";
+}
+
+
+// Test that we can use NestedMessage from outside TestAllTypes.
+message TestForeignNested {
+  TestAllTypes.NestedMessage foreign_nested = 1;
+}
+
+// Test that really large tag numbers don't break anything.
+message TestReallyLargeTagNumber {
+  // The largest possible tag number is 2^28 - 1, since the wire format uses
+  // three bits to communicate wire type.
+  int32 a = 1;
+  int32 bb = 268435455;
+}
+
+message TestRecursiveMessage {
+  TestRecursiveMessage a = 1;
+  int32 i = 2;
+}
+
+// Test that mutual recursion works.
+message TestMutualRecursionA {
+  TestMutualRecursionB bb = 1;
+}
+
+message TestMutualRecursionB {
+  TestMutualRecursionA a = 1;
+  int32 optional_int32 = 2;
+}
+
+message TestEnumAllowAlias {
+  TestEnumWithDupValue value = 1;
+}
+
+// Test an enum that has multiple values with the same number.
+enum TestEnumWithDupValue {
+  TEST_ENUM_WITH_DUP_VALUE_UNSPECIFIED = 0;
+  option allow_alias = true;
+
+  FOO1 = 1;
+  BAR1 = 2;
+  BAZ = 3;
+  FOO2 = 1;
+  BAR2 = 2;
+}
+
+// Test an enum with large, unordered values.
+enum TestSparseEnum {
+  TEST_SPARSE_ENUM_UNSPECIFIED = 0;
+  SPARSE_A = 123;
+  SPARSE_B = 62374;
+  SPARSE_C = 12589234;
+  SPARSE_D = -15;
+  SPARSE_E = -53452;
+  // In proto3, value 0 must be the first one specified
+  // SPARSE_F = 0;
+  SPARSE_G = 2;
+}
+
+// Test message with CamelCase field names.  This violates Protocol Buffer
+// standard style.
+message TestCamelCaseFieldNames {
+  int32 PrimitiveField = 1;
+  string StringField = 2;
+  ForeignEnum EnumField = 3;
+  ForeignMessage MessageField = 4;
+
+  repeated int32 RepeatedPrimitiveField = 7;
+  repeated string RepeatedStringField = 8;
+  repeated ForeignEnum RepeatedEnumField = 9;
+  repeated ForeignMessage RepeatedMessageField = 10;
+}
+
+
+// We list fields out of order, to ensure that we're using field number and not
+// field index to determine serialization order.
+message TestFieldOrderings {
+  string my_string = 11;
+  int64 my_int = 1;
+  float my_float = 101;
+  message NestedMessage {
+    int64 oo = 2;
+    // The field name "b" fails to compile in proto1 because it conflicts with
+    // a local variable named "b" in one of the generated methods.  Doh.
+    // This file needs to compile in proto1 to test backwards-compatibility.
+    int32 bb = 1;
+  }
+
+  NestedMessage single_nested_message  = 200;
+}
+
+message SparseEnumMessage {
+  TestSparseEnum sparse_enum = 1;
+}
+
+// Test String and Bytes: string is for valid UTF-8 strings
+message OneString {
+  string data = 1;
+}
+
+message MoreString {
+  repeated string data = 1;
+}
+
+message OneBytes {
+  bytes data = 1;
+}
+
+message MoreBytes {
+  bytes data = 1;
+}
+
+// Test int32, uint32, int64, uint64, and bool are all compatible
+message Int32Message {
+  int32 data = 1;
+}
+
+message Uint32Message {
+  uint32 data = 1;
+}
+
+message Int64Message {
+  int64 data = 1;
+}
+
+message Uint64Message {
+  uint64 data = 1;
+}
+
+message BoolMessage {
+  bool data = 1;
+}
+
+// Test oneofs.
+message TestOneof {
+  oneof foo {
+    int32 foo_int = 1;
+    string foo_string = 2;
+    TestAllTypes foo_message = 3;
+  }
+}
+
+// Test messages for packed fields
+
+message TestPackedTypes {
+  repeated    int32 packed_int32    =  90 [packed = true];
+  repeated    int64 packed_int64    =  91 [packed = true];
+  repeated   uint32 packed_uint32   =  92 [packed = true];
+  repeated   uint64 packed_uint64   =  93 [packed = true];
+  repeated   sint32 packed_sint32   =  94 [packed = true];
+  repeated   sint64 packed_sint64   =  95 [packed = true];
+  repeated  fixed32 packed_fixed32  =  96 [packed = true];
+  repeated  fixed64 packed_fixed64  =  97 [packed = true];
+  repeated sfixed32 packed_sfixed32 =  98 [packed = true];
+  repeated sfixed64 packed_sfixed64 =  99 [packed = true];
+  repeated    float packed_float    = 100 [packed = true];
+  repeated   double packed_double   = 101 [packed = true];
+  repeated     bool packed_bool     = 102 [packed = true];
+  repeated ForeignEnum packed_enum  = 103 [packed = true];
+}
+
+// A message with the same fields as TestPackedTypes, but without packing. Used
+// to test packed <-> unpacked wire compatibility.
+message TestUnpackedTypes {
+  repeated    int32 unpacked_int32    =  90 [packed = false];
+  repeated    int64 unpacked_int64    =  91 [packed = false];
+  repeated   uint32 unpacked_uint32   =  92 [packed = false];
+  repeated   uint64 unpacked_uint64   =  93 [packed = false];
+  repeated   sint32 unpacked_sint32   =  94 [packed = false];
+  repeated   sint64 unpacked_sint64   =  95 [packed = false];
+  repeated  fixed32 unpacked_fixed32  =  96 [packed = false];
+  repeated  fixed64 unpacked_fixed64  =  97 [packed = false];
+  repeated sfixed32 unpacked_sfixed32 =  98 [packed = false];
+  repeated sfixed64 unpacked_sfixed64 =  99 [packed = false];
+  repeated    float unpacked_float    = 100 [packed = false];
+  repeated   double unpacked_double   = 101 [packed = false];
+  repeated     bool unpacked_bool     = 102 [packed = false];
+  repeated ForeignEnum unpacked_enum  = 103 [packed = false];
+}
+
+message TestRepeatedScalarDifferentTagSizes {
+  // Parsing repeated fixed size values used to fail. This message needs to be
+  // used in order to get a tag of the right size; all of the repeated fields
+  // in TestAllTypes didn't trigger the check.
+  repeated fixed32 repeated_fixed32 = 12;
+  // Check for a varint type, just for good measure.
+  repeated int32   repeated_int32   = 13;
+
+  // These have two-byte tags.
+  repeated fixed64 repeated_fixed64 = 2046;
+  repeated int64   repeated_int64   = 2047;
+
+  // Three byte tags.
+  repeated float   repeated_float   = 262142;
+  repeated uint64  repeated_uint64  = 262143;
+}
+
+message TestCommentInjectionMessage {
+  // */ <- This should not close the generated doc comment
+  string a = 1;
+}
+
+
+// Test that RPC services work.
+message FooRequest  {}
+message FooResponse {}
+
+message FooClientMessage {}
+message FooServerMessage{}
+
+service TestService {
+  rpc Foo(FooRequest) returns (FooResponse);
+  rpc Bar(BarRequest) returns (BarResponse);
+}
+
+
+message BarRequest  {}
+message BarResponse {}
+
+message TestEmptyMessage {}

+ 46 - 8
csharp/src/AddressBook/Addressbook.cs

@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: addressbook.proto
+// <auto-generated>
+//     Generated by the protocol buffer compiler.  DO NOT EDIT!
+//     source: addressbook.proto
+// </auto-generated>
 #pragma warning disable 1591, 0612, 3021
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code
 #region Designer generated code
 
 
@@ -49,6 +51,7 @@ namespace Google.Protobuf.Examples.AddressBook {
   /// </summary>
   /// </summary>
   public sealed partial class Person : pb::IMessage<Person> {
   public sealed partial class Person : pb::IMessage<Person> {
     private static readonly pb::MessageParser<Person> _parser = new pb::MessageParser<Person>(() => new Person());
     private static readonly pb::MessageParser<Person> _parser = new pb::MessageParser<Person>(() => new Person());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<Person> Parser { get { return _parser; } }
     public static pb::MessageParser<Person> Parser { get { return _parser; } }
 
 
@@ -76,6 +79,7 @@ namespace Google.Protobuf.Examples.AddressBook {
       email_ = other.email_;
       email_ = other.email_;
       phones_ = other.phones_.Clone();
       phones_ = other.phones_.Clone();
       LastUpdated = other.lastUpdated_ != null ? other.LastUpdated.Clone() : null;
       LastUpdated = other.lastUpdated_ != null ? other.LastUpdated.Clone() : null;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -158,7 +162,7 @@ namespace Google.Protobuf.Examples.AddressBook {
       if (Email != other.Email) return false;
       if (Email != other.Email) return false;
       if(!phones_.Equals(other.phones_)) return false;
       if(!phones_.Equals(other.phones_)) return false;
       if (!object.Equals(LastUpdated, other.LastUpdated)) return false;
       if (!object.Equals(LastUpdated, other.LastUpdated)) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -169,6 +173,9 @@ namespace Google.Protobuf.Examples.AddressBook {
       if (Email.Length != 0) hash ^= Email.GetHashCode();
       if (Email.Length != 0) hash ^= Email.GetHashCode();
       hash ^= phones_.GetHashCode();
       hash ^= phones_.GetHashCode();
       if (lastUpdated_ != null) hash ^= LastUpdated.GetHashCode();
       if (lastUpdated_ != null) hash ^= LastUpdated.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -196,6 +203,9 @@ namespace Google.Protobuf.Examples.AddressBook {
         output.WriteRawTag(42);
         output.WriteRawTag(42);
         output.WriteMessage(LastUpdated);
         output.WriteMessage(LastUpdated);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -214,6 +224,9 @@ namespace Google.Protobuf.Examples.AddressBook {
       if (lastUpdated_ != null) {
       if (lastUpdated_ != null) {
         size += 1 + pb::CodedOutputStream.ComputeMessageSize(LastUpdated);
         size += 1 + pb::CodedOutputStream.ComputeMessageSize(LastUpdated);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -238,6 +251,7 @@ namespace Google.Protobuf.Examples.AddressBook {
         }
         }
         LastUpdated.MergeFrom(other.LastUpdated);
         LastUpdated.MergeFrom(other.LastUpdated);
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -246,7 +260,7 @@ namespace Google.Protobuf.Examples.AddressBook {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             Name = input.ReadString();
             Name = input.ReadString();
@@ -287,6 +301,7 @@ namespace Google.Protobuf.Examples.AddressBook {
 
 
       public sealed partial class PhoneNumber : pb::IMessage<PhoneNumber> {
       public sealed partial class PhoneNumber : pb::IMessage<PhoneNumber> {
         private static readonly pb::MessageParser<PhoneNumber> _parser = new pb::MessageParser<PhoneNumber>(() => new PhoneNumber());
         private static readonly pb::MessageParser<PhoneNumber> _parser = new pb::MessageParser<PhoneNumber>(() => new PhoneNumber());
+        private pb::UnknownFieldSet _unknownFields;
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         public static pb::MessageParser<PhoneNumber> Parser { get { return _parser; } }
         public static pb::MessageParser<PhoneNumber> Parser { get { return _parser; } }
 
 
@@ -311,6 +326,7 @@ namespace Google.Protobuf.Examples.AddressBook {
         public PhoneNumber(PhoneNumber other) : this() {
         public PhoneNumber(PhoneNumber other) : this() {
           number_ = other.number_;
           number_ = other.number_;
           type_ = other.type_;
           type_ = other.type_;
+          _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -355,7 +371,7 @@ namespace Google.Protobuf.Examples.AddressBook {
           }
           }
           if (Number != other.Number) return false;
           if (Number != other.Number) return false;
           if (Type != other.Type) return false;
           if (Type != other.Type) return false;
-          return true;
+          return Equals(_unknownFields, other._unknownFields);
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -363,6 +379,9 @@ namespace Google.Protobuf.Examples.AddressBook {
           int hash = 1;
           int hash = 1;
           if (Number.Length != 0) hash ^= Number.GetHashCode();
           if (Number.Length != 0) hash ^= Number.GetHashCode();
           if (Type != 0) hash ^= Type.GetHashCode();
           if (Type != 0) hash ^= Type.GetHashCode();
+          if (_unknownFields != null) {
+            hash ^= _unknownFields.GetHashCode();
+          }
           return hash;
           return hash;
         }
         }
 
 
@@ -381,6 +400,9 @@ namespace Google.Protobuf.Examples.AddressBook {
             output.WriteRawTag(16);
             output.WriteRawTag(16);
             output.WriteEnum((int) Type);
             output.WriteEnum((int) Type);
           }
           }
+          if (_unknownFields != null) {
+            _unknownFields.WriteTo(output);
+          }
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -392,6 +414,9 @@ namespace Google.Protobuf.Examples.AddressBook {
           if (Type != 0) {
           if (Type != 0) {
             size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type);
             size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type);
           }
           }
+          if (_unknownFields != null) {
+            size += _unknownFields.CalculateSize();
+          }
           return size;
           return size;
         }
         }
 
 
@@ -406,6 +431,7 @@ namespace Google.Protobuf.Examples.AddressBook {
           if (other.Type != 0) {
           if (other.Type != 0) {
             Type = other.Type;
             Type = other.Type;
           }
           }
+          _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -414,7 +440,7 @@ namespace Google.Protobuf.Examples.AddressBook {
           while ((tag = input.ReadTag()) != 0) {
           while ((tag = input.ReadTag()) != 0) {
             switch(tag) {
             switch(tag) {
               default:
               default:
-                input.SkipLastField();
+                _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
                 break;
                 break;
               case 10: {
               case 10: {
                 Number = input.ReadString();
                 Number = input.ReadString();
@@ -440,6 +466,7 @@ namespace Google.Protobuf.Examples.AddressBook {
   /// </summary>
   /// </summary>
   public sealed partial class AddressBook : pb::IMessage<AddressBook> {
   public sealed partial class AddressBook : pb::IMessage<AddressBook> {
     private static readonly pb::MessageParser<AddressBook> _parser = new pb::MessageParser<AddressBook>(() => new AddressBook());
     private static readonly pb::MessageParser<AddressBook> _parser = new pb::MessageParser<AddressBook>(() => new AddressBook());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<AddressBook> Parser { get { return _parser; } }
     public static pb::MessageParser<AddressBook> Parser { get { return _parser; } }
 
 
@@ -463,6 +490,7 @@ namespace Google.Protobuf.Examples.AddressBook {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public AddressBook(AddressBook other) : this() {
     public AddressBook(AddressBook other) : this() {
       people_ = other.people_.Clone();
       people_ = other.people_.Clone();
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -494,13 +522,16 @@ namespace Google.Protobuf.Examples.AddressBook {
         return true;
         return true;
       }
       }
       if(!people_.Equals(other.people_)) return false;
       if(!people_.Equals(other.people_)) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       hash ^= people_.GetHashCode();
       hash ^= people_.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -512,12 +543,18 @@ namespace Google.Protobuf.Examples.AddressBook {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public void WriteTo(pb::CodedOutputStream output) {
     public void WriteTo(pb::CodedOutputStream output) {
       people_.WriteTo(output, _repeated_people_codec);
       people_.WriteTo(output, _repeated_people_codec);
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public int CalculateSize() {
     public int CalculateSize() {
       int size = 0;
       int size = 0;
       size += people_.CalculateSize(_repeated_people_codec);
       size += people_.CalculateSize(_repeated_people_codec);
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -527,6 +564,7 @@ namespace Google.Protobuf.Examples.AddressBook {
         return;
         return;
       }
       }
       people_.Add(other.people_);
       people_.Add(other.people_);
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -535,7 +573,7 @@ namespace Google.Protobuf.Examples.AddressBook {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             people_.AddEntriesFrom(input, _repeated_people_codec);
             people_.AddEntriesFrom(input, _repeated_people_codec);

+ 32 - 6
csharp/src/Google.Protobuf.Conformance/Conformance.cs

@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: conformance.proto
+// <auto-generated>
+//     Generated by the protocol buffer compiler.  DO NOT EDIT!
+//     source: conformance.proto
+// </auto-generated>
 #pragma warning disable 1591, 0612, 3021
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code
 #region Designer generated code
 
 
@@ -62,6 +64,7 @@ namespace Conformance {
   /// </summary>
   /// </summary>
   public sealed partial class ConformanceRequest : pb::IMessage<ConformanceRequest> {
   public sealed partial class ConformanceRequest : pb::IMessage<ConformanceRequest> {
     private static readonly pb::MessageParser<ConformanceRequest> _parser = new pb::MessageParser<ConformanceRequest>(() => new ConformanceRequest());
     private static readonly pb::MessageParser<ConformanceRequest> _parser = new pb::MessageParser<ConformanceRequest>(() => new ConformanceRequest());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<ConformanceRequest> Parser { get { return _parser; } }
     public static pb::MessageParser<ConformanceRequest> Parser { get { return _parser; } }
 
 
@@ -95,6 +98,7 @@ namespace Conformance {
           break;
           break;
       }
       }
 
 
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -191,7 +195,7 @@ namespace Conformance {
       if (RequestedOutputFormat != other.RequestedOutputFormat) return false;
       if (RequestedOutputFormat != other.RequestedOutputFormat) return false;
       if (MessageType != other.MessageType) return false;
       if (MessageType != other.MessageType) return false;
       if (PayloadCase != other.PayloadCase) return false;
       if (PayloadCase != other.PayloadCase) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -202,6 +206,9 @@ namespace Conformance {
       if (RequestedOutputFormat != 0) hash ^= RequestedOutputFormat.GetHashCode();
       if (RequestedOutputFormat != 0) hash ^= RequestedOutputFormat.GetHashCode();
       if (MessageType.Length != 0) hash ^= MessageType.GetHashCode();
       if (MessageType.Length != 0) hash ^= MessageType.GetHashCode();
       hash ^= (int) payloadCase_;
       hash ^= (int) payloadCase_;
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -228,6 +235,9 @@ namespace Conformance {
         output.WriteRawTag(34);
         output.WriteRawTag(34);
         output.WriteString(MessageType);
         output.WriteString(MessageType);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -245,6 +255,9 @@ namespace Conformance {
       if (MessageType.Length != 0) {
       if (MessageType.Length != 0) {
         size += 1 + pb::CodedOutputStream.ComputeStringSize(MessageType);
         size += 1 + pb::CodedOutputStream.ComputeStringSize(MessageType);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -268,6 +281,7 @@ namespace Conformance {
           break;
           break;
       }
       }
 
 
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -276,7 +290,7 @@ namespace Conformance {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             ProtobufPayload = input.ReadBytes();
             ProtobufPayload = input.ReadBytes();
@@ -305,6 +319,7 @@ namespace Conformance {
   /// </summary>
   /// </summary>
   public sealed partial class ConformanceResponse : pb::IMessage<ConformanceResponse> {
   public sealed partial class ConformanceResponse : pb::IMessage<ConformanceResponse> {
     private static readonly pb::MessageParser<ConformanceResponse> _parser = new pb::MessageParser<ConformanceResponse>(() => new ConformanceResponse());
     private static readonly pb::MessageParser<ConformanceResponse> _parser = new pb::MessageParser<ConformanceResponse>(() => new ConformanceResponse());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<ConformanceResponse> Parser { get { return _parser; } }
     public static pb::MessageParser<ConformanceResponse> Parser { get { return _parser; } }
 
 
@@ -348,6 +363,7 @@ namespace Conformance {
           break;
           break;
       }
       }
 
 
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -493,7 +509,7 @@ namespace Conformance {
       if (JsonPayload != other.JsonPayload) return false;
       if (JsonPayload != other.JsonPayload) return false;
       if (Skipped != other.Skipped) return false;
       if (Skipped != other.Skipped) return false;
       if (ResultCase != other.ResultCase) return false;
       if (ResultCase != other.ResultCase) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -506,6 +522,9 @@ namespace Conformance {
       if (resultCase_ == ResultOneofCase.JsonPayload) hash ^= JsonPayload.GetHashCode();
       if (resultCase_ == ResultOneofCase.JsonPayload) hash ^= JsonPayload.GetHashCode();
       if (resultCase_ == ResultOneofCase.Skipped) hash ^= Skipped.GetHashCode();
       if (resultCase_ == ResultOneofCase.Skipped) hash ^= Skipped.GetHashCode();
       hash ^= (int) resultCase_;
       hash ^= (int) resultCase_;
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -540,6 +559,9 @@ namespace Conformance {
         output.WriteRawTag(50);
         output.WriteRawTag(50);
         output.WriteString(SerializeError);
         output.WriteString(SerializeError);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -563,6 +585,9 @@ namespace Conformance {
       if (resultCase_ == ResultOneofCase.Skipped) {
       if (resultCase_ == ResultOneofCase.Skipped) {
         size += 1 + pb::CodedOutputStream.ComputeStringSize(Skipped);
         size += 1 + pb::CodedOutputStream.ComputeStringSize(Skipped);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -592,6 +617,7 @@ namespace Conformance {
           break;
           break;
       }
       }
 
 
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -600,7 +626,7 @@ namespace Conformance {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             ParseError = input.ReadString();
             ParseError = input.ReadString();

+ 43 - 0
csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs

@@ -540,6 +540,49 @@ namespace Google.Protobuf.Collections
             Assert.Throws<ArgumentException>(() => map.ToString());
             Assert.Throws<ArgumentException>(() => map.ToString());
         }
         }
 
 
+        [Test]
+        public void NaNValuesComparedBitwise()
+        {
+            var map1 = new MapField<string, double>
+            {
+                { "x", SampleNaNs.Regular },
+                { "y", SampleNaNs.SignallingFlipped }
+            };
+
+            var map2 = new MapField<string, double>
+            {
+                { "x", SampleNaNs.Regular },
+                { "y", SampleNaNs.PayloadFlipped }
+            };
+
+            var map3 = new MapField<string, double>
+            {
+                { "x", SampleNaNs.Regular },
+                { "y", SampleNaNs.SignallingFlipped }
+            };
+
+            EqualityTester.AssertInequality(map1, map2);
+            EqualityTester.AssertEquality(map1, map3);
+            Assert.True(map1.Values.Contains(SampleNaNs.SignallingFlipped));
+            Assert.False(map2.Values.Contains(SampleNaNs.SignallingFlipped));
+        }
+
+        // This wouldn't usually happen, as protos can't use doubles as map keys,
+        // but let's be consistent.
+        [Test]
+        public void NaNKeysComparedBitwise()
+        {
+            var map = new MapField<double, string>
+            {
+                { SampleNaNs.Regular, "x" },
+                { SampleNaNs.SignallingFlipped, "y" }
+            };
+            Assert.AreEqual("x", map[SampleNaNs.Regular]);
+            Assert.AreEqual("y", map[SampleNaNs.SignallingFlipped]);
+            string ignored;
+            Assert.False(map.TryGetValue(SampleNaNs.PayloadFlipped, out ignored));
+        }
+
 #if !NET35
 #if !NET35
         [Test]
         [Test]
         public void IDictionaryKeys_Equals_IReadOnlyDictionaryKeys()
         public void IDictionaryKeys_Equals_IReadOnlyDictionaryKeys()

+ 124 - 0
csharp/src/Google.Protobuf.Test/Collections/ProtobufEqualityComparersTest.cs

@@ -0,0 +1,124 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2017 Google Inc.  All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using NUnit.Framework;
+using System.Collections.Generic;
+using System.Linq;
+using static Google.Protobuf.Collections.ProtobufEqualityComparers;
+
+namespace Google.Protobuf.Collections
+{
+    public class ProtobufEqualityComparersTest
+    {
+        private static readonly double[] doubles =
+        {
+            0,
+            1,
+            1.5,
+            -1.5,
+            double.PositiveInfinity,
+            double.NegativeInfinity,
+            // Three different types of NaN...
+            SampleNaNs.Regular,
+            SampleNaNs.SignallingFlipped,
+            SampleNaNs.PayloadFlipped
+        };
+
+        [Test]
+        public void GetEqualityComparer_Default()
+        {
+            // It's more pain than it's worth to try to parameterize these tests.
+            Assert.AreSame(EqualityComparer<object>.Default, GetEqualityComparer<object>());
+            Assert.AreSame(EqualityComparer<string>.Default, GetEqualityComparer<string>());
+            Assert.AreSame(EqualityComparer<int>.Default, GetEqualityComparer<int>());
+            Assert.AreSame(EqualityComparer<int?>.Default, GetEqualityComparer<int?>());
+        }
+
+        [Test]
+        public void GetEqualityComparer_NotDefault()
+        {
+            // It's more pain than it's worth to try to parameterize these tests.
+            Assert.AreSame(BitwiseDoubleEqualityComparer, GetEqualityComparer<double>());
+            Assert.AreSame(BitwiseSingleEqualityComparer, GetEqualityComparer<float>());
+            Assert.AreSame(BitwiseNullableDoubleEqualityComparer, GetEqualityComparer<double?>());
+            Assert.AreSame(BitwiseNullableSingleEqualityComparer, GetEqualityComparer<float?>());
+        }
+
+        [Test]
+        public void DoubleComparisons()
+        {
+            ValidateEqualityComparer(BitwiseDoubleEqualityComparer, doubles);
+        }
+
+        [Test]
+        public void NullableDoubleComparisons()
+        {
+            ValidateEqualityComparer(BitwiseNullableDoubleEqualityComparer, doubles.Select(d => (double?) d).Concat(new double?[] { null }));
+        }
+
+        [Test]
+        public void SingleComparisons()
+        {
+            ValidateEqualityComparer(BitwiseSingleEqualityComparer, doubles.Select(d => (float) d));
+        }
+
+        [Test]
+        public void NullableSingleComparisons()
+        {
+            ValidateEqualityComparer(BitwiseNullableSingleEqualityComparer, doubles.Select(d => (float?) d).Concat(new float?[] { null }));
+        }
+
+        private static void ValidateEqualityComparer<T>(EqualityComparer<T> comparer, IEnumerable<T> values)
+        {
+            var array = values.ToArray();
+            // Each value should be equal to itself, but not to any other value.
+            for (int i = 0; i < array.Length; i++)
+            {
+                for (int j = 0; j < array.Length; j++)
+                {
+                    if (i == j)
+                    {
+                        Assert.IsTrue(comparer.Equals(array[i], array[j]),
+                            "{0} should be equal to itself", array[i], array[j]);
+                    }
+                    else
+                    {
+                        Assert.IsFalse(comparer.Equals(array[i], array[j]),
+                            "{0} and {1} should not be equal", array[i], array[j]);
+                        Assert.AreNotEqual(comparer.GetHashCode(array[i]), comparer.GetHashCode(array[j]),
+                            "Hash codes for {0} and {1} should not be equal", array[i], array[j]);
+                    }
+                }
+            }
+        }
+    }    
+}

+ 13 - 0
csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs

@@ -742,5 +742,18 @@ namespace Google.Protobuf.Collections
             var text = list.ToString();
             var text = list.ToString();
             Assert.AreEqual(text, "[ { \"foo\": 20 } ]", message.ToString());
             Assert.AreEqual(text, "[ { \"foo\": 20 } ]", message.ToString());
         }
         }
+
+        [Test]
+        public void NaNValuesComparedBitwise()
+        {
+            var list1 = new RepeatedField<double> { SampleNaNs.Regular, SampleNaNs.SignallingFlipped };
+            var list2 = new RepeatedField<double> { SampleNaNs.Regular, SampleNaNs.PayloadFlipped };
+            var list3 = new RepeatedField<double> { SampleNaNs.Regular, SampleNaNs.SignallingFlipped };
+
+            EqualityTester.AssertInequality(list1, list2);
+            EqualityTester.AssertEquality(list1, list3);
+            Assert.True(list1.Contains(SampleNaNs.SignallingFlipped));
+            Assert.False(list2.Contains(SampleNaNs.SignallingFlipped));
+        }
     }
     }
 }
 }

+ 17 - 4
csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs

@@ -638,7 +638,7 @@ namespace Google.Protobuf
         }
         }
 
 
         [Test]
         [Test]
-        public void IgnoreUnknownFields_RealDataStillRead()
+        public void DiscardUnknownFields_RealDataStillRead()
         {
         {
             var message = SampleMessages.CreateFullTestAllTypes();
             var message = SampleMessages.CreateFullTestAllTypes();
             var stream = new MemoryStream();
             var stream = new MemoryStream();
@@ -652,16 +652,18 @@ namespace Google.Protobuf
 
 
             stream.Position = 0;
             stream.Position = 0;
             var parsed = TestAllTypes.Parser.ParseFrom(stream);
             var parsed = TestAllTypes.Parser.ParseFrom(stream);
-            Assert.AreEqual(message, parsed);
+            // TODO(jieluo): Add test back when DiscardUnknownFields API is supported.
+            // Assert.AreEqual(message, parsed);
         }
         }
 
 
         [Test]
         [Test]
-        public void IgnoreUnknownFields_AllTypes()
+        public void DiscardUnknownFields_AllTypes()
         {
         {
             // Simple way of ensuring we can skip all kinds of fields.
             // Simple way of ensuring we can skip all kinds of fields.
             var data = SampleMessages.CreateFullTestAllTypes().ToByteArray();
             var data = SampleMessages.CreateFullTestAllTypes().ToByteArray();
             var empty = Empty.Parser.ParseFrom(data);
             var empty = Empty.Parser.ParseFrom(data);
-            Assert.AreEqual(new Empty(), empty);
+            // TODO(jieluo): Add test back when DiscardUnknownFields API is supported.
+            // Assert.AreNotEqual(new Empty(), empty);
         }
         }
 
 
         // This was originally seen as a conformance test failure.
         // This was originally seen as a conformance test failure.
@@ -719,5 +721,16 @@ namespace Google.Protobuf
             JsonFormatter.Default.Format(message, writer);
             JsonFormatter.Default.Format(message, writer);
             Assert.AreEqual("{ \"c\": 31 }", writer.ToString());
             Assert.AreEqual("{ \"c\": 31 }", writer.ToString());
         }
         }
+
+        [Test]
+        public void NaNComparisons()
+        {
+            var message1 = new TestAllTypes { SingleDouble = SampleNaNs.Regular };
+            var message2 = new TestAllTypes { SingleDouble = SampleNaNs.PayloadFlipped };
+            var message3 = new TestAllTypes { SingleDouble = SampleNaNs.Regular };
+
+            EqualityTester.AssertInequality(message1, message2);
+            EqualityTester.AssertEquality(message1, message3);
+        }
     }
     }
 }
 }

+ 3 - 3
csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs

@@ -514,7 +514,7 @@ namespace Google.Protobuf
             var formatter = new JsonFormatter(JsonFormatter.Settings.Default.WithTypeRegistry(TypeRegistry.FromMessages(TestAllTypes.Descriptor)));
             var formatter = new JsonFormatter(JsonFormatter.Settings.Default.WithTypeRegistry(TypeRegistry.FromMessages(TestAllTypes.Descriptor)));
             var message = new TestAllTypes { SingleInt32 = 10, SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 } };
             var message = new TestAllTypes { SingleInt32 = 10, SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 } };
             var any = Any.Pack(message);
             var any = Any.Pack(message);
-            AssertJson("{ '@type': 'type.googleapis.com/protobuf_unittest.TestAllTypes', 'singleInt32': 10, 'singleNestedMessage': { 'bb': 20 } }", formatter.Format(any));
+            AssertJson("{ '@type': 'type.googleapis.com/protobuf_unittest3.TestAllTypes', 'singleInt32': 10, 'singleNestedMessage': { 'bb': 20 } }", formatter.Format(any));
         }
         }
 
 
         [Test]
         [Test]
@@ -523,7 +523,7 @@ namespace Google.Protobuf
             var formatter = new JsonFormatter(JsonFormatter.Settings.Default.WithTypeRegistry(TypeRegistry.FromMessages(TestAllTypes.Descriptor)));
             var formatter = new JsonFormatter(JsonFormatter.Settings.Default.WithTypeRegistry(TypeRegistry.FromMessages(TestAllTypes.Descriptor)));
             var message = new TestAllTypes { SingleInt32 = 10 };
             var message = new TestAllTypes { SingleInt32 = 10 };
             var any = Any.Pack(message, "foo.bar/baz");
             var any = Any.Pack(message, "foo.bar/baz");
-            AssertJson("{ '@type': 'foo.bar/baz/protobuf_unittest.TestAllTypes', 'singleInt32': 10 }", formatter.Format(any));
+            AssertJson("{ '@type': 'foo.bar/baz/protobuf_unittest3.TestAllTypes', 'singleInt32': 10 }", formatter.Format(any));
         }
         }
 
 
         [Test]
         [Test]
@@ -536,7 +536,7 @@ namespace Google.Protobuf
             var doubleNestedMessage = new TestAllTypes { SingleInt32 = 20 };
             var doubleNestedMessage = new TestAllTypes { SingleInt32 = 20 };
             var nestedMessage = Any.Pack(doubleNestedMessage);
             var nestedMessage = Any.Pack(doubleNestedMessage);
             var message = new TestWellKnownTypes { AnyField = Any.Pack(nestedMessage) };
             var message = new TestWellKnownTypes { AnyField = Any.Pack(nestedMessage) };
-            AssertJson("{ 'anyField': { '@type': 'type.googleapis.com/google.protobuf.Any', 'value': { '@type': 'type.googleapis.com/protobuf_unittest.TestAllTypes', 'singleInt32': 20 } } }",
+            AssertJson("{ 'anyField': { '@type': 'type.googleapis.com/google.protobuf.Any', 'value': { '@type': 'type.googleapis.com/protobuf_unittest3.TestAllTypes', 'singleInt32': 20 } } }",
                 formatter.Format(message));
                 formatter.Format(message));
         }
         }
 
 

+ 2 - 2
csharp/src/Google.Protobuf.Test/JsonParserTest.cs

@@ -809,7 +809,7 @@ namespace Google.Protobuf
             var json = formatter.Format(original); // This is tested in JsonFormatterTest
             var json = formatter.Format(original); // This is tested in JsonFormatterTest
             var parser = new JsonParser(new JsonParser.Settings(10, registry));
             var parser = new JsonParser(new JsonParser.Settings(10, registry));
             Assert.AreEqual(original, parser.Parse<Any>(json));
             Assert.AreEqual(original, parser.Parse<Any>(json));
-            string valueFirstJson = "{ \"singleInt32\": 10, \"singleNestedMessage\": { \"bb\": 20 }, \"@type\": \"type.googleapis.com/protobuf_unittest.TestAllTypes\" }";
+            string valueFirstJson = "{ \"singleInt32\": 10, \"singleNestedMessage\": { \"bb\": 20 }, \"@type\": \"type.googleapis.com/protobuf_unittest3.TestAllTypes\" }";
             Assert.AreEqual(original, parser.Parse<Any>(valueFirstJson));
             Assert.AreEqual(original, parser.Parse<Any>(valueFirstJson));
         }
         }
 
 
@@ -820,7 +820,7 @@ namespace Google.Protobuf
             var message = new TestAllTypes { SingleInt32 = 10 };
             var message = new TestAllTypes { SingleInt32 = 10 };
             var original = Any.Pack(message, "custom.prefix/middle-part");
             var original = Any.Pack(message, "custom.prefix/middle-part");
             var parser = new JsonParser(new JsonParser.Settings(10, registry));
             var parser = new JsonParser(new JsonParser.Settings(10, registry));
-            string json = "{ \"@type\": \"custom.prefix/middle-part/protobuf_unittest.TestAllTypes\", \"singleInt32\": 10 }";
+            string json = "{ \"@type\": \"custom.prefix/middle-part/protobuf_unittest3.TestAllTypes\", \"singleInt32\": 10 }";
             Assert.AreEqual(original, parser.Parse<Any>(json));
             Assert.AreEqual(original, parser.Parse<Any>(json));
         }
         }
 
 

+ 22 - 12
csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs

@@ -48,13 +48,13 @@ namespace Google.Protobuf.Reflection
         {
         {
             FileDescriptor file = UnittestProto3Reflection.Descriptor;
             FileDescriptor file = UnittestProto3Reflection.Descriptor;
 
 
-            Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Name);
-            Assert.AreEqual("protobuf_unittest", file.Package);
+            Assert.AreEqual("unittest_proto3.proto", file.Name);
+            Assert.AreEqual("protobuf_unittest3", file.Package);
 
 
             Assert.AreEqual("UnittestProto", file.Proto.Options.JavaOuterClassname);
             Assert.AreEqual("UnittestProto", file.Proto.Options.JavaOuterClassname);
-            Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Proto.Name);
+            Assert.AreEqual("unittest_proto3.proto", file.Proto.Name);
 
 
-            // unittest.proto doesn't have any public imports, but unittest_import.proto does.
+            // unittest_proto3.proto doesn't have any public imports, but unittest_import_proto3.proto does.
             Assert.AreEqual(0, file.PublicDependencies.Count);
             Assert.AreEqual(0, file.PublicDependencies.Count);
             Assert.AreEqual(1, UnittestImportProto3Reflection.Descriptor.PublicDependencies.Count);
             Assert.AreEqual(1, UnittestImportProto3Reflection.Descriptor.PublicDependencies.Count);
             Assert.AreEqual(UnittestImportPublicProto3Reflection.Descriptor, UnittestImportProto3Reflection.Descriptor.PublicDependencies[0]);
             Assert.AreEqual(UnittestImportPublicProto3Reflection.Descriptor, UnittestImportProto3Reflection.Descriptor.PublicDependencies[0]);
@@ -68,7 +68,7 @@ namespace Google.Protobuf.Reflection
             Assert.AreEqual(messageType, file.MessageTypes[0]);
             Assert.AreEqual(messageType, file.MessageTypes[0]);
             Assert.AreEqual(messageType, file.FindTypeByName<MessageDescriptor>("TestAllTypes"));
             Assert.AreEqual(messageType, file.FindTypeByName<MessageDescriptor>("TestAllTypes"));
             Assert.Null(file.FindTypeByName<MessageDescriptor>("NoSuchType"));
             Assert.Null(file.FindTypeByName<MessageDescriptor>("NoSuchType"));
-            Assert.Null(file.FindTypeByName<MessageDescriptor>("protobuf_unittest.TestAllTypes"));
+            Assert.Null(file.FindTypeByName<MessageDescriptor>("protobuf_unittest3.TestAllTypes"));
             for (int i = 0; i < file.MessageTypes.Count; i++)
             for (int i = 0; i < file.MessageTypes.Count; i++)
             {
             {
                 Assert.AreEqual(i, file.MessageTypes[i].Index);
                 Assert.AreEqual(i, file.MessageTypes[i].Index);
@@ -76,7 +76,7 @@ namespace Google.Protobuf.Reflection
 
 
             Assert.AreEqual(file.EnumTypes[0], file.FindTypeByName<EnumDescriptor>("ForeignEnum"));
             Assert.AreEqual(file.EnumTypes[0], file.FindTypeByName<EnumDescriptor>("ForeignEnum"));
             Assert.Null(file.FindTypeByName<EnumDescriptor>("NoSuchType"));
             Assert.Null(file.FindTypeByName<EnumDescriptor>("NoSuchType"));
-            Assert.Null(file.FindTypeByName<EnumDescriptor>("protobuf_unittest.ForeignEnum"));
+            Assert.Null(file.FindTypeByName<EnumDescriptor>("protobuf_unittest3.ForeignEnum"));
             Assert.AreEqual(1, UnittestImportProto3Reflection.Descriptor.EnumTypes.Count);
             Assert.AreEqual(1, UnittestImportProto3Reflection.Descriptor.EnumTypes.Count);
             Assert.AreEqual("ImportEnum", UnittestImportProto3Reflection.Descriptor.EnumTypes[0].Name);
             Assert.AreEqual("ImportEnum", UnittestImportProto3Reflection.Descriptor.EnumTypes[0].Name);
             for (int i = 0; i < file.EnumTypes.Count; i++)
             for (int i = 0; i < file.EnumTypes.Count; i++)
@@ -87,6 +87,16 @@ namespace Google.Protobuf.Reflection
             Assert.AreEqual(10, file.SerializedData[0]);
             Assert.AreEqual(10, file.SerializedData[0]);
         }
         }
 
 
+        [Test]
+        public void FileDescriptor_NonRootPath()
+        {
+            // unittest_proto3.proto used to be in google/protobuf. Now it's in the C#-specific location,
+            // let's test something that's still in a directory.
+            FileDescriptor file = UnittestWellKnownTypesReflection.Descriptor;
+            Assert.AreEqual("google/protobuf/unittest_well_known_types.proto", file.Name);
+            Assert.AreEqual("protobuf_unittest", file.Package);
+        }
+
         [Test]
         [Test]
         public void MessageDescriptor()
         public void MessageDescriptor()
         {
         {
@@ -94,7 +104,7 @@ namespace Google.Protobuf.Reflection
             MessageDescriptor nestedType = TestAllTypes.Types.NestedMessage.Descriptor;
             MessageDescriptor nestedType = TestAllTypes.Types.NestedMessage.Descriptor;
 
 
             Assert.AreEqual("TestAllTypes", messageType.Name);
             Assert.AreEqual("TestAllTypes", messageType.Name);
-            Assert.AreEqual("protobuf_unittest.TestAllTypes", messageType.FullName);
+            Assert.AreEqual("protobuf_unittest3.TestAllTypes", messageType.FullName);
             Assert.AreEqual(UnittestProto3Reflection.Descriptor, messageType.File);
             Assert.AreEqual(UnittestProto3Reflection.Descriptor, messageType.File);
             Assert.IsNull(messageType.ContainingType);
             Assert.IsNull(messageType.ContainingType);
             Assert.IsNull(messageType.Proto.Options);
             Assert.IsNull(messageType.Proto.Options);
@@ -102,7 +112,7 @@ namespace Google.Protobuf.Reflection
             Assert.AreEqual("TestAllTypes", messageType.Name);
             Assert.AreEqual("TestAllTypes", messageType.Name);
 
 
             Assert.AreEqual("NestedMessage", nestedType.Name);
             Assert.AreEqual("NestedMessage", nestedType.Name);
-            Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedMessage", nestedType.FullName);
+            Assert.AreEqual("protobuf_unittest3.TestAllTypes.NestedMessage", nestedType.FullName);
             Assert.AreEqual(UnittestProto3Reflection.Descriptor, nestedType.File);
             Assert.AreEqual(UnittestProto3Reflection.Descriptor, nestedType.File);
             Assert.AreEqual(messageType, nestedType.ContainingType);
             Assert.AreEqual(messageType, nestedType.ContainingType);
 
 
@@ -143,7 +153,7 @@ namespace Google.Protobuf.Reflection
             FieldDescriptor messageField = messageType.FindDescriptor<FieldDescriptor>("single_foreign_message");
             FieldDescriptor messageField = messageType.FindDescriptor<FieldDescriptor>("single_foreign_message");
 
 
             Assert.AreEqual("single_int32", primitiveField.Name);
             Assert.AreEqual("single_int32", primitiveField.Name);
-            Assert.AreEqual("protobuf_unittest.TestAllTypes.single_int32",
+            Assert.AreEqual("protobuf_unittest3.TestAllTypes.single_int32",
                             primitiveField.FullName);
                             primitiveField.FullName);
             Assert.AreEqual(1, primitiveField.FieldNumber);
             Assert.AreEqual(1, primitiveField.FieldNumber);
             Assert.AreEqual(messageType, primitiveField.ContainingType);
             Assert.AreEqual(messageType, primitiveField.ContainingType);
@@ -180,13 +190,13 @@ namespace Google.Protobuf.Reflection
             EnumDescriptor nestedType = TestAllTypes.Descriptor.FindDescriptor<EnumDescriptor>("NestedEnum");
             EnumDescriptor nestedType = TestAllTypes.Descriptor.FindDescriptor<EnumDescriptor>("NestedEnum");
 
 
             Assert.AreEqual("ForeignEnum", enumType.Name);
             Assert.AreEqual("ForeignEnum", enumType.Name);
-            Assert.AreEqual("protobuf_unittest.ForeignEnum", enumType.FullName);
+            Assert.AreEqual("protobuf_unittest3.ForeignEnum", enumType.FullName);
             Assert.AreEqual(UnittestProto3Reflection.Descriptor, enumType.File);
             Assert.AreEqual(UnittestProto3Reflection.Descriptor, enumType.File);
             Assert.Null(enumType.ContainingType);
             Assert.Null(enumType.ContainingType);
             Assert.Null(enumType.Proto.Options);
             Assert.Null(enumType.Proto.Options);
 
 
             Assert.AreEqual("NestedEnum", nestedType.Name);
             Assert.AreEqual("NestedEnum", nestedType.Name);
-            Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedEnum",
+            Assert.AreEqual("protobuf_unittest3.TestAllTypes.NestedEnum",
                             nestedType.FullName);
                             nestedType.FullName);
             Assert.AreEqual(UnittestProto3Reflection.Descriptor, nestedType.File);
             Assert.AreEqual(UnittestProto3Reflection.Descriptor, nestedType.File);
             Assert.AreEqual(TestAllTypes.Descriptor, nestedType.ContainingType);
             Assert.AreEqual(TestAllTypes.Descriptor, nestedType.ContainingType);
@@ -209,7 +219,7 @@ namespace Google.Protobuf.Reflection
         {
         {
             OneofDescriptor descriptor = TestAllTypes.Descriptor.FindDescriptor<OneofDescriptor>("oneof_field");
             OneofDescriptor descriptor = TestAllTypes.Descriptor.FindDescriptor<OneofDescriptor>("oneof_field");
             Assert.AreEqual("oneof_field", descriptor.Name);
             Assert.AreEqual("oneof_field", descriptor.Name);
-            Assert.AreEqual("protobuf_unittest.TestAllTypes.oneof_field", descriptor.FullName);
+            Assert.AreEqual("protobuf_unittest3.TestAllTypes.oneof_field", descriptor.FullName);
 
 
             var expectedFields = new[] {
             var expectedFields = new[] {
                 TestAllTypes.OneofBytesFieldNumber,
                 TestAllTypes.OneofBytesFieldNumber,

+ 53 - 0
csharp/src/Google.Protobuf.Test/SampleNaNs.cs

@@ -0,0 +1,53 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2017 Google Inc.  All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System;
+
+namespace Google.Protobuf
+{
+    /// <summary>
+    /// Samples of different not-a-number values, for testing equality comparisons.
+    /// </summary>
+    public static class SampleNaNs
+    {
+        public static double Regular { get; } = double.NaN;
+
+        // Signalling bit is inverted compared with double.NaN. Doesn't really matter
+        // whether that makes it quiet or signalling - it's different.
+        public static double SignallingFlipped { get; } = 
+            BitConverter.Int64BitsToDouble(BitConverter.DoubleToInt64Bits(double.NaN) ^ -0x8000_0000_0000_0000L);
+
+        // A bit in the middle of the mantissa is flipped; this difference is preserved when casting to float.
+        public static double PayloadFlipped { get; } =
+            BitConverter.Int64BitsToDouble(BitConverter.DoubleToInt64Bits(double.NaN) ^ 0x1_0000_0000L);
+    }
+}

+ 228 - 142
csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs

@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: google/protobuf/map_unittest_proto3.proto
+// <auto-generated>
+//     Generated by the protocol buffer compiler.  DO NOT EDIT!
+//     source: map_unittest_proto3.proto
+// </auto-generated>
 #pragma warning disable 1591, 0612, 3021
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code
 #region Designer generated code
 
 
@@ -9,11 +11,11 @@ using pbr = global::Google.Protobuf.Reflection;
 using scg = global::System.Collections.Generic;
 using scg = global::System.Collections.Generic;
 namespace Google.Protobuf.TestProtos {
 namespace Google.Protobuf.TestProtos {
 
 
-  /// <summary>Holder for reflection information generated from google/protobuf/map_unittest_proto3.proto</summary>
+  /// <summary>Holder for reflection information generated from map_unittest_proto3.proto</summary>
   public static partial class MapUnittestProto3Reflection {
   public static partial class MapUnittestProto3Reflection {
 
 
     #region Descriptor
     #region Descriptor
-    /// <summary>File descriptor for google/protobuf/map_unittest_proto3.proto</summary>
+    /// <summary>File descriptor for map_unittest_proto3.proto</summary>
     public static pbr::FileDescriptor Descriptor {
     public static pbr::FileDescriptor Descriptor {
       get { return descriptor; }
       get { return descriptor; }
     }
     }
@@ -22,130 +24,130 @@ namespace Google.Protobuf.TestProtos {
     static MapUnittestProto3Reflection() {
     static MapUnittestProto3Reflection() {
       byte[] descriptorData = global::System.Convert.FromBase64String(
       byte[] descriptorData = global::System.Convert.FromBase64String(
           string.Concat(
           string.Concat(
-            "Cilnb29nbGUvcHJvdG9idWYvbWFwX3VuaXR0ZXN0X3Byb3RvMy5wcm90bxIR",
-            "cHJvdG9idWZfdW5pdHRlc3QaJWdvb2dsZS9wcm90b2J1Zi91bml0dGVzdF9w",
-            "cm90bzMucHJvdG8ilhIKB1Rlc3RNYXASRgoPbWFwX2ludDMyX2ludDMyGAEg",
-            "AygLMi0ucHJvdG9idWZfdW5pdHRlc3QuVGVzdE1hcC5NYXBJbnQzMkludDMy",
-            "RW50cnkSRgoPbWFwX2ludDY0X2ludDY0GAIgAygLMi0ucHJvdG9idWZfdW5p",
-            "dHRlc3QuVGVzdE1hcC5NYXBJbnQ2NEludDY0RW50cnkSSgoRbWFwX3VpbnQz",
-            "Ml91aW50MzIYAyADKAsyLy5wcm90b2J1Zl91bml0dGVzdC5UZXN0TWFwLk1h",
-            "cFVpbnQzMlVpbnQzMkVudHJ5EkoKEW1hcF91aW50NjRfdWludDY0GAQgAygL",
-            "Mi8ucHJvdG9idWZfdW5pdHRlc3QuVGVzdE1hcC5NYXBVaW50NjRVaW50NjRF",
-            "bnRyeRJKChFtYXBfc2ludDMyX3NpbnQzMhgFIAMoCzIvLnByb3RvYnVmX3Vu",
-            "aXR0ZXN0LlRlc3RNYXAuTWFwU2ludDMyU2ludDMyRW50cnkSSgoRbWFwX3Np",
-            "bnQ2NF9zaW50NjQYBiADKAsyLy5wcm90b2J1Zl91bml0dGVzdC5UZXN0TWFw",
-            "Lk1hcFNpbnQ2NFNpbnQ2NEVudHJ5Ek4KE21hcF9maXhlZDMyX2ZpeGVkMzIY",
-            "ByADKAsyMS5wcm90b2J1Zl91bml0dGVzdC5UZXN0TWFwLk1hcEZpeGVkMzJG",
-            "aXhlZDMyRW50cnkSTgoTbWFwX2ZpeGVkNjRfZml4ZWQ2NBgIIAMoCzIxLnBy",
-            "b3RvYnVmX3VuaXR0ZXN0LlRlc3RNYXAuTWFwRml4ZWQ2NEZpeGVkNjRFbnRy",
-            "eRJSChVtYXBfc2ZpeGVkMzJfc2ZpeGVkMzIYCSADKAsyMy5wcm90b2J1Zl91",
-            "bml0dGVzdC5UZXN0TWFwLk1hcFNmaXhlZDMyU2ZpeGVkMzJFbnRyeRJSChVt",
-            "YXBfc2ZpeGVkNjRfc2ZpeGVkNjQYCiADKAsyMy5wcm90b2J1Zl91bml0dGVz",
-            "dC5UZXN0TWFwLk1hcFNmaXhlZDY0U2ZpeGVkNjRFbnRyeRJGCg9tYXBfaW50",
-            "MzJfZmxvYXQYCyADKAsyLS5wcm90b2J1Zl91bml0dGVzdC5UZXN0TWFwLk1h",
-            "cEludDMyRmxvYXRFbnRyeRJIChBtYXBfaW50MzJfZG91YmxlGAwgAygLMi4u",
-            "cHJvdG9idWZfdW5pdHRlc3QuVGVzdE1hcC5NYXBJbnQzMkRvdWJsZUVudHJ5",
-            "EkIKDW1hcF9ib29sX2Jvb2wYDSADKAsyKy5wcm90b2J1Zl91bml0dGVzdC5U",
-            "ZXN0TWFwLk1hcEJvb2xCb29sRW50cnkSSgoRbWFwX3N0cmluZ19zdHJpbmcY",
-            "DiADKAsyLy5wcm90b2J1Zl91bml0dGVzdC5UZXN0TWFwLk1hcFN0cmluZ1N0",
-            "cmluZ0VudHJ5EkYKD21hcF9pbnQzMl9ieXRlcxgPIAMoCzItLnByb3RvYnVm",
-            "X3VuaXR0ZXN0LlRlc3RNYXAuTWFwSW50MzJCeXRlc0VudHJ5EkQKDm1hcF9p",
-            "bnQzMl9lbnVtGBAgAygLMiwucHJvdG9idWZfdW5pdHRlc3QuVGVzdE1hcC5N",
-            "YXBJbnQzMkVudW1FbnRyeRJZChltYXBfaW50MzJfZm9yZWlnbl9tZXNzYWdl",
-            "GBEgAygLMjYucHJvdG9idWZfdW5pdHRlc3QuVGVzdE1hcC5NYXBJbnQzMkZv",
-            "cmVpZ25NZXNzYWdlRW50cnkaNAoSTWFwSW50MzJJbnQzMkVudHJ5EgsKA2tl",
-            "eRgBIAEoBRINCgV2YWx1ZRgCIAEoBToCOAEaNAoSTWFwSW50NjRJbnQ2NEVu",
-            "dHJ5EgsKA2tleRgBIAEoAxINCgV2YWx1ZRgCIAEoAzoCOAEaNgoUTWFwVWlu",
-            "dDMyVWludDMyRW50cnkSCwoDa2V5GAEgASgNEg0KBXZhbHVlGAIgASgNOgI4",
-            "ARo2ChRNYXBVaW50NjRVaW50NjRFbnRyeRILCgNrZXkYASABKAQSDQoFdmFs",
-            "dWUYAiABKAQ6AjgBGjYKFE1hcFNpbnQzMlNpbnQzMkVudHJ5EgsKA2tleRgB",
-            "IAEoERINCgV2YWx1ZRgCIAEoEToCOAEaNgoUTWFwU2ludDY0U2ludDY0RW50",
-            "cnkSCwoDa2V5GAEgASgSEg0KBXZhbHVlGAIgASgSOgI4ARo4ChZNYXBGaXhl",
-            "ZDMyRml4ZWQzMkVudHJ5EgsKA2tleRgBIAEoBxINCgV2YWx1ZRgCIAEoBzoC",
-            "OAEaOAoWTWFwRml4ZWQ2NEZpeGVkNjRFbnRyeRILCgNrZXkYASABKAYSDQoF",
-            "dmFsdWUYAiABKAY6AjgBGjoKGE1hcFNmaXhlZDMyU2ZpeGVkMzJFbnRyeRIL",
-            "CgNrZXkYASABKA8SDQoFdmFsdWUYAiABKA86AjgBGjoKGE1hcFNmaXhlZDY0",
-            "U2ZpeGVkNjRFbnRyeRILCgNrZXkYASABKBASDQoFdmFsdWUYAiABKBA6AjgB",
-            "GjQKEk1hcEludDMyRmxvYXRFbnRyeRILCgNrZXkYASABKAUSDQoFdmFsdWUY",
-            "AiABKAI6AjgBGjUKE01hcEludDMyRG91YmxlRW50cnkSCwoDa2V5GAEgASgF",
-            "Eg0KBXZhbHVlGAIgASgBOgI4ARoyChBNYXBCb29sQm9vbEVudHJ5EgsKA2tl",
-            "eRgBIAEoCBINCgV2YWx1ZRgCIAEoCDoCOAEaNgoUTWFwU3RyaW5nU3RyaW5n",
-            "RW50cnkSCwoDa2V5GAEgASgJEg0KBXZhbHVlGAIgASgJOgI4ARo0ChJNYXBJ",
-            "bnQzMkJ5dGVzRW50cnkSCwoDa2V5GAEgASgFEg0KBXZhbHVlGAIgASgMOgI4",
-            "ARpPChFNYXBJbnQzMkVudW1FbnRyeRILCgNrZXkYASABKAUSKQoFdmFsdWUY",
-            "AiABKA4yGi5wcm90b2J1Zl91bml0dGVzdC5NYXBFbnVtOgI4ARpgChtNYXBJ",
-            "bnQzMkZvcmVpZ25NZXNzYWdlRW50cnkSCwoDa2V5GAEgASgFEjAKBXZhbHVl",
-            "GAIgASgLMiEucHJvdG9idWZfdW5pdHRlc3QuRm9yZWlnbk1lc3NhZ2U6AjgB",
-            "IkEKEVRlc3RNYXBTdWJtZXNzYWdlEiwKCHRlc3RfbWFwGAEgASgLMhoucHJv",
-            "dG9idWZfdW5pdHRlc3QuVGVzdE1hcCK8AQoOVGVzdE1lc3NhZ2VNYXASUQoR",
-            "bWFwX2ludDMyX21lc3NhZ2UYASADKAsyNi5wcm90b2J1Zl91bml0dGVzdC5U",
-            "ZXN0TWVzc2FnZU1hcC5NYXBJbnQzMk1lc3NhZ2VFbnRyeRpXChRNYXBJbnQz",
-            "Mk1lc3NhZ2VFbnRyeRILCgNrZXkYASABKAUSLgoFdmFsdWUYAiABKAsyHy5w",
-            "cm90b2J1Zl91bml0dGVzdC5UZXN0QWxsVHlwZXM6AjgBIuMBCg9UZXN0U2Ft",
-            "ZVR5cGVNYXASOgoEbWFwMRgBIAMoCzIsLnByb3RvYnVmX3VuaXR0ZXN0LlRl",
-            "c3RTYW1lVHlwZU1hcC5NYXAxRW50cnkSOgoEbWFwMhgCIAMoCzIsLnByb3Rv",
-            "YnVmX3VuaXR0ZXN0LlRlc3RTYW1lVHlwZU1hcC5NYXAyRW50cnkaKwoJTWFw",
-            "MUVudHJ5EgsKA2tleRgBIAEoBRINCgV2YWx1ZRgCIAEoBToCOAEaKwoJTWFw",
-            "MkVudHJ5EgsKA2tleRgBIAEoBRINCgV2YWx1ZRgCIAEoBToCOAEi5BAKDFRl",
-            "c3RBcmVuYU1hcBJLCg9tYXBfaW50MzJfaW50MzIYASADKAsyMi5wcm90b2J1",
-            "Zl91bml0dGVzdC5UZXN0QXJlbmFNYXAuTWFwSW50MzJJbnQzMkVudHJ5EksK",
-            "D21hcF9pbnQ2NF9pbnQ2NBgCIAMoCzIyLnByb3RvYnVmX3VuaXR0ZXN0LlRl",
-            "c3RBcmVuYU1hcC5NYXBJbnQ2NEludDY0RW50cnkSTwoRbWFwX3VpbnQzMl91",
-            "aW50MzIYAyADKAsyNC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QXJlbmFNYXAu",
-            "TWFwVWludDMyVWludDMyRW50cnkSTwoRbWFwX3VpbnQ2NF91aW50NjQYBCAD",
-            "KAsyNC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QXJlbmFNYXAuTWFwVWludDY0",
-            "VWludDY0RW50cnkSTwoRbWFwX3NpbnQzMl9zaW50MzIYBSADKAsyNC5wcm90",
-            "b2J1Zl91bml0dGVzdC5UZXN0QXJlbmFNYXAuTWFwU2ludDMyU2ludDMyRW50",
-            "cnkSTwoRbWFwX3NpbnQ2NF9zaW50NjQYBiADKAsyNC5wcm90b2J1Zl91bml0",
-            "dGVzdC5UZXN0QXJlbmFNYXAuTWFwU2ludDY0U2ludDY0RW50cnkSUwoTbWFw",
-            "X2ZpeGVkMzJfZml4ZWQzMhgHIAMoCzI2LnByb3RvYnVmX3VuaXR0ZXN0LlRl",
-            "c3RBcmVuYU1hcC5NYXBGaXhlZDMyRml4ZWQzMkVudHJ5ElMKE21hcF9maXhl",
-            "ZDY0X2ZpeGVkNjQYCCADKAsyNi5wcm90b2J1Zl91bml0dGVzdC5UZXN0QXJl",
-            "bmFNYXAuTWFwRml4ZWQ2NEZpeGVkNjRFbnRyeRJXChVtYXBfc2ZpeGVkMzJf",
-            "c2ZpeGVkMzIYCSADKAsyOC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QXJlbmFN",
-            "YXAuTWFwU2ZpeGVkMzJTZml4ZWQzMkVudHJ5ElcKFW1hcF9zZml4ZWQ2NF9z",
-            "Zml4ZWQ2NBgKIAMoCzI4LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBcmVuYU1h",
-            "cC5NYXBTZml4ZWQ2NFNmaXhlZDY0RW50cnkSSwoPbWFwX2ludDMyX2Zsb2F0",
-            "GAsgAygLMjIucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFyZW5hTWFwLk1hcElu",
-            "dDMyRmxvYXRFbnRyeRJNChBtYXBfaW50MzJfZG91YmxlGAwgAygLMjMucHJv",
-            "dG9idWZfdW5pdHRlc3QuVGVzdEFyZW5hTWFwLk1hcEludDMyRG91YmxlRW50",
-            "cnkSRwoNbWFwX2Jvb2xfYm9vbBgNIAMoCzIwLnByb3RvYnVmX3VuaXR0ZXN0",
-            "LlRlc3RBcmVuYU1hcC5NYXBCb29sQm9vbEVudHJ5EkkKDm1hcF9pbnQzMl9l",
-            "bnVtGA4gAygLMjEucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFyZW5hTWFwLk1h",
-            "cEludDMyRW51bUVudHJ5El4KGW1hcF9pbnQzMl9mb3JlaWduX21lc3NhZ2UY",
-            "DyADKAsyOy5wcm90b2J1Zl91bml0dGVzdC5UZXN0QXJlbmFNYXAuTWFwSW50",
-            "MzJGb3JlaWduTWVzc2FnZUVudHJ5GjQKEk1hcEludDMySW50MzJFbnRyeRIL",
-            "CgNrZXkYASABKAUSDQoFdmFsdWUYAiABKAU6AjgBGjQKEk1hcEludDY0SW50",
-            "NjRFbnRyeRILCgNrZXkYASABKAMSDQoFdmFsdWUYAiABKAM6AjgBGjYKFE1h",
-            "cFVpbnQzMlVpbnQzMkVudHJ5EgsKA2tleRgBIAEoDRINCgV2YWx1ZRgCIAEo",
-            "DToCOAEaNgoUTWFwVWludDY0VWludDY0RW50cnkSCwoDa2V5GAEgASgEEg0K",
-            "BXZhbHVlGAIgASgEOgI4ARo2ChRNYXBTaW50MzJTaW50MzJFbnRyeRILCgNr",
-            "ZXkYASABKBESDQoFdmFsdWUYAiABKBE6AjgBGjYKFE1hcFNpbnQ2NFNpbnQ2",
-            "NEVudHJ5EgsKA2tleRgBIAEoEhINCgV2YWx1ZRgCIAEoEjoCOAEaOAoWTWFw",
-            "Rml4ZWQzMkZpeGVkMzJFbnRyeRILCgNrZXkYASABKAcSDQoFdmFsdWUYAiAB",
-            "KAc6AjgBGjgKFk1hcEZpeGVkNjRGaXhlZDY0RW50cnkSCwoDa2V5GAEgASgG",
-            "Eg0KBXZhbHVlGAIgASgGOgI4ARo6ChhNYXBTZml4ZWQzMlNmaXhlZDMyRW50",
-            "cnkSCwoDa2V5GAEgASgPEg0KBXZhbHVlGAIgASgPOgI4ARo6ChhNYXBTZml4",
-            "ZWQ2NFNmaXhlZDY0RW50cnkSCwoDa2V5GAEgASgQEg0KBXZhbHVlGAIgASgQ",
-            "OgI4ARo0ChJNYXBJbnQzMkZsb2F0RW50cnkSCwoDa2V5GAEgASgFEg0KBXZh",
-            "bHVlGAIgASgCOgI4ARo1ChNNYXBJbnQzMkRvdWJsZUVudHJ5EgsKA2tleRgB",
-            "IAEoBRINCgV2YWx1ZRgCIAEoAToCOAEaMgoQTWFwQm9vbEJvb2xFbnRyeRIL",
-            "CgNrZXkYASABKAgSDQoFdmFsdWUYAiABKAg6AjgBGk8KEU1hcEludDMyRW51",
-            "bUVudHJ5EgsKA2tleRgBIAEoBRIpCgV2YWx1ZRgCIAEoDjIaLnByb3RvYnVm",
-            "X3VuaXR0ZXN0Lk1hcEVudW06AjgBGmAKG01hcEludDMyRm9yZWlnbk1lc3Nh",
-            "Z2VFbnRyeRILCgNrZXkYASABKAUSMAoFdmFsdWUYAiABKAsyIS5wcm90b2J1",
-            "Zl91bml0dGVzdC5Gb3JlaWduTWVzc2FnZToCOAEi5AEKH01lc3NhZ2VDb250",
-            "YWluaW5nRW51bUNhbGxlZFR5cGUSSgoEdHlwZRgBIAMoCzI8LnByb3RvYnVm",
-            "X3VuaXR0ZXN0Lk1lc3NhZ2VDb250YWluaW5nRW51bUNhbGxlZFR5cGUuVHlw",
-            "ZUVudHJ5Gl8KCVR5cGVFbnRyeRILCgNrZXkYASABKAUSQQoFdmFsdWUYAiAB",
-            "KAsyMi5wcm90b2J1Zl91bml0dGVzdC5NZXNzYWdlQ29udGFpbmluZ0VudW1D",
-            "YWxsZWRUeXBlOgI4ASIUCgRUeXBlEgwKCFRZUEVfRk9PEAAinQEKH01lc3Nh",
-            "Z2VDb250YWluaW5nTWFwQ2FsbGVkRW50cnkSTAoFZW50cnkYASADKAsyPS5w",
-            "cm90b2J1Zl91bml0dGVzdC5NZXNzYWdlQ29udGFpbmluZ01hcENhbGxlZEVu",
-            "dHJ5LkVudHJ5RW50cnkaLAoKRW50cnlFbnRyeRILCgNrZXkYASABKAUSDQoF",
-            "dmFsdWUYAiABKAU6AjgBKj8KB01hcEVudW0SEAoMTUFQX0VOVU1fRk9PEAAS",
-            "EAoMTUFQX0VOVU1fQkFSEAESEAoMTUFQX0VOVU1fQkFaEAJCIPgBAaoCGkdv",
-            "b2dsZS5Qcm90b2J1Zi5UZXN0UHJvdG9zYgZwcm90bzM="));
+            "ChltYXBfdW5pdHRlc3RfcHJvdG8zLnByb3RvEhJwcm90b2J1Zl91bml0dGVz",
+            "dDMaFXVuaXR0ZXN0X3Byb3RvMy5wcm90byKpEgoHVGVzdE1hcBJHCg9tYXBf",
+            "aW50MzJfaW50MzIYASADKAsyLi5wcm90b2J1Zl91bml0dGVzdDMuVGVzdE1h",
+            "cC5NYXBJbnQzMkludDMyRW50cnkSRwoPbWFwX2ludDY0X2ludDY0GAIgAygL",
+            "Mi4ucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RNYXAuTWFwSW50NjRJbnQ2NEVu",
+            "dHJ5EksKEW1hcF91aW50MzJfdWludDMyGAMgAygLMjAucHJvdG9idWZfdW5p",
+            "dHRlc3QzLlRlc3RNYXAuTWFwVWludDMyVWludDMyRW50cnkSSwoRbWFwX3Vp",
+            "bnQ2NF91aW50NjQYBCADKAsyMC5wcm90b2J1Zl91bml0dGVzdDMuVGVzdE1h",
+            "cC5NYXBVaW50NjRVaW50NjRFbnRyeRJLChFtYXBfc2ludDMyX3NpbnQzMhgF",
+            "IAMoCzIwLnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0TWFwLk1hcFNpbnQzMlNp",
+            "bnQzMkVudHJ5EksKEW1hcF9zaW50NjRfc2ludDY0GAYgAygLMjAucHJvdG9i",
+            "dWZfdW5pdHRlc3QzLlRlc3RNYXAuTWFwU2ludDY0U2ludDY0RW50cnkSTwoT",
+            "bWFwX2ZpeGVkMzJfZml4ZWQzMhgHIAMoCzIyLnByb3RvYnVmX3VuaXR0ZXN0",
+            "My5UZXN0TWFwLk1hcEZpeGVkMzJGaXhlZDMyRW50cnkSTwoTbWFwX2ZpeGVk",
+            "NjRfZml4ZWQ2NBgIIAMoCzIyLnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0TWFw",
+            "Lk1hcEZpeGVkNjRGaXhlZDY0RW50cnkSUwoVbWFwX3NmaXhlZDMyX3NmaXhl",
+            "ZDMyGAkgAygLMjQucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RNYXAuTWFwU2Zp",
+            "eGVkMzJTZml4ZWQzMkVudHJ5ElMKFW1hcF9zZml4ZWQ2NF9zZml4ZWQ2NBgK",
+            "IAMoCzI0LnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0TWFwLk1hcFNmaXhlZDY0",
+            "U2ZpeGVkNjRFbnRyeRJHCg9tYXBfaW50MzJfZmxvYXQYCyADKAsyLi5wcm90",
+            "b2J1Zl91bml0dGVzdDMuVGVzdE1hcC5NYXBJbnQzMkZsb2F0RW50cnkSSQoQ",
+            "bWFwX2ludDMyX2RvdWJsZRgMIAMoCzIvLnByb3RvYnVmX3VuaXR0ZXN0My5U",
+            "ZXN0TWFwLk1hcEludDMyRG91YmxlRW50cnkSQwoNbWFwX2Jvb2xfYm9vbBgN",
+            "IAMoCzIsLnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0TWFwLk1hcEJvb2xCb29s",
+            "RW50cnkSSwoRbWFwX3N0cmluZ19zdHJpbmcYDiADKAsyMC5wcm90b2J1Zl91",
+            "bml0dGVzdDMuVGVzdE1hcC5NYXBTdHJpbmdTdHJpbmdFbnRyeRJHCg9tYXBf",
+            "aW50MzJfYnl0ZXMYDyADKAsyLi5wcm90b2J1Zl91bml0dGVzdDMuVGVzdE1h",
+            "cC5NYXBJbnQzMkJ5dGVzRW50cnkSRQoObWFwX2ludDMyX2VudW0YECADKAsy",
+            "LS5wcm90b2J1Zl91bml0dGVzdDMuVGVzdE1hcC5NYXBJbnQzMkVudW1FbnRy",
+            "eRJaChltYXBfaW50MzJfZm9yZWlnbl9tZXNzYWdlGBEgAygLMjcucHJvdG9i",
+            "dWZfdW5pdHRlc3QzLlRlc3RNYXAuTWFwSW50MzJGb3JlaWduTWVzc2FnZUVu",
+            "dHJ5GjQKEk1hcEludDMySW50MzJFbnRyeRILCgNrZXkYASABKAUSDQoFdmFs",
+            "dWUYAiABKAU6AjgBGjQKEk1hcEludDY0SW50NjRFbnRyeRILCgNrZXkYASAB",
+            "KAMSDQoFdmFsdWUYAiABKAM6AjgBGjYKFE1hcFVpbnQzMlVpbnQzMkVudHJ5",
+            "EgsKA2tleRgBIAEoDRINCgV2YWx1ZRgCIAEoDToCOAEaNgoUTWFwVWludDY0",
+            "VWludDY0RW50cnkSCwoDa2V5GAEgASgEEg0KBXZhbHVlGAIgASgEOgI4ARo2",
+            "ChRNYXBTaW50MzJTaW50MzJFbnRyeRILCgNrZXkYASABKBESDQoFdmFsdWUY",
+            "AiABKBE6AjgBGjYKFE1hcFNpbnQ2NFNpbnQ2NEVudHJ5EgsKA2tleRgBIAEo",
+            "EhINCgV2YWx1ZRgCIAEoEjoCOAEaOAoWTWFwRml4ZWQzMkZpeGVkMzJFbnRy",
+            "eRILCgNrZXkYASABKAcSDQoFdmFsdWUYAiABKAc6AjgBGjgKFk1hcEZpeGVk",
+            "NjRGaXhlZDY0RW50cnkSCwoDa2V5GAEgASgGEg0KBXZhbHVlGAIgASgGOgI4",
+            "ARo6ChhNYXBTZml4ZWQzMlNmaXhlZDMyRW50cnkSCwoDa2V5GAEgASgPEg0K",
+            "BXZhbHVlGAIgASgPOgI4ARo6ChhNYXBTZml4ZWQ2NFNmaXhlZDY0RW50cnkS",
+            "CwoDa2V5GAEgASgQEg0KBXZhbHVlGAIgASgQOgI4ARo0ChJNYXBJbnQzMkZs",
+            "b2F0RW50cnkSCwoDa2V5GAEgASgFEg0KBXZhbHVlGAIgASgCOgI4ARo1ChNN",
+            "YXBJbnQzMkRvdWJsZUVudHJ5EgsKA2tleRgBIAEoBRINCgV2YWx1ZRgCIAEo",
+            "AToCOAEaMgoQTWFwQm9vbEJvb2xFbnRyeRILCgNrZXkYASABKAgSDQoFdmFs",
+            "dWUYAiABKAg6AjgBGjYKFE1hcFN0cmluZ1N0cmluZ0VudHJ5EgsKA2tleRgB",
+            "IAEoCRINCgV2YWx1ZRgCIAEoCToCOAEaNAoSTWFwSW50MzJCeXRlc0VudHJ5",
+            "EgsKA2tleRgBIAEoBRINCgV2YWx1ZRgCIAEoDDoCOAEaUAoRTWFwSW50MzJF",
+            "bnVtRW50cnkSCwoDa2V5GAEgASgFEioKBXZhbHVlGAIgASgOMhsucHJvdG9i",
+            "dWZfdW5pdHRlc3QzLk1hcEVudW06AjgBGmEKG01hcEludDMyRm9yZWlnbk1l",
+            "c3NhZ2VFbnRyeRILCgNrZXkYASABKAUSMQoFdmFsdWUYAiABKAsyIi5wcm90",
+            "b2J1Zl91bml0dGVzdDMuRm9yZWlnbk1lc3NhZ2U6AjgBIkIKEVRlc3RNYXBT",
+            "dWJtZXNzYWdlEi0KCHRlc3RfbWFwGAEgASgLMhsucHJvdG9idWZfdW5pdHRl",
+            "c3QzLlRlc3RNYXAivgEKDlRlc3RNZXNzYWdlTWFwElIKEW1hcF9pbnQzMl9t",
+            "ZXNzYWdlGAEgAygLMjcucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RNZXNzYWdl",
+            "TWFwLk1hcEludDMyTWVzc2FnZUVudHJ5GlgKFE1hcEludDMyTWVzc2FnZUVu",
+            "dHJ5EgsKA2tleRgBIAEoBRIvCgV2YWx1ZRgCIAEoCzIgLnByb3RvYnVmX3Vu",
+            "aXR0ZXN0My5UZXN0QWxsVHlwZXM6AjgBIuUBCg9UZXN0U2FtZVR5cGVNYXAS",
+            "OwoEbWFwMRgBIAMoCzItLnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0U2FtZVR5",
+            "cGVNYXAuTWFwMUVudHJ5EjsKBG1hcDIYAiADKAsyLS5wcm90b2J1Zl91bml0",
+            "dGVzdDMuVGVzdFNhbWVUeXBlTWFwLk1hcDJFbnRyeRorCglNYXAxRW50cnkS",
+            "CwoDa2V5GAEgASgFEg0KBXZhbHVlGAIgASgFOgI4ARorCglNYXAyRW50cnkS",
+            "CwoDa2V5GAEgASgFEg0KBXZhbHVlGAIgASgFOgI4ASL1EAoMVGVzdEFyZW5h",
+            "TWFwEkwKD21hcF9pbnQzMl9pbnQzMhgBIAMoCzIzLnByb3RvYnVmX3VuaXR0",
+            "ZXN0My5UZXN0QXJlbmFNYXAuTWFwSW50MzJJbnQzMkVudHJ5EkwKD21hcF9p",
+            "bnQ2NF9pbnQ2NBgCIAMoCzIzLnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0QXJl",
+            "bmFNYXAuTWFwSW50NjRJbnQ2NEVudHJ5ElAKEW1hcF91aW50MzJfdWludDMy",
+            "GAMgAygLMjUucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RBcmVuYU1hcC5NYXBV",
+            "aW50MzJVaW50MzJFbnRyeRJQChFtYXBfdWludDY0X3VpbnQ2NBgEIAMoCzI1",
+            "LnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0QXJlbmFNYXAuTWFwVWludDY0VWlu",
+            "dDY0RW50cnkSUAoRbWFwX3NpbnQzMl9zaW50MzIYBSADKAsyNS5wcm90b2J1",
+            "Zl91bml0dGVzdDMuVGVzdEFyZW5hTWFwLk1hcFNpbnQzMlNpbnQzMkVudHJ5",
+            "ElAKEW1hcF9zaW50NjRfc2ludDY0GAYgAygLMjUucHJvdG9idWZfdW5pdHRl",
+            "c3QzLlRlc3RBcmVuYU1hcC5NYXBTaW50NjRTaW50NjRFbnRyeRJUChNtYXBf",
+            "Zml4ZWQzMl9maXhlZDMyGAcgAygLMjcucHJvdG9idWZfdW5pdHRlc3QzLlRl",
+            "c3RBcmVuYU1hcC5NYXBGaXhlZDMyRml4ZWQzMkVudHJ5ElQKE21hcF9maXhl",
+            "ZDY0X2ZpeGVkNjQYCCADKAsyNy5wcm90b2J1Zl91bml0dGVzdDMuVGVzdEFy",
+            "ZW5hTWFwLk1hcEZpeGVkNjRGaXhlZDY0RW50cnkSWAoVbWFwX3NmaXhlZDMy",
+            "X3NmaXhlZDMyGAkgAygLMjkucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RBcmVu",
+            "YU1hcC5NYXBTZml4ZWQzMlNmaXhlZDMyRW50cnkSWAoVbWFwX3NmaXhlZDY0",
+            "X3NmaXhlZDY0GAogAygLMjkucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RBcmVu",
+            "YU1hcC5NYXBTZml4ZWQ2NFNmaXhlZDY0RW50cnkSTAoPbWFwX2ludDMyX2Zs",
+            "b2F0GAsgAygLMjMucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RBcmVuYU1hcC5N",
+            "YXBJbnQzMkZsb2F0RW50cnkSTgoQbWFwX2ludDMyX2RvdWJsZRgMIAMoCzI0",
+            "LnByb3RvYnVmX3VuaXR0ZXN0My5UZXN0QXJlbmFNYXAuTWFwSW50MzJEb3Vi",
+            "bGVFbnRyeRJICg1tYXBfYm9vbF9ib29sGA0gAygLMjEucHJvdG9idWZfdW5p",
+            "dHRlc3QzLlRlc3RBcmVuYU1hcC5NYXBCb29sQm9vbEVudHJ5EkoKDm1hcF9p",
+            "bnQzMl9lbnVtGA4gAygLMjIucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RBcmVu",
+            "YU1hcC5NYXBJbnQzMkVudW1FbnRyeRJfChltYXBfaW50MzJfZm9yZWlnbl9t",
+            "ZXNzYWdlGA8gAygLMjwucHJvdG9idWZfdW5pdHRlc3QzLlRlc3RBcmVuYU1h",
+            "cC5NYXBJbnQzMkZvcmVpZ25NZXNzYWdlRW50cnkaNAoSTWFwSW50MzJJbnQz",
+            "MkVudHJ5EgsKA2tleRgBIAEoBRINCgV2YWx1ZRgCIAEoBToCOAEaNAoSTWFw",
+            "SW50NjRJbnQ2NEVudHJ5EgsKA2tleRgBIAEoAxINCgV2YWx1ZRgCIAEoAzoC",
+            "OAEaNgoUTWFwVWludDMyVWludDMyRW50cnkSCwoDa2V5GAEgASgNEg0KBXZh",
+            "bHVlGAIgASgNOgI4ARo2ChRNYXBVaW50NjRVaW50NjRFbnRyeRILCgNrZXkY",
+            "ASABKAQSDQoFdmFsdWUYAiABKAQ6AjgBGjYKFE1hcFNpbnQzMlNpbnQzMkVu",
+            "dHJ5EgsKA2tleRgBIAEoERINCgV2YWx1ZRgCIAEoEToCOAEaNgoUTWFwU2lu",
+            "dDY0U2ludDY0RW50cnkSCwoDa2V5GAEgASgSEg0KBXZhbHVlGAIgASgSOgI4",
+            "ARo4ChZNYXBGaXhlZDMyRml4ZWQzMkVudHJ5EgsKA2tleRgBIAEoBxINCgV2",
+            "YWx1ZRgCIAEoBzoCOAEaOAoWTWFwRml4ZWQ2NEZpeGVkNjRFbnRyeRILCgNr",
+            "ZXkYASABKAYSDQoFdmFsdWUYAiABKAY6AjgBGjoKGE1hcFNmaXhlZDMyU2Zp",
+            "eGVkMzJFbnRyeRILCgNrZXkYASABKA8SDQoFdmFsdWUYAiABKA86AjgBGjoK",
+            "GE1hcFNmaXhlZDY0U2ZpeGVkNjRFbnRyeRILCgNrZXkYASABKBASDQoFdmFs",
+            "dWUYAiABKBA6AjgBGjQKEk1hcEludDMyRmxvYXRFbnRyeRILCgNrZXkYASAB",
+            "KAUSDQoFdmFsdWUYAiABKAI6AjgBGjUKE01hcEludDMyRG91YmxlRW50cnkS",
+            "CwoDa2V5GAEgASgFEg0KBXZhbHVlGAIgASgBOgI4ARoyChBNYXBCb29sQm9v",
+            "bEVudHJ5EgsKA2tleRgBIAEoCBINCgV2YWx1ZRgCIAEoCDoCOAEaUAoRTWFw",
+            "SW50MzJFbnVtRW50cnkSCwoDa2V5GAEgASgFEioKBXZhbHVlGAIgASgOMhsu",
+            "cHJvdG9idWZfdW5pdHRlc3QzLk1hcEVudW06AjgBGmEKG01hcEludDMyRm9y",
+            "ZWlnbk1lc3NhZ2VFbnRyeRILCgNrZXkYASABKAUSMQoFdmFsdWUYAiABKAsy",
+            "Ii5wcm90b2J1Zl91bml0dGVzdDMuRm9yZWlnbk1lc3NhZ2U6AjgBIuYBCh9N",
+            "ZXNzYWdlQ29udGFpbmluZ0VudW1DYWxsZWRUeXBlEksKBHR5cGUYASADKAsy",
+            "PS5wcm90b2J1Zl91bml0dGVzdDMuTWVzc2FnZUNvbnRhaW5pbmdFbnVtQ2Fs",
+            "bGVkVHlwZS5UeXBlRW50cnkaYAoJVHlwZUVudHJ5EgsKA2tleRgBIAEoBRJC",
+            "CgV2YWx1ZRgCIAEoCzIzLnByb3RvYnVmX3VuaXR0ZXN0My5NZXNzYWdlQ29u",
+            "dGFpbmluZ0VudW1DYWxsZWRUeXBlOgI4ASIUCgRUeXBlEgwKCFRZUEVfRk9P",
+            "EAAingEKH01lc3NhZ2VDb250YWluaW5nTWFwQ2FsbGVkRW50cnkSTQoFZW50",
+            "cnkYASADKAsyPi5wcm90b2J1Zl91bml0dGVzdDMuTWVzc2FnZUNvbnRhaW5p",
+            "bmdNYXBDYWxsZWRFbnRyeS5FbnRyeUVudHJ5GiwKCkVudHJ5RW50cnkSCwoD",
+            "a2V5GAEgASgFEg0KBXZhbHVlGAIgASgFOgI4ASo/CgdNYXBFbnVtEhAKDE1B",
+            "UF9FTlVNX0ZPTxAAEhAKDE1BUF9FTlVNX0JBUhABEhAKDE1BUF9FTlVNX0JB",
+            "WhACQh2qAhpHb29nbGUuUHJvdG9idWYuVGVzdFByb3Rvc2IGcHJvdG8z"));
       descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
       descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
           new pbr::FileDescriptor[] { global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor, },
           new pbr::FileDescriptor[] { global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor, },
           new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.TestProtos.MapEnum), }, new pbr::GeneratedClrTypeInfo[] {
           new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.TestProtos.MapEnum), }, new pbr::GeneratedClrTypeInfo[] {
@@ -176,6 +178,7 @@ namespace Google.Protobuf.TestProtos {
   /// </summary>
   /// </summary>
   public sealed partial class TestMap : pb::IMessage<TestMap> {
   public sealed partial class TestMap : pb::IMessage<TestMap> {
     private static readonly pb::MessageParser<TestMap> _parser = new pb::MessageParser<TestMap>(() => new TestMap());
     private static readonly pb::MessageParser<TestMap> _parser = new pb::MessageParser<TestMap>(() => new TestMap());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<TestMap> Parser { get { return _parser; } }
     public static pb::MessageParser<TestMap> Parser { get { return _parser; } }
 
 
@@ -215,6 +218,7 @@ namespace Google.Protobuf.TestProtos {
       mapInt32Bytes_ = other.mapInt32Bytes_.Clone();
       mapInt32Bytes_ = other.mapInt32Bytes_.Clone();
       mapInt32Enum_ = other.mapInt32Enum_.Clone();
       mapInt32Enum_ = other.mapInt32Enum_.Clone();
       mapInt32ForeignMessage_ = other.mapInt32ForeignMessage_.Clone();
       mapInt32ForeignMessage_ = other.mapInt32ForeignMessage_.Clone();
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -422,7 +426,7 @@ namespace Google.Protobuf.TestProtos {
       if (!MapInt32Bytes.Equals(other.MapInt32Bytes)) return false;
       if (!MapInt32Bytes.Equals(other.MapInt32Bytes)) return false;
       if (!MapInt32Enum.Equals(other.MapInt32Enum)) return false;
       if (!MapInt32Enum.Equals(other.MapInt32Enum)) return false;
       if (!MapInt32ForeignMessage.Equals(other.MapInt32ForeignMessage)) return false;
       if (!MapInt32ForeignMessage.Equals(other.MapInt32ForeignMessage)) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -445,6 +449,9 @@ namespace Google.Protobuf.TestProtos {
       hash ^= MapInt32Bytes.GetHashCode();
       hash ^= MapInt32Bytes.GetHashCode();
       hash ^= MapInt32Enum.GetHashCode();
       hash ^= MapInt32Enum.GetHashCode();
       hash ^= MapInt32ForeignMessage.GetHashCode();
       hash ^= MapInt32ForeignMessage.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -472,6 +479,9 @@ namespace Google.Protobuf.TestProtos {
       mapInt32Bytes_.WriteTo(output, _map_mapInt32Bytes_codec);
       mapInt32Bytes_.WriteTo(output, _map_mapInt32Bytes_codec);
       mapInt32Enum_.WriteTo(output, _map_mapInt32Enum_codec);
       mapInt32Enum_.WriteTo(output, _map_mapInt32Enum_codec);
       mapInt32ForeignMessage_.WriteTo(output, _map_mapInt32ForeignMessage_codec);
       mapInt32ForeignMessage_.WriteTo(output, _map_mapInt32ForeignMessage_codec);
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -494,6 +504,9 @@ namespace Google.Protobuf.TestProtos {
       size += mapInt32Bytes_.CalculateSize(_map_mapInt32Bytes_codec);
       size += mapInt32Bytes_.CalculateSize(_map_mapInt32Bytes_codec);
       size += mapInt32Enum_.CalculateSize(_map_mapInt32Enum_codec);
       size += mapInt32Enum_.CalculateSize(_map_mapInt32Enum_codec);
       size += mapInt32ForeignMessage_.CalculateSize(_map_mapInt32ForeignMessage_codec);
       size += mapInt32ForeignMessage_.CalculateSize(_map_mapInt32ForeignMessage_codec);
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -519,6 +532,7 @@ namespace Google.Protobuf.TestProtos {
       mapInt32Bytes_.Add(other.mapInt32Bytes_);
       mapInt32Bytes_.Add(other.mapInt32Bytes_);
       mapInt32Enum_.Add(other.mapInt32Enum_);
       mapInt32Enum_.Add(other.mapInt32Enum_);
       mapInt32ForeignMessage_.Add(other.mapInt32ForeignMessage_);
       mapInt32ForeignMessage_.Add(other.mapInt32ForeignMessage_);
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -527,7 +541,7 @@ namespace Google.Protobuf.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec);
             mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec);
@@ -605,6 +619,7 @@ namespace Google.Protobuf.TestProtos {
 
 
   public sealed partial class TestMapSubmessage : pb::IMessage<TestMapSubmessage> {
   public sealed partial class TestMapSubmessage : pb::IMessage<TestMapSubmessage> {
     private static readonly pb::MessageParser<TestMapSubmessage> _parser = new pb::MessageParser<TestMapSubmessage>(() => new TestMapSubmessage());
     private static readonly pb::MessageParser<TestMapSubmessage> _parser = new pb::MessageParser<TestMapSubmessage>(() => new TestMapSubmessage());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<TestMapSubmessage> Parser { get { return _parser; } }
     public static pb::MessageParser<TestMapSubmessage> Parser { get { return _parser; } }
 
 
@@ -628,6 +643,7 @@ namespace Google.Protobuf.TestProtos {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public TestMapSubmessage(TestMapSubmessage other) : this() {
     public TestMapSubmessage(TestMapSubmessage other) : this() {
       TestMap = other.testMap_ != null ? other.TestMap.Clone() : null;
       TestMap = other.testMap_ != null ? other.TestMap.Clone() : null;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -660,13 +676,16 @@ namespace Google.Protobuf.TestProtos {
         return true;
         return true;
       }
       }
       if (!object.Equals(TestMap, other.TestMap)) return false;
       if (!object.Equals(TestMap, other.TestMap)) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       if (testMap_ != null) hash ^= TestMap.GetHashCode();
       if (testMap_ != null) hash ^= TestMap.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -681,6 +700,9 @@ namespace Google.Protobuf.TestProtos {
         output.WriteRawTag(10);
         output.WriteRawTag(10);
         output.WriteMessage(TestMap);
         output.WriteMessage(TestMap);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -689,6 +711,9 @@ namespace Google.Protobuf.TestProtos {
       if (testMap_ != null) {
       if (testMap_ != null) {
         size += 1 + pb::CodedOutputStream.ComputeMessageSize(TestMap);
         size += 1 + pb::CodedOutputStream.ComputeMessageSize(TestMap);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -703,6 +728,7 @@ namespace Google.Protobuf.TestProtos {
         }
         }
         TestMap.MergeFrom(other.TestMap);
         TestMap.MergeFrom(other.TestMap);
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -711,7 +737,7 @@ namespace Google.Protobuf.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             if (testMap_ == null) {
             if (testMap_ == null) {
@@ -728,6 +754,7 @@ namespace Google.Protobuf.TestProtos {
 
 
   public sealed partial class TestMessageMap : pb::IMessage<TestMessageMap> {
   public sealed partial class TestMessageMap : pb::IMessage<TestMessageMap> {
     private static readonly pb::MessageParser<TestMessageMap> _parser = new pb::MessageParser<TestMessageMap>(() => new TestMessageMap());
     private static readonly pb::MessageParser<TestMessageMap> _parser = new pb::MessageParser<TestMessageMap>(() => new TestMessageMap());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<TestMessageMap> Parser { get { return _parser; } }
     public static pb::MessageParser<TestMessageMap> Parser { get { return _parser; } }
 
 
@@ -751,6 +778,7 @@ namespace Google.Protobuf.TestProtos {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public TestMessageMap(TestMessageMap other) : this() {
     public TestMessageMap(TestMessageMap other) : this() {
       mapInt32Message_ = other.mapInt32Message_.Clone();
       mapInt32Message_ = other.mapInt32Message_.Clone();
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -782,13 +810,16 @@ namespace Google.Protobuf.TestProtos {
         return true;
         return true;
       }
       }
       if (!MapInt32Message.Equals(other.MapInt32Message)) return false;
       if (!MapInt32Message.Equals(other.MapInt32Message)) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       hash ^= MapInt32Message.GetHashCode();
       hash ^= MapInt32Message.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -800,12 +831,18 @@ namespace Google.Protobuf.TestProtos {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public void WriteTo(pb::CodedOutputStream output) {
     public void WriteTo(pb::CodedOutputStream output) {
       mapInt32Message_.WriteTo(output, _map_mapInt32Message_codec);
       mapInt32Message_.WriteTo(output, _map_mapInt32Message_codec);
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public int CalculateSize() {
     public int CalculateSize() {
       int size = 0;
       int size = 0;
       size += mapInt32Message_.CalculateSize(_map_mapInt32Message_codec);
       size += mapInt32Message_.CalculateSize(_map_mapInt32Message_codec);
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -815,6 +852,7 @@ namespace Google.Protobuf.TestProtos {
         return;
         return;
       }
       }
       mapInt32Message_.Add(other.mapInt32Message_);
       mapInt32Message_.Add(other.mapInt32Message_);
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -823,7 +861,7 @@ namespace Google.Protobuf.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             mapInt32Message_.AddEntriesFrom(input, _map_mapInt32Message_codec);
             mapInt32Message_.AddEntriesFrom(input, _map_mapInt32Message_codec);
@@ -840,6 +878,7 @@ namespace Google.Protobuf.TestProtos {
   /// </summary>
   /// </summary>
   public sealed partial class TestSameTypeMap : pb::IMessage<TestSameTypeMap> {
   public sealed partial class TestSameTypeMap : pb::IMessage<TestSameTypeMap> {
     private static readonly pb::MessageParser<TestSameTypeMap> _parser = new pb::MessageParser<TestSameTypeMap>(() => new TestSameTypeMap());
     private static readonly pb::MessageParser<TestSameTypeMap> _parser = new pb::MessageParser<TestSameTypeMap>(() => new TestSameTypeMap());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<TestSameTypeMap> Parser { get { return _parser; } }
     public static pb::MessageParser<TestSameTypeMap> Parser { get { return _parser; } }
 
 
@@ -864,6 +903,7 @@ namespace Google.Protobuf.TestProtos {
     public TestSameTypeMap(TestSameTypeMap other) : this() {
     public TestSameTypeMap(TestSameTypeMap other) : this() {
       map1_ = other.map1_.Clone();
       map1_ = other.map1_.Clone();
       map2_ = other.map2_.Clone();
       map2_ = other.map2_.Clone();
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -906,7 +946,7 @@ namespace Google.Protobuf.TestProtos {
       }
       }
       if (!Map1.Equals(other.Map1)) return false;
       if (!Map1.Equals(other.Map1)) return false;
       if (!Map2.Equals(other.Map2)) return false;
       if (!Map2.Equals(other.Map2)) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -914,6 +954,9 @@ namespace Google.Protobuf.TestProtos {
       int hash = 1;
       int hash = 1;
       hash ^= Map1.GetHashCode();
       hash ^= Map1.GetHashCode();
       hash ^= Map2.GetHashCode();
       hash ^= Map2.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -926,6 +969,9 @@ namespace Google.Protobuf.TestProtos {
     public void WriteTo(pb::CodedOutputStream output) {
     public void WriteTo(pb::CodedOutputStream output) {
       map1_.WriteTo(output, _map_map1_codec);
       map1_.WriteTo(output, _map_map1_codec);
       map2_.WriteTo(output, _map_map2_codec);
       map2_.WriteTo(output, _map_map2_codec);
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -933,6 +979,9 @@ namespace Google.Protobuf.TestProtos {
       int size = 0;
       int size = 0;
       size += map1_.CalculateSize(_map_map1_codec);
       size += map1_.CalculateSize(_map_map1_codec);
       size += map2_.CalculateSize(_map_map2_codec);
       size += map2_.CalculateSize(_map_map2_codec);
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -943,6 +992,7 @@ namespace Google.Protobuf.TestProtos {
       }
       }
       map1_.Add(other.map1_);
       map1_.Add(other.map1_);
       map2_.Add(other.map2_);
       map2_.Add(other.map2_);
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -951,7 +1001,7 @@ namespace Google.Protobuf.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             map1_.AddEntriesFrom(input, _map_map1_codec);
             map1_.AddEntriesFrom(input, _map_map1_codec);
@@ -969,6 +1019,7 @@ namespace Google.Protobuf.TestProtos {
 
 
   public sealed partial class TestArenaMap : pb::IMessage<TestArenaMap> {
   public sealed partial class TestArenaMap : pb::IMessage<TestArenaMap> {
     private static readonly pb::MessageParser<TestArenaMap> _parser = new pb::MessageParser<TestArenaMap>(() => new TestArenaMap());
     private static readonly pb::MessageParser<TestArenaMap> _parser = new pb::MessageParser<TestArenaMap>(() => new TestArenaMap());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<TestArenaMap> Parser { get { return _parser; } }
     public static pb::MessageParser<TestArenaMap> Parser { get { return _parser; } }
 
 
@@ -1006,6 +1057,7 @@ namespace Google.Protobuf.TestProtos {
       mapBoolBool_ = other.mapBoolBool_.Clone();
       mapBoolBool_ = other.mapBoolBool_.Clone();
       mapInt32Enum_ = other.mapInt32Enum_.Clone();
       mapInt32Enum_ = other.mapInt32Enum_.Clone();
       mapInt32ForeignMessage_ = other.mapInt32ForeignMessage_.Clone();
       mapInt32ForeignMessage_ = other.mapInt32ForeignMessage_.Clone();
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1191,7 +1243,7 @@ namespace Google.Protobuf.TestProtos {
       if (!MapBoolBool.Equals(other.MapBoolBool)) return false;
       if (!MapBoolBool.Equals(other.MapBoolBool)) return false;
       if (!MapInt32Enum.Equals(other.MapInt32Enum)) return false;
       if (!MapInt32Enum.Equals(other.MapInt32Enum)) return false;
       if (!MapInt32ForeignMessage.Equals(other.MapInt32ForeignMessage)) return false;
       if (!MapInt32ForeignMessage.Equals(other.MapInt32ForeignMessage)) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1212,6 +1264,9 @@ namespace Google.Protobuf.TestProtos {
       hash ^= MapBoolBool.GetHashCode();
       hash ^= MapBoolBool.GetHashCode();
       hash ^= MapInt32Enum.GetHashCode();
       hash ^= MapInt32Enum.GetHashCode();
       hash ^= MapInt32ForeignMessage.GetHashCode();
       hash ^= MapInt32ForeignMessage.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -1237,6 +1292,9 @@ namespace Google.Protobuf.TestProtos {
       mapBoolBool_.WriteTo(output, _map_mapBoolBool_codec);
       mapBoolBool_.WriteTo(output, _map_mapBoolBool_codec);
       mapInt32Enum_.WriteTo(output, _map_mapInt32Enum_codec);
       mapInt32Enum_.WriteTo(output, _map_mapInt32Enum_codec);
       mapInt32ForeignMessage_.WriteTo(output, _map_mapInt32ForeignMessage_codec);
       mapInt32ForeignMessage_.WriteTo(output, _map_mapInt32ForeignMessage_codec);
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1257,6 +1315,9 @@ namespace Google.Protobuf.TestProtos {
       size += mapBoolBool_.CalculateSize(_map_mapBoolBool_codec);
       size += mapBoolBool_.CalculateSize(_map_mapBoolBool_codec);
       size += mapInt32Enum_.CalculateSize(_map_mapInt32Enum_codec);
       size += mapInt32Enum_.CalculateSize(_map_mapInt32Enum_codec);
       size += mapInt32ForeignMessage_.CalculateSize(_map_mapInt32ForeignMessage_codec);
       size += mapInt32ForeignMessage_.CalculateSize(_map_mapInt32ForeignMessage_codec);
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -1280,6 +1341,7 @@ namespace Google.Protobuf.TestProtos {
       mapBoolBool_.Add(other.mapBoolBool_);
       mapBoolBool_.Add(other.mapBoolBool_);
       mapInt32Enum_.Add(other.mapInt32Enum_);
       mapInt32Enum_.Add(other.mapInt32Enum_);
       mapInt32ForeignMessage_.Add(other.mapInt32ForeignMessage_);
       mapInt32ForeignMessage_.Add(other.mapInt32ForeignMessage_);
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1288,7 +1350,7 @@ namespace Google.Protobuf.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec);
             mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec);
@@ -1362,6 +1424,7 @@ namespace Google.Protobuf.TestProtos {
   /// </summary>
   /// </summary>
   public sealed partial class MessageContainingEnumCalledType : pb::IMessage<MessageContainingEnumCalledType> {
   public sealed partial class MessageContainingEnumCalledType : pb::IMessage<MessageContainingEnumCalledType> {
     private static readonly pb::MessageParser<MessageContainingEnumCalledType> _parser = new pb::MessageParser<MessageContainingEnumCalledType>(() => new MessageContainingEnumCalledType());
     private static readonly pb::MessageParser<MessageContainingEnumCalledType> _parser = new pb::MessageParser<MessageContainingEnumCalledType>(() => new MessageContainingEnumCalledType());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<MessageContainingEnumCalledType> Parser { get { return _parser; } }
     public static pb::MessageParser<MessageContainingEnumCalledType> Parser { get { return _parser; } }
 
 
@@ -1385,6 +1448,7 @@ namespace Google.Protobuf.TestProtos {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public MessageContainingEnumCalledType(MessageContainingEnumCalledType other) : this() {
     public MessageContainingEnumCalledType(MessageContainingEnumCalledType other) : this() {
       type_ = other.type_.Clone();
       type_ = other.type_.Clone();
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1416,13 +1480,16 @@ namespace Google.Protobuf.TestProtos {
         return true;
         return true;
       }
       }
       if (!Type.Equals(other.Type)) return false;
       if (!Type.Equals(other.Type)) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       hash ^= Type.GetHashCode();
       hash ^= Type.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -1434,12 +1501,18 @@ namespace Google.Protobuf.TestProtos {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public void WriteTo(pb::CodedOutputStream output) {
     public void WriteTo(pb::CodedOutputStream output) {
       type_.WriteTo(output, _map_type_codec);
       type_.WriteTo(output, _map_type_codec);
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public int CalculateSize() {
     public int CalculateSize() {
       int size = 0;
       int size = 0;
       size += type_.CalculateSize(_map_type_codec);
       size += type_.CalculateSize(_map_type_codec);
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -1449,6 +1522,7 @@ namespace Google.Protobuf.TestProtos {
         return;
         return;
       }
       }
       type_.Add(other.type_);
       type_.Add(other.type_);
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1457,7 +1531,7 @@ namespace Google.Protobuf.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             type_.AddEntriesFrom(input, _map_type_codec);
             type_.AddEntriesFrom(input, _map_type_codec);
@@ -1485,6 +1559,7 @@ namespace Google.Protobuf.TestProtos {
   /// </summary>
   /// </summary>
   public sealed partial class MessageContainingMapCalledEntry : pb::IMessage<MessageContainingMapCalledEntry> {
   public sealed partial class MessageContainingMapCalledEntry : pb::IMessage<MessageContainingMapCalledEntry> {
     private static readonly pb::MessageParser<MessageContainingMapCalledEntry> _parser = new pb::MessageParser<MessageContainingMapCalledEntry>(() => new MessageContainingMapCalledEntry());
     private static readonly pb::MessageParser<MessageContainingMapCalledEntry> _parser = new pb::MessageParser<MessageContainingMapCalledEntry>(() => new MessageContainingMapCalledEntry());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<MessageContainingMapCalledEntry> Parser { get { return _parser; } }
     public static pb::MessageParser<MessageContainingMapCalledEntry> Parser { get { return _parser; } }
 
 
@@ -1508,6 +1583,7 @@ namespace Google.Protobuf.TestProtos {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public MessageContainingMapCalledEntry(MessageContainingMapCalledEntry other) : this() {
     public MessageContainingMapCalledEntry(MessageContainingMapCalledEntry other) : this() {
       entry_ = other.entry_.Clone();
       entry_ = other.entry_.Clone();
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1539,13 +1615,16 @@ namespace Google.Protobuf.TestProtos {
         return true;
         return true;
       }
       }
       if (!Entry.Equals(other.Entry)) return false;
       if (!Entry.Equals(other.Entry)) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       hash ^= Entry.GetHashCode();
       hash ^= Entry.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -1557,12 +1636,18 @@ namespace Google.Protobuf.TestProtos {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public void WriteTo(pb::CodedOutputStream output) {
     public void WriteTo(pb::CodedOutputStream output) {
       entry_.WriteTo(output, _map_entry_codec);
       entry_.WriteTo(output, _map_entry_codec);
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public int CalculateSize() {
     public int CalculateSize() {
       int size = 0;
       int size = 0;
       size += entry_.CalculateSize(_map_entry_codec);
       size += entry_.CalculateSize(_map_entry_codec);
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -1572,6 +1657,7 @@ namespace Google.Protobuf.TestProtos {
         return;
         return;
       }
       }
       entry_.Add(other.entry_);
       entry_.Add(other.entry_);
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1580,7 +1666,7 @@ namespace Google.Protobuf.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             entry_.AddEntriesFrom(input, _map_entry_codec);
             entry_.AddEntriesFrom(input, _map_entry_codec);

+ 68 - 27
csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs

@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: google/protobuf/test_messages_proto3.proto
+// <auto-generated>
+//     Generated by the protocol buffer compiler.  DO NOT EDIT!
+//     source: google/protobuf/test_messages_proto3.proto
+// </auto-generated>
 #pragma warning disable 1591, 0612, 3021
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code
 #region Designer generated code
 
 
@@ -27,7 +29,7 @@ namespace ProtobufTestMessages.Proto3 {
             "dWYvYW55LnByb3RvGh5nb29nbGUvcHJvdG9idWYvZHVyYXRpb24ucHJvdG8a",
             "dWYvYW55LnByb3RvGh5nb29nbGUvcHJvdG9idWYvZHVyYXRpb24ucHJvdG8a",
             "IGdvb2dsZS9wcm90b2J1Zi9maWVsZF9tYXNrLnByb3RvGhxnb29nbGUvcHJv",
             "IGdvb2dsZS9wcm90b2J1Zi9maWVsZF9tYXNrLnByb3RvGhxnb29nbGUvcHJv",
             "dG9idWYvc3RydWN0LnByb3RvGh9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1w",
             "dG9idWYvc3RydWN0LnByb3RvGh9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1w",
-            "LnByb3RvGh5nb29nbGUvcHJvdG9idWYvd3JhcHBlcnMucHJvdG8irDsKElRl",
+            "LnByb3RvGh5nb29nbGUvcHJvdG9idWYvd3JhcHBlcnMucHJvdG8itDsKElRl",
             "c3RBbGxUeXBlc1Byb3RvMxIWCg5vcHRpb25hbF9pbnQzMhgBIAEoBRIWCg5v",
             "c3RBbGxUeXBlc1Byb3RvMxIWCg5vcHRpb25hbF9pbnQzMhgBIAEoBRIWCg5v",
             "cHRpb25hbF9pbnQ2NBgCIAEoAxIXCg9vcHRpb25hbF91aW50MzIYAyABKA0S",
             "cHRpb25hbF9pbnQ2NBgCIAEoAxIXCg9vcHRpb25hbF91aW50MzIYAyABKA0S",
             "FwoPb3B0aW9uYWxfdWludDY0GAQgASgEEhcKD29wdGlvbmFsX3NpbnQzMhgF",
             "FwoPb3B0aW9uYWxfdWludDY0GAQgASgEEhcKD29wdGlvbmFsX3NpbnQzMhgF",
@@ -196,11 +198,11 @@ namespace ProtobufTestMessages.Proto3 {
             "Z0ZvcmVpZ25FbnVtRW50cnkSCwoDa2V5GAEgASgJEjkKBXZhbHVlGAIgASgO",
             "Z0ZvcmVpZ25FbnVtRW50cnkSCwoDa2V5GAEgASgJEjkKBXZhbHVlGAIgASgO",
             "MioucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuRm9yZWlnbkVudW06",
             "MioucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuRm9yZWlnbkVudW06",
             "AjgBIjkKCk5lc3RlZEVudW0SBwoDRk9PEAASBwoDQkFSEAESBwoDQkFaEAIS",
             "AjgBIjkKCk5lc3RlZEVudW0SBwoDRk9PEAASBwoDQkFSEAESBwoDQkFaEAIS",
-            "EAoDTkVHEP///////////wFCDQoLb25lb2ZfZmllbGQiGwoORm9yZWlnbk1l",
-            "c3NhZ2USCQoBYxgBIAEoBSpACgtGb3JlaWduRW51bRIPCgtGT1JFSUdOX0ZP",
-            "TxAAEg8KC0ZPUkVJR05fQkFSEAESDwoLRk9SRUlHTl9CQVoQAkI4Cihjb20u",
-            "Z29vZ2xlLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zSAH4AQGiAgZQ",
-            "cm90bzNiBnByb3RvMw=="));
+            "EAoDTkVHEP///////////wFCDQoLb25lb2ZfZmllbGRKBgj1AxD/AyIbCg5G",
+            "b3JlaWduTWVzc2FnZRIJCgFjGAEgASgFKkAKC0ZvcmVpZ25FbnVtEg8KC0ZP",
+            "UkVJR05fRk9PEAASDwoLRk9SRUlHTl9CQVIQARIPCgtGT1JFSUdOX0JBWhAC",
+            "QjgKKGNvbS5nb29nbGUucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzNI",
+            "AfgBAaICBlByb3RvM2IGcHJvdG8z"));
       descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
       descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
           new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.DurationReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.FieldMaskReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.StructReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.WrappersReflection.Descriptor, },
           new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.DurationReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.FieldMaskReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.StructReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.WrappersReflection.Descriptor, },
           new pbr::GeneratedClrTypeInfo(new[] {typeof(global::ProtobufTestMessages.Proto3.ForeignEnum), }, new pbr::GeneratedClrTypeInfo[] {
           new pbr::GeneratedClrTypeInfo(new[] {typeof(global::ProtobufTestMessages.Proto3.ForeignEnum), }, new pbr::GeneratedClrTypeInfo[] {
@@ -233,6 +235,7 @@ namespace ProtobufTestMessages.Proto3 {
   /// </summary>
   /// </summary>
   public sealed partial class TestAllTypesProto3 : pb::IMessage<TestAllTypesProto3> {
   public sealed partial class TestAllTypesProto3 : pb::IMessage<TestAllTypesProto3> {
     private static readonly pb::MessageParser<TestAllTypesProto3> _parser = new pb::MessageParser<TestAllTypesProto3>(() => new TestAllTypesProto3());
     private static readonly pb::MessageParser<TestAllTypesProto3> _parser = new pb::MessageParser<TestAllTypesProto3>(() => new TestAllTypesProto3());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<TestAllTypesProto3> Parser { get { return _parser; } }
     public static pb::MessageParser<TestAllTypesProto3> Parser { get { return _parser; } }
 
 
@@ -395,6 +398,7 @@ namespace ProtobufTestMessages.Proto3 {
           break;
           break;
       }
       }
 
 
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1730,8 +1734,8 @@ namespace ProtobufTestMessages.Proto3 {
       if (OptionalFixed64 != other.OptionalFixed64) return false;
       if (OptionalFixed64 != other.OptionalFixed64) return false;
       if (OptionalSfixed32 != other.OptionalSfixed32) return false;
       if (OptionalSfixed32 != other.OptionalSfixed32) return false;
       if (OptionalSfixed64 != other.OptionalSfixed64) return false;
       if (OptionalSfixed64 != other.OptionalSfixed64) return false;
-      if (OptionalFloat != other.OptionalFloat) return false;
-      if (OptionalDouble != other.OptionalDouble) return false;
+      if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(OptionalFloat, other.OptionalFloat)) return false;
+      if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(OptionalDouble, other.OptionalDouble)) return false;
       if (OptionalBool != other.OptionalBool) return false;
       if (OptionalBool != other.OptionalBool) return false;
       if (OptionalString != other.OptionalString) return false;
       if (OptionalString != other.OptionalString) return false;
       if (OptionalBytes != other.OptionalBytes) return false;
       if (OptionalBytes != other.OptionalBytes) return false;
@@ -1788,16 +1792,16 @@ namespace ProtobufTestMessages.Proto3 {
       if (OneofBytes != other.OneofBytes) return false;
       if (OneofBytes != other.OneofBytes) return false;
       if (OneofBool != other.OneofBool) return false;
       if (OneofBool != other.OneofBool) return false;
       if (OneofUint64 != other.OneofUint64) return false;
       if (OneofUint64 != other.OneofUint64) return false;
-      if (OneofFloat != other.OneofFloat) return false;
-      if (OneofDouble != other.OneofDouble) return false;
+      if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(OneofFloat, other.OneofFloat)) return false;
+      if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(OneofDouble, other.OneofDouble)) return false;
       if (OneofEnum != other.OneofEnum) return false;
       if (OneofEnum != other.OneofEnum) return false;
       if (OptionalBoolWrapper != other.OptionalBoolWrapper) return false;
       if (OptionalBoolWrapper != other.OptionalBoolWrapper) return false;
       if (OptionalInt32Wrapper != other.OptionalInt32Wrapper) return false;
       if (OptionalInt32Wrapper != other.OptionalInt32Wrapper) return false;
       if (OptionalInt64Wrapper != other.OptionalInt64Wrapper) return false;
       if (OptionalInt64Wrapper != other.OptionalInt64Wrapper) return false;
       if (OptionalUint32Wrapper != other.OptionalUint32Wrapper) return false;
       if (OptionalUint32Wrapper != other.OptionalUint32Wrapper) return false;
       if (OptionalUint64Wrapper != other.OptionalUint64Wrapper) return false;
       if (OptionalUint64Wrapper != other.OptionalUint64Wrapper) return false;
-      if (OptionalFloatWrapper != other.OptionalFloatWrapper) return false;
-      if (OptionalDoubleWrapper != other.OptionalDoubleWrapper) return false;
+      if (!pbc::ProtobufEqualityComparers.BitwiseNullableSingleEqualityComparer.Equals(OptionalFloatWrapper, other.OptionalFloatWrapper)) return false;
+      if (!pbc::ProtobufEqualityComparers.BitwiseNullableDoubleEqualityComparer.Equals(OptionalDoubleWrapper, other.OptionalDoubleWrapper)) return false;
       if (OptionalStringWrapper != other.OptionalStringWrapper) return false;
       if (OptionalStringWrapper != other.OptionalStringWrapper) return false;
       if (OptionalBytesWrapper != other.OptionalBytesWrapper) return false;
       if (OptionalBytesWrapper != other.OptionalBytesWrapper) return false;
       if(!repeatedBoolWrapper_.Equals(other.repeatedBoolWrapper_)) return false;
       if(!repeatedBoolWrapper_.Equals(other.repeatedBoolWrapper_)) return false;
@@ -1840,7 +1844,7 @@ namespace ProtobufTestMessages.Proto3 {
       if (FieldName17 != other.FieldName17) return false;
       if (FieldName17 != other.FieldName17) return false;
       if (FieldName18 != other.FieldName18) return false;
       if (FieldName18 != other.FieldName18) return false;
       if (OneofFieldCase != other.OneofFieldCase) return false;
       if (OneofFieldCase != other.OneofFieldCase) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1856,8 +1860,8 @@ namespace ProtobufTestMessages.Proto3 {
       if (OptionalFixed64 != 0UL) hash ^= OptionalFixed64.GetHashCode();
       if (OptionalFixed64 != 0UL) hash ^= OptionalFixed64.GetHashCode();
       if (OptionalSfixed32 != 0) hash ^= OptionalSfixed32.GetHashCode();
       if (OptionalSfixed32 != 0) hash ^= OptionalSfixed32.GetHashCode();
       if (OptionalSfixed64 != 0L) hash ^= OptionalSfixed64.GetHashCode();
       if (OptionalSfixed64 != 0L) hash ^= OptionalSfixed64.GetHashCode();
-      if (OptionalFloat != 0F) hash ^= OptionalFloat.GetHashCode();
-      if (OptionalDouble != 0D) hash ^= OptionalDouble.GetHashCode();
+      if (OptionalFloat != 0F) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(OptionalFloat);
+      if (OptionalDouble != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(OptionalDouble);
       if (OptionalBool != false) hash ^= OptionalBool.GetHashCode();
       if (OptionalBool != false) hash ^= OptionalBool.GetHashCode();
       if (OptionalString.Length != 0) hash ^= OptionalString.GetHashCode();
       if (OptionalString.Length != 0) hash ^= OptionalString.GetHashCode();
       if (OptionalBytes.Length != 0) hash ^= OptionalBytes.GetHashCode();
       if (OptionalBytes.Length != 0) hash ^= OptionalBytes.GetHashCode();
@@ -1914,16 +1918,16 @@ namespace ProtobufTestMessages.Proto3 {
       if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) hash ^= OneofBytes.GetHashCode();
       if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) hash ^= OneofBytes.GetHashCode();
       if (oneofFieldCase_ == OneofFieldOneofCase.OneofBool) hash ^= OneofBool.GetHashCode();
       if (oneofFieldCase_ == OneofFieldOneofCase.OneofBool) hash ^= OneofBool.GetHashCode();
       if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint64) hash ^= OneofUint64.GetHashCode();
       if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint64) hash ^= OneofUint64.GetHashCode();
-      if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) hash ^= OneofFloat.GetHashCode();
-      if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) hash ^= OneofDouble.GetHashCode();
+      if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(OneofFloat);
+      if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(OneofDouble);
       if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) hash ^= OneofEnum.GetHashCode();
       if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) hash ^= OneofEnum.GetHashCode();
       if (optionalBoolWrapper_ != null) hash ^= OptionalBoolWrapper.GetHashCode();
       if (optionalBoolWrapper_ != null) hash ^= OptionalBoolWrapper.GetHashCode();
       if (optionalInt32Wrapper_ != null) hash ^= OptionalInt32Wrapper.GetHashCode();
       if (optionalInt32Wrapper_ != null) hash ^= OptionalInt32Wrapper.GetHashCode();
       if (optionalInt64Wrapper_ != null) hash ^= OptionalInt64Wrapper.GetHashCode();
       if (optionalInt64Wrapper_ != null) hash ^= OptionalInt64Wrapper.GetHashCode();
       if (optionalUint32Wrapper_ != null) hash ^= OptionalUint32Wrapper.GetHashCode();
       if (optionalUint32Wrapper_ != null) hash ^= OptionalUint32Wrapper.GetHashCode();
       if (optionalUint64Wrapper_ != null) hash ^= OptionalUint64Wrapper.GetHashCode();
       if (optionalUint64Wrapper_ != null) hash ^= OptionalUint64Wrapper.GetHashCode();
-      if (optionalFloatWrapper_ != null) hash ^= OptionalFloatWrapper.GetHashCode();
-      if (optionalDoubleWrapper_ != null) hash ^= OptionalDoubleWrapper.GetHashCode();
+      if (optionalFloatWrapper_ != null) hash ^= pbc::ProtobufEqualityComparers.BitwiseNullableSingleEqualityComparer.GetHashCode(OptionalFloatWrapper);
+      if (optionalDoubleWrapper_ != null) hash ^= pbc::ProtobufEqualityComparers.BitwiseNullableDoubleEqualityComparer.GetHashCode(OptionalDoubleWrapper);
       if (optionalStringWrapper_ != null) hash ^= OptionalStringWrapper.GetHashCode();
       if (optionalStringWrapper_ != null) hash ^= OptionalStringWrapper.GetHashCode();
       if (optionalBytesWrapper_ != null) hash ^= OptionalBytesWrapper.GetHashCode();
       if (optionalBytesWrapper_ != null) hash ^= OptionalBytesWrapper.GetHashCode();
       hash ^= repeatedBoolWrapper_.GetHashCode();
       hash ^= repeatedBoolWrapper_.GetHashCode();
@@ -1966,6 +1970,9 @@ namespace ProtobufTestMessages.Proto3 {
       if (FieldName17 != 0) hash ^= FieldName17.GetHashCode();
       if (FieldName17 != 0) hash ^= FieldName17.GetHashCode();
       if (FieldName18 != 0) hash ^= FieldName18.GetHashCode();
       if (FieldName18 != 0) hash ^= FieldName18.GetHashCode();
       hash ^= (int) oneofFieldCase_;
       hash ^= (int) oneofFieldCase_;
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -2278,6 +2285,9 @@ namespace ProtobufTestMessages.Proto3 {
         output.WriteRawTag(144, 26);
         output.WriteRawTag(144, 26);
         output.WriteInt32(FieldName18);
         output.WriteInt32(FieldName18);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -2530,6 +2540,9 @@ namespace ProtobufTestMessages.Proto3 {
       if (FieldName18 != 0) {
       if (FieldName18 != 0) {
         size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName18);
         size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName18);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -2808,7 +2821,10 @@ namespace ProtobufTestMessages.Proto3 {
           OneofUint32 = other.OneofUint32;
           OneofUint32 = other.OneofUint32;
           break;
           break;
         case OneofFieldOneofCase.OneofNestedMessage:
         case OneofFieldOneofCase.OneofNestedMessage:
-          OneofNestedMessage = other.OneofNestedMessage;
+          if (OneofNestedMessage == null) {
+            OneofNestedMessage = new global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage();
+          }
+          OneofNestedMessage.MergeFrom(other.OneofNestedMessage);
           break;
           break;
         case OneofFieldOneofCase.OneofString:
         case OneofFieldOneofCase.OneofString:
           OneofString = other.OneofString;
           OneofString = other.OneofString;
@@ -2833,6 +2849,7 @@ namespace ProtobufTestMessages.Proto3 {
           break;
           break;
       }
       }
 
 
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -2841,7 +2858,7 @@ namespace ProtobufTestMessages.Proto3 {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 8: {
           case 8: {
             OptionalInt32 = input.ReadInt32();
             OptionalInt32 = input.ReadInt32();
@@ -3414,6 +3431,7 @@ namespace ProtobufTestMessages.Proto3 {
 
 
       public sealed partial class NestedMessage : pb::IMessage<NestedMessage> {
       public sealed partial class NestedMessage : pb::IMessage<NestedMessage> {
         private static readonly pb::MessageParser<NestedMessage> _parser = new pb::MessageParser<NestedMessage>(() => new NestedMessage());
         private static readonly pb::MessageParser<NestedMessage> _parser = new pb::MessageParser<NestedMessage>(() => new NestedMessage());
+        private pb::UnknownFieldSet _unknownFields;
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         public static pb::MessageParser<NestedMessage> Parser { get { return _parser; } }
         public static pb::MessageParser<NestedMessage> Parser { get { return _parser; } }
 
 
@@ -3438,6 +3456,7 @@ namespace ProtobufTestMessages.Proto3 {
         public NestedMessage(NestedMessage other) : this() {
         public NestedMessage(NestedMessage other) : this() {
           a_ = other.a_;
           a_ = other.a_;
           Corecursive = other.corecursive_ != null ? other.Corecursive.Clone() : null;
           Corecursive = other.corecursive_ != null ? other.Corecursive.Clone() : null;
+          _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -3482,7 +3501,7 @@ namespace ProtobufTestMessages.Proto3 {
           }
           }
           if (A != other.A) return false;
           if (A != other.A) return false;
           if (!object.Equals(Corecursive, other.Corecursive)) return false;
           if (!object.Equals(Corecursive, other.Corecursive)) return false;
-          return true;
+          return Equals(_unknownFields, other._unknownFields);
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -3490,6 +3509,9 @@ namespace ProtobufTestMessages.Proto3 {
           int hash = 1;
           int hash = 1;
           if (A != 0) hash ^= A.GetHashCode();
           if (A != 0) hash ^= A.GetHashCode();
           if (corecursive_ != null) hash ^= Corecursive.GetHashCode();
           if (corecursive_ != null) hash ^= Corecursive.GetHashCode();
+          if (_unknownFields != null) {
+            hash ^= _unknownFields.GetHashCode();
+          }
           return hash;
           return hash;
         }
         }
 
 
@@ -3508,6 +3530,9 @@ namespace ProtobufTestMessages.Proto3 {
             output.WriteRawTag(18);
             output.WriteRawTag(18);
             output.WriteMessage(Corecursive);
             output.WriteMessage(Corecursive);
           }
           }
+          if (_unknownFields != null) {
+            _unknownFields.WriteTo(output);
+          }
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -3519,6 +3544,9 @@ namespace ProtobufTestMessages.Proto3 {
           if (corecursive_ != null) {
           if (corecursive_ != null) {
             size += 1 + pb::CodedOutputStream.ComputeMessageSize(Corecursive);
             size += 1 + pb::CodedOutputStream.ComputeMessageSize(Corecursive);
           }
           }
+          if (_unknownFields != null) {
+            size += _unknownFields.CalculateSize();
+          }
           return size;
           return size;
         }
         }
 
 
@@ -3536,6 +3564,7 @@ namespace ProtobufTestMessages.Proto3 {
             }
             }
             Corecursive.MergeFrom(other.Corecursive);
             Corecursive.MergeFrom(other.Corecursive);
           }
           }
+          _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -3544,7 +3573,7 @@ namespace ProtobufTestMessages.Proto3 {
           while ((tag = input.ReadTag()) != 0) {
           while ((tag = input.ReadTag()) != 0) {
             switch(tag) {
             switch(tag) {
               default:
               default:
-                input.SkipLastField();
+                _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
                 break;
                 break;
               case 8: {
               case 8: {
                 A = input.ReadInt32();
                 A = input.ReadInt32();
@@ -3570,6 +3599,7 @@ namespace ProtobufTestMessages.Proto3 {
 
 
   public sealed partial class ForeignMessage : pb::IMessage<ForeignMessage> {
   public sealed partial class ForeignMessage : pb::IMessage<ForeignMessage> {
     private static readonly pb::MessageParser<ForeignMessage> _parser = new pb::MessageParser<ForeignMessage>(() => new ForeignMessage());
     private static readonly pb::MessageParser<ForeignMessage> _parser = new pb::MessageParser<ForeignMessage>(() => new ForeignMessage());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<ForeignMessage> Parser { get { return _parser; } }
     public static pb::MessageParser<ForeignMessage> Parser { get { return _parser; } }
 
 
@@ -3593,6 +3623,7 @@ namespace ProtobufTestMessages.Proto3 {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public ForeignMessage(ForeignMessage other) : this() {
     public ForeignMessage(ForeignMessage other) : this() {
       c_ = other.c_;
       c_ = other.c_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -3625,13 +3656,16 @@ namespace ProtobufTestMessages.Proto3 {
         return true;
         return true;
       }
       }
       if (C != other.C) return false;
       if (C != other.C) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       if (C != 0) hash ^= C.GetHashCode();
       if (C != 0) hash ^= C.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -3646,6 +3680,9 @@ namespace ProtobufTestMessages.Proto3 {
         output.WriteRawTag(8);
         output.WriteRawTag(8);
         output.WriteInt32(C);
         output.WriteInt32(C);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -3654,6 +3691,9 @@ namespace ProtobufTestMessages.Proto3 {
       if (C != 0) {
       if (C != 0) {
         size += 1 + pb::CodedOutputStream.ComputeInt32Size(C);
         size += 1 + pb::CodedOutputStream.ComputeInt32Size(C);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -3665,6 +3705,7 @@ namespace ProtobufTestMessages.Proto3 {
       if (other.C != 0) {
       if (other.C != 0) {
         C = other.C;
         C = other.C;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -3673,7 +3714,7 @@ namespace ProtobufTestMessages.Proto3 {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 8: {
           case 8: {
             C = input.ReadInt32();
             C = input.ReadInt32();

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 206 - 31
csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs


+ 26 - 14
csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs

@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: google/protobuf/unittest_import_proto3.proto
+// <auto-generated>
+//     Generated by the protocol buffer compiler.  DO NOT EDIT!
+//     source: unittest_import_proto3.proto
+// </auto-generated>
 #pragma warning disable 1591, 0612, 3021
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code
 #region Designer generated code
 
 
@@ -9,11 +11,11 @@ using pbr = global::Google.Protobuf.Reflection;
 using scg = global::System.Collections.Generic;
 using scg = global::System.Collections.Generic;
 namespace Google.Protobuf.TestProtos {
 namespace Google.Protobuf.TestProtos {
 
 
-  /// <summary>Holder for reflection information generated from google/protobuf/unittest_import_proto3.proto</summary>
+  /// <summary>Holder for reflection information generated from unittest_import_proto3.proto</summary>
   public static partial class UnittestImportProto3Reflection {
   public static partial class UnittestImportProto3Reflection {
 
 
     #region Descriptor
     #region Descriptor
-    /// <summary>File descriptor for google/protobuf/unittest_import_proto3.proto</summary>
+    /// <summary>File descriptor for unittest_import_proto3.proto</summary>
     public static pbr::FileDescriptor Descriptor {
     public static pbr::FileDescriptor Descriptor {
       get { return descriptor; }
       get { return descriptor; }
     }
     }
@@ -22,14 +24,12 @@ namespace Google.Protobuf.TestProtos {
     static UnittestImportProto3Reflection() {
     static UnittestImportProto3Reflection() {
       byte[] descriptorData = global::System.Convert.FromBase64String(
       byte[] descriptorData = global::System.Convert.FromBase64String(
           string.Concat(
           string.Concat(
-            "Cixnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfaW1wb3J0X3Byb3RvMy5wcm90",
-            "bxIYcHJvdG9idWZfdW5pdHRlc3RfaW1wb3J0GjNnb29nbGUvcHJvdG9idWYv",
-            "dW5pdHRlc3RfaW1wb3J0X3B1YmxpY19wcm90bzMucHJvdG8iGgoNSW1wb3J0",
-            "TWVzc2FnZRIJCgFkGAEgASgFKlkKCkltcG9ydEVudW0SGwoXSU1QT1JUX0VO",
-            "VU1fVU5TUEVDSUZJRUQQABIOCgpJTVBPUlRfRk9PEAcSDgoKSU1QT1JUX0JB",
-            "UhAIEg4KCklNUE9SVF9CQVoQCUI8Chhjb20uZ29vZ2xlLnByb3RvYnVmLnRl",
-            "c3RIAfgBAaoCGkdvb2dsZS5Qcm90b2J1Zi5UZXN0UHJvdG9zUABiBnByb3Rv",
-            "Mw=="));
+            "Chx1bml0dGVzdF9pbXBvcnRfcHJvdG8zLnByb3RvEhhwcm90b2J1Zl91bml0",
+            "dGVzdF9pbXBvcnQaI3VuaXR0ZXN0X2ltcG9ydF9wdWJsaWNfcHJvdG8zLnBy",
+            "b3RvIhoKDUltcG9ydE1lc3NhZ2USCQoBZBgBIAEoBSpZCgpJbXBvcnRFbnVt",
+            "EhsKF0lNUE9SVF9FTlVNX1VOU1BFQ0lGSUVEEAASDgoKSU1QT1JUX0ZPTxAH",
+            "Eg4KCklNUE9SVF9CQVIQCBIOCgpJTVBPUlRfQkFaEAlCHaoCGkdvb2dsZS5Q",
+            "cm90b2J1Zi5UZXN0UHJvdG9zUABiBnByb3RvMw=="));
       descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
       descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
           new pbr::FileDescriptor[] { global::Google.Protobuf.TestProtos.UnittestImportPublicProto3Reflection.Descriptor, },
           new pbr::FileDescriptor[] { global::Google.Protobuf.TestProtos.UnittestImportPublicProto3Reflection.Descriptor, },
           new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.TestProtos.ImportEnum), }, new pbr::GeneratedClrTypeInfo[] {
           new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.TestProtos.ImportEnum), }, new pbr::GeneratedClrTypeInfo[] {
@@ -52,6 +52,7 @@ namespace Google.Protobuf.TestProtos {
   #region Messages
   #region Messages
   public sealed partial class ImportMessage : pb::IMessage<ImportMessage> {
   public sealed partial class ImportMessage : pb::IMessage<ImportMessage> {
     private static readonly pb::MessageParser<ImportMessage> _parser = new pb::MessageParser<ImportMessage>(() => new ImportMessage());
     private static readonly pb::MessageParser<ImportMessage> _parser = new pb::MessageParser<ImportMessage>(() => new ImportMessage());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<ImportMessage> Parser { get { return _parser; } }
     public static pb::MessageParser<ImportMessage> Parser { get { return _parser; } }
 
 
@@ -75,6 +76,7 @@ namespace Google.Protobuf.TestProtos {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public ImportMessage(ImportMessage other) : this() {
     public ImportMessage(ImportMessage other) : this() {
       d_ = other.d_;
       d_ = other.d_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -107,13 +109,16 @@ namespace Google.Protobuf.TestProtos {
         return true;
         return true;
       }
       }
       if (D != other.D) return false;
       if (D != other.D) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       if (D != 0) hash ^= D.GetHashCode();
       if (D != 0) hash ^= D.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -128,6 +133,9 @@ namespace Google.Protobuf.TestProtos {
         output.WriteRawTag(8);
         output.WriteRawTag(8);
         output.WriteInt32(D);
         output.WriteInt32(D);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -136,6 +144,9 @@ namespace Google.Protobuf.TestProtos {
       if (D != 0) {
       if (D != 0) {
         size += 1 + pb::CodedOutputStream.ComputeInt32Size(D);
         size += 1 + pb::CodedOutputStream.ComputeInt32Size(D);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -147,6 +158,7 @@ namespace Google.Protobuf.TestProtos {
       if (other.D != 0) {
       if (other.D != 0) {
         D = other.D;
         D = other.D;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -155,7 +167,7 @@ namespace Google.Protobuf.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 8: {
           case 8: {
             D = input.ReadInt32();
             D = input.ReadInt32();

+ 24 - 10
csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs

@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: google/protobuf/unittest_import_public_proto3.proto
+// <auto-generated>
+//     Generated by the protocol buffer compiler.  DO NOT EDIT!
+//     source: unittest_import_public_proto3.proto
+// </auto-generated>
 #pragma warning disable 1591, 0612, 3021
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code
 #region Designer generated code
 
 
@@ -9,11 +11,11 @@ using pbr = global::Google.Protobuf.Reflection;
 using scg = global::System.Collections.Generic;
 using scg = global::System.Collections.Generic;
 namespace Google.Protobuf.TestProtos {
 namespace Google.Protobuf.TestProtos {
 
 
-  /// <summary>Holder for reflection information generated from google/protobuf/unittest_import_public_proto3.proto</summary>
+  /// <summary>Holder for reflection information generated from unittest_import_public_proto3.proto</summary>
   public static partial class UnittestImportPublicProto3Reflection {
   public static partial class UnittestImportPublicProto3Reflection {
 
 
     #region Descriptor
     #region Descriptor
-    /// <summary>File descriptor for google/protobuf/unittest_import_public_proto3.proto</summary>
+    /// <summary>File descriptor for unittest_import_public_proto3.proto</summary>
     public static pbr::FileDescriptor Descriptor {
     public static pbr::FileDescriptor Descriptor {
       get { return descriptor; }
       get { return descriptor; }
     }
     }
@@ -22,10 +24,10 @@ namespace Google.Protobuf.TestProtos {
     static UnittestImportPublicProto3Reflection() {
     static UnittestImportPublicProto3Reflection() {
       byte[] descriptorData = global::System.Convert.FromBase64String(
       byte[] descriptorData = global::System.Convert.FromBase64String(
           string.Concat(
           string.Concat(
-            "CjNnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfaW1wb3J0X3B1YmxpY19wcm90",
-            "bzMucHJvdG8SGHByb3RvYnVmX3VuaXR0ZXN0X2ltcG9ydCIgChNQdWJsaWNJ",
-            "bXBvcnRNZXNzYWdlEgkKAWUYASABKAVCNwoYY29tLmdvb2dsZS5wcm90b2J1",
-            "Zi50ZXN0qgIaR29vZ2xlLlByb3RvYnVmLlRlc3RQcm90b3NiBnByb3RvMw=="));
+            "CiN1bml0dGVzdF9pbXBvcnRfcHVibGljX3Byb3RvMy5wcm90bxIYcHJvdG9i",
+            "dWZfdW5pdHRlc3RfaW1wb3J0IiAKE1B1YmxpY0ltcG9ydE1lc3NhZ2USCQoB",
+            "ZRgBIAEoBUIdqgIaR29vZ2xlLlByb3RvYnVmLlRlc3RQcm90b3NiBnByb3Rv",
+            "Mw=="));
       descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
       descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
           new pbr::FileDescriptor[] { },
           new pbr::FileDescriptor[] { },
           new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
           new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
@@ -38,6 +40,7 @@ namespace Google.Protobuf.TestProtos {
   #region Messages
   #region Messages
   public sealed partial class PublicImportMessage : pb::IMessage<PublicImportMessage> {
   public sealed partial class PublicImportMessage : pb::IMessage<PublicImportMessage> {
     private static readonly pb::MessageParser<PublicImportMessage> _parser = new pb::MessageParser<PublicImportMessage>(() => new PublicImportMessage());
     private static readonly pb::MessageParser<PublicImportMessage> _parser = new pb::MessageParser<PublicImportMessage>(() => new PublicImportMessage());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<PublicImportMessage> Parser { get { return _parser; } }
     public static pb::MessageParser<PublicImportMessage> Parser { get { return _parser; } }
 
 
@@ -61,6 +64,7 @@ namespace Google.Protobuf.TestProtos {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public PublicImportMessage(PublicImportMessage other) : this() {
     public PublicImportMessage(PublicImportMessage other) : this() {
       e_ = other.e_;
       e_ = other.e_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -93,13 +97,16 @@ namespace Google.Protobuf.TestProtos {
         return true;
         return true;
       }
       }
       if (E != other.E) return false;
       if (E != other.E) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       if (E != 0) hash ^= E.GetHashCode();
       if (E != 0) hash ^= E.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -114,6 +121,9 @@ namespace Google.Protobuf.TestProtos {
         output.WriteRawTag(8);
         output.WriteRawTag(8);
         output.WriteInt32(E);
         output.WriteInt32(E);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -122,6 +132,9 @@ namespace Google.Protobuf.TestProtos {
       if (E != 0) {
       if (E != 0) {
         size += 1 + pb::CodedOutputStream.ComputeInt32Size(E);
         size += 1 + pb::CodedOutputStream.ComputeInt32Size(E);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -133,6 +146,7 @@ namespace Google.Protobuf.TestProtos {
       if (other.E != 0) {
       if (other.E != 0) {
         E = other.E;
         E = other.E;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -141,7 +155,7 @@ namespace Google.Protobuf.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 8: {
           case 8: {
             E = input.ReadInt32();
             E = input.ReadInt32();

+ 188 - 30
csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs

@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: unittest_issues.proto
+// <auto-generated>
+//     Generated by the protocol buffer compiler.  DO NOT EDIT!
+//     source: unittest_issues.proto
+// </auto-generated>
 #pragma warning disable 1591, 0612, 3021
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code
 #region Designer generated code
 
 
@@ -48,8 +50,8 @@ namespace UnitTest.Issues.TestProtos {
             "GAEgASgFEgkKAXkYAiABKAVCBwoFdmFsdWUqVQoMTmVnYXRpdmVFbnVtEhYK",
             "GAEgASgFEgkKAXkYAiABKAVCBwoFdmFsdWUqVQoMTmVnYXRpdmVFbnVtEhYK",
             "Ek5FR0FUSVZFX0VOVU1fWkVSTxAAEhYKCUZpdmVCZWxvdxD7//////////8B",
             "Ek5FR0FUSVZFX0VOVU1fWkVSTxAAEhYKCUZpdmVCZWxvdxD7//////////8B",
             "EhUKCE1pbnVzT25lEP///////////wEqLgoORGVwcmVjYXRlZEVudW0SEwoP",
             "EhUKCE1pbnVzT25lEP///////////wEqLgoORGVwcmVjYXRlZEVudW0SEwoP",
-            "REVQUkVDQVRFRF9aRVJPEAASBwoDb25lEAFCH0gBqgIaVW5pdFRlc3QuSXNz",
-            "dWVzLlRlc3RQcm90b3NiBnByb3RvMw=="));
+            "REVQUkVDQVRFRF9aRVJPEAASBwoDb25lEAFCHaoCGlVuaXRUZXN0Lklzc3Vl",
+            "cy5UZXN0UHJvdG9zYgZwcm90bzM="));
       descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
       descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
           new pbr::FileDescriptor[] { },
           new pbr::FileDescriptor[] { },
           new pbr::GeneratedClrTypeInfo(new[] {typeof(global::UnitTest.Issues.TestProtos.NegativeEnum), typeof(global::UnitTest.Issues.TestProtos.DeprecatedEnum), }, new pbr::GeneratedClrTypeInfo[] {
           new pbr::GeneratedClrTypeInfo(new[] {typeof(global::UnitTest.Issues.TestProtos.NegativeEnum), typeof(global::UnitTest.Issues.TestProtos.DeprecatedEnum), }, new pbr::GeneratedClrTypeInfo[] {
@@ -88,6 +90,7 @@ namespace UnitTest.Issues.TestProtos {
   /// </summary>
   /// </summary>
   public sealed partial class Issue307 : pb::IMessage<Issue307> {
   public sealed partial class Issue307 : pb::IMessage<Issue307> {
     private static readonly pb::MessageParser<Issue307> _parser = new pb::MessageParser<Issue307>(() => new Issue307());
     private static readonly pb::MessageParser<Issue307> _parser = new pb::MessageParser<Issue307>(() => new Issue307());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<Issue307> Parser { get { return _parser; } }
     public static pb::MessageParser<Issue307> Parser { get { return _parser; } }
 
 
@@ -110,6 +113,7 @@ namespace UnitTest.Issues.TestProtos {
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public Issue307(Issue307 other) : this() {
     public Issue307(Issue307 other) : this() {
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -130,12 +134,15 @@ namespace UnitTest.Issues.TestProtos {
       if (ReferenceEquals(other, this)) {
       if (ReferenceEquals(other, this)) {
         return true;
         return true;
       }
       }
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -146,11 +153,17 @@ namespace UnitTest.Issues.TestProtos {
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public void WriteTo(pb::CodedOutputStream output) {
     public void WriteTo(pb::CodedOutputStream output) {
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public int CalculateSize() {
     public int CalculateSize() {
       int size = 0;
       int size = 0;
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -159,6 +172,7 @@ namespace UnitTest.Issues.TestProtos {
       if (other == null) {
       if (other == null) {
         return;
         return;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -167,7 +181,7 @@ namespace UnitTest.Issues.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
         }
         }
       }
       }
@@ -179,6 +193,7 @@ namespace UnitTest.Issues.TestProtos {
     public static partial class Types {
     public static partial class Types {
       public sealed partial class NestedOnce : pb::IMessage<NestedOnce> {
       public sealed partial class NestedOnce : pb::IMessage<NestedOnce> {
         private static readonly pb::MessageParser<NestedOnce> _parser = new pb::MessageParser<NestedOnce>(() => new NestedOnce());
         private static readonly pb::MessageParser<NestedOnce> _parser = new pb::MessageParser<NestedOnce>(() => new NestedOnce());
+        private pb::UnknownFieldSet _unknownFields;
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         public static pb::MessageParser<NestedOnce> Parser { get { return _parser; } }
         public static pb::MessageParser<NestedOnce> Parser { get { return _parser; } }
 
 
@@ -201,6 +216,7 @@ namespace UnitTest.Issues.TestProtos {
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         public NestedOnce(NestedOnce other) : this() {
         public NestedOnce(NestedOnce other) : this() {
+          _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -221,12 +237,15 @@ namespace UnitTest.Issues.TestProtos {
           if (ReferenceEquals(other, this)) {
           if (ReferenceEquals(other, this)) {
             return true;
             return true;
           }
           }
-          return true;
+          return Equals(_unknownFields, other._unknownFields);
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         public override int GetHashCode() {
         public override int GetHashCode() {
           int hash = 1;
           int hash = 1;
+          if (_unknownFields != null) {
+            hash ^= _unknownFields.GetHashCode();
+          }
           return hash;
           return hash;
         }
         }
 
 
@@ -237,11 +256,17 @@ namespace UnitTest.Issues.TestProtos {
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         public void WriteTo(pb::CodedOutputStream output) {
         public void WriteTo(pb::CodedOutputStream output) {
+          if (_unknownFields != null) {
+            _unknownFields.WriteTo(output);
+          }
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         public int CalculateSize() {
         public int CalculateSize() {
           int size = 0;
           int size = 0;
+          if (_unknownFields != null) {
+            size += _unknownFields.CalculateSize();
+          }
           return size;
           return size;
         }
         }
 
 
@@ -250,6 +275,7 @@ namespace UnitTest.Issues.TestProtos {
           if (other == null) {
           if (other == null) {
             return;
             return;
           }
           }
+          _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -258,7 +284,7 @@ namespace UnitTest.Issues.TestProtos {
           while ((tag = input.ReadTag()) != 0) {
           while ((tag = input.ReadTag()) != 0) {
             switch(tag) {
             switch(tag) {
               default:
               default:
-                input.SkipLastField();
+                _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
                 break;
                 break;
             }
             }
           }
           }
@@ -270,6 +296,7 @@ namespace UnitTest.Issues.TestProtos {
         public static partial class Types {
         public static partial class Types {
           public sealed partial class NestedTwice : pb::IMessage<NestedTwice> {
           public sealed partial class NestedTwice : pb::IMessage<NestedTwice> {
             private static readonly pb::MessageParser<NestedTwice> _parser = new pb::MessageParser<NestedTwice>(() => new NestedTwice());
             private static readonly pb::MessageParser<NestedTwice> _parser = new pb::MessageParser<NestedTwice>(() => new NestedTwice());
+            private pb::UnknownFieldSet _unknownFields;
             [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
             [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
             public static pb::MessageParser<NestedTwice> Parser { get { return _parser; } }
             public static pb::MessageParser<NestedTwice> Parser { get { return _parser; } }
 
 
@@ -292,6 +319,7 @@ namespace UnitTest.Issues.TestProtos {
 
 
             [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
             [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
             public NestedTwice(NestedTwice other) : this() {
             public NestedTwice(NestedTwice other) : this() {
+              _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
             }
             }
 
 
             [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
             [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -312,12 +340,15 @@ namespace UnitTest.Issues.TestProtos {
               if (ReferenceEquals(other, this)) {
               if (ReferenceEquals(other, this)) {
                 return true;
                 return true;
               }
               }
-              return true;
+              return Equals(_unknownFields, other._unknownFields);
             }
             }
 
 
             [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
             [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
             public override int GetHashCode() {
             public override int GetHashCode() {
               int hash = 1;
               int hash = 1;
+              if (_unknownFields != null) {
+                hash ^= _unknownFields.GetHashCode();
+              }
               return hash;
               return hash;
             }
             }
 
 
@@ -328,11 +359,17 @@ namespace UnitTest.Issues.TestProtos {
 
 
             [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
             [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
             public void WriteTo(pb::CodedOutputStream output) {
             public void WriteTo(pb::CodedOutputStream output) {
+              if (_unknownFields != null) {
+                _unknownFields.WriteTo(output);
+              }
             }
             }
 
 
             [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
             [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
             public int CalculateSize() {
             public int CalculateSize() {
               int size = 0;
               int size = 0;
+              if (_unknownFields != null) {
+                size += _unknownFields.CalculateSize();
+              }
               return size;
               return size;
             }
             }
 
 
@@ -341,6 +378,7 @@ namespace UnitTest.Issues.TestProtos {
               if (other == null) {
               if (other == null) {
                 return;
                 return;
               }
               }
+              _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
             }
             }
 
 
             [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
             [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -349,7 +387,7 @@ namespace UnitTest.Issues.TestProtos {
               while ((tag = input.ReadTag()) != 0) {
               while ((tag = input.ReadTag()) != 0) {
                 switch(tag) {
                 switch(tag) {
                   default:
                   default:
-                    input.SkipLastField();
+                    _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
                     break;
                     break;
                 }
                 }
               }
               }
@@ -369,6 +407,7 @@ namespace UnitTest.Issues.TestProtos {
 
 
   public sealed partial class NegativeEnumMessage : pb::IMessage<NegativeEnumMessage> {
   public sealed partial class NegativeEnumMessage : pb::IMessage<NegativeEnumMessage> {
     private static readonly pb::MessageParser<NegativeEnumMessage> _parser = new pb::MessageParser<NegativeEnumMessage>(() => new NegativeEnumMessage());
     private static readonly pb::MessageParser<NegativeEnumMessage> _parser = new pb::MessageParser<NegativeEnumMessage>(() => new NegativeEnumMessage());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<NegativeEnumMessage> Parser { get { return _parser; } }
     public static pb::MessageParser<NegativeEnumMessage> Parser { get { return _parser; } }
 
 
@@ -394,6 +433,7 @@ namespace UnitTest.Issues.TestProtos {
       value_ = other.value_;
       value_ = other.value_;
       values_ = other.values_.Clone();
       values_ = other.values_.Clone();
       packedValues_ = other.packedValues_.Clone();
       packedValues_ = other.packedValues_.Clone();
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -448,7 +488,7 @@ namespace UnitTest.Issues.TestProtos {
       if (Value != other.Value) return false;
       if (Value != other.Value) return false;
       if(!values_.Equals(other.values_)) return false;
       if(!values_.Equals(other.values_)) return false;
       if(!packedValues_.Equals(other.packedValues_)) return false;
       if(!packedValues_.Equals(other.packedValues_)) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -457,6 +497,9 @@ namespace UnitTest.Issues.TestProtos {
       if (Value != 0) hash ^= Value.GetHashCode();
       if (Value != 0) hash ^= Value.GetHashCode();
       hash ^= values_.GetHashCode();
       hash ^= values_.GetHashCode();
       hash ^= packedValues_.GetHashCode();
       hash ^= packedValues_.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -473,6 +516,9 @@ namespace UnitTest.Issues.TestProtos {
       }
       }
       values_.WriteTo(output, _repeated_values_codec);
       values_.WriteTo(output, _repeated_values_codec);
       packedValues_.WriteTo(output, _repeated_packedValues_codec);
       packedValues_.WriteTo(output, _repeated_packedValues_codec);
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -483,6 +529,9 @@ namespace UnitTest.Issues.TestProtos {
       }
       }
       size += values_.CalculateSize(_repeated_values_codec);
       size += values_.CalculateSize(_repeated_values_codec);
       size += packedValues_.CalculateSize(_repeated_packedValues_codec);
       size += packedValues_.CalculateSize(_repeated_packedValues_codec);
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -496,6 +545,7 @@ namespace UnitTest.Issues.TestProtos {
       }
       }
       values_.Add(other.values_);
       values_.Add(other.values_);
       packedValues_.Add(other.packedValues_);
       packedValues_.Add(other.packedValues_);
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -504,7 +554,7 @@ namespace UnitTest.Issues.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 8: {
           case 8: {
             value_ = (global::UnitTest.Issues.TestProtos.NegativeEnum) input.ReadEnum();
             value_ = (global::UnitTest.Issues.TestProtos.NegativeEnum) input.ReadEnum();
@@ -528,6 +578,7 @@ namespace UnitTest.Issues.TestProtos {
 
 
   public sealed partial class DeprecatedChild : pb::IMessage<DeprecatedChild> {
   public sealed partial class DeprecatedChild : pb::IMessage<DeprecatedChild> {
     private static readonly pb::MessageParser<DeprecatedChild> _parser = new pb::MessageParser<DeprecatedChild>(() => new DeprecatedChild());
     private static readonly pb::MessageParser<DeprecatedChild> _parser = new pb::MessageParser<DeprecatedChild>(() => new DeprecatedChild());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<DeprecatedChild> Parser { get { return _parser; } }
     public static pb::MessageParser<DeprecatedChild> Parser { get { return _parser; } }
 
 
@@ -550,6 +601,7 @@ namespace UnitTest.Issues.TestProtos {
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public DeprecatedChild(DeprecatedChild other) : this() {
     public DeprecatedChild(DeprecatedChild other) : this() {
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -570,12 +622,15 @@ namespace UnitTest.Issues.TestProtos {
       if (ReferenceEquals(other, this)) {
       if (ReferenceEquals(other, this)) {
         return true;
         return true;
       }
       }
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -586,11 +641,17 @@ namespace UnitTest.Issues.TestProtos {
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public void WriteTo(pb::CodedOutputStream output) {
     public void WriteTo(pb::CodedOutputStream output) {
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public int CalculateSize() {
     public int CalculateSize() {
       int size = 0;
       int size = 0;
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -599,6 +660,7 @@ namespace UnitTest.Issues.TestProtos {
       if (other == null) {
       if (other == null) {
         return;
         return;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -607,7 +669,7 @@ namespace UnitTest.Issues.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
         }
         }
       }
       }
@@ -617,6 +679,7 @@ namespace UnitTest.Issues.TestProtos {
 
 
   public sealed partial class DeprecatedFieldsMessage : pb::IMessage<DeprecatedFieldsMessage> {
   public sealed partial class DeprecatedFieldsMessage : pb::IMessage<DeprecatedFieldsMessage> {
     private static readonly pb::MessageParser<DeprecatedFieldsMessage> _parser = new pb::MessageParser<DeprecatedFieldsMessage>(() => new DeprecatedFieldsMessage());
     private static readonly pb::MessageParser<DeprecatedFieldsMessage> _parser = new pb::MessageParser<DeprecatedFieldsMessage>(() => new DeprecatedFieldsMessage());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<DeprecatedFieldsMessage> Parser { get { return _parser; } }
     public static pb::MessageParser<DeprecatedFieldsMessage> Parser { get { return _parser; } }
 
 
@@ -645,6 +708,7 @@ namespace UnitTest.Issues.TestProtos {
       messageArray_ = other.messageArray_.Clone();
       messageArray_ = other.messageArray_.Clone();
       enumValue_ = other.enumValue_;
       enumValue_ = other.enumValue_;
       enumArray_ = other.enumArray_.Clone();
       enumArray_ = other.enumArray_.Clone();
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -740,7 +804,7 @@ namespace UnitTest.Issues.TestProtos {
       if(!messageArray_.Equals(other.messageArray_)) return false;
       if(!messageArray_.Equals(other.messageArray_)) return false;
       if (EnumValue != other.EnumValue) return false;
       if (EnumValue != other.EnumValue) return false;
       if(!enumArray_.Equals(other.enumArray_)) return false;
       if(!enumArray_.Equals(other.enumArray_)) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -752,6 +816,9 @@ namespace UnitTest.Issues.TestProtos {
       hash ^= messageArray_.GetHashCode();
       hash ^= messageArray_.GetHashCode();
       if (EnumValue != 0) hash ^= EnumValue.GetHashCode();
       if (EnumValue != 0) hash ^= EnumValue.GetHashCode();
       hash ^= enumArray_.GetHashCode();
       hash ^= enumArray_.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -777,6 +844,9 @@ namespace UnitTest.Issues.TestProtos {
         output.WriteEnum((int) EnumValue);
         output.WriteEnum((int) EnumValue);
       }
       }
       enumArray_.WriteTo(output, _repeated_enumArray_codec);
       enumArray_.WriteTo(output, _repeated_enumArray_codec);
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -794,6 +864,9 @@ namespace UnitTest.Issues.TestProtos {
         size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) EnumValue);
         size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) EnumValue);
       }
       }
       size += enumArray_.CalculateSize(_repeated_enumArray_codec);
       size += enumArray_.CalculateSize(_repeated_enumArray_codec);
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -817,6 +890,7 @@ namespace UnitTest.Issues.TestProtos {
         EnumValue = other.EnumValue;
         EnumValue = other.EnumValue;
       }
       }
       enumArray_.Add(other.enumArray_);
       enumArray_.Add(other.enumArray_);
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -825,7 +899,7 @@ namespace UnitTest.Issues.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 8: {
           case 8: {
             PrimitiveValue = input.ReadInt32();
             PrimitiveValue = input.ReadInt32();
@@ -867,6 +941,7 @@ namespace UnitTest.Issues.TestProtos {
   /// </summary>
   /// </summary>
   public sealed partial class ItemField : pb::IMessage<ItemField> {
   public sealed partial class ItemField : pb::IMessage<ItemField> {
     private static readonly pb::MessageParser<ItemField> _parser = new pb::MessageParser<ItemField>(() => new ItemField());
     private static readonly pb::MessageParser<ItemField> _parser = new pb::MessageParser<ItemField>(() => new ItemField());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<ItemField> Parser { get { return _parser; } }
     public static pb::MessageParser<ItemField> Parser { get { return _parser; } }
 
 
@@ -890,6 +965,7 @@ namespace UnitTest.Issues.TestProtos {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public ItemField(ItemField other) : this() {
     public ItemField(ItemField other) : this() {
       item_ = other.item_;
       item_ = other.item_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -922,13 +998,16 @@ namespace UnitTest.Issues.TestProtos {
         return true;
         return true;
       }
       }
       if (Item != other.Item) return false;
       if (Item != other.Item) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       if (Item != 0) hash ^= Item.GetHashCode();
       if (Item != 0) hash ^= Item.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -943,6 +1022,9 @@ namespace UnitTest.Issues.TestProtos {
         output.WriteRawTag(8);
         output.WriteRawTag(8);
         output.WriteInt32(Item);
         output.WriteInt32(Item);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -951,6 +1033,9 @@ namespace UnitTest.Issues.TestProtos {
       if (Item != 0) {
       if (Item != 0) {
         size += 1 + pb::CodedOutputStream.ComputeInt32Size(Item);
         size += 1 + pb::CodedOutputStream.ComputeInt32Size(Item);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -962,6 +1047,7 @@ namespace UnitTest.Issues.TestProtos {
       if (other.Item != 0) {
       if (other.Item != 0) {
         Item = other.Item;
         Item = other.Item;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -970,7 +1056,7 @@ namespace UnitTest.Issues.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 8: {
           case 8: {
             Item = input.ReadInt32();
             Item = input.ReadInt32();
@@ -984,6 +1070,7 @@ namespace UnitTest.Issues.TestProtos {
 
 
   public sealed partial class ReservedNames : pb::IMessage<ReservedNames> {
   public sealed partial class ReservedNames : pb::IMessage<ReservedNames> {
     private static readonly pb::MessageParser<ReservedNames> _parser = new pb::MessageParser<ReservedNames>(() => new ReservedNames());
     private static readonly pb::MessageParser<ReservedNames> _parser = new pb::MessageParser<ReservedNames>(() => new ReservedNames());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<ReservedNames> Parser { get { return _parser; } }
     public static pb::MessageParser<ReservedNames> Parser { get { return _parser; } }
 
 
@@ -1008,6 +1095,7 @@ namespace UnitTest.Issues.TestProtos {
     public ReservedNames(ReservedNames other) : this() {
     public ReservedNames(ReservedNames other) : this() {
       types_ = other.types_;
       types_ = other.types_;
       descriptor_ = other.descriptor_;
       descriptor_ = other.descriptor_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1052,7 +1140,7 @@ namespace UnitTest.Issues.TestProtos {
       }
       }
       if (Types_ != other.Types_) return false;
       if (Types_ != other.Types_) return false;
       if (Descriptor_ != other.Descriptor_) return false;
       if (Descriptor_ != other.Descriptor_) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1060,6 +1148,9 @@ namespace UnitTest.Issues.TestProtos {
       int hash = 1;
       int hash = 1;
       if (Types_ != 0) hash ^= Types_.GetHashCode();
       if (Types_ != 0) hash ^= Types_.GetHashCode();
       if (Descriptor_ != 0) hash ^= Descriptor_.GetHashCode();
       if (Descriptor_ != 0) hash ^= Descriptor_.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -1078,6 +1169,9 @@ namespace UnitTest.Issues.TestProtos {
         output.WriteRawTag(16);
         output.WriteRawTag(16);
         output.WriteInt32(Descriptor_);
         output.WriteInt32(Descriptor_);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1089,6 +1183,9 @@ namespace UnitTest.Issues.TestProtos {
       if (Descriptor_ != 0) {
       if (Descriptor_ != 0) {
         size += 1 + pb::CodedOutputStream.ComputeInt32Size(Descriptor_);
         size += 1 + pb::CodedOutputStream.ComputeInt32Size(Descriptor_);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -1103,6 +1200,7 @@ namespace UnitTest.Issues.TestProtos {
       if (other.Descriptor_ != 0) {
       if (other.Descriptor_ != 0) {
         Descriptor_ = other.Descriptor_;
         Descriptor_ = other.Descriptor_;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1111,7 +1209,7 @@ namespace UnitTest.Issues.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 8: {
           case 8: {
             Types_ = input.ReadInt32();
             Types_ = input.ReadInt32();
@@ -1134,6 +1232,7 @@ namespace UnitTest.Issues.TestProtos {
       /// </summary>
       /// </summary>
       public sealed partial class SomeNestedType : pb::IMessage<SomeNestedType> {
       public sealed partial class SomeNestedType : pb::IMessage<SomeNestedType> {
         private static readonly pb::MessageParser<SomeNestedType> _parser = new pb::MessageParser<SomeNestedType>(() => new SomeNestedType());
         private static readonly pb::MessageParser<SomeNestedType> _parser = new pb::MessageParser<SomeNestedType>(() => new SomeNestedType());
+        private pb::UnknownFieldSet _unknownFields;
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         public static pb::MessageParser<SomeNestedType> Parser { get { return _parser; } }
         public static pb::MessageParser<SomeNestedType> Parser { get { return _parser; } }
 
 
@@ -1156,6 +1255,7 @@ namespace UnitTest.Issues.TestProtos {
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         public SomeNestedType(SomeNestedType other) : this() {
         public SomeNestedType(SomeNestedType other) : this() {
+          _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1176,12 +1276,15 @@ namespace UnitTest.Issues.TestProtos {
           if (ReferenceEquals(other, this)) {
           if (ReferenceEquals(other, this)) {
             return true;
             return true;
           }
           }
-          return true;
+          return Equals(_unknownFields, other._unknownFields);
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         public override int GetHashCode() {
         public override int GetHashCode() {
           int hash = 1;
           int hash = 1;
+          if (_unknownFields != null) {
+            hash ^= _unknownFields.GetHashCode();
+          }
           return hash;
           return hash;
         }
         }
 
 
@@ -1192,11 +1295,17 @@ namespace UnitTest.Issues.TestProtos {
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         public void WriteTo(pb::CodedOutputStream output) {
         public void WriteTo(pb::CodedOutputStream output) {
+          if (_unknownFields != null) {
+            _unknownFields.WriteTo(output);
+          }
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         public int CalculateSize() {
         public int CalculateSize() {
           int size = 0;
           int size = 0;
+          if (_unknownFields != null) {
+            size += _unknownFields.CalculateSize();
+          }
           return size;
           return size;
         }
         }
 
 
@@ -1205,6 +1314,7 @@ namespace UnitTest.Issues.TestProtos {
           if (other == null) {
           if (other == null) {
             return;
             return;
           }
           }
+          _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1213,7 +1323,7 @@ namespace UnitTest.Issues.TestProtos {
           while ((tag = input.ReadTag()) != 0) {
           while ((tag = input.ReadTag()) != 0) {
             switch(tag) {
             switch(tag) {
               default:
               default:
-                input.SkipLastField();
+                _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
                 break;
                 break;
             }
             }
           }
           }
@@ -1240,6 +1350,7 @@ namespace UnitTest.Issues.TestProtos {
   /// </summary>
   /// </summary>
   public sealed partial class TestJsonFieldOrdering : pb::IMessage<TestJsonFieldOrdering> {
   public sealed partial class TestJsonFieldOrdering : pb::IMessage<TestJsonFieldOrdering> {
     private static readonly pb::MessageParser<TestJsonFieldOrdering> _parser = new pb::MessageParser<TestJsonFieldOrdering>(() => new TestJsonFieldOrdering());
     private static readonly pb::MessageParser<TestJsonFieldOrdering> _parser = new pb::MessageParser<TestJsonFieldOrdering>(() => new TestJsonFieldOrdering());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<TestJsonFieldOrdering> Parser { get { return _parser; } }
     public static pb::MessageParser<TestJsonFieldOrdering> Parser { get { return _parser; } }
 
 
@@ -1282,6 +1393,7 @@ namespace UnitTest.Issues.TestProtos {
           break;
           break;
       }
       }
 
 
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1414,7 +1526,7 @@ namespace UnitTest.Issues.TestProtos {
       if (O2String != other.O2String) return false;
       if (O2String != other.O2String) return false;
       if (O1Case != other.O1Case) return false;
       if (O1Case != other.O1Case) return false;
       if (O2Case != other.O2Case) return false;
       if (O2Case != other.O2Case) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1428,6 +1540,9 @@ namespace UnitTest.Issues.TestProtos {
       if (o2Case_ == O2OneofCase.O2String) hash ^= O2String.GetHashCode();
       if (o2Case_ == O2OneofCase.O2String) hash ^= O2String.GetHashCode();
       hash ^= (int) o1Case_;
       hash ^= (int) o1Case_;
       hash ^= (int) o2Case_;
       hash ^= (int) o2Case_;
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -1462,6 +1577,9 @@ namespace UnitTest.Issues.TestProtos {
         output.WriteRawTag(48);
         output.WriteRawTag(48);
         output.WriteInt32(O2Int32);
         output.WriteInt32(O2Int32);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1485,6 +1603,9 @@ namespace UnitTest.Issues.TestProtos {
       if (o2Case_ == O2OneofCase.O2String) {
       if (o2Case_ == O2OneofCase.O2String) {
         size += 1 + pb::CodedOutputStream.ComputeStringSize(O2String);
         size += 1 + pb::CodedOutputStream.ComputeStringSize(O2String);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -1517,6 +1638,7 @@ namespace UnitTest.Issues.TestProtos {
           break;
           break;
       }
       }
 
 
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1525,7 +1647,7 @@ namespace UnitTest.Issues.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             PlainString = input.ReadString();
             PlainString = input.ReadString();
@@ -1559,6 +1681,7 @@ namespace UnitTest.Issues.TestProtos {
 
 
   public sealed partial class TestJsonName : pb::IMessage<TestJsonName> {
   public sealed partial class TestJsonName : pb::IMessage<TestJsonName> {
     private static readonly pb::MessageParser<TestJsonName> _parser = new pb::MessageParser<TestJsonName>(() => new TestJsonName());
     private static readonly pb::MessageParser<TestJsonName> _parser = new pb::MessageParser<TestJsonName>(() => new TestJsonName());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<TestJsonName> Parser { get { return _parser; } }
     public static pb::MessageParser<TestJsonName> Parser { get { return _parser; } }
 
 
@@ -1584,6 +1707,7 @@ namespace UnitTest.Issues.TestProtos {
       name_ = other.name_;
       name_ = other.name_;
       description_ = other.description_;
       description_ = other.description_;
       guid_ = other.guid_;
       guid_ = other.guid_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1643,7 +1767,7 @@ namespace UnitTest.Issues.TestProtos {
       if (Name != other.Name) return false;
       if (Name != other.Name) return false;
       if (Description != other.Description) return false;
       if (Description != other.Description) return false;
       if (Guid != other.Guid) return false;
       if (Guid != other.Guid) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1652,6 +1776,9 @@ namespace UnitTest.Issues.TestProtos {
       if (Name.Length != 0) hash ^= Name.GetHashCode();
       if (Name.Length != 0) hash ^= Name.GetHashCode();
       if (Description.Length != 0) hash ^= Description.GetHashCode();
       if (Description.Length != 0) hash ^= Description.GetHashCode();
       if (Guid.Length != 0) hash ^= Guid.GetHashCode();
       if (Guid.Length != 0) hash ^= Guid.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -1674,6 +1801,9 @@ namespace UnitTest.Issues.TestProtos {
         output.WriteRawTag(26);
         output.WriteRawTag(26);
         output.WriteString(Guid);
         output.WriteString(Guid);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1688,6 +1818,9 @@ namespace UnitTest.Issues.TestProtos {
       if (Guid.Length != 0) {
       if (Guid.Length != 0) {
         size += 1 + pb::CodedOutputStream.ComputeStringSize(Guid);
         size += 1 + pb::CodedOutputStream.ComputeStringSize(Guid);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -1705,6 +1838,7 @@ namespace UnitTest.Issues.TestProtos {
       if (other.Guid.Length != 0) {
       if (other.Guid.Length != 0) {
         Guid = other.Guid;
         Guid = other.Guid;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1713,7 +1847,7 @@ namespace UnitTest.Issues.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             Name = input.ReadString();
             Name = input.ReadString();
@@ -1740,6 +1874,7 @@ namespace UnitTest.Issues.TestProtos {
   /// </summary>
   /// </summary>
   public sealed partial class OneofMerging : pb::IMessage<OneofMerging> {
   public sealed partial class OneofMerging : pb::IMessage<OneofMerging> {
     private static readonly pb::MessageParser<OneofMerging> _parser = new pb::MessageParser<OneofMerging>(() => new OneofMerging());
     private static readonly pb::MessageParser<OneofMerging> _parser = new pb::MessageParser<OneofMerging>(() => new OneofMerging());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<OneofMerging> Parser { get { return _parser; } }
     public static pb::MessageParser<OneofMerging> Parser { get { return _parser; } }
 
 
@@ -1771,6 +1906,7 @@ namespace UnitTest.Issues.TestProtos {
           break;
           break;
       }
       }
 
 
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1835,7 +1971,7 @@ namespace UnitTest.Issues.TestProtos {
       if (Text != other.Text) return false;
       if (Text != other.Text) return false;
       if (!object.Equals(Nested, other.Nested)) return false;
       if (!object.Equals(Nested, other.Nested)) return false;
       if (ValueCase != other.ValueCase) return false;
       if (ValueCase != other.ValueCase) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1844,6 +1980,9 @@ namespace UnitTest.Issues.TestProtos {
       if (valueCase_ == ValueOneofCase.Text) hash ^= Text.GetHashCode();
       if (valueCase_ == ValueOneofCase.Text) hash ^= Text.GetHashCode();
       if (valueCase_ == ValueOneofCase.Nested) hash ^= Nested.GetHashCode();
       if (valueCase_ == ValueOneofCase.Nested) hash ^= Nested.GetHashCode();
       hash ^= (int) valueCase_;
       hash ^= (int) valueCase_;
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -1862,6 +2001,9 @@ namespace UnitTest.Issues.TestProtos {
         output.WriteRawTag(18);
         output.WriteRawTag(18);
         output.WriteMessage(Nested);
         output.WriteMessage(Nested);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1873,6 +2015,9 @@ namespace UnitTest.Issues.TestProtos {
       if (valueCase_ == ValueOneofCase.Nested) {
       if (valueCase_ == ValueOneofCase.Nested) {
         size += 1 + pb::CodedOutputStream.ComputeMessageSize(Nested);
         size += 1 + pb::CodedOutputStream.ComputeMessageSize(Nested);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -1893,6 +2038,7 @@ namespace UnitTest.Issues.TestProtos {
           break;
           break;
       }
       }
 
 
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1901,7 +2047,7 @@ namespace UnitTest.Issues.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             Text = input.ReadString();
             Text = input.ReadString();
@@ -1926,6 +2072,7 @@ namespace UnitTest.Issues.TestProtos {
     public static partial class Types {
     public static partial class Types {
       public sealed partial class Nested : pb::IMessage<Nested> {
       public sealed partial class Nested : pb::IMessage<Nested> {
         private static readonly pb::MessageParser<Nested> _parser = new pb::MessageParser<Nested>(() => new Nested());
         private static readonly pb::MessageParser<Nested> _parser = new pb::MessageParser<Nested>(() => new Nested());
+        private pb::UnknownFieldSet _unknownFields;
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         public static pb::MessageParser<Nested> Parser { get { return _parser; } }
         public static pb::MessageParser<Nested> Parser { get { return _parser; } }
 
 
@@ -1950,6 +2097,7 @@ namespace UnitTest.Issues.TestProtos {
         public Nested(Nested other) : this() {
         public Nested(Nested other) : this() {
           x_ = other.x_;
           x_ = other.x_;
           y_ = other.y_;
           y_ = other.y_;
+          _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1994,7 +2142,7 @@ namespace UnitTest.Issues.TestProtos {
           }
           }
           if (X != other.X) return false;
           if (X != other.X) return false;
           if (Y != other.Y) return false;
           if (Y != other.Y) return false;
-          return true;
+          return Equals(_unknownFields, other._unknownFields);
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -2002,6 +2150,9 @@ namespace UnitTest.Issues.TestProtos {
           int hash = 1;
           int hash = 1;
           if (X != 0) hash ^= X.GetHashCode();
           if (X != 0) hash ^= X.GetHashCode();
           if (Y != 0) hash ^= Y.GetHashCode();
           if (Y != 0) hash ^= Y.GetHashCode();
+          if (_unknownFields != null) {
+            hash ^= _unknownFields.GetHashCode();
+          }
           return hash;
           return hash;
         }
         }
 
 
@@ -2020,6 +2171,9 @@ namespace UnitTest.Issues.TestProtos {
             output.WriteRawTag(16);
             output.WriteRawTag(16);
             output.WriteInt32(Y);
             output.WriteInt32(Y);
           }
           }
+          if (_unknownFields != null) {
+            _unknownFields.WriteTo(output);
+          }
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -2031,6 +2185,9 @@ namespace UnitTest.Issues.TestProtos {
           if (Y != 0) {
           if (Y != 0) {
             size += 1 + pb::CodedOutputStream.ComputeInt32Size(Y);
             size += 1 + pb::CodedOutputStream.ComputeInt32Size(Y);
           }
           }
+          if (_unknownFields != null) {
+            size += _unknownFields.CalculateSize();
+          }
           return size;
           return size;
         }
         }
 
 
@@ -2045,6 +2202,7 @@ namespace UnitTest.Issues.TestProtos {
           if (other.Y != 0) {
           if (other.Y != 0) {
             Y = other.Y;
             Y = other.Y;
           }
           }
+          _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
         }
         }
 
 
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -2053,7 +2211,7 @@ namespace UnitTest.Issues.TestProtos {
           while ((tag = input.ReadTag()) != 0) {
           while ((tag = input.ReadTag()) != 0) {
             switch(tag) {
             switch(tag) {
               default:
               default:
-                input.SkipLastField();
+                _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
                 break;
                 break;
               case 8: {
               case 8: {
                 X = input.ReadInt32();
                 X = input.ReadInt32();

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 277 - 158
csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs


+ 104 - 27
csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs

@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: google/protobuf/unittest_well_known_types.proto
+// <auto-generated>
+//     Generated by the protocol buffer compiler.  DO NOT EDIT!
+//     source: google/protobuf/unittest_well_known_types.proto
+// </auto-generated>
 #pragma warning disable 1591, 0612, 3021
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code
 #region Designer generated code
 
 
@@ -179,6 +181,7 @@ namespace Google.Protobuf.TestProtos {
   /// </summary>
   /// </summary>
   public sealed partial class TestWellKnownTypes : pb::IMessage<TestWellKnownTypes> {
   public sealed partial class TestWellKnownTypes : pb::IMessage<TestWellKnownTypes> {
     private static readonly pb::MessageParser<TestWellKnownTypes> _parser = new pb::MessageParser<TestWellKnownTypes>(() => new TestWellKnownTypes());
     private static readonly pb::MessageParser<TestWellKnownTypes> _parser = new pb::MessageParser<TestWellKnownTypes>(() => new TestWellKnownTypes());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<TestWellKnownTypes> Parser { get { return _parser; } }
     public static pb::MessageParser<TestWellKnownTypes> Parser { get { return _parser; } }
 
 
@@ -220,6 +223,7 @@ namespace Google.Protobuf.TestProtos {
       StringField = other.StringField;
       StringField = other.StringField;
       BytesField = other.BytesField;
       BytesField = other.BytesField;
       ValueField = other.valueField_ != null ? other.ValueField.Clone() : null;
       ValueField = other.valueField_ != null ? other.ValueField.Clone() : null;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -470,8 +474,8 @@ namespace Google.Protobuf.TestProtos {
       if (!object.Equals(StructField, other.StructField)) return false;
       if (!object.Equals(StructField, other.StructField)) return false;
       if (!object.Equals(TimestampField, other.TimestampField)) return false;
       if (!object.Equals(TimestampField, other.TimestampField)) return false;
       if (!object.Equals(TypeField, other.TypeField)) return false;
       if (!object.Equals(TypeField, other.TypeField)) return false;
-      if (DoubleField != other.DoubleField) return false;
-      if (FloatField != other.FloatField) return false;
+      if (!pbc::ProtobufEqualityComparers.BitwiseNullableDoubleEqualityComparer.Equals(DoubleField, other.DoubleField)) return false;
+      if (!pbc::ProtobufEqualityComparers.BitwiseNullableSingleEqualityComparer.Equals(FloatField, other.FloatField)) return false;
       if (Int64Field != other.Int64Field) return false;
       if (Int64Field != other.Int64Field) return false;
       if (Uint64Field != other.Uint64Field) return false;
       if (Uint64Field != other.Uint64Field) return false;
       if (Int32Field != other.Int32Field) return false;
       if (Int32Field != other.Int32Field) return false;
@@ -480,7 +484,7 @@ namespace Google.Protobuf.TestProtos {
       if (StringField != other.StringField) return false;
       if (StringField != other.StringField) return false;
       if (BytesField != other.BytesField) return false;
       if (BytesField != other.BytesField) return false;
       if (!object.Equals(ValueField, other.ValueField)) return false;
       if (!object.Equals(ValueField, other.ValueField)) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -495,8 +499,8 @@ namespace Google.Protobuf.TestProtos {
       if (structField_ != null) hash ^= StructField.GetHashCode();
       if (structField_ != null) hash ^= StructField.GetHashCode();
       if (timestampField_ != null) hash ^= TimestampField.GetHashCode();
       if (timestampField_ != null) hash ^= TimestampField.GetHashCode();
       if (typeField_ != null) hash ^= TypeField.GetHashCode();
       if (typeField_ != null) hash ^= TypeField.GetHashCode();
-      if (doubleField_ != null) hash ^= DoubleField.GetHashCode();
-      if (floatField_ != null) hash ^= FloatField.GetHashCode();
+      if (doubleField_ != null) hash ^= pbc::ProtobufEqualityComparers.BitwiseNullableDoubleEqualityComparer.GetHashCode(DoubleField);
+      if (floatField_ != null) hash ^= pbc::ProtobufEqualityComparers.BitwiseNullableSingleEqualityComparer.GetHashCode(FloatField);
       if (int64Field_ != null) hash ^= Int64Field.GetHashCode();
       if (int64Field_ != null) hash ^= Int64Field.GetHashCode();
       if (uint64Field_ != null) hash ^= Uint64Field.GetHashCode();
       if (uint64Field_ != null) hash ^= Uint64Field.GetHashCode();
       if (int32Field_ != null) hash ^= Int32Field.GetHashCode();
       if (int32Field_ != null) hash ^= Int32Field.GetHashCode();
@@ -505,6 +509,9 @@ namespace Google.Protobuf.TestProtos {
       if (stringField_ != null) hash ^= StringField.GetHashCode();
       if (stringField_ != null) hash ^= StringField.GetHashCode();
       if (bytesField_ != null) hash ^= BytesField.GetHashCode();
       if (bytesField_ != null) hash ^= BytesField.GetHashCode();
       if (valueField_ != null) hash ^= ValueField.GetHashCode();
       if (valueField_ != null) hash ^= ValueField.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -582,6 +589,9 @@ namespace Google.Protobuf.TestProtos {
         output.WriteRawTag(154, 1);
         output.WriteRawTag(154, 1);
         output.WriteMessage(ValueField);
         output.WriteMessage(ValueField);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -644,6 +654,9 @@ namespace Google.Protobuf.TestProtos {
       if (valueField_ != null) {
       if (valueField_ != null) {
         size += 2 + pb::CodedOutputStream.ComputeMessageSize(ValueField);
         size += 2 + pb::CodedOutputStream.ComputeMessageSize(ValueField);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -757,6 +770,7 @@ namespace Google.Protobuf.TestProtos {
         }
         }
         ValueField.MergeFrom(other.ValueField);
         ValueField.MergeFrom(other.ValueField);
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -765,7 +779,7 @@ namespace Google.Protobuf.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             if (anyField_ == null) {
             if (anyField_ == null) {
@@ -911,6 +925,7 @@ namespace Google.Protobuf.TestProtos {
   /// </summary>
   /// </summary>
   public sealed partial class RepeatedWellKnownTypes : pb::IMessage<RepeatedWellKnownTypes> {
   public sealed partial class RepeatedWellKnownTypes : pb::IMessage<RepeatedWellKnownTypes> {
     private static readonly pb::MessageParser<RepeatedWellKnownTypes> _parser = new pb::MessageParser<RepeatedWellKnownTypes>(() => new RepeatedWellKnownTypes());
     private static readonly pb::MessageParser<RepeatedWellKnownTypes> _parser = new pb::MessageParser<RepeatedWellKnownTypes>(() => new RepeatedWellKnownTypes());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<RepeatedWellKnownTypes> Parser { get { return _parser; } }
     public static pb::MessageParser<RepeatedWellKnownTypes> Parser { get { return _parser; } }
 
 
@@ -951,6 +966,7 @@ namespace Google.Protobuf.TestProtos {
       boolField_ = other.boolField_.Clone();
       boolField_ = other.boolField_.Clone();
       stringField_ = other.stringField_.Clone();
       stringField_ = other.stringField_.Clone();
       bytesField_ = other.bytesField_.Clone();
       bytesField_ = other.bytesField_.Clone();
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1172,7 +1188,7 @@ namespace Google.Protobuf.TestProtos {
       if(!boolField_.Equals(other.boolField_)) return false;
       if(!boolField_.Equals(other.boolField_)) return false;
       if(!stringField_.Equals(other.stringField_)) return false;
       if(!stringField_.Equals(other.stringField_)) return false;
       if(!bytesField_.Equals(other.bytesField_)) return false;
       if(!bytesField_.Equals(other.bytesField_)) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1196,6 +1212,9 @@ namespace Google.Protobuf.TestProtos {
       hash ^= boolField_.GetHashCode();
       hash ^= boolField_.GetHashCode();
       hash ^= stringField_.GetHashCode();
       hash ^= stringField_.GetHashCode();
       hash ^= bytesField_.GetHashCode();
       hash ^= bytesField_.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -1224,6 +1243,9 @@ namespace Google.Protobuf.TestProtos {
       boolField_.WriteTo(output, _repeated_boolField_codec);
       boolField_.WriteTo(output, _repeated_boolField_codec);
       stringField_.WriteTo(output, _repeated_stringField_codec);
       stringField_.WriteTo(output, _repeated_stringField_codec);
       bytesField_.WriteTo(output, _repeated_bytesField_codec);
       bytesField_.WriteTo(output, _repeated_bytesField_codec);
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1247,6 +1269,9 @@ namespace Google.Protobuf.TestProtos {
       size += boolField_.CalculateSize(_repeated_boolField_codec);
       size += boolField_.CalculateSize(_repeated_boolField_codec);
       size += stringField_.CalculateSize(_repeated_stringField_codec);
       size += stringField_.CalculateSize(_repeated_stringField_codec);
       size += bytesField_.CalculateSize(_repeated_bytesField_codec);
       size += bytesField_.CalculateSize(_repeated_bytesField_codec);
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -1273,6 +1298,7 @@ namespace Google.Protobuf.TestProtos {
       boolField_.Add(other.boolField_);
       boolField_.Add(other.boolField_);
       stringField_.Add(other.stringField_);
       stringField_.Add(other.stringField_);
       bytesField_.Add(other.bytesField_);
       bytesField_.Add(other.bytesField_);
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1281,7 +1307,7 @@ namespace Google.Protobuf.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             anyField_.AddEntriesFrom(input, _repeated_anyField_codec);
             anyField_.AddEntriesFrom(input, _repeated_anyField_codec);
@@ -1363,6 +1389,7 @@ namespace Google.Protobuf.TestProtos {
 
 
   public sealed partial class OneofWellKnownTypes : pb::IMessage<OneofWellKnownTypes> {
   public sealed partial class OneofWellKnownTypes : pb::IMessage<OneofWellKnownTypes> {
     private static readonly pb::MessageParser<OneofWellKnownTypes> _parser = new pb::MessageParser<OneofWellKnownTypes>(() => new OneofWellKnownTypes());
     private static readonly pb::MessageParser<OneofWellKnownTypes> _parser = new pb::MessageParser<OneofWellKnownTypes>(() => new OneofWellKnownTypes());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<OneofWellKnownTypes> Parser { get { return _parser; } }
     public static pb::MessageParser<OneofWellKnownTypes> Parser { get { return _parser; } }
 
 
@@ -1442,6 +1469,7 @@ namespace Google.Protobuf.TestProtos {
           break;
           break;
       }
       }
 
 
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1713,8 +1741,8 @@ namespace Google.Protobuf.TestProtos {
       if (!object.Equals(StructField, other.StructField)) return false;
       if (!object.Equals(StructField, other.StructField)) return false;
       if (!object.Equals(TimestampField, other.TimestampField)) return false;
       if (!object.Equals(TimestampField, other.TimestampField)) return false;
       if (!object.Equals(TypeField, other.TypeField)) return false;
       if (!object.Equals(TypeField, other.TypeField)) return false;
-      if (DoubleField != other.DoubleField) return false;
-      if (FloatField != other.FloatField) return false;
+      if (!pbc::ProtobufEqualityComparers.BitwiseNullableDoubleEqualityComparer.Equals(DoubleField, other.DoubleField)) return false;
+      if (!pbc::ProtobufEqualityComparers.BitwiseNullableSingleEqualityComparer.Equals(FloatField, other.FloatField)) return false;
       if (Int64Field != other.Int64Field) return false;
       if (Int64Field != other.Int64Field) return false;
       if (Uint64Field != other.Uint64Field) return false;
       if (Uint64Field != other.Uint64Field) return false;
       if (Int32Field != other.Int32Field) return false;
       if (Int32Field != other.Int32Field) return false;
@@ -1723,7 +1751,7 @@ namespace Google.Protobuf.TestProtos {
       if (StringField != other.StringField) return false;
       if (StringField != other.StringField) return false;
       if (BytesField != other.BytesField) return false;
       if (BytesField != other.BytesField) return false;
       if (OneofFieldCase != other.OneofFieldCase) return false;
       if (OneofFieldCase != other.OneofFieldCase) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1738,8 +1766,8 @@ namespace Google.Protobuf.TestProtos {
       if (oneofFieldCase_ == OneofFieldOneofCase.StructField) hash ^= StructField.GetHashCode();
       if (oneofFieldCase_ == OneofFieldOneofCase.StructField) hash ^= StructField.GetHashCode();
       if (oneofFieldCase_ == OneofFieldOneofCase.TimestampField) hash ^= TimestampField.GetHashCode();
       if (oneofFieldCase_ == OneofFieldOneofCase.TimestampField) hash ^= TimestampField.GetHashCode();
       if (oneofFieldCase_ == OneofFieldOneofCase.TypeField) hash ^= TypeField.GetHashCode();
       if (oneofFieldCase_ == OneofFieldOneofCase.TypeField) hash ^= TypeField.GetHashCode();
-      if (oneofFieldCase_ == OneofFieldOneofCase.DoubleField) hash ^= DoubleField.GetHashCode();
-      if (oneofFieldCase_ == OneofFieldOneofCase.FloatField) hash ^= FloatField.GetHashCode();
+      if (oneofFieldCase_ == OneofFieldOneofCase.DoubleField) hash ^= pbc::ProtobufEqualityComparers.BitwiseNullableDoubleEqualityComparer.GetHashCode(DoubleField);
+      if (oneofFieldCase_ == OneofFieldOneofCase.FloatField) hash ^= pbc::ProtobufEqualityComparers.BitwiseNullableSingleEqualityComparer.GetHashCode(FloatField);
       if (oneofFieldCase_ == OneofFieldOneofCase.Int64Field) hash ^= Int64Field.GetHashCode();
       if (oneofFieldCase_ == OneofFieldOneofCase.Int64Field) hash ^= Int64Field.GetHashCode();
       if (oneofFieldCase_ == OneofFieldOneofCase.Uint64Field) hash ^= Uint64Field.GetHashCode();
       if (oneofFieldCase_ == OneofFieldOneofCase.Uint64Field) hash ^= Uint64Field.GetHashCode();
       if (oneofFieldCase_ == OneofFieldOneofCase.Int32Field) hash ^= Int32Field.GetHashCode();
       if (oneofFieldCase_ == OneofFieldOneofCase.Int32Field) hash ^= Int32Field.GetHashCode();
@@ -1748,6 +1776,9 @@ namespace Google.Protobuf.TestProtos {
       if (oneofFieldCase_ == OneofFieldOneofCase.StringField) hash ^= StringField.GetHashCode();
       if (oneofFieldCase_ == OneofFieldOneofCase.StringField) hash ^= StringField.GetHashCode();
       if (oneofFieldCase_ == OneofFieldOneofCase.BytesField) hash ^= BytesField.GetHashCode();
       if (oneofFieldCase_ == OneofFieldOneofCase.BytesField) hash ^= BytesField.GetHashCode();
       hash ^= (int) oneofFieldCase_;
       hash ^= (int) oneofFieldCase_;
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -1821,6 +1852,9 @@ namespace Google.Protobuf.TestProtos {
       if (oneofFieldCase_ == OneofFieldOneofCase.BytesField) {
       if (oneofFieldCase_ == OneofFieldOneofCase.BytesField) {
         _oneof_bytesField_codec.WriteTagAndValue(output, (pb::ByteString) oneofField_);
         _oneof_bytesField_codec.WriteTagAndValue(output, (pb::ByteString) oneofField_);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1880,6 +1914,9 @@ namespace Google.Protobuf.TestProtos {
       if (oneofFieldCase_ == OneofFieldOneofCase.BytesField) {
       if (oneofFieldCase_ == OneofFieldOneofCase.BytesField) {
         size += _oneof_bytesField_codec.CalculateSizeWithTag(BytesField);
         size += _oneof_bytesField_codec.CalculateSizeWithTag(BytesField);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -1890,31 +1927,58 @@ namespace Google.Protobuf.TestProtos {
       }
       }
       switch (other.OneofFieldCase) {
       switch (other.OneofFieldCase) {
         case OneofFieldOneofCase.AnyField:
         case OneofFieldOneofCase.AnyField:
-          AnyField = other.AnyField;
+          if (AnyField == null) {
+            AnyField = new global::Google.Protobuf.WellKnownTypes.Any();
+          }
+          AnyField.MergeFrom(other.AnyField);
           break;
           break;
         case OneofFieldOneofCase.ApiField:
         case OneofFieldOneofCase.ApiField:
-          ApiField = other.ApiField;
+          if (ApiField == null) {
+            ApiField = new global::Google.Protobuf.WellKnownTypes.Api();
+          }
+          ApiField.MergeFrom(other.ApiField);
           break;
           break;
         case OneofFieldOneofCase.DurationField:
         case OneofFieldOneofCase.DurationField:
-          DurationField = other.DurationField;
+          if (DurationField == null) {
+            DurationField = new global::Google.Protobuf.WellKnownTypes.Duration();
+          }
+          DurationField.MergeFrom(other.DurationField);
           break;
           break;
         case OneofFieldOneofCase.EmptyField:
         case OneofFieldOneofCase.EmptyField:
-          EmptyField = other.EmptyField;
+          if (EmptyField == null) {
+            EmptyField = new global::Google.Protobuf.WellKnownTypes.Empty();
+          }
+          EmptyField.MergeFrom(other.EmptyField);
           break;
           break;
         case OneofFieldOneofCase.FieldMaskField:
         case OneofFieldOneofCase.FieldMaskField:
-          FieldMaskField = other.FieldMaskField;
+          if (FieldMaskField == null) {
+            FieldMaskField = new global::Google.Protobuf.WellKnownTypes.FieldMask();
+          }
+          FieldMaskField.MergeFrom(other.FieldMaskField);
           break;
           break;
         case OneofFieldOneofCase.SourceContextField:
         case OneofFieldOneofCase.SourceContextField:
-          SourceContextField = other.SourceContextField;
+          if (SourceContextField == null) {
+            SourceContextField = new global::Google.Protobuf.WellKnownTypes.SourceContext();
+          }
+          SourceContextField.MergeFrom(other.SourceContextField);
           break;
           break;
         case OneofFieldOneofCase.StructField:
         case OneofFieldOneofCase.StructField:
-          StructField = other.StructField;
+          if (StructField == null) {
+            StructField = new global::Google.Protobuf.WellKnownTypes.Struct();
+          }
+          StructField.MergeFrom(other.StructField);
           break;
           break;
         case OneofFieldOneofCase.TimestampField:
         case OneofFieldOneofCase.TimestampField:
-          TimestampField = other.TimestampField;
+          if (TimestampField == null) {
+            TimestampField = new global::Google.Protobuf.WellKnownTypes.Timestamp();
+          }
+          TimestampField.MergeFrom(other.TimestampField);
           break;
           break;
         case OneofFieldOneofCase.TypeField:
         case OneofFieldOneofCase.TypeField:
-          TypeField = other.TypeField;
+          if (TypeField == null) {
+            TypeField = new global::Google.Protobuf.WellKnownTypes.Type();
+          }
+          TypeField.MergeFrom(other.TypeField);
           break;
           break;
         case OneofFieldOneofCase.DoubleField:
         case OneofFieldOneofCase.DoubleField:
           DoubleField = other.DoubleField;
           DoubleField = other.DoubleField;
@@ -1945,6 +2009,7 @@ namespace Google.Protobuf.TestProtos {
           break;
           break;
       }
       }
 
 
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1953,7 +2018,7 @@ namespace Google.Protobuf.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             global::Google.Protobuf.WellKnownTypes.Any subBuilder = new global::Google.Protobuf.WellKnownTypes.Any();
             global::Google.Protobuf.WellKnownTypes.Any subBuilder = new global::Google.Protobuf.WellKnownTypes.Any();
@@ -2085,6 +2150,7 @@ namespace Google.Protobuf.TestProtos {
   /// </summary>
   /// </summary>
   public sealed partial class MapWellKnownTypes : pb::IMessage<MapWellKnownTypes> {
   public sealed partial class MapWellKnownTypes : pb::IMessage<MapWellKnownTypes> {
     private static readonly pb::MessageParser<MapWellKnownTypes> _parser = new pb::MessageParser<MapWellKnownTypes>(() => new MapWellKnownTypes());
     private static readonly pb::MessageParser<MapWellKnownTypes> _parser = new pb::MessageParser<MapWellKnownTypes>(() => new MapWellKnownTypes());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<MapWellKnownTypes> Parser { get { return _parser; } }
     public static pb::MessageParser<MapWellKnownTypes> Parser { get { return _parser; } }
 
 
@@ -2125,6 +2191,7 @@ namespace Google.Protobuf.TestProtos {
       boolField_ = other.boolField_.Clone();
       boolField_ = other.boolField_.Clone();
       stringField_ = other.stringField_.Clone();
       stringField_ = other.stringField_.Clone();
       bytesField_ = other.bytesField_.Clone();
       bytesField_ = other.bytesField_.Clone();
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -2343,7 +2410,7 @@ namespace Google.Protobuf.TestProtos {
       if (!BoolField.Equals(other.BoolField)) return false;
       if (!BoolField.Equals(other.BoolField)) return false;
       if (!StringField.Equals(other.StringField)) return false;
       if (!StringField.Equals(other.StringField)) return false;
       if (!BytesField.Equals(other.BytesField)) return false;
       if (!BytesField.Equals(other.BytesField)) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -2367,6 +2434,9 @@ namespace Google.Protobuf.TestProtos {
       hash ^= BoolField.GetHashCode();
       hash ^= BoolField.GetHashCode();
       hash ^= StringField.GetHashCode();
       hash ^= StringField.GetHashCode();
       hash ^= BytesField.GetHashCode();
       hash ^= BytesField.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -2395,6 +2465,9 @@ namespace Google.Protobuf.TestProtos {
       boolField_.WriteTo(output, _map_boolField_codec);
       boolField_.WriteTo(output, _map_boolField_codec);
       stringField_.WriteTo(output, _map_stringField_codec);
       stringField_.WriteTo(output, _map_stringField_codec);
       bytesField_.WriteTo(output, _map_bytesField_codec);
       bytesField_.WriteTo(output, _map_bytesField_codec);
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -2418,6 +2491,9 @@ namespace Google.Protobuf.TestProtos {
       size += boolField_.CalculateSize(_map_boolField_codec);
       size += boolField_.CalculateSize(_map_boolField_codec);
       size += stringField_.CalculateSize(_map_stringField_codec);
       size += stringField_.CalculateSize(_map_stringField_codec);
       size += bytesField_.CalculateSize(_map_bytesField_codec);
       size += bytesField_.CalculateSize(_map_bytesField_codec);
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -2444,6 +2520,7 @@ namespace Google.Protobuf.TestProtos {
       boolField_.Add(other.boolField_);
       boolField_.Add(other.boolField_);
       stringField_.Add(other.stringField_);
       stringField_.Add(other.stringField_);
       bytesField_.Add(other.bytesField_);
       bytesField_.Add(other.bytesField_);
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -2452,7 +2529,7 @@ namespace Google.Protobuf.TestProtos {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             anyField_.AddEntriesFrom(input, _map_anyField_codec);
             anyField_.AddEntriesFrom(input, _map_anyField_codec);

+ 128 - 0
csharp/src/Google.Protobuf.Test/UnknownFieldSetTest.cs

@@ -0,0 +1,128 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc.  All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System;
+using Google.Protobuf.TestProtos;
+using NUnit.Framework;
+
+namespace Google.Protobuf
+{
+    public class UnknownFieldSetTest
+    {
+        [Test]
+        public void EmptyUnknownFieldSet()
+        {
+            UnknownFieldSet unknownFields = new UnknownFieldSet();
+            Assert.AreEqual(0, unknownFields.CalculateSize());
+        }
+
+        [Test]
+        public void MergeUnknownFieldSet()
+        {
+            UnknownFieldSet unknownFields = new UnknownFieldSet();
+            UnknownField field = new UnknownField();
+            field.AddFixed32(123);
+            unknownFields.AddOrReplaceField(1, field);
+            UnknownFieldSet otherUnknownFields = new UnknownFieldSet();
+            Assert.IsFalse(otherUnknownFields.HasField(1));
+            UnknownFieldSet.MergeFrom(otherUnknownFields, unknownFields);
+            Assert.IsTrue(otherUnknownFields.HasField(1));
+        }
+
+        [Test]
+        public void TestMergeCodedInput()
+        {
+            var message = SampleMessages.CreateFullTestAllTypes();
+            var emptyMessage = new TestEmptyMessage();
+            emptyMessage.MergeFrom(message.ToByteArray());
+            Assert.AreEqual(message.CalculateSize(), emptyMessage.CalculateSize());
+            Assert.AreEqual(message.ToByteArray(), emptyMessage.ToByteArray());
+
+            var newMessage = new TestAllTypes();
+            newMessage.MergeFrom(emptyMessage.ToByteArray());
+            Assert.AreEqual(message, newMessage);
+            Assert.AreEqual(message.CalculateSize(), newMessage.CalculateSize());
+        }
+
+        [Test]
+        public void TestMergeMessage()
+        {
+            var message = SampleMessages.CreateFullTestAllTypes();
+            var emptyMessage = new TestEmptyMessage();
+            var otherEmptyMessage = new TestEmptyMessage();
+            emptyMessage.MergeFrom(message.ToByteArray());
+            otherEmptyMessage.MergeFrom(emptyMessage);
+
+            Assert.AreEqual(message.CalculateSize(), otherEmptyMessage.CalculateSize());
+            Assert.AreEqual(message.ToByteArray(), otherEmptyMessage.ToByteArray());
+        }
+
+        [Test]
+        public void TestEquals()
+        {
+            var message = SampleMessages.CreateFullTestAllTypes();
+            var emptyMessage = new TestEmptyMessage();
+            var otherEmptyMessage = new TestEmptyMessage();
+            Assert.AreEqual(emptyMessage, otherEmptyMessage);
+            emptyMessage.MergeFrom(message.ToByteArray());
+            Assert.AreNotEqual(emptyMessage.CalculateSize(),
+                               otherEmptyMessage.CalculateSize());
+            Assert.AreNotEqual(emptyMessage, otherEmptyMessage);
+        }
+
+        [Test]
+        public void TestHashCode()
+        {
+            var message = SampleMessages.CreateFullTestAllTypes();
+            var emptyMessage = new TestEmptyMessage();
+            int hashCode = emptyMessage.GetHashCode();
+            emptyMessage.MergeFrom(message.ToByteArray());
+            Assert.AreNotEqual(hashCode, emptyMessage.GetHashCode());
+        }
+
+        [Test]
+        public void TestClone()
+        {
+            var emptyMessage = new TestEmptyMessage();
+            var otherEmptyMessage = new TestEmptyMessage();
+            otherEmptyMessage = emptyMessage.Clone();
+            Assert.AreEqual(emptyMessage.CalculateSize(), otherEmptyMessage.CalculateSize());
+            Assert.AreEqual(emptyMessage.ToByteArray(), otherEmptyMessage.ToByteArray());
+
+            var message = SampleMessages.CreateFullTestAllTypes();
+            emptyMessage.MergeFrom(message.ToByteArray());
+            otherEmptyMessage = emptyMessage.Clone();
+            Assert.AreEqual(message.CalculateSize(), otherEmptyMessage.CalculateSize());
+            Assert.AreEqual(message.ToByteArray(), otherEmptyMessage.ToByteArray());
+        }
+    }
+}

+ 3 - 3
csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs

@@ -42,7 +42,7 @@ namespace Google.Protobuf.WellKnownTypes
         {
         {
             var message = SampleMessages.CreateFullTestAllTypes();
             var message = SampleMessages.CreateFullTestAllTypes();
             var any = Any.Pack(message);
             var any = Any.Pack(message);
-            Assert.AreEqual("type.googleapis.com/protobuf_unittest.TestAllTypes", any.TypeUrl);
+            Assert.AreEqual("type.googleapis.com/protobuf_unittest3.TestAllTypes", any.TypeUrl);
             Assert.AreEqual(message.CalculateSize(), any.Value.Length);
             Assert.AreEqual(message.CalculateSize(), any.Value.Length);
         }
         }
 
 
@@ -51,7 +51,7 @@ namespace Google.Protobuf.WellKnownTypes
         {
         {
             var message = SampleMessages.CreateFullTestAllTypes();
             var message = SampleMessages.CreateFullTestAllTypes();
             var any = Any.Pack(message, "foo.bar/baz");
             var any = Any.Pack(message, "foo.bar/baz");
-            Assert.AreEqual("foo.bar/baz/protobuf_unittest.TestAllTypes", any.TypeUrl);
+            Assert.AreEqual("foo.bar/baz/protobuf_unittest3.TestAllTypes", any.TypeUrl);
             Assert.AreEqual(message.CalculateSize(), any.Value.Length);
             Assert.AreEqual(message.CalculateSize(), any.Value.Length);
         }
         }
 
 
@@ -60,7 +60,7 @@ namespace Google.Protobuf.WellKnownTypes
         {
         {
             var message = SampleMessages.CreateFullTestAllTypes();
             var message = SampleMessages.CreateFullTestAllTypes();
             var any = Any.Pack(message, "foo.bar/baz/");
             var any = Any.Pack(message, "foo.bar/baz/");
-            Assert.AreEqual("foo.bar/baz/protobuf_unittest.TestAllTypes", any.TypeUrl);
+            Assert.AreEqual("foo.bar/baz/protobuf_unittest3.TestAllTypes", any.TypeUrl);
             Assert.AreEqual(message.CalculateSize(), any.Value.Length);
             Assert.AreEqual(message.CalculateSize(), any.Value.Length);
         }
         }
 
 

+ 11 - 0
csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs

@@ -417,5 +417,16 @@ namespace Google.Protobuf.WellKnownTypes
             TestWellKnownTypes.Descriptor.Fields[TestWellKnownTypes.StringFieldFieldNumber].Accessor.Clear(message);
             TestWellKnownTypes.Descriptor.Fields[TestWellKnownTypes.StringFieldFieldNumber].Accessor.Clear(message);
             Assert.IsNull(message.StringField);
             Assert.IsNull(message.StringField);
         }
         }
+
+        [Test]
+        public void NaNComparisons()
+        {
+            var message1 = new TestWellKnownTypes { DoubleField = SampleNaNs.Regular };
+            var message2 = new TestWellKnownTypes { DoubleField = SampleNaNs.PayloadFlipped };
+            var message3 = new TestWellKnownTypes { DoubleField = SampleNaNs.Regular };
+
+            EqualityTester.AssertInequality(message1, message2);
+            EqualityTester.AssertEquality(message1, message3);
+        }
     }
     }
 }
 }

+ 4 - 2
csharp/src/Google.Protobuf/CodedInputStream.cs

@@ -424,7 +424,10 @@ namespace Google.Protobuf
             }
             }
         }
         }
 
 
-        private void SkipGroup(uint startGroupTag)
+        /// <summary>
+        /// Skip a group.
+        /// </summary>
+        internal void SkipGroup(uint startGroupTag)
         {
         {
             // Note: Currently we expect this to be the way that groups are read. We could put the recursion
             // Note: Currently we expect this to be the way that groups are read. We could put the recursion
             // depth changes into the ReadTag method instead, potentially...
             // depth changes into the ReadTag method instead, potentially...
@@ -1270,7 +1273,6 @@ namespace Google.Protobuf
                 }
                 }
             }
             }
         }
         }
-
         #endregion
         #endregion
     }
     }
 }
 }

+ 89 - 0
csharp/src/Google.Protobuf/Collections/Lists.cs

@@ -0,0 +1,89 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2017 Google Inc.  All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+
+namespace Google.Protobuf.Collections
+{
+    /// <summary>
+    /// Utility to compare if two Lists are the same, and the hash code
+    /// of a List.
+    /// </summary>
+    public static class Lists
+    {
+        /// <summary>
+        /// Checks if two lists are equal.
+        /// </summary>
+        public static bool Equals<T>(List<T> left, List<T> right)
+        {
+            if (left == right)
+            {
+                return true;
+            }
+            if (left == null || right == null)
+            {
+                return false;
+            }
+            if (left.Count != right.Count)
+            {
+                return false;
+            }
+            IEqualityComparer<T> comparer = EqualityComparer<T>.Default;
+            for (int i = 0; i < left.Count; i++)
+            {
+                if (!comparer.Equals(left[i], right[i]))
+                {
+                    return false;
+                }
+            }
+            return true;
+        }
+
+        /// <summary>
+        /// Gets the list's hash code.
+        /// </summary>
+        public static int GetHashCode<T>(List<T> list)
+        {
+            if (list == null)
+            {
+                return 0;
+            }
+            int hash = 31;
+            foreach (T element in list)
+            {
+                hash = hash * 29 + element.GetHashCode();
+            }
+            return hash;
+        }
+    }
+}

+ 11 - 11
csharp/src/Google.Protobuf/Collections/MapField.cs

@@ -71,9 +71,12 @@ namespace Google.Protobuf.Collections
         , IReadOnlyDictionary<TKey, TValue>
         , IReadOnlyDictionary<TKey, TValue>
 #endif
 #endif
     {
     {
+        private static readonly EqualityComparer<TValue> ValueEqualityComparer = ProtobufEqualityComparers.GetEqualityComparer<TValue>();
+        private static readonly EqualityComparer<TKey> KeyEqualityComparer = ProtobufEqualityComparers.GetEqualityComparer<TKey>();
+
         // TODO: Don't create the map/list until we have an entry. (Assume many maps will be empty.)
         // TODO: Don't create the map/list until we have an entry. (Assume many maps will be empty.)
         private readonly Dictionary<TKey, LinkedListNode<KeyValuePair<TKey, TValue>>> map =
         private readonly Dictionary<TKey, LinkedListNode<KeyValuePair<TKey, TValue>>> map =
-            new Dictionary<TKey, LinkedListNode<KeyValuePair<TKey, TValue>>>();
+            new Dictionary<TKey, LinkedListNode<KeyValuePair<TKey, TValue>>>(KeyEqualityComparer);
         private readonly LinkedList<KeyValuePair<TKey, TValue>> list = new LinkedList<KeyValuePair<TKey, TValue>>();
         private readonly LinkedList<KeyValuePair<TKey, TValue>> list = new LinkedList<KeyValuePair<TKey, TValue>>();
 
 
         /// <summary>
         /// <summary>
@@ -131,11 +134,8 @@ namespace Google.Protobuf.Collections
             return map.ContainsKey(key);
             return map.ContainsKey(key);
         }
         }
 
 
-        private bool ContainsValue(TValue value)
-        {
-            var comparer = EqualityComparer<TValue>.Default;
-            return list.Any(pair => comparer.Equals(pair.Value, value));
-        }
+        private bool ContainsValue(TValue value) =>
+            list.Any(pair => ValueEqualityComparer.Equals(pair.Value, value));
 
 
         /// <summary>
         /// <summary>
         /// Removes the entry identified by the given key from the map.
         /// Removes the entry identified by the given key from the map.
@@ -293,8 +293,7 @@ namespace Google.Protobuf.Collections
         bool ICollection<KeyValuePair<TKey, TValue>>.Contains(KeyValuePair<TKey, TValue> item)
         bool ICollection<KeyValuePair<TKey, TValue>>.Contains(KeyValuePair<TKey, TValue> item)
         {
         {
             TValue value;
             TValue value;
-            return TryGetValue(item.Key, out value)
-                && EqualityComparer<TValue>.Default.Equals(item.Value, value);
+            return TryGetValue(item.Key, out value) && ValueEqualityComparer.Equals(item.Value, value);
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -363,11 +362,12 @@ namespace Google.Protobuf.Collections
         /// </returns>
         /// </returns>
         public override int GetHashCode()
         public override int GetHashCode()
         {
         {
-            var valueComparer = EqualityComparer<TValue>.Default;
+            var keyComparer = KeyEqualityComparer;
+            var valueComparer = ValueEqualityComparer;
             int hash = 0;
             int hash = 0;
             foreach (var pair in list)
             foreach (var pair in list)
             {
             {
-                hash ^= pair.Key.GetHashCode() * 31 + valueComparer.GetHashCode(pair.Value);
+                hash ^= keyComparer.GetHashCode(pair.Key) * 31 + valueComparer.GetHashCode(pair.Value);
             }
             }
             return hash;
             return hash;
         }
         }
@@ -394,7 +394,7 @@ namespace Google.Protobuf.Collections
             {
             {
                 return false;
                 return false;
             }
             }
-            var valueComparer = EqualityComparer<TValue>.Default;
+            var valueComparer = ValueEqualityComparer;
             foreach (var pair in this)
             foreach (var pair in this)
             {
             {
                 TValue value;
                 TValue value;

+ 130 - 0
csharp/src/Google.Protobuf/Collections/ProtobufEqualityComparers.cs

@@ -0,0 +1,130 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2017 Google Inc.  All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System;
+using System.Collections.Generic;
+
+namespace Google.Protobuf.Collections
+{
+    /// <summary>
+    /// Provides a central place to implement equality comparisons, primarily for bitwise float/double equality.
+    /// </summary>
+    public static class ProtobufEqualityComparers
+    {
+        /// <summary>
+        /// Returns an equality comparer for <typeparamref name="T"/> suitable for Protobuf equality comparisons.
+        /// This is usually just the default equality comparer for the type, but floating point numbers are compared
+        /// bitwise.
+        /// </summary>
+        /// <typeparam name="T">The type of equality comparer to return.</typeparam>
+        /// <returns>The equality comparer.</returns>
+        public static EqualityComparer<T> GetEqualityComparer<T>()
+        {
+            return typeof(T) == typeof(double) ? (EqualityComparer<T>) (object) BitwiseDoubleEqualityComparer
+                : typeof(T) == typeof(float) ? (EqualityComparer<T>) (object) BitwiseSingleEqualityComparer
+                : typeof(T) == typeof(double?) ? (EqualityComparer<T>) (object) BitwiseNullableDoubleEqualityComparer
+                : typeof(T) == typeof(float?) ? (EqualityComparer<T>) (object) BitwiseNullableSingleEqualityComparer
+                : EqualityComparer<T>.Default;
+        }
+
+        /// <summary>
+        /// Returns an equality comparer suitable for comparing 64-bit floating point values, by bitwise comparison.
+        /// (NaN values are considered equal, but only when they have the same representation.)
+        /// </summary>
+        public static EqualityComparer<double> BitwiseDoubleEqualityComparer { get; } = new BitwiseDoubleEqualityComparerImpl();
+
+        /// <summary>
+        /// Returns an equality comparer suitable for comparing 32-bit floating point values, by bitwise comparison.
+        /// (NaN values are considered equal, but only when they have the same representation.)
+        /// </summary>
+        public static EqualityComparer<float> BitwiseSingleEqualityComparer { get; } = new BitwiseSingleEqualityComparerImpl();
+
+        /// <summary>
+        /// Returns an equality comparer suitable for comparing nullable 64-bit floating point values, by bitwise comparison.
+        /// (NaN values are considered equal, but only when they have the same representation.)
+        /// </summary>
+        public static EqualityComparer<double?> BitwiseNullableDoubleEqualityComparer { get; } = new BitwiseNullableDoubleEqualityComparerImpl();
+
+        /// <summary>
+        /// Returns an equality comparer suitable for comparing nullable 32-bit floating point values, by bitwise comparison.
+        /// (NaN values are considered equal, but only when they have the same representation.)
+        /// </summary>
+        public static EqualityComparer<float?> BitwiseNullableSingleEqualityComparer { get; } = new BitwiseNullableSingleEqualityComparerImpl();
+
+        private class BitwiseDoubleEqualityComparerImpl : EqualityComparer<double>
+        {
+            public override bool Equals(double x, double y) =>
+                BitConverter.DoubleToInt64Bits(x) == BitConverter.DoubleToInt64Bits(y);
+
+            public override int GetHashCode(double obj) =>
+                BitConverter.DoubleToInt64Bits(obj).GetHashCode();
+        }
+
+        private class BitwiseSingleEqualityComparerImpl : EqualityComparer<float>
+        {
+            // Just promote values to double and use BitConverter.DoubleToInt64Bits,
+            // as there's no BitConverter.SingleToInt32Bits, unfortunately.
+
+            public override bool Equals(float x, float y) =>
+                BitConverter.DoubleToInt64Bits(x) == BitConverter.DoubleToInt64Bits(y);
+
+            public override int GetHashCode(float obj) =>
+                BitConverter.DoubleToInt64Bits(obj).GetHashCode();
+        }
+
+        private class BitwiseNullableDoubleEqualityComparerImpl : EqualityComparer<double?>
+        {
+            public override bool Equals(double? x, double? y) =>
+                x == null && y == null ? true
+                : x == null || y == null ? false
+                : BitwiseDoubleEqualityComparer.Equals(x.Value, y.Value);
+
+            // The hash code for null is just a constant which is at least *unlikely* to be used
+            // elsewhere. (Compared with 0, say.)
+            public override int GetHashCode(double? obj) =>
+                obj == null ? 293864 : BitwiseDoubleEqualityComparer.GetHashCode(obj.Value);
+        }
+
+        private class BitwiseNullableSingleEqualityComparerImpl : EqualityComparer<float?>
+        {
+            public override bool Equals(float? x, float? y) =>
+                x == null && y == null ? true
+                : x == null || y == null ? false
+                : BitwiseSingleEqualityComparer.Equals(x.Value, y.Value);
+
+            // The hash code for null is just a constant which is at least *unlikely* to be used
+            // elsewhere. (Compared with 0, say.)
+            public override int GetHashCode(float? obj) =>
+                obj == null ? 293864 : BitwiseSingleEqualityComparer.GetHashCode(obj.Value);
+        }
+    }
+}

+ 3 - 2
csharp/src/Google.Protobuf/Collections/RepeatedField.cs

@@ -51,6 +51,7 @@ namespace Google.Protobuf.Collections
         , IReadOnlyList<T>
         , IReadOnlyList<T>
 #endif
 #endif
     {
     {
+        private static readonly EqualityComparer<T> EqualityComparer = ProtobufEqualityComparers.GetEqualityComparer<T>();
         private static readonly T[] EmptyArray = new T[0];
         private static readonly T[] EmptyArray = new T[0];
         private const int MinArraySize = 8;
         private const int MinArraySize = 8;
 
 
@@ -434,7 +435,7 @@ namespace Google.Protobuf.Collections
             {
             {
                 return false;
                 return false;
             }
             }
-            EqualityComparer<T> comparer = EqualityComparer<T>.Default;
+            EqualityComparer<T> comparer = EqualityComparer;
             for (int i = 0; i < count; i++)
             for (int i = 0; i < count; i++)
             {
             {
                 if (!comparer.Equals(array[i], other.array[i]))
                 if (!comparer.Equals(array[i], other.array[i]))
@@ -454,7 +455,7 @@ namespace Google.Protobuf.Collections
         public int IndexOf(T item)
         public int IndexOf(T item)
         {
         {
             ProtoPreconditions.CheckNotNullUnconstrained(item, nameof(item));
             ProtoPreconditions.CheckNotNullUnconstrained(item, nameof(item));
-            EqualityComparer<T> comparer = EqualityComparer<T>.Default;
+            EqualityComparer<T> comparer = EqualityComparer;
             for (int i = 0; i < count; i++)
             for (int i = 0; i < count; i++)
             {
             {
                 if (comparer.Equals(array[i], item))
                 if (comparer.Equals(array[i], item))

+ 3 - 1
csharp/src/Google.Protobuf/FieldCodec.cs

@@ -30,6 +30,7 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #endregion
 #endregion
 
 
+using Google.Protobuf.Collections;
 using Google.Protobuf.Compatibility;
 using Google.Protobuf.Compatibility;
 using Google.Protobuf.WellKnownTypes;
 using Google.Protobuf.WellKnownTypes;
 using System;
 using System;
@@ -346,6 +347,7 @@ namespace Google.Protobuf
     /// </remarks>
     /// </remarks>
     public sealed class FieldCodec<T>
     public sealed class FieldCodec<T>
     {
     {
+        private static readonly EqualityComparer<T> EqualityComparer = ProtobufEqualityComparers.GetEqualityComparer<T>();
         private static readonly T DefaultDefault;
         private static readonly T DefaultDefault;
         // Only non-nullable value types support packing. This is the simplest way of detecting that.
         // Only non-nullable value types support packing. This is the simplest way of detecting that.
         private static readonly bool TypeSupportsPacking = default(T) != null;
         private static readonly bool TypeSupportsPacking = default(T) != null;
@@ -469,6 +471,6 @@ namespace Google.Protobuf
         /// </summary>
         /// </summary>
         public int CalculateSizeWithTag(T value) => IsDefault(value) ? 0 : ValueSizeCalculator(value) + tagSize;
         public int CalculateSizeWithTag(T value) => IsDefault(value) ? 0 : ValueSizeCalculator(value) + tagSize;
 
 
-        private bool IsDefault(T value) => EqualityComparer<T>.Default.Equals(value, DefaultValue);
+        private bool IsDefault(T value) => EqualityComparer.Equals(value, DefaultValue);
     }
     }
 }
 }

+ 1 - 1
csharp/src/Google.Protobuf/JsonTokenizer.cs

@@ -245,7 +245,7 @@ namespace Google.Protobuf
                             state = State.ObjectAfterColon;
                             state = State.ObjectAfterColon;
                             break;
                             break;
                         case ',':
                         case ',':
-                            ValidateState(State.ObjectAfterProperty | State.ArrayAfterValue, "Invalid state to read a colon: ");
+                            ValidateState(State.ObjectAfterProperty | State.ArrayAfterValue, "Invalid state to read a comma: ");
                             state = state == State.ObjectAfterProperty ? State.ObjectAfterComma : State.ArrayAfterComma;
                             state = state == State.ObjectAfterProperty ? State.ObjectAfterComma : State.ArrayAfterComma;
                             break;
                             break;
                         case '"':
                         case '"':

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 199 - 29
csharp/src/Google.Protobuf/Reflection/Descriptor.cs


+ 263 - 0
csharp/src/Google.Protobuf/UnknownField.cs

@@ -0,0 +1,263 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2017 Google Inc.  All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using Google.Protobuf.Collections;
+
+namespace Google.Protobuf
+{
+    /// <summary>
+    /// Represents a single field in an UnknownFieldSet.
+    ///
+    /// An UnknownField consists of four lists of values. The lists correspond
+    /// to the four "wire types" used in the protocol buffer binary format.
+    /// Normally, only one of the four lists will contain any values, since it
+    /// is impossible to define a valid message type that declares two different
+    /// types for the same field number. However, the code is designed to allow
+    /// for the case where the same unknown field number is encountered using
+    /// multiple different wire types.
+    ///
+    /// </summary>
+    internal sealed class UnknownField
+    {
+        private List<ulong> varintList;
+        private List<uint> fixed32List;
+        private List<ulong> fixed64List;
+        private List<ByteString> lengthDelimitedList;
+
+        /// <summary>
+        /// Creates a new UnknownField.
+        /// </summary>
+        public UnknownField()
+        {
+        }
+
+        /// <summary>
+        /// Checks if two unknown field are equal.
+        /// </summary>
+        public override bool Equals(object other)
+        {
+            if (ReferenceEquals(this, other))
+            {
+                return true;
+            }
+            UnknownField otherField = other as UnknownField;
+            return otherField != null
+                   && Lists.Equals(varintList, otherField.varintList)
+                   && Lists.Equals(fixed32List, otherField.fixed32List)
+                   && Lists.Equals(fixed64List, otherField.fixed64List)
+                   && Lists.Equals(lengthDelimitedList, otherField.lengthDelimitedList);
+        }
+
+        /// <summary>
+        /// Get the hash code of the unknown field.
+        /// </summary>
+        public override int GetHashCode()
+        {
+            int hash = 43;
+            hash = hash * 47 + Lists.GetHashCode(varintList);
+            hash = hash * 47 + Lists.GetHashCode(fixed32List);
+            hash = hash * 47 + Lists.GetHashCode(fixed64List);
+            hash = hash * 47 + Lists.GetHashCode(lengthDelimitedList);
+            return hash;
+        }
+
+        /// <summary>
+        /// Serializes the field, including the field number, and writes it to
+        /// <paramref name="output"/>
+        /// </summary>
+        /// <param name="fieldNumber">The unknown field number.</param>
+        /// <param name="output">The CodedOutputStream to write to.</param>
+        internal void WriteTo(int fieldNumber, CodedOutputStream output)
+        {
+            if (varintList != null)
+            {
+                foreach (ulong value in varintList)
+                {
+                    output.WriteTag(fieldNumber, WireFormat.WireType.Varint);
+                    output.WriteUInt64(value);
+                }
+            }
+            if (fixed32List != null)
+            {
+                foreach (uint value in fixed32List)
+                {
+                    output.WriteTag(fieldNumber, WireFormat.WireType.Fixed32);
+                    output.WriteFixed32(value);
+                }
+            }
+            if (fixed64List != null)
+            {
+                foreach (ulong value in fixed64List)
+                {
+                    output.WriteTag(fieldNumber, WireFormat.WireType.Fixed64);
+                    output.WriteFixed64(value);
+                }
+            }
+            if (lengthDelimitedList != null)
+            {
+                foreach (ByteString value in lengthDelimitedList)
+                {
+                    output.WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
+                    output.WriteBytes(value);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Computes the number of bytes required to encode this field, including field
+        /// number.
+        /// </summary>
+        internal int GetSerializedSize(int fieldNumber)
+        {
+            int result = 0;
+            if (varintList != null)
+            {
+                result += CodedOutputStream.ComputeTagSize(fieldNumber) * varintList.Count;
+                foreach (ulong value in varintList)
+                {
+                    result += CodedOutputStream.ComputeUInt64Size(value);
+                }
+            }
+            if (fixed32List != null)
+            {
+                result += CodedOutputStream.ComputeTagSize(fieldNumber) * fixed32List.Count;
+                result += CodedOutputStream.ComputeFixed32Size(1) * fixed32List.Count;
+            }
+            if (fixed64List != null)
+            {
+                result += CodedOutputStream.ComputeTagSize(fieldNumber) * fixed64List.Count;
+                result += CodedOutputStream.ComputeFixed64Size(1) * fixed64List.Count;
+            }                
+            if (lengthDelimitedList != null)
+            {
+                result += CodedOutputStream.ComputeTagSize(fieldNumber) * lengthDelimitedList.Count;
+                foreach (ByteString value in lengthDelimitedList)
+                {
+                    result += CodedOutputStream.ComputeBytesSize(value);
+                }
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// Merge the values in <paramref name="other" /> into this field.  For each list
+        /// of values, <paramref name="other"/>'s values are append to the ones in this
+        /// field.
+        /// </summary>
+        internal UnknownField MergeFrom(UnknownField other)
+        {
+            varintList = AddAll(varintList, other.varintList);
+            fixed32List = AddAll(fixed32List, other.fixed32List);
+            fixed64List = AddAll(fixed64List, other.fixed64List);
+            lengthDelimitedList = AddAll(lengthDelimitedList, other.lengthDelimitedList);
+            return this;
+        }
+
+        /// <summary>
+        /// Returns a new list containing all of the given specified values from
+        /// both the <paramref name="current"/> and <paramref name="extras"/> lists.
+        /// If <paramref name="current" /> is null and <paramref name="extras"/> is empty,
+        /// null is returned. Otherwise, either a new list is created (if <paramref name="current" />
+        /// is null) or the elements of <paramref name="extras"/> are added to <paramref name="current" />.
+        /// </summary>
+        private static List<T> AddAll<T>(List<T> current, IList<T> extras)
+        {
+            if (extras.Count == 0)
+            {
+                return current;
+            }
+            if (current == null)
+            {
+                current = new List<T>(extras);
+            }
+            else
+            {
+                current.AddRange(extras);
+            }
+            return current;
+        }
+
+        /// <summary>
+        /// Adds a varint value.
+        /// </summary>
+        internal UnknownField AddVarint(ulong value)
+        {
+            varintList = Add(varintList, value);
+            return this;
+        }
+
+        /// <summary>
+        /// Adds a fixed32 value.
+        /// </summary>
+        internal UnknownField AddFixed32(uint value)
+        {
+            fixed32List = Add(fixed32List, value);
+            return this;
+        }
+
+        /// <summary>
+        /// Adds a fixed64 value.
+        /// </summary>
+        internal UnknownField AddFixed64(ulong value)
+        {
+            fixed64List = Add(fixed64List, value);
+            return this;
+        }
+
+        /// <summary>
+        /// Adds a length-delimited value.
+        /// </summary>
+        internal UnknownField AddLengthDelimited(ByteString value)
+        {
+            lengthDelimitedList = Add(lengthDelimitedList, value);
+            return this;
+        }
+
+        /// <summary>
+        /// Adds <paramref name="value"/> to the <paramref name="list"/>, creating
+        /// a new list if <paramref name="list"/> is null. The list is returned - either
+        /// the original reference or the new list.
+        /// </summary>
+        private static List<T> Add<T>(List<T> list, T value)
+        {
+            if (list == null)
+            {
+                list = new List<T>();
+            }
+            list.Add(value);
+            return list;
+        }
+    }
+}

+ 324 - 0
csharp/src/Google.Protobuf/UnknownFieldSet.cs

@@ -0,0 +1,324 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc.  All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using Google.Protobuf.Reflection;
+
+namespace Google.Protobuf
+{
+    /// <summary>
+    /// Used to keep track of fields which were seen when parsing a protocol message
+    /// but whose field numbers or types are unrecognized. This most frequently
+    /// occurs when new fields are added to a message type and then messages containing
+    /// those fields are read by old software that was built before the new types were
+    /// added.
+    ///
+    /// Most users will never need to use this class directly.
+    /// </summary>
+    public sealed partial class UnknownFieldSet
+    {
+        private readonly IDictionary<int, UnknownField> fields;
+
+        /// <summary>
+        /// Creates a new UnknownFieldSet.
+        /// </summary>
+        internal UnknownFieldSet()
+        {
+            this.fields = new Dictionary<int, UnknownField>();
+        }
+
+        /// <summary>
+        /// Checks whether or not the given field number is present in the set.
+        /// </summary>
+        internal bool HasField(int field)
+        {
+            return fields.ContainsKey(field);
+        }
+
+        /// <summary>
+        /// Serializes the set and writes it to <paramref name="output"/>.
+        /// </summary>
+        public void WriteTo(CodedOutputStream output)
+        {
+            foreach (KeyValuePair<int, UnknownField> entry in fields)
+            {
+                entry.Value.WriteTo(entry.Key, output);
+            }
+        }
+
+        /// <summary>
+        /// Gets the number of bytes required to encode this set.
+        /// </summary>
+        public int CalculateSize()
+        {
+            int result = 0;
+            foreach (KeyValuePair<int, UnknownField> entry in fields)
+            {
+                result += entry.Value.GetSerializedSize(entry.Key);
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// Checks if two unknown field sets are equal.
+        /// </summary>
+        public override bool Equals(object other)
+        {
+            if (ReferenceEquals(this, other))
+            {
+                return true;
+            }
+            UnknownFieldSet otherSet = other as UnknownFieldSet;
+            IDictionary<int, UnknownField> otherFields = otherSet.fields;
+            if (fields.Count  != otherFields.Count)
+            {
+                return false;
+            }
+            foreach (KeyValuePair<int, UnknownField> leftEntry in fields)
+            {
+                UnknownField rightValue;
+                if (!otherFields.TryGetValue(leftEntry.Key, out rightValue))
+                {
+                    return false;
+                }
+                if (!leftEntry.Value.Equals(rightValue))
+                {
+                    return false;
+                }
+            }
+            return true;
+        }
+
+        /// <summary>
+        /// Gets the unknown field set's hash code.
+        /// </summary>
+        public override int GetHashCode()
+        {
+            int ret = 1;
+            foreach (KeyValuePair<int, UnknownField> field in fields)
+            {
+                // Use ^ here to make the field order irrelevant.
+                int hash = field.Key.GetHashCode() ^ field.Value.GetHashCode();
+                ret ^= hash;
+            }
+            return ret;
+        }
+
+        // Optimization:  We keep around the last field that was
+        // modified so that we can efficiently add to it multiple times in a
+        // row (important when parsing an unknown repeated field).
+        private int lastFieldNumber;
+        private UnknownField lastField;
+
+        private UnknownField GetOrAddField(int number)
+        {
+            if (lastField != null && number == lastFieldNumber)
+            {
+                return lastField;
+            }
+            if (number == 0)
+            {
+                return null;
+            }
+
+            UnknownField existing;
+            if (fields.TryGetValue(number, out existing))
+            {
+                return existing;
+            }
+            lastField = new UnknownField();
+            AddOrReplaceField(number, lastField);
+            lastFieldNumber = number;
+            return lastField;
+        }
+
+        /// <summary>
+        /// Adds a field to the set. If a field with the same number already exists, it
+        /// is replaced.
+        /// </summary>
+        internal UnknownFieldSet AddOrReplaceField(int number, UnknownField field)
+        {
+            if (number == 0)
+            {
+                throw new ArgumentOutOfRangeException("number", "Zero is not a valid field number.");
+            }
+            fields[number] = field;
+            return this;
+        }
+
+        /// <summary>
+        /// Parse a single field from <paramref name="input"/> and merge it
+        /// into this set.
+        /// </summary>
+        /// <param name="input">The coded input stream containing the field</param>
+        /// <returns>false if the tag is an "end group" tag, true otherwise</returns>
+        private void MergeFieldFrom(CodedInputStream input)
+        {
+            uint tag = input.LastTag;
+            int number = WireFormat.GetTagFieldNumber(tag);
+            switch (WireFormat.GetTagWireType(tag))
+            {
+                case WireFormat.WireType.Varint:
+                    {
+                        ulong uint64 = input.ReadUInt64();
+                        GetOrAddField(number).AddVarint(uint64);
+                        return;
+                    }
+                case WireFormat.WireType.Fixed32:
+                    {
+                        uint uint32 = input.ReadFixed32();
+                        GetOrAddField(number).AddFixed32(uint32);
+                        return;
+                    }
+                case WireFormat.WireType.Fixed64:
+                    {
+                        ulong uint64 = input.ReadFixed64();
+                        GetOrAddField(number).AddFixed64(uint64);
+                        return;
+                    }
+                case WireFormat.WireType.LengthDelimited:
+                    {
+                        ByteString bytes = input.ReadBytes();
+                        GetOrAddField(number).AddLengthDelimited(bytes);
+                        return;
+                    }
+                case WireFormat.WireType.StartGroup:
+                    {
+                        input.SkipGroup(tag);
+                        return;
+                    }
+                case WireFormat.WireType.EndGroup:
+                    {
+                        throw new InvalidProtocolBufferException("Merge an unknown field of end-group tag, indicating that the corresponding start-group was missing.");
+                    }
+                default:
+                    throw new InvalidOperationException("Wire Type is invalid.");
+            }
+        }
+
+        /// <summary>
+        /// Create a new UnknownFieldSet if unknownFields is null.
+        /// Parse a single field from <paramref name="input"/> and merge it
+        /// into unknownFields.
+        /// </summary>
+        /// <param name="unknownFields">The UnknownFieldSet which need to be merged</param>
+        /// <param name="input">The coded input stream containing the field</param>
+        /// <returns>The merged UnknownFieldSet</returns>
+        public static UnknownFieldSet MergeFieldFrom(UnknownFieldSet unknownFields,
+                                                     CodedInputStream input)
+        {
+            if (unknownFields == null)
+            {
+                unknownFields = new UnknownFieldSet();
+            }
+            unknownFields.MergeFieldFrom(input);
+            return unknownFields;
+        }
+
+        /// <summary>
+        /// Merges the fields from <paramref name="other"/> into this set.
+        /// If a field number exists in both sets, the values in <paramref name="other"/>
+        /// will be appended to the values in this set.
+        /// </summary>
+        private UnknownFieldSet MergeFrom(UnknownFieldSet other)
+        {
+            if (other != null)
+            {
+                foreach (KeyValuePair<int, UnknownField> entry in other.fields)
+                {
+                    MergeField(entry.Key, entry.Value);
+                }
+            }
+            return this;
+        }
+
+        /// <summary>
+        /// Created a new UnknownFieldSet to <paramref name="unknownFields"/> if
+        /// needed and merges the fields from <paramref name="other"/> into the first set.
+        /// If a field number exists in both sets, the values in <paramref name="other"/>
+        /// will be appended to the values in this set.
+        /// </summary>
+        public static UnknownFieldSet MergeFrom(UnknownFieldSet unknownFields,
+                                                UnknownFieldSet other)
+        {
+            if (other == null)
+            {
+                return unknownFields;
+            }
+            if (unknownFields == null)
+            {
+                unknownFields = new UnknownFieldSet();
+            }
+            unknownFields.MergeFrom(other);
+            return unknownFields;
+        }
+
+
+        /// <summary>
+        /// Adds a field to the unknown field set. If a field with the same
+        /// number already exists, the two are merged.
+        /// </summary>
+        private UnknownFieldSet MergeField(int number, UnknownField field)
+        {
+            if (number == 0)
+            {
+                throw new ArgumentOutOfRangeException("number", "Zero is not a valid field number.");
+            }
+            if (HasField(number))
+            {
+                GetOrAddField(number).MergeFrom(field);
+            }
+            else
+            {
+                AddOrReplaceField(number, field);
+            }
+            return this;
+        }
+
+        /// <summary>
+        /// Clone an unknown field set from <paramref name="other"/>.
+        /// </summary>
+        public static UnknownFieldSet Clone(UnknownFieldSet other)
+        {
+            if (other == null)
+            {
+                return null;
+            }
+            UnknownFieldSet unknownFields = new UnknownFieldSet();
+            unknownFields.MergeFrom(other);
+            return unknownFields;
+        }
+    }
+}
+

+ 18 - 4
csharp/src/Google.Protobuf/WellKnownTypes/Any.cs

@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: google/protobuf/any.proto
+// <auto-generated>
+//     Generated by the protocol buffer compiler.  DO NOT EDIT!
+//     source: google/protobuf/any.proto
+// </auto-generated>
 #pragma warning disable 1591, 0612, 3021
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code
 #region Designer generated code
 
 
@@ -119,6 +121,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class Any : pb::IMessage<Any> {
   public sealed partial class Any : pb::IMessage<Any> {
     private static readonly pb::MessageParser<Any> _parser = new pb::MessageParser<Any>(() => new Any());
     private static readonly pb::MessageParser<Any> _parser = new pb::MessageParser<Any>(() => new Any());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<Any> Parser { get { return _parser; } }
     public static pb::MessageParser<Any> Parser { get { return _parser; } }
 
 
@@ -143,6 +146,7 @@ namespace Google.Protobuf.WellKnownTypes {
     public Any(Any other) : this() {
     public Any(Any other) : this() {
       typeUrl_ = other.typeUrl_;
       typeUrl_ = other.typeUrl_;
       value_ = other.value_;
       value_ = other.value_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -213,7 +217,7 @@ namespace Google.Protobuf.WellKnownTypes {
       }
       }
       if (TypeUrl != other.TypeUrl) return false;
       if (TypeUrl != other.TypeUrl) return false;
       if (Value != other.Value) return false;
       if (Value != other.Value) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -221,6 +225,9 @@ namespace Google.Protobuf.WellKnownTypes {
       int hash = 1;
       int hash = 1;
       if (TypeUrl.Length != 0) hash ^= TypeUrl.GetHashCode();
       if (TypeUrl.Length != 0) hash ^= TypeUrl.GetHashCode();
       if (Value.Length != 0) hash ^= Value.GetHashCode();
       if (Value.Length != 0) hash ^= Value.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -239,6 +246,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(18);
         output.WriteRawTag(18);
         output.WriteBytes(Value);
         output.WriteBytes(Value);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -250,6 +260,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (Value.Length != 0) {
       if (Value.Length != 0) {
         size += 1 + pb::CodedOutputStream.ComputeBytesSize(Value);
         size += 1 + pb::CodedOutputStream.ComputeBytesSize(Value);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -264,6 +277,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other.Value.Length != 0) {
       if (other.Value.Length != 0) {
         Value = other.Value;
         Value = other.Value;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -272,7 +286,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             TypeUrl = input.ReadString();
             TypeUrl = input.ReadString();

+ 46 - 8
csharp/src/Google.Protobuf/WellKnownTypes/Api.cs

@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: google/protobuf/api.proto
+// <auto-generated>
+//     Generated by the protocol buffer compiler.  DO NOT EDIT!
+//     source: google/protobuf/api.proto
+// </auto-generated>
 #pragma warning disable 1591, 0612, 3021
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code
 #region Designer generated code
 
 
@@ -64,6 +66,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class Api : pb::IMessage<Api> {
   public sealed partial class Api : pb::IMessage<Api> {
     private static readonly pb::MessageParser<Api> _parser = new pb::MessageParser<Api>(() => new Api());
     private static readonly pb::MessageParser<Api> _parser = new pb::MessageParser<Api>(() => new Api());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<Api> Parser { get { return _parser; } }
     public static pb::MessageParser<Api> Parser { get { return _parser; } }
 
 
@@ -93,6 +96,7 @@ namespace Google.Protobuf.WellKnownTypes {
       SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null;
       SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null;
       mixins_ = other.mixins_.Clone();
       mixins_ = other.mixins_.Clone();
       syntax_ = other.syntax_;
       syntax_ = other.syntax_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -235,7 +239,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (!object.Equals(SourceContext, other.SourceContext)) return false;
       if (!object.Equals(SourceContext, other.SourceContext)) return false;
       if(!mixins_.Equals(other.mixins_)) return false;
       if(!mixins_.Equals(other.mixins_)) return false;
       if (Syntax != other.Syntax) return false;
       if (Syntax != other.Syntax) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -248,6 +252,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (sourceContext_ != null) hash ^= SourceContext.GetHashCode();
       if (sourceContext_ != null) hash ^= SourceContext.GetHashCode();
       hash ^= mixins_.GetHashCode();
       hash ^= mixins_.GetHashCode();
       if (Syntax != 0) hash ^= Syntax.GetHashCode();
       if (Syntax != 0) hash ^= Syntax.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -277,6 +284,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(56);
         output.WriteRawTag(56);
         output.WriteEnum((int) Syntax);
         output.WriteEnum((int) Syntax);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -297,6 +307,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (Syntax != 0) {
       if (Syntax != 0) {
         size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax);
         size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -323,6 +336,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other.Syntax != 0) {
       if (other.Syntax != 0) {
         Syntax = other.Syntax;
         Syntax = other.Syntax;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -331,7 +345,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             Name = input.ReadString();
             Name = input.ReadString();
@@ -375,6 +389,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class Method : pb::IMessage<Method> {
   public sealed partial class Method : pb::IMessage<Method> {
     private static readonly pb::MessageParser<Method> _parser = new pb::MessageParser<Method>(() => new Method());
     private static readonly pb::MessageParser<Method> _parser = new pb::MessageParser<Method>(() => new Method());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<Method> Parser { get { return _parser; } }
     public static pb::MessageParser<Method> Parser { get { return _parser; } }
 
 
@@ -404,6 +419,7 @@ namespace Google.Protobuf.WellKnownTypes {
       responseStreaming_ = other.responseStreaming_;
       responseStreaming_ = other.responseStreaming_;
       options_ = other.options_.Clone();
       options_ = other.options_.Clone();
       syntax_ = other.syntax_;
       syntax_ = other.syntax_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -528,7 +544,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (ResponseStreaming != other.ResponseStreaming) return false;
       if (ResponseStreaming != other.ResponseStreaming) return false;
       if(!options_.Equals(other.options_)) return false;
       if(!options_.Equals(other.options_)) return false;
       if (Syntax != other.Syntax) return false;
       if (Syntax != other.Syntax) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -541,6 +557,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (ResponseStreaming != false) hash ^= ResponseStreaming.GetHashCode();
       if (ResponseStreaming != false) hash ^= ResponseStreaming.GetHashCode();
       hash ^= options_.GetHashCode();
       hash ^= options_.GetHashCode();
       if (Syntax != 0) hash ^= Syntax.GetHashCode();
       if (Syntax != 0) hash ^= Syntax.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -576,6 +595,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(56);
         output.WriteRawTag(56);
         output.WriteEnum((int) Syntax);
         output.WriteEnum((int) Syntax);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -600,6 +622,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (Syntax != 0) {
       if (Syntax != 0) {
         size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax);
         size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -627,6 +652,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other.Syntax != 0) {
       if (other.Syntax != 0) {
         Syntax = other.Syntax;
         Syntax = other.Syntax;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -635,7 +661,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             Name = input.ReadString();
             Name = input.ReadString();
@@ -753,6 +779,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class Mixin : pb::IMessage<Mixin> {
   public sealed partial class Mixin : pb::IMessage<Mixin> {
     private static readonly pb::MessageParser<Mixin> _parser = new pb::MessageParser<Mixin>(() => new Mixin());
     private static readonly pb::MessageParser<Mixin> _parser = new pb::MessageParser<Mixin>(() => new Mixin());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<Mixin> Parser { get { return _parser; } }
     public static pb::MessageParser<Mixin> Parser { get { return _parser; } }
 
 
@@ -777,6 +804,7 @@ namespace Google.Protobuf.WellKnownTypes {
     public Mixin(Mixin other) : this() {
     public Mixin(Mixin other) : this() {
       name_ = other.name_;
       name_ = other.name_;
       root_ = other.root_;
       root_ = other.root_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -828,7 +856,7 @@ namespace Google.Protobuf.WellKnownTypes {
       }
       }
       if (Name != other.Name) return false;
       if (Name != other.Name) return false;
       if (Root != other.Root) return false;
       if (Root != other.Root) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -836,6 +864,9 @@ namespace Google.Protobuf.WellKnownTypes {
       int hash = 1;
       int hash = 1;
       if (Name.Length != 0) hash ^= Name.GetHashCode();
       if (Name.Length != 0) hash ^= Name.GetHashCode();
       if (Root.Length != 0) hash ^= Root.GetHashCode();
       if (Root.Length != 0) hash ^= Root.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -854,6 +885,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(18);
         output.WriteRawTag(18);
         output.WriteString(Root);
         output.WriteString(Root);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -865,6 +899,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (Root.Length != 0) {
       if (Root.Length != 0) {
         size += 1 + pb::CodedOutputStream.ComputeStringSize(Root);
         size += 1 + pb::CodedOutputStream.ComputeStringSize(Root);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -879,6 +916,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other.Root.Length != 0) {
       if (other.Root.Length != 0) {
         Root = other.Root;
         Root = other.Root;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -887,7 +925,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             Name = input.ReadString();
             Name = input.ReadString();

+ 18 - 4
csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs

@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: google/protobuf/duration.proto
+// <auto-generated>
+//     Generated by the protocol buffer compiler.  DO NOT EDIT!
+//     source: google/protobuf/duration.proto
+// </auto-generated>
 #pragma warning disable 1591, 0612, 3021
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code
 #region Designer generated code
 
 
@@ -100,6 +102,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class Duration : pb::IMessage<Duration> {
   public sealed partial class Duration : pb::IMessage<Duration> {
     private static readonly pb::MessageParser<Duration> _parser = new pb::MessageParser<Duration>(() => new Duration());
     private static readonly pb::MessageParser<Duration> _parser = new pb::MessageParser<Duration>(() => new Duration());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<Duration> Parser { get { return _parser; } }
     public static pb::MessageParser<Duration> Parser { get { return _parser; } }
 
 
@@ -124,6 +127,7 @@ namespace Google.Protobuf.WellKnownTypes {
     public Duration(Duration other) : this() {
     public Duration(Duration other) : this() {
       seconds_ = other.seconds_;
       seconds_ = other.seconds_;
       nanos_ = other.nanos_;
       nanos_ = other.nanos_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -181,7 +185,7 @@ namespace Google.Protobuf.WellKnownTypes {
       }
       }
       if (Seconds != other.Seconds) return false;
       if (Seconds != other.Seconds) return false;
       if (Nanos != other.Nanos) return false;
       if (Nanos != other.Nanos) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -189,6 +193,9 @@ namespace Google.Protobuf.WellKnownTypes {
       int hash = 1;
       int hash = 1;
       if (Seconds != 0L) hash ^= Seconds.GetHashCode();
       if (Seconds != 0L) hash ^= Seconds.GetHashCode();
       if (Nanos != 0) hash ^= Nanos.GetHashCode();
       if (Nanos != 0) hash ^= Nanos.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -207,6 +214,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(16);
         output.WriteRawTag(16);
         output.WriteInt32(Nanos);
         output.WriteInt32(Nanos);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -218,6 +228,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (Nanos != 0) {
       if (Nanos != 0) {
         size += 1 + pb::CodedOutputStream.ComputeInt32Size(Nanos);
         size += 1 + pb::CodedOutputStream.ComputeInt32Size(Nanos);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -232,6 +245,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other.Nanos != 0) {
       if (other.Nanos != 0) {
         Nanos = other.Nanos;
         Nanos = other.Nanos;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -240,7 +254,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 8: {
           case 8: {
             Seconds = input.ReadInt64();
             Seconds = input.ReadInt64();

+ 18 - 4
csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs

@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: google/protobuf/empty.proto
+// <auto-generated>
+//     Generated by the protocol buffer compiler.  DO NOT EDIT!
+//     source: google/protobuf/empty.proto
+// </auto-generated>
 #pragma warning disable 1591, 0612, 3021
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code
 #region Designer generated code
 
 
@@ -50,6 +52,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class Empty : pb::IMessage<Empty> {
   public sealed partial class Empty : pb::IMessage<Empty> {
     private static readonly pb::MessageParser<Empty> _parser = new pb::MessageParser<Empty>(() => new Empty());
     private static readonly pb::MessageParser<Empty> _parser = new pb::MessageParser<Empty>(() => new Empty());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<Empty> Parser { get { return _parser; } }
     public static pb::MessageParser<Empty> Parser { get { return _parser; } }
 
 
@@ -72,6 +75,7 @@ namespace Google.Protobuf.WellKnownTypes {
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public Empty(Empty other) : this() {
     public Empty(Empty other) : this() {
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -92,12 +96,15 @@ namespace Google.Protobuf.WellKnownTypes {
       if (ReferenceEquals(other, this)) {
       if (ReferenceEquals(other, this)) {
         return true;
         return true;
       }
       }
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -108,11 +115,17 @@ namespace Google.Protobuf.WellKnownTypes {
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public void WriteTo(pb::CodedOutputStream output) {
     public void WriteTo(pb::CodedOutputStream output) {
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public int CalculateSize() {
     public int CalculateSize() {
       int size = 0;
       int size = 0;
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -121,6 +134,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other == null) {
       if (other == null) {
         return;
         return;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -129,7 +143,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
         }
         }
       }
       }

+ 18 - 4
csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs

@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: google/protobuf/field_mask.proto
+// <auto-generated>
+//     Generated by the protocol buffer compiler.  DO NOT EDIT!
+//     source: google/protobuf/field_mask.proto
+// </auto-generated>
 #pragma warning disable 1591, 0612, 3021
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code
 #region Designer generated code
 
 
@@ -248,6 +250,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class FieldMask : pb::IMessage<FieldMask> {
   public sealed partial class FieldMask : pb::IMessage<FieldMask> {
     private static readonly pb::MessageParser<FieldMask> _parser = new pb::MessageParser<FieldMask>(() => new FieldMask());
     private static readonly pb::MessageParser<FieldMask> _parser = new pb::MessageParser<FieldMask>(() => new FieldMask());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<FieldMask> Parser { get { return _parser; } }
     public static pb::MessageParser<FieldMask> Parser { get { return _parser; } }
 
 
@@ -271,6 +274,7 @@ namespace Google.Protobuf.WellKnownTypes {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public FieldMask(FieldMask other) : this() {
     public FieldMask(FieldMask other) : this() {
       paths_ = other.paths_.Clone();
       paths_ = other.paths_.Clone();
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -305,13 +309,16 @@ namespace Google.Protobuf.WellKnownTypes {
         return true;
         return true;
       }
       }
       if(!paths_.Equals(other.paths_)) return false;
       if(!paths_.Equals(other.paths_)) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       hash ^= paths_.GetHashCode();
       hash ^= paths_.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -323,12 +330,18 @@ namespace Google.Protobuf.WellKnownTypes {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public void WriteTo(pb::CodedOutputStream output) {
     public void WriteTo(pb::CodedOutputStream output) {
       paths_.WriteTo(output, _repeated_paths_codec);
       paths_.WriteTo(output, _repeated_paths_codec);
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public int CalculateSize() {
     public int CalculateSize() {
       int size = 0;
       int size = 0;
       size += paths_.CalculateSize(_repeated_paths_codec);
       size += paths_.CalculateSize(_repeated_paths_codec);
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -338,6 +351,7 @@ namespace Google.Protobuf.WellKnownTypes {
         return;
         return;
       }
       }
       paths_.Add(other.paths_);
       paths_.Add(other.paths_);
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -346,7 +360,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             paths_.AddEntriesFrom(input, _repeated_paths_codec);
             paths_.AddEntriesFrom(input, _repeated_paths_codec);

+ 18 - 4
csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs

@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: google/protobuf/source_context.proto
+// <auto-generated>
+//     Generated by the protocol buffer compiler.  DO NOT EDIT!
+//     source: google/protobuf/source_context.proto
+// </auto-generated>
 #pragma warning disable 1591, 0612, 3021
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code
 #region Designer generated code
 
 
@@ -44,6 +46,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class SourceContext : pb::IMessage<SourceContext> {
   public sealed partial class SourceContext : pb::IMessage<SourceContext> {
     private static readonly pb::MessageParser<SourceContext> _parser = new pb::MessageParser<SourceContext>(() => new SourceContext());
     private static readonly pb::MessageParser<SourceContext> _parser = new pb::MessageParser<SourceContext>(() => new SourceContext());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<SourceContext> Parser { get { return _parser; } }
     public static pb::MessageParser<SourceContext> Parser { get { return _parser; } }
 
 
@@ -67,6 +70,7 @@ namespace Google.Protobuf.WellKnownTypes {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public SourceContext(SourceContext other) : this() {
     public SourceContext(SourceContext other) : this() {
       fileName_ = other.fileName_;
       fileName_ = other.fileName_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -103,13 +107,16 @@ namespace Google.Protobuf.WellKnownTypes {
         return true;
         return true;
       }
       }
       if (FileName != other.FileName) return false;
       if (FileName != other.FileName) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       if (FileName.Length != 0) hash ^= FileName.GetHashCode();
       if (FileName.Length != 0) hash ^= FileName.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -124,6 +131,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(10);
         output.WriteRawTag(10);
         output.WriteString(FileName);
         output.WriteString(FileName);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -132,6 +142,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (FileName.Length != 0) {
       if (FileName.Length != 0) {
         size += 1 + pb::CodedOutputStream.ComputeStringSize(FileName);
         size += 1 + pb::CodedOutputStream.ComputeStringSize(FileName);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -143,6 +156,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other.FileName.Length != 0) {
       if (other.FileName.Length != 0) {
         FileName = other.FileName;
         FileName = other.FileName;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -151,7 +165,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             FileName = input.ReadString();
             FileName = input.ReadString();

+ 48 - 10
csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs

@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: google/protobuf/struct.proto
+// <auto-generated>
+//     Generated by the protocol buffer compiler.  DO NOT EDIT!
+//     source: google/protobuf/struct.proto
+// </auto-generated>
 #pragma warning disable 1591, 0612, 3021
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code
 #region Designer generated code
 
 
@@ -77,6 +79,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class Struct : pb::IMessage<Struct> {
   public sealed partial class Struct : pb::IMessage<Struct> {
     private static readonly pb::MessageParser<Struct> _parser = new pb::MessageParser<Struct>(() => new Struct());
     private static readonly pb::MessageParser<Struct> _parser = new pb::MessageParser<Struct>(() => new Struct());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<Struct> Parser { get { return _parser; } }
     public static pb::MessageParser<Struct> Parser { get { return _parser; } }
 
 
@@ -100,6 +103,7 @@ namespace Google.Protobuf.WellKnownTypes {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public Struct(Struct other) : this() {
     public Struct(Struct other) : this() {
       fields_ = other.fields_.Clone();
       fields_ = other.fields_.Clone();
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -134,13 +138,16 @@ namespace Google.Protobuf.WellKnownTypes {
         return true;
         return true;
       }
       }
       if (!Fields.Equals(other.Fields)) return false;
       if (!Fields.Equals(other.Fields)) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       hash ^= Fields.GetHashCode();
       hash ^= Fields.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -152,12 +159,18 @@ namespace Google.Protobuf.WellKnownTypes {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public void WriteTo(pb::CodedOutputStream output) {
     public void WriteTo(pb::CodedOutputStream output) {
       fields_.WriteTo(output, _map_fields_codec);
       fields_.WriteTo(output, _map_fields_codec);
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public int CalculateSize() {
     public int CalculateSize() {
       int size = 0;
       int size = 0;
       size += fields_.CalculateSize(_map_fields_codec);
       size += fields_.CalculateSize(_map_fields_codec);
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -167,6 +180,7 @@ namespace Google.Protobuf.WellKnownTypes {
         return;
         return;
       }
       }
       fields_.Add(other.fields_);
       fields_.Add(other.fields_);
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -175,7 +189,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             fields_.AddEntriesFrom(input, _map_fields_codec);
             fields_.AddEntriesFrom(input, _map_fields_codec);
@@ -197,6 +211,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class Value : pb::IMessage<Value> {
   public sealed partial class Value : pb::IMessage<Value> {
     private static readonly pb::MessageParser<Value> _parser = new pb::MessageParser<Value>(() => new Value());
     private static readonly pb::MessageParser<Value> _parser = new pb::MessageParser<Value>(() => new Value());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<Value> Parser { get { return _parser; } }
     public static pb::MessageParser<Value> Parser { get { return _parser; } }
 
 
@@ -240,6 +255,7 @@ namespace Google.Protobuf.WellKnownTypes {
           break;
           break;
       }
       }
 
 
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -368,25 +384,28 @@ namespace Google.Protobuf.WellKnownTypes {
         return true;
         return true;
       }
       }
       if (NullValue != other.NullValue) return false;
       if (NullValue != other.NullValue) return false;
-      if (NumberValue != other.NumberValue) return false;
+      if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(NumberValue, other.NumberValue)) return false;
       if (StringValue != other.StringValue) return false;
       if (StringValue != other.StringValue) return false;
       if (BoolValue != other.BoolValue) return false;
       if (BoolValue != other.BoolValue) return false;
       if (!object.Equals(StructValue, other.StructValue)) return false;
       if (!object.Equals(StructValue, other.StructValue)) return false;
       if (!object.Equals(ListValue, other.ListValue)) return false;
       if (!object.Equals(ListValue, other.ListValue)) return false;
       if (KindCase != other.KindCase) return false;
       if (KindCase != other.KindCase) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       if (kindCase_ == KindOneofCase.NullValue) hash ^= NullValue.GetHashCode();
       if (kindCase_ == KindOneofCase.NullValue) hash ^= NullValue.GetHashCode();
-      if (kindCase_ == KindOneofCase.NumberValue) hash ^= NumberValue.GetHashCode();
+      if (kindCase_ == KindOneofCase.NumberValue) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(NumberValue);
       if (kindCase_ == KindOneofCase.StringValue) hash ^= StringValue.GetHashCode();
       if (kindCase_ == KindOneofCase.StringValue) hash ^= StringValue.GetHashCode();
       if (kindCase_ == KindOneofCase.BoolValue) hash ^= BoolValue.GetHashCode();
       if (kindCase_ == KindOneofCase.BoolValue) hash ^= BoolValue.GetHashCode();
       if (kindCase_ == KindOneofCase.StructValue) hash ^= StructValue.GetHashCode();
       if (kindCase_ == KindOneofCase.StructValue) hash ^= StructValue.GetHashCode();
       if (kindCase_ == KindOneofCase.ListValue) hash ^= ListValue.GetHashCode();
       if (kindCase_ == KindOneofCase.ListValue) hash ^= ListValue.GetHashCode();
       hash ^= (int) kindCase_;
       hash ^= (int) kindCase_;
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -421,6 +440,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(50);
         output.WriteRawTag(50);
         output.WriteMessage(ListValue);
         output.WriteMessage(ListValue);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -444,6 +466,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (kindCase_ == KindOneofCase.ListValue) {
       if (kindCase_ == KindOneofCase.ListValue) {
         size += 1 + pb::CodedOutputStream.ComputeMessageSize(ListValue);
         size += 1 + pb::CodedOutputStream.ComputeMessageSize(ListValue);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -479,6 +504,7 @@ namespace Google.Protobuf.WellKnownTypes {
           break;
           break;
       }
       }
 
 
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -487,7 +513,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 8: {
           case 8: {
             kind_ = input.ReadEnum();
             kind_ = input.ReadEnum();
@@ -537,6 +563,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class ListValue : pb::IMessage<ListValue> {
   public sealed partial class ListValue : pb::IMessage<ListValue> {
     private static readonly pb::MessageParser<ListValue> _parser = new pb::MessageParser<ListValue>(() => new ListValue());
     private static readonly pb::MessageParser<ListValue> _parser = new pb::MessageParser<ListValue>(() => new ListValue());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<ListValue> Parser { get { return _parser; } }
     public static pb::MessageParser<ListValue> Parser { get { return _parser; } }
 
 
@@ -560,6 +587,7 @@ namespace Google.Protobuf.WellKnownTypes {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public ListValue(ListValue other) : this() {
     public ListValue(ListValue other) : this() {
       values_ = other.values_.Clone();
       values_ = other.values_.Clone();
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -594,13 +622,16 @@ namespace Google.Protobuf.WellKnownTypes {
         return true;
         return true;
       }
       }
       if(!values_.Equals(other.values_)) return false;
       if(!values_.Equals(other.values_)) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       hash ^= values_.GetHashCode();
       hash ^= values_.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -612,12 +643,18 @@ namespace Google.Protobuf.WellKnownTypes {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public void WriteTo(pb::CodedOutputStream output) {
     public void WriteTo(pb::CodedOutputStream output) {
       values_.WriteTo(output, _repeated_values_codec);
       values_.WriteTo(output, _repeated_values_codec);
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public int CalculateSize() {
     public int CalculateSize() {
       int size = 0;
       int size = 0;
       size += values_.CalculateSize(_repeated_values_codec);
       size += values_.CalculateSize(_repeated_values_codec);
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -627,6 +664,7 @@ namespace Google.Protobuf.WellKnownTypes {
         return;
         return;
       }
       }
       values_.Add(other.values_);
       values_.Add(other.values_);
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -635,7 +673,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             values_.AddEntriesFrom(input, _repeated_values_codec);
             values_.AddEntriesFrom(input, _repeated_values_codec);

+ 18 - 4
csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs

@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: google/protobuf/timestamp.proto
+// <auto-generated>
+//     Generated by the protocol buffer compiler.  DO NOT EDIT!
+//     source: google/protobuf/timestamp.proto
+// </auto-generated>
 #pragma warning disable 1591, 0612, 3021
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code
 #region Designer generated code
 
 
@@ -117,6 +119,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class Timestamp : pb::IMessage<Timestamp> {
   public sealed partial class Timestamp : pb::IMessage<Timestamp> {
     private static readonly pb::MessageParser<Timestamp> _parser = new pb::MessageParser<Timestamp>(() => new Timestamp());
     private static readonly pb::MessageParser<Timestamp> _parser = new pb::MessageParser<Timestamp>(() => new Timestamp());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<Timestamp> Parser { get { return _parser; } }
     public static pb::MessageParser<Timestamp> Parser { get { return _parser; } }
 
 
@@ -141,6 +144,7 @@ namespace Google.Protobuf.WellKnownTypes {
     public Timestamp(Timestamp other) : this() {
     public Timestamp(Timestamp other) : this() {
       seconds_ = other.seconds_;
       seconds_ = other.seconds_;
       nanos_ = other.nanos_;
       nanos_ = other.nanos_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -196,7 +200,7 @@ namespace Google.Protobuf.WellKnownTypes {
       }
       }
       if (Seconds != other.Seconds) return false;
       if (Seconds != other.Seconds) return false;
       if (Nanos != other.Nanos) return false;
       if (Nanos != other.Nanos) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -204,6 +208,9 @@ namespace Google.Protobuf.WellKnownTypes {
       int hash = 1;
       int hash = 1;
       if (Seconds != 0L) hash ^= Seconds.GetHashCode();
       if (Seconds != 0L) hash ^= Seconds.GetHashCode();
       if (Nanos != 0) hash ^= Nanos.GetHashCode();
       if (Nanos != 0) hash ^= Nanos.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -222,6 +229,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(16);
         output.WriteRawTag(16);
         output.WriteInt32(Nanos);
         output.WriteInt32(Nanos);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -233,6 +243,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (Nanos != 0) {
       if (Nanos != 0) {
         size += 1 + pb::CodedOutputStream.ComputeInt32Size(Nanos);
         size += 1 + pb::CodedOutputStream.ComputeInt32Size(Nanos);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -247,6 +260,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other.Nanos != 0) {
       if (other.Nanos != 0) {
         Nanos = other.Nanos;
         Nanos = other.Nanos;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -255,7 +269,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 8: {
           case 8: {
             Seconds = input.ReadInt64();
             Seconds = input.ReadInt64();

+ 74 - 12
csharp/src/Google.Protobuf/WellKnownTypes/Type.cs

@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: google/protobuf/type.proto
+// <auto-generated>
+//     Generated by the protocol buffer compiler.  DO NOT EDIT!
+//     source: google/protobuf/type.proto
+// </auto-generated>
 #pragma warning disable 1591, 0612, 3021
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code
 #region Designer generated code
 
 
@@ -94,6 +96,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class Type : pb::IMessage<Type> {
   public sealed partial class Type : pb::IMessage<Type> {
     private static readonly pb::MessageParser<Type> _parser = new pb::MessageParser<Type>(() => new Type());
     private static readonly pb::MessageParser<Type> _parser = new pb::MessageParser<Type>(() => new Type());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<Type> Parser { get { return _parser; } }
     public static pb::MessageParser<Type> Parser { get { return _parser; } }
 
 
@@ -122,6 +125,7 @@ namespace Google.Protobuf.WellKnownTypes {
       options_ = other.options_.Clone();
       options_ = other.options_.Clone();
       SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null;
       SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null;
       syntax_ = other.syntax_;
       syntax_ = other.syntax_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -229,7 +233,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if(!options_.Equals(other.options_)) return false;
       if(!options_.Equals(other.options_)) return false;
       if (!object.Equals(SourceContext, other.SourceContext)) return false;
       if (!object.Equals(SourceContext, other.SourceContext)) return false;
       if (Syntax != other.Syntax) return false;
       if (Syntax != other.Syntax) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -241,6 +245,9 @@ namespace Google.Protobuf.WellKnownTypes {
       hash ^= options_.GetHashCode();
       hash ^= options_.GetHashCode();
       if (sourceContext_ != null) hash ^= SourceContext.GetHashCode();
       if (sourceContext_ != null) hash ^= SourceContext.GetHashCode();
       if (Syntax != 0) hash ^= Syntax.GetHashCode();
       if (Syntax != 0) hash ^= Syntax.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -266,6 +273,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(48);
         output.WriteRawTag(48);
         output.WriteEnum((int) Syntax);
         output.WriteEnum((int) Syntax);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -283,6 +293,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (Syntax != 0) {
       if (Syntax != 0) {
         size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax);
         size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -306,6 +319,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other.Syntax != 0) {
       if (other.Syntax != 0) {
         Syntax = other.Syntax;
         Syntax = other.Syntax;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -314,7 +328,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             Name = input.ReadString();
             Name = input.ReadString();
@@ -354,6 +368,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class Field : pb::IMessage<Field> {
   public sealed partial class Field : pb::IMessage<Field> {
     private static readonly pb::MessageParser<Field> _parser = new pb::MessageParser<Field>(() => new Field());
     private static readonly pb::MessageParser<Field> _parser = new pb::MessageParser<Field>(() => new Field());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<Field> Parser { get { return _parser; } }
     public static pb::MessageParser<Field> Parser { get { return _parser; } }
 
 
@@ -386,6 +401,7 @@ namespace Google.Protobuf.WellKnownTypes {
       options_ = other.options_.Clone();
       options_ = other.options_.Clone();
       jsonName_ = other.jsonName_;
       jsonName_ = other.jsonName_;
       defaultValue_ = other.defaultValue_;
       defaultValue_ = other.defaultValue_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -557,7 +573,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if(!options_.Equals(other.options_)) return false;
       if(!options_.Equals(other.options_)) return false;
       if (JsonName != other.JsonName) return false;
       if (JsonName != other.JsonName) return false;
       if (DefaultValue != other.DefaultValue) return false;
       if (DefaultValue != other.DefaultValue) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -573,6 +589,9 @@ namespace Google.Protobuf.WellKnownTypes {
       hash ^= options_.GetHashCode();
       hash ^= options_.GetHashCode();
       if (JsonName.Length != 0) hash ^= JsonName.GetHashCode();
       if (JsonName.Length != 0) hash ^= JsonName.GetHashCode();
       if (DefaultValue.Length != 0) hash ^= DefaultValue.GetHashCode();
       if (DefaultValue.Length != 0) hash ^= DefaultValue.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -620,6 +639,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(90);
         output.WriteRawTag(90);
         output.WriteString(DefaultValue);
         output.WriteString(DefaultValue);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -653,6 +675,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (DefaultValue.Length != 0) {
       if (DefaultValue.Length != 0) {
         size += 1 + pb::CodedOutputStream.ComputeStringSize(DefaultValue);
         size += 1 + pb::CodedOutputStream.ComputeStringSize(DefaultValue);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -689,6 +714,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other.DefaultValue.Length != 0) {
       if (other.DefaultValue.Length != 0) {
         DefaultValue = other.DefaultValue;
         DefaultValue = other.DefaultValue;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -697,7 +723,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 8: {
           case 8: {
             kind_ = (global::Google.Protobuf.WellKnownTypes.Field.Types.Kind) input.ReadEnum();
             kind_ = (global::Google.Protobuf.WellKnownTypes.Field.Types.Kind) input.ReadEnum();
@@ -861,6 +887,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class Enum : pb::IMessage<Enum> {
   public sealed partial class Enum : pb::IMessage<Enum> {
     private static readonly pb::MessageParser<Enum> _parser = new pb::MessageParser<Enum>(() => new Enum());
     private static readonly pb::MessageParser<Enum> _parser = new pb::MessageParser<Enum>(() => new Enum());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<Enum> Parser { get { return _parser; } }
     public static pb::MessageParser<Enum> Parser { get { return _parser; } }
 
 
@@ -888,6 +915,7 @@ namespace Google.Protobuf.WellKnownTypes {
       options_ = other.options_.Clone();
       options_ = other.options_.Clone();
       SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null;
       SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null;
       syntax_ = other.syntax_;
       syntax_ = other.syntax_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -981,7 +1009,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if(!options_.Equals(other.options_)) return false;
       if(!options_.Equals(other.options_)) return false;
       if (!object.Equals(SourceContext, other.SourceContext)) return false;
       if (!object.Equals(SourceContext, other.SourceContext)) return false;
       if (Syntax != other.Syntax) return false;
       if (Syntax != other.Syntax) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -992,6 +1020,9 @@ namespace Google.Protobuf.WellKnownTypes {
       hash ^= options_.GetHashCode();
       hash ^= options_.GetHashCode();
       if (sourceContext_ != null) hash ^= SourceContext.GetHashCode();
       if (sourceContext_ != null) hash ^= SourceContext.GetHashCode();
       if (Syntax != 0) hash ^= Syntax.GetHashCode();
       if (Syntax != 0) hash ^= Syntax.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -1016,6 +1047,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(40);
         output.WriteRawTag(40);
         output.WriteEnum((int) Syntax);
         output.WriteEnum((int) Syntax);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1032,6 +1066,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (Syntax != 0) {
       if (Syntax != 0) {
         size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax);
         size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -1054,6 +1091,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other.Syntax != 0) {
       if (other.Syntax != 0) {
         Syntax = other.Syntax;
         Syntax = other.Syntax;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1062,7 +1100,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             Name = input.ReadString();
             Name = input.ReadString();
@@ -1098,6 +1136,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class EnumValue : pb::IMessage<EnumValue> {
   public sealed partial class EnumValue : pb::IMessage<EnumValue> {
     private static readonly pb::MessageParser<EnumValue> _parser = new pb::MessageParser<EnumValue>(() => new EnumValue());
     private static readonly pb::MessageParser<EnumValue> _parser = new pb::MessageParser<EnumValue>(() => new EnumValue());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<EnumValue> Parser { get { return _parser; } }
     public static pb::MessageParser<EnumValue> Parser { get { return _parser; } }
 
 
@@ -1123,6 +1162,7 @@ namespace Google.Protobuf.WellKnownTypes {
       name_ = other.name_;
       name_ = other.name_;
       number_ = other.number_;
       number_ = other.number_;
       options_ = other.options_.Clone();
       options_ = other.options_.Clone();
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1187,7 +1227,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (Name != other.Name) return false;
       if (Name != other.Name) return false;
       if (Number != other.Number) return false;
       if (Number != other.Number) return false;
       if(!options_.Equals(other.options_)) return false;
       if(!options_.Equals(other.options_)) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1196,6 +1236,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (Name.Length != 0) hash ^= Name.GetHashCode();
       if (Name.Length != 0) hash ^= Name.GetHashCode();
       if (Number != 0) hash ^= Number.GetHashCode();
       if (Number != 0) hash ^= Number.GetHashCode();
       hash ^= options_.GetHashCode();
       hash ^= options_.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -1215,6 +1258,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteInt32(Number);
         output.WriteInt32(Number);
       }
       }
       options_.WriteTo(output, _repeated_options_codec);
       options_.WriteTo(output, _repeated_options_codec);
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1227,6 +1273,9 @@ namespace Google.Protobuf.WellKnownTypes {
         size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number);
         size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number);
       }
       }
       size += options_.CalculateSize(_repeated_options_codec);
       size += options_.CalculateSize(_repeated_options_codec);
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -1242,6 +1291,7 @@ namespace Google.Protobuf.WellKnownTypes {
         Number = other.Number;
         Number = other.Number;
       }
       }
       options_.Add(other.options_);
       options_.Add(other.options_);
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1250,7 +1300,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             Name = input.ReadString();
             Name = input.ReadString();
@@ -1276,6 +1326,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class Option : pb::IMessage<Option> {
   public sealed partial class Option : pb::IMessage<Option> {
     private static readonly pb::MessageParser<Option> _parser = new pb::MessageParser<Option>(() => new Option());
     private static readonly pb::MessageParser<Option> _parser = new pb::MessageParser<Option>(() => new Option());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<Option> Parser { get { return _parser; } }
     public static pb::MessageParser<Option> Parser { get { return _parser; } }
 
 
@@ -1300,6 +1351,7 @@ namespace Google.Protobuf.WellKnownTypes {
     public Option(Option other) : this() {
     public Option(Option other) : this() {
       name_ = other.name_;
       name_ = other.name_;
       Value = other.value_ != null ? other.Value.Clone() : null;
       Value = other.value_ != null ? other.Value.Clone() : null;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1356,7 +1408,7 @@ namespace Google.Protobuf.WellKnownTypes {
       }
       }
       if (Name != other.Name) return false;
       if (Name != other.Name) return false;
       if (!object.Equals(Value, other.Value)) return false;
       if (!object.Equals(Value, other.Value)) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1364,6 +1416,9 @@ namespace Google.Protobuf.WellKnownTypes {
       int hash = 1;
       int hash = 1;
       if (Name.Length != 0) hash ^= Name.GetHashCode();
       if (Name.Length != 0) hash ^= Name.GetHashCode();
       if (value_ != null) hash ^= Value.GetHashCode();
       if (value_ != null) hash ^= Value.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -1382,6 +1437,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(18);
         output.WriteRawTag(18);
         output.WriteMessage(Value);
         output.WriteMessage(Value);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1393,6 +1451,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (value_ != null) {
       if (value_ != null) {
         size += 1 + pb::CodedOutputStream.ComputeMessageSize(Value);
         size += 1 + pb::CodedOutputStream.ComputeMessageSize(Value);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -1410,6 +1471,7 @@ namespace Google.Protobuf.WellKnownTypes {
         }
         }
         Value.MergeFrom(other.Value);
         Value.MergeFrom(other.Value);
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1418,7 +1480,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             Name = input.ReadString();
             Name = input.ReadString();

+ 134 - 24
csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs

@@ -1,5 +1,7 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: google/protobuf/wrappers.proto
+// <auto-generated>
+//     Generated by the protocol buffer compiler.  DO NOT EDIT!
+//     source: google/protobuf/wrappers.proto
+// </auto-generated>
 #pragma warning disable 1591, 0612, 3021
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code
 #region Designer generated code
 
 
@@ -57,6 +59,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class DoubleValue : pb::IMessage<DoubleValue> {
   public sealed partial class DoubleValue : pb::IMessage<DoubleValue> {
     private static readonly pb::MessageParser<DoubleValue> _parser = new pb::MessageParser<DoubleValue>(() => new DoubleValue());
     private static readonly pb::MessageParser<DoubleValue> _parser = new pb::MessageParser<DoubleValue>(() => new DoubleValue());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<DoubleValue> Parser { get { return _parser; } }
     public static pb::MessageParser<DoubleValue> Parser { get { return _parser; } }
 
 
@@ -80,6 +83,7 @@ namespace Google.Protobuf.WellKnownTypes {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public DoubleValue(DoubleValue other) : this() {
     public DoubleValue(DoubleValue other) : this() {
       value_ = other.value_;
       value_ = other.value_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -114,14 +118,17 @@ namespace Google.Protobuf.WellKnownTypes {
       if (ReferenceEquals(other, this)) {
       if (ReferenceEquals(other, this)) {
         return true;
         return true;
       }
       }
-      if (Value != other.Value) return false;
-      return true;
+      if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(Value, other.Value)) return false;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
-      if (Value != 0D) hash ^= Value.GetHashCode();
+      if (Value != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Value);
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -136,6 +143,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(9);
         output.WriteRawTag(9);
         output.WriteDouble(Value);
         output.WriteDouble(Value);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -144,6 +154,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (Value != 0D) {
       if (Value != 0D) {
         size += 1 + 8;
         size += 1 + 8;
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -155,6 +168,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other.Value != 0D) {
       if (other.Value != 0D) {
         Value = other.Value;
         Value = other.Value;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -163,7 +177,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 9: {
           case 9: {
             Value = input.ReadDouble();
             Value = input.ReadDouble();
@@ -182,6 +196,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class FloatValue : pb::IMessage<FloatValue> {
   public sealed partial class FloatValue : pb::IMessage<FloatValue> {
     private static readonly pb::MessageParser<FloatValue> _parser = new pb::MessageParser<FloatValue>(() => new FloatValue());
     private static readonly pb::MessageParser<FloatValue> _parser = new pb::MessageParser<FloatValue>(() => new FloatValue());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<FloatValue> Parser { get { return _parser; } }
     public static pb::MessageParser<FloatValue> Parser { get { return _parser; } }
 
 
@@ -205,6 +220,7 @@ namespace Google.Protobuf.WellKnownTypes {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public FloatValue(FloatValue other) : this() {
     public FloatValue(FloatValue other) : this() {
       value_ = other.value_;
       value_ = other.value_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -239,14 +255,17 @@ namespace Google.Protobuf.WellKnownTypes {
       if (ReferenceEquals(other, this)) {
       if (ReferenceEquals(other, this)) {
         return true;
         return true;
       }
       }
-      if (Value != other.Value) return false;
-      return true;
+      if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(Value, other.Value)) return false;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
-      if (Value != 0F) hash ^= Value.GetHashCode();
+      if (Value != 0F) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(Value);
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -261,6 +280,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(13);
         output.WriteRawTag(13);
         output.WriteFloat(Value);
         output.WriteFloat(Value);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -269,6 +291,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (Value != 0F) {
       if (Value != 0F) {
         size += 1 + 4;
         size += 1 + 4;
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -280,6 +305,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other.Value != 0F) {
       if (other.Value != 0F) {
         Value = other.Value;
         Value = other.Value;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -288,7 +314,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 13: {
           case 13: {
             Value = input.ReadFloat();
             Value = input.ReadFloat();
@@ -307,6 +333,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class Int64Value : pb::IMessage<Int64Value> {
   public sealed partial class Int64Value : pb::IMessage<Int64Value> {
     private static readonly pb::MessageParser<Int64Value> _parser = new pb::MessageParser<Int64Value>(() => new Int64Value());
     private static readonly pb::MessageParser<Int64Value> _parser = new pb::MessageParser<Int64Value>(() => new Int64Value());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<Int64Value> Parser { get { return _parser; } }
     public static pb::MessageParser<Int64Value> Parser { get { return _parser; } }
 
 
@@ -330,6 +357,7 @@ namespace Google.Protobuf.WellKnownTypes {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public Int64Value(Int64Value other) : this() {
     public Int64Value(Int64Value other) : this() {
       value_ = other.value_;
       value_ = other.value_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -365,13 +393,16 @@ namespace Google.Protobuf.WellKnownTypes {
         return true;
         return true;
       }
       }
       if (Value != other.Value) return false;
       if (Value != other.Value) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       if (Value != 0L) hash ^= Value.GetHashCode();
       if (Value != 0L) hash ^= Value.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -386,6 +417,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(8);
         output.WriteRawTag(8);
         output.WriteInt64(Value);
         output.WriteInt64(Value);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -394,6 +428,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (Value != 0L) {
       if (Value != 0L) {
         size += 1 + pb::CodedOutputStream.ComputeInt64Size(Value);
         size += 1 + pb::CodedOutputStream.ComputeInt64Size(Value);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -405,6 +442,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other.Value != 0L) {
       if (other.Value != 0L) {
         Value = other.Value;
         Value = other.Value;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -413,7 +451,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 8: {
           case 8: {
             Value = input.ReadInt64();
             Value = input.ReadInt64();
@@ -432,6 +470,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class UInt64Value : pb::IMessage<UInt64Value> {
   public sealed partial class UInt64Value : pb::IMessage<UInt64Value> {
     private static readonly pb::MessageParser<UInt64Value> _parser = new pb::MessageParser<UInt64Value>(() => new UInt64Value());
     private static readonly pb::MessageParser<UInt64Value> _parser = new pb::MessageParser<UInt64Value>(() => new UInt64Value());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<UInt64Value> Parser { get { return _parser; } }
     public static pb::MessageParser<UInt64Value> Parser { get { return _parser; } }
 
 
@@ -455,6 +494,7 @@ namespace Google.Protobuf.WellKnownTypes {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public UInt64Value(UInt64Value other) : this() {
     public UInt64Value(UInt64Value other) : this() {
       value_ = other.value_;
       value_ = other.value_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -490,13 +530,16 @@ namespace Google.Protobuf.WellKnownTypes {
         return true;
         return true;
       }
       }
       if (Value != other.Value) return false;
       if (Value != other.Value) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       if (Value != 0UL) hash ^= Value.GetHashCode();
       if (Value != 0UL) hash ^= Value.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -511,6 +554,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(8);
         output.WriteRawTag(8);
         output.WriteUInt64(Value);
         output.WriteUInt64(Value);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -519,6 +565,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (Value != 0UL) {
       if (Value != 0UL) {
         size += 1 + pb::CodedOutputStream.ComputeUInt64Size(Value);
         size += 1 + pb::CodedOutputStream.ComputeUInt64Size(Value);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -530,6 +579,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other.Value != 0UL) {
       if (other.Value != 0UL) {
         Value = other.Value;
         Value = other.Value;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -538,7 +588,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 8: {
           case 8: {
             Value = input.ReadUInt64();
             Value = input.ReadUInt64();
@@ -557,6 +607,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class Int32Value : pb::IMessage<Int32Value> {
   public sealed partial class Int32Value : pb::IMessage<Int32Value> {
     private static readonly pb::MessageParser<Int32Value> _parser = new pb::MessageParser<Int32Value>(() => new Int32Value());
     private static readonly pb::MessageParser<Int32Value> _parser = new pb::MessageParser<Int32Value>(() => new Int32Value());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<Int32Value> Parser { get { return _parser; } }
     public static pb::MessageParser<Int32Value> Parser { get { return _parser; } }
 
 
@@ -580,6 +631,7 @@ namespace Google.Protobuf.WellKnownTypes {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public Int32Value(Int32Value other) : this() {
     public Int32Value(Int32Value other) : this() {
       value_ = other.value_;
       value_ = other.value_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -615,13 +667,16 @@ namespace Google.Protobuf.WellKnownTypes {
         return true;
         return true;
       }
       }
       if (Value != other.Value) return false;
       if (Value != other.Value) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       if (Value != 0) hash ^= Value.GetHashCode();
       if (Value != 0) hash ^= Value.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -636,6 +691,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(8);
         output.WriteRawTag(8);
         output.WriteInt32(Value);
         output.WriteInt32(Value);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -644,6 +702,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (Value != 0) {
       if (Value != 0) {
         size += 1 + pb::CodedOutputStream.ComputeInt32Size(Value);
         size += 1 + pb::CodedOutputStream.ComputeInt32Size(Value);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -655,6 +716,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other.Value != 0) {
       if (other.Value != 0) {
         Value = other.Value;
         Value = other.Value;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -663,7 +725,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 8: {
           case 8: {
             Value = input.ReadInt32();
             Value = input.ReadInt32();
@@ -682,6 +744,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class UInt32Value : pb::IMessage<UInt32Value> {
   public sealed partial class UInt32Value : pb::IMessage<UInt32Value> {
     private static readonly pb::MessageParser<UInt32Value> _parser = new pb::MessageParser<UInt32Value>(() => new UInt32Value());
     private static readonly pb::MessageParser<UInt32Value> _parser = new pb::MessageParser<UInt32Value>(() => new UInt32Value());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<UInt32Value> Parser { get { return _parser; } }
     public static pb::MessageParser<UInt32Value> Parser { get { return _parser; } }
 
 
@@ -705,6 +768,7 @@ namespace Google.Protobuf.WellKnownTypes {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public UInt32Value(UInt32Value other) : this() {
     public UInt32Value(UInt32Value other) : this() {
       value_ = other.value_;
       value_ = other.value_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -740,13 +804,16 @@ namespace Google.Protobuf.WellKnownTypes {
         return true;
         return true;
       }
       }
       if (Value != other.Value) return false;
       if (Value != other.Value) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       if (Value != 0) hash ^= Value.GetHashCode();
       if (Value != 0) hash ^= Value.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -761,6 +828,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(8);
         output.WriteRawTag(8);
         output.WriteUInt32(Value);
         output.WriteUInt32(Value);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -769,6 +839,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (Value != 0) {
       if (Value != 0) {
         size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Value);
         size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Value);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -780,6 +853,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other.Value != 0) {
       if (other.Value != 0) {
         Value = other.Value;
         Value = other.Value;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -788,7 +862,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 8: {
           case 8: {
             Value = input.ReadUInt32();
             Value = input.ReadUInt32();
@@ -807,6 +881,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class BoolValue : pb::IMessage<BoolValue> {
   public sealed partial class BoolValue : pb::IMessage<BoolValue> {
     private static readonly pb::MessageParser<BoolValue> _parser = new pb::MessageParser<BoolValue>(() => new BoolValue());
     private static readonly pb::MessageParser<BoolValue> _parser = new pb::MessageParser<BoolValue>(() => new BoolValue());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<BoolValue> Parser { get { return _parser; } }
     public static pb::MessageParser<BoolValue> Parser { get { return _parser; } }
 
 
@@ -830,6 +905,7 @@ namespace Google.Protobuf.WellKnownTypes {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public BoolValue(BoolValue other) : this() {
     public BoolValue(BoolValue other) : this() {
       value_ = other.value_;
       value_ = other.value_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -865,13 +941,16 @@ namespace Google.Protobuf.WellKnownTypes {
         return true;
         return true;
       }
       }
       if (Value != other.Value) return false;
       if (Value != other.Value) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       if (Value != false) hash ^= Value.GetHashCode();
       if (Value != false) hash ^= Value.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -886,6 +965,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(8);
         output.WriteRawTag(8);
         output.WriteBool(Value);
         output.WriteBool(Value);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -894,6 +976,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (Value != false) {
       if (Value != false) {
         size += 1 + 1;
         size += 1 + 1;
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -905,6 +990,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other.Value != false) {
       if (other.Value != false) {
         Value = other.Value;
         Value = other.Value;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -913,7 +999,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 8: {
           case 8: {
             Value = input.ReadBool();
             Value = input.ReadBool();
@@ -932,6 +1018,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class StringValue : pb::IMessage<StringValue> {
   public sealed partial class StringValue : pb::IMessage<StringValue> {
     private static readonly pb::MessageParser<StringValue> _parser = new pb::MessageParser<StringValue>(() => new StringValue());
     private static readonly pb::MessageParser<StringValue> _parser = new pb::MessageParser<StringValue>(() => new StringValue());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<StringValue> Parser { get { return _parser; } }
     public static pb::MessageParser<StringValue> Parser { get { return _parser; } }
 
 
@@ -955,6 +1042,7 @@ namespace Google.Protobuf.WellKnownTypes {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public StringValue(StringValue other) : this() {
     public StringValue(StringValue other) : this() {
       value_ = other.value_;
       value_ = other.value_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -990,13 +1078,16 @@ namespace Google.Protobuf.WellKnownTypes {
         return true;
         return true;
       }
       }
       if (Value != other.Value) return false;
       if (Value != other.Value) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       if (Value.Length != 0) hash ^= Value.GetHashCode();
       if (Value.Length != 0) hash ^= Value.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -1011,6 +1102,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(10);
         output.WriteRawTag(10);
         output.WriteString(Value);
         output.WriteString(Value);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1019,6 +1113,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (Value.Length != 0) {
       if (Value.Length != 0) {
         size += 1 + pb::CodedOutputStream.ComputeStringSize(Value);
         size += 1 + pb::CodedOutputStream.ComputeStringSize(Value);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -1030,6 +1127,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other.Value.Length != 0) {
       if (other.Value.Length != 0) {
         Value = other.Value;
         Value = other.Value;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1038,7 +1136,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             Value = input.ReadString();
             Value = input.ReadString();
@@ -1057,6 +1155,7 @@ namespace Google.Protobuf.WellKnownTypes {
   /// </summary>
   /// </summary>
   public sealed partial class BytesValue : pb::IMessage<BytesValue> {
   public sealed partial class BytesValue : pb::IMessage<BytesValue> {
     private static readonly pb::MessageParser<BytesValue> _parser = new pb::MessageParser<BytesValue>(() => new BytesValue());
     private static readonly pb::MessageParser<BytesValue> _parser = new pb::MessageParser<BytesValue>(() => new BytesValue());
+    private pb::UnknownFieldSet _unknownFields;
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pb::MessageParser<BytesValue> Parser { get { return _parser; } }
     public static pb::MessageParser<BytesValue> Parser { get { return _parser; } }
 
 
@@ -1080,6 +1179,7 @@ namespace Google.Protobuf.WellKnownTypes {
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public BytesValue(BytesValue other) : this() {
     public BytesValue(BytesValue other) : this() {
       value_ = other.value_;
       value_ = other.value_;
+      _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1115,13 +1215,16 @@ namespace Google.Protobuf.WellKnownTypes {
         return true;
         return true;
       }
       }
       if (Value != other.Value) return false;
       if (Value != other.Value) return false;
-      return true;
+      return Equals(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public override int GetHashCode() {
     public override int GetHashCode() {
       int hash = 1;
       int hash = 1;
       if (Value.Length != 0) hash ^= Value.GetHashCode();
       if (Value.Length != 0) hash ^= Value.GetHashCode();
+      if (_unknownFields != null) {
+        hash ^= _unknownFields.GetHashCode();
+      }
       return hash;
       return hash;
     }
     }
 
 
@@ -1136,6 +1239,9 @@ namespace Google.Protobuf.WellKnownTypes {
         output.WriteRawTag(10);
         output.WriteRawTag(10);
         output.WriteBytes(Value);
         output.WriteBytes(Value);
       }
       }
+      if (_unknownFields != null) {
+        _unknownFields.WriteTo(output);
+      }
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1144,6 +1250,9 @@ namespace Google.Protobuf.WellKnownTypes {
       if (Value.Length != 0) {
       if (Value.Length != 0) {
         size += 1 + pb::CodedOutputStream.ComputeBytesSize(Value);
         size += 1 + pb::CodedOutputStream.ComputeBytesSize(Value);
       }
       }
+      if (_unknownFields != null) {
+        size += _unknownFields.CalculateSize();
+      }
       return size;
       return size;
     }
     }
 
 
@@ -1155,6 +1264,7 @@ namespace Google.Protobuf.WellKnownTypes {
       if (other.Value.Length != 0) {
       if (other.Value.Length != 0) {
         Value = other.Value;
         Value = other.Value;
       }
       }
+      _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
     }
     }
 
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1163,7 +1273,7 @@ namespace Google.Protobuf.WellKnownTypes {
       while ((tag = input.ReadTag()) != 0) {
       while ((tag = input.ReadTag()) != 0) {
         switch(tag) {
         switch(tag) {
           default:
           default:
-            input.SkipLastField();
+            _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
             break;
             break;
           case 10: {
           case 10: {
             Value = input.ReadBytes();
             Value = input.ReadBytes();

+ 65 - 37
src/google/protobuf/compiler/csharp/csharp_message.cc

@@ -111,7 +111,7 @@ void MessageGenerator::Generate(io::Printer* printer) {
 
 
   WriteMessageDocComment(printer, descriptor_);
   WriteMessageDocComment(printer, descriptor_);
   AddDeprecatedFlag(printer);
   AddDeprecatedFlag(printer);
-  
+
   printer->Print(
   printer->Print(
     vars,
     vars,
     "$access_level$ sealed partial class $class_name$ : pb::IMessage<$class_name$> {\n");
     "$access_level$ sealed partial class $class_name$ : pb::IMessage<$class_name$> {\n");
@@ -119,14 +119,17 @@ void MessageGenerator::Generate(io::Printer* printer) {
 
 
   // All static fields and properties
   // All static fields and properties
   printer->Print(
   printer->Print(
-	  vars,
-	  "private static readonly pb::MessageParser<$class_name$> _parser = new pb::MessageParser<$class_name$>(() => new $class_name$());\n");
+      vars,
+      "private static readonly pb::MessageParser<$class_name$> _parser = new pb::MessageParser<$class_name$>(() => new $class_name$());\n");
+
+  printer->Print(
+      "private pb::UnknownFieldSet _unknownFields;\n");
 
 
   WriteGeneratedCodeAttributes(printer);
   WriteGeneratedCodeAttributes(printer);
 
 
   printer->Print(
   printer->Print(
-	  vars,
-	  "public static pb::MessageParser<$class_name$> Parser { get { return _parser; } }\n\n");
+      vars,
+      "public static pb::MessageParser<$class_name$> Parser { get { return _parser; } }\n\n");
 
 
   // Access the message descriptor via the relevant file descriptor or containing message descriptor.
   // Access the message descriptor via the relevant file descriptor or containing message descriptor.
   if (!descriptor_->containing_type()) {
   if (!descriptor_->containing_type()) {
@@ -139,14 +142,14 @@ void MessageGenerator::Generate(io::Printer* printer) {
 
 
   WriteGeneratedCodeAttributes(printer);
   WriteGeneratedCodeAttributes(printer);
   printer->Print(
   printer->Print(
-	vars,
-	"public static pbr::MessageDescriptor Descriptor {\n"
-	"  get { return $descriptor_accessor$; }\n"
-	"}\n"
-	"\n");
+    vars,
+    "public static pbr::MessageDescriptor Descriptor {\n"
+    "  get { return $descriptor_accessor$; }\n"
+    "}\n"
+    "\n");
   WriteGeneratedCodeAttributes(printer);
   WriteGeneratedCodeAttributes(printer);
   printer->Print(
   printer->Print(
-	vars,
+    vars,
     "pbr::MessageDescriptor pb::IMessage.Descriptor {\n"
     "pbr::MessageDescriptor pb::IMessage.Descriptor {\n"
     "  get { return Descriptor; }\n"
     "  get { return Descriptor; }\n"
     "}\n"
     "}\n"
@@ -209,18 +212,18 @@ void MessageGenerator::Generate(io::Printer* printer) {
     printer->Print("}\n");
     printer->Print("}\n");
     // TODO: Should we put the oneof .proto comments here?
     // TODO: Should we put the oneof .proto comments here?
     // It's unclear exactly where they should go.
     // It's unclear exactly where they should go.
-	printer->Print(
-	  vars,
-	  "private $property_name$OneofCase $name$Case_ = $property_name$OneofCase.None;\n");
-	WriteGeneratedCodeAttributes(printer);
-	printer->Print(
-	  vars,
-	  "public $property_name$OneofCase $property_name$Case {\n"
-	  "  get { return $name$Case_; }\n"
-	  "}\n\n");
-	WriteGeneratedCodeAttributes(printer);
-	printer->Print(
-	  vars,
+    printer->Print(
+      vars,
+      "private $property_name$OneofCase $name$Case_ = $property_name$OneofCase.None;\n");
+    WriteGeneratedCodeAttributes(printer);
+    printer->Print(
+      vars,
+      "public $property_name$OneofCase $property_name$Case {\n"
+      "  get { return $name$Case_; }\n"
+      "}\n\n");
+    WriteGeneratedCodeAttributes(printer);
+    printer->Print(
+      vars,
       "public void Clear$property_name$() {\n"
       "public void Clear$property_name$() {\n"
       "  $name$Case_ = $property_name$OneofCase.None;\n"
       "  $name$Case_ = $property_name$OneofCase.None;\n"
       "  $name$_ = null;\n"
       "  $name$_ = null;\n"
@@ -317,6 +320,9 @@ void MessageGenerator::GenerateCloningCode(io::Printer* printer) {
     printer->Outdent();
     printer->Outdent();
     printer->Print("}\n\n");
     printer->Print("}\n\n");
   }
   }
+  // Clone unknown fields
+  printer->Print(
+      "_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);\n");
 
 
   printer->Outdent();
   printer->Outdent();
   printer->Print("}\n\n");
   printer->Print("}\n\n");
@@ -337,15 +343,15 @@ void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) {
     vars["class_name"] = class_name();
     vars["class_name"] = class_name();
 
 
     // Equality
     // Equality
-	WriteGeneratedCodeAttributes(printer);
+    WriteGeneratedCodeAttributes(printer);
     printer->Print(
     printer->Print(
         vars,
         vars,
         "public override bool Equals(object other) {\n"
         "public override bool Equals(object other) {\n"
         "  return Equals(other as $class_name$);\n"
         "  return Equals(other as $class_name$);\n"
         "}\n\n");
         "}\n\n");
-	WriteGeneratedCodeAttributes(printer);
-	printer->Print(
-	    vars,
+    WriteGeneratedCodeAttributes(printer);
+    printer->Print(
+        vars,
         "public bool Equals($class_name$ other) {\n"
         "public bool Equals($class_name$ other) {\n"
         "  if (ReferenceEquals(other, null)) {\n"
         "  if (ReferenceEquals(other, null)) {\n"
         "    return false;\n"
         "    return false;\n"
@@ -365,13 +371,13 @@ void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) {
     }
     }
     printer->Outdent();
     printer->Outdent();
     printer->Print(
     printer->Print(
-        "  return true;\n"
+        "  return Equals(_unknownFields, other._unknownFields);\n"
         "}\n\n");
         "}\n\n");
 
 
     // GetHashCode
     // GetHashCode
     // Start with a non-zero value to easily distinguish between null and "empty" messages.
     // Start with a non-zero value to easily distinguish between null and "empty" messages.
-	WriteGeneratedCodeAttributes(printer);
-	printer->Print(
+    WriteGeneratedCodeAttributes(printer);
+    printer->Print(
         "public override int GetHashCode() {\n"
         "public override int GetHashCode() {\n"
         "  int hash = 1;\n");
         "  int hash = 1;\n");
     printer->Indent();
     printer->Indent();
@@ -384,12 +390,16 @@ void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) {
         printer->Print("hash ^= (int) $name$Case_;\n",
         printer->Print("hash ^= (int) $name$Case_;\n",
             "name", UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false));
             "name", UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false));
     }
     }
-    printer->Print("return hash;\n");
+    printer->Print(
+        "if (_unknownFields != null) {\n"
+        "  hash ^= _unknownFields.GetHashCode();\n"
+        "}\n"
+        "return hash;\n");
     printer->Outdent();
     printer->Outdent();
     printer->Print("}\n\n");
     printer->Print("}\n\n");
 
 
-	WriteGeneratedCodeAttributes(printer);
-	printer->Print(
+    WriteGeneratedCodeAttributes(printer);
+    printer->Print(
         "public override string ToString() {\n"
         "public override string ToString() {\n"
         "  return pb::JsonFormatter.ToDiagnosticString(this);\n"
         "  return pb::JsonFormatter.ToDiagnosticString(this);\n"
         "}\n\n");
         "}\n\n");
@@ -408,11 +418,17 @@ void MessageGenerator::GenerateMessageSerializationMethods(io::Printer* printer)
     generator->GenerateSerializationCode(printer);
     generator->GenerateSerializationCode(printer);
   }
   }
 
 
+  // Serialize unknown fields
+  printer->Print(
+    "if (_unknownFields != null) {\n"
+    "  _unknownFields.WriteTo(output);\n"
+    "}\n");
+
   // TODO(jonskeet): Memoize size of frozen messages?
   // TODO(jonskeet): Memoize size of frozen messages?
   printer->Outdent();
   printer->Outdent();
   printer->Print(
   printer->Print(
-	"}\n"
-	"\n");
+    "}\n"
+    "\n");
   WriteGeneratedCodeAttributes(printer);
   WriteGeneratedCodeAttributes(printer);
   printer->Print(
   printer->Print(
     "public int CalculateSize() {\n");
     "public int CalculateSize() {\n");
@@ -423,6 +439,12 @@ void MessageGenerator::GenerateMessageSerializationMethods(io::Printer* printer)
         CreateFieldGeneratorInternal(descriptor_->field(i)));
         CreateFieldGeneratorInternal(descriptor_->field(i)));
     generator->GenerateSerializedSizeCode(printer);
     generator->GenerateSerializedSizeCode(printer);
   }
   }
+
+  printer->Print(
+    "if (_unknownFields != null) {\n"
+    "  size += _unknownFields.CalculateSize();\n"
+    "}\n");
+
   printer->Print("return size;\n");
   printer->Print("return size;\n");
   printer->Outdent();
   printer->Outdent();
   printer->Print("}\n\n");
   printer->Print("}\n\n");
@@ -473,8 +495,14 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) {
     printer->Outdent();
     printer->Outdent();
     printer->Print("}\n\n");
     printer->Print("}\n\n");
   }
   }
+  // Merge unknown fields.
+  printer->Print(
+      "_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);\n");
+
   printer->Outdent();
   printer->Outdent();
   printer->Print("}\n\n");
   printer->Print("}\n\n");
+
+
   WriteGeneratedCodeAttributes(printer);
   WriteGeneratedCodeAttributes(printer);
   printer->Print("public void MergeFrom(pb::CodedInputStream input) {\n");
   printer->Print("public void MergeFrom(pb::CodedInputStream input) {\n");
   printer->Indent();
   printer->Indent();
@@ -486,14 +514,14 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) {
   printer->Indent();
   printer->Indent();
   // Option messages need to store unknown fields so that options can be parsed later.
   // Option messages need to store unknown fields so that options can be parsed later.
   if (IsDescriptorOptionMessage(descriptor_)) {
   if (IsDescriptorOptionMessage(descriptor_)) {
-	printer->Print(
+    printer->Print(
       "default:\n"
       "default:\n"
       "  CustomOptions = CustomOptions.ReadOrSkipUnknownField(input);\n"
       "  CustomOptions = CustomOptions.ReadOrSkipUnknownField(input);\n"
       "  break;\n");
       "  break;\n");
   } else {
   } else {
     printer->Print(
     printer->Print(
       "default:\n"
       "default:\n"
-      "  input.SkipLastField();\n" // We're not storing the data, but we still need to consume it.
+      "  _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);\n"
       "  break;\n");
       "  break;\n");
   }
   }
   for (int i = 0; i < fields_by_number().size(); i++) {
   for (int i = 0; i < fields_by_number().size(); i++) {

+ 14 - 6
src/google/protobuf/compiler/csharp/csharp_primitive_field.cc

@@ -137,14 +137,22 @@ void PrimitiveFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {
 }
 }
 
 
 void PrimitiveFieldGenerator::WriteHash(io::Printer* printer) {
 void PrimitiveFieldGenerator::WriteHash(io::Printer* printer) {
-  printer->Print(
-    variables_,
-    "if ($has_property_check$) hash ^= $property_name$.GetHashCode();\n");
+  const char *text = "if ($has_property_check$) hash ^= $property_name$.GetHashCode();\n";
+  if (descriptor_->type() == FieldDescriptor::TYPE_FLOAT) {
+    text = "if ($has_property_check$) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode($property_name$);\n";
+  } else if (descriptor_->type() == FieldDescriptor::TYPE_DOUBLE) {
+    text = "if ($has_property_check$) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode($property_name$);\n";
+  }
+	printer->Print(variables_, text);
 }
 }
 void PrimitiveFieldGenerator::WriteEquals(io::Printer* printer) {
 void PrimitiveFieldGenerator::WriteEquals(io::Printer* printer) {
-  printer->Print(
-    variables_,
-    "if ($property_name$ != other.$property_name$) return false;\n");
+  const char *text = "if ($property_name$ != other.$property_name$) return false;\n";
+  if (descriptor_->type() == FieldDescriptor::TYPE_FLOAT) {
+    text = "if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals($property_name$, other.$property_name$)) return false;\n";
+  } else if (descriptor_->type() == FieldDescriptor::TYPE_DOUBLE) {
+    text = "if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals($property_name$, other.$property_name$)) return false;\n";
+  }
+  printer->Print(variables_, text);
 }
 }
 void PrimitiveFieldGenerator::WriteToString(io::Printer* printer) {
 void PrimitiveFieldGenerator::WriteToString(io::Printer* printer) {
   printer->Print(
   printer->Print(

+ 4 - 2
src/google/protobuf/compiler/csharp/csharp_reflection_class.cc

@@ -104,8 +104,10 @@ void ReflectionClassGenerator::Generate(io::Printer* printer) {
 
 
 void ReflectionClassGenerator::WriteIntroduction(io::Printer* printer) {
 void ReflectionClassGenerator::WriteIntroduction(io::Printer* printer) {
   printer->Print(
   printer->Print(
-    "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n"
-    "// source: $file_name$\n"
+    "// <auto-generated>\n"
+    "//     Generated by the protocol buffer compiler.  DO NOT EDIT!\n"
+    "//     source: $file_name$\n"
+    "// </auto-generated>\n"
     "#pragma warning disable 1591, 0612, 3021\n"
     "#pragma warning disable 1591, 0612, 3021\n"
     "#region Designer generated code\n"
     "#region Designer generated code\n"
     "\n"
     "\n"

+ 16 - 6
src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc

@@ -120,15 +120,25 @@ void WrapperFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {
 }
 }
 
 
 void WrapperFieldGenerator::WriteHash(io::Printer* printer) {
 void WrapperFieldGenerator::WriteHash(io::Printer* printer) {
-  printer->Print(
-    variables_,
-    "if ($has_property_check$) hash ^= $property_name$.GetHashCode();\n");
+  const char *text = "if ($has_property_check$) hash ^= $property_name$.GetHashCode();\n";
+  if (descriptor_->message_type()->field(0)->type() == FieldDescriptor::TYPE_FLOAT) {
+    text = "if ($has_property_check$) hash ^= pbc::ProtobufEqualityComparers.BitwiseNullableSingleEqualityComparer.GetHashCode($property_name$);\n";
+  }
+  else if (descriptor_->message_type()->field(0)->type() == FieldDescriptor::TYPE_DOUBLE) {
+    text = "if ($has_property_check$) hash ^= pbc::ProtobufEqualityComparers.BitwiseNullableDoubleEqualityComparer.GetHashCode($property_name$);\n";
+  }
+  printer->Print(variables_, text);
 }
 }
 
 
 void WrapperFieldGenerator::WriteEquals(io::Printer* printer) {
 void WrapperFieldGenerator::WriteEquals(io::Printer* printer) {
-  printer->Print(
-    variables_,
-    "if ($property_name$ != other.$property_name$) return false;\n");
+  const char *text = "if ($property_name$ != other.$property_name$) return false;\n";
+  if (descriptor_->message_type()->field(0)->type() == FieldDescriptor::TYPE_FLOAT) {
+    text = "if (!pbc::ProtobufEqualityComparers.BitwiseNullableSingleEqualityComparer.Equals($property_name$, other.$property_name$)) return false;\n";
+  }
+  else if (descriptor_->message_type()->field(0)->type() == FieldDescriptor::TYPE_DOUBLE) {
+    text = "if (!pbc::ProtobufEqualityComparers.BitwiseNullableDoubleEqualityComparer.Equals($property_name$, other.$property_name$)) return false;\n";
+  }
+  printer->Print(variables_, text);
 }
 }
 
 
 void WrapperFieldGenerator::WriteToString(io::Printer* printer) {
 void WrapperFieldGenerator::WriteToString(io::Printer* printer) {

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно