From 58e1655b3a60c38b3c9e1efe9279a9c8df6b459f Mon Sep 17 00:00:00 2001
From: Vlad Taranov <wvlad.dev@gmail.com>
Date: Wed, 4 May 2016 14:33:35 +0300
Subject: [PATCH] build

---
 Nuget/aqlaserializer.nuspec                      |  2 +-
 precompile/Properties/AssemblyInfo.cs            |  4 ++--
 .../Properties/AssemblyInfo.cs                   |  4 ++--
 protobuf-net.unittest/Aqla/LegacyTupleMode.cs    |  2 +-
 protobuf-net/Helpers.cs                          |  9 +++++++++
 protobuf-net/Meta/RuntimeTypeModel.cs            |  2 +-
 protobuf-net/Meta/TypeModel.cs                   |  2 +-
 protobuf-net/NetObjectHelpers.Read.cs            | 16 +++++++++++++---
 protobuf-net/NetObjectHelpers.Write.cs           | 11 +++++++++++
 protobuf-net/Properties/AssemblyInfo.cs          |  4 ++--
 .../NetObjectValueDecorator.cs                   |  3 +--
 11 files changed, 44 insertions(+), 15 deletions(-)

diff --git a/Nuget/aqlaserializer.nuspec b/Nuget/aqlaserializer.nuspec
index 2386110a..de7b8af1 100644
--- a/Nuget/aqlaserializer.nuspec
+++ b/Nuget/aqlaserializer.nuspec
@@ -2,7 +2,7 @@
 <package>
   <metadata>
     <id>aqlaserializer</id>
-    <version>2.0.0.96</version>
+    <version>2.0.0.186</version>
     <authors>Vladyslav Taranov</authors>
     <copyright>Vladyslav Taranov 2016, fork source from Marc Gravell 2016</copyright>
     <owners>Vladyslav Taranov</owners>
diff --git a/precompile/Properties/AssemblyInfo.cs b/precompile/Properties/AssemblyInfo.cs
index f0d7aa89..761ea707 100644
--- a/precompile/Properties/AssemblyInfo.cs
+++ b/precompile/Properties/AssemblyInfo.cs
@@ -33,5 +33,5 @@
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.0.0.96")]
-[assembly: AssemblyFileVersion("2.0.0.96")]
+[assembly: AssemblyVersion("2.0.0.186")]
+[assembly: AssemblyFileVersion("2.0.0.186")]
diff --git a/protobuf-net.Extensions/Properties/AssemblyInfo.cs b/protobuf-net.Extensions/Properties/AssemblyInfo.cs
index 44cb4d54..efaafc4e 100644
--- a/protobuf-net.Extensions/Properties/AssemblyInfo.cs
+++ b/protobuf-net.Extensions/Properties/AssemblyInfo.cs
@@ -33,8 +33,8 @@
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.0.0.96")]
+[assembly: AssemblyVersion("2.0.0.186")]
 #if !CF
-[assembly: AssemblyFileVersion("2.0.0.96")]
+[assembly: AssemblyFileVersion("2.0.0.186")]
 #endif
 [assembly: CLSCompliant(true)]
\ No newline at end of file
diff --git a/protobuf-net.unittest/Aqla/LegacyTupleMode.cs b/protobuf-net.unittest/Aqla/LegacyTupleMode.cs
index cdc2c1b7..68731700 100644
--- a/protobuf-net.unittest/Aqla/LegacyTupleMode.cs
+++ b/protobuf-net.unittest/Aqla/LegacyTupleMode.cs
@@ -22,7 +22,7 @@ public class ElementDef
         public class Container
         {
             [ProtoMember(1)]
-            public Dictionary<string, List<Element>> Foo { get; set; }
+            public Dictionary<string, List<LegacyTupleMode.Element>> Foo { get; set; }
 
             [ProtoMember(2)]
             public Dictionary<Element, ElementDef> Bar { get; set; }
diff --git a/protobuf-net/Helpers.cs b/protobuf-net/Helpers.cs
index f444f18a..bc885c57 100644
--- a/protobuf-net/Helpers.cs
+++ b/protobuf-net/Helpers.cs
@@ -109,6 +109,15 @@ public static bool IsGenericTypeDefinition(Type type)
 #endif
         }
 
+        public static bool IsGenericType(Type type)
+        {
+#if WINRT
+            return type.GetTypeInfo().IsGenericType;
+#else
+            return type.IsGenericType;
+#endif
+        }
+
         public static Type[] GetTypes(Assembly assembly)
         {
 #if WINRT
diff --git a/protobuf-net/Meta/RuntimeTypeModel.cs b/protobuf-net/Meta/RuntimeTypeModel.cs
index 5e61e183..5f7b3277 100644
--- a/protobuf-net/Meta/RuntimeTypeModel.cs
+++ b/protobuf-net/Meta/RuntimeTypeModel.cs
@@ -453,7 +453,7 @@ internal int FindOrAddAuto(Type type, bool demand, bool addWithContractOnly, boo
                     { // otherwise, check if it is a contract
                         MetaType.AttributeFamily family = _autoAddStrategy.GetContractFamily(type);
 
-                        if (family == MetaType.AttributeFamily.AutoTuple && type.IsGenericType)
+                        if (family == MetaType.AttributeFamily.AutoTuple && Helpers.IsGenericType(type))
                         {
                             // always add safe tuples
                             Type def = type.GetGenericTypeDefinition();
diff --git a/protobuf-net/Meta/TypeModel.cs b/protobuf-net/Meta/TypeModel.cs
index e535e856..c4e27102 100644
--- a/protobuf-net/Meta/TypeModel.cs
+++ b/protobuf-net/Meta/TypeModel.cs
@@ -37,7 +37,7 @@ internal TypeInfo MapType(TypeInfo type)
         /// </summary>
         public bool AllowReferenceVersioningSeeking { get; set; } = true;
         
-        internal const int DefaultArrayLengthReadLimit = 100000;
+        internal const int DefaultArrayLengthReadLimit = 500000;
 
         /// <summary>
         /// Max count for list for <see cref="AllowReferenceVersioningSeeking"/>
diff --git a/protobuf-net/NetObjectHelpers.Read.cs b/protobuf-net/NetObjectHelpers.Read.cs
index 70b277ac..119e2091 100644
--- a/protobuf-net/NetObjectHelpers.Read.cs
+++ b/protobuf-net/NetObjectHelpers.Read.cs
@@ -1,5 +1,16 @@
 using System;
+#if FEAT_COMPILER
+using AqlaSerializer.Compiler;
+#endif
 using System.Diagnostics;
+using AqlaSerializer.Meta;
+#if FEAT_IKVM
+using Type = IKVM.Reflection.Type;
+using IKVM.Reflection;
+#else
+using System.Reflection;
+
+#endif
 
 namespace AqlaSerializer
 {
@@ -177,17 +188,16 @@ public static ReadReturnValue ReadNetObject_Start(ref object value, ProtoReader
             return r;
 #endif
         }
-
+#if !FEAT_IKVM
         static void ReadNewType(ProtoReader source, out Type type, out int typeKey)
         {
-
             string typeName = source.ReadString();
             type = source.DeserializeType(typeName);
             if (type == null)
                 throw new ProtoException("Unable to resolve type: " + typeName + " (you can use the TypeModel.DynamicTypeFormatting event to provide a custom mapping)");
             typeKey = source.GetTypeKey(ref type);
         }
-
+#endif
         private const int
             FieldExistingObjectKey = 1,
             FieldNewObjectKey = 2,
diff --git a/protobuf-net/NetObjectHelpers.Write.cs b/protobuf-net/NetObjectHelpers.Write.cs
index 777664c4..ffb28596 100644
--- a/protobuf-net/NetObjectHelpers.Write.cs
+++ b/protobuf-net/NetObjectHelpers.Write.cs
@@ -1,5 +1,16 @@
 using System;
+#if FEAT_COMPILER
+using AqlaSerializer.Compiler;
+#endif
+using System.Diagnostics;
 using AqlaSerializer.Meta;
+#if FEAT_IKVM
+using Type = IKVM.Reflection.Type;
+using IKVM.Reflection;
+#else
+using System.Reflection;
+
+#endif
 
 namespace AqlaSerializer
 {
diff --git a/protobuf-net/Properties/AssemblyInfo.cs b/protobuf-net/Properties/AssemblyInfo.cs
index a50498d6..312bcfa8 100644
--- a/protobuf-net/Properties/AssemblyInfo.cs
+++ b/protobuf-net/Properties/AssemblyInfo.cs
@@ -35,9 +35,9 @@
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.0.0.96")]
+[assembly: AssemblyVersion("2.0.0.186")]
 #if !CF
-[assembly: AssemblyFileVersion("2.0.0.96")]
+[assembly: AssemblyFileVersion("2.0.0.186")]
 #endif
 #if !FX11
 [assembly: InternalsVisibleTo("aqlaserializer.unittest, PublicKey=002400000480000094000000060200000024000052534131000400000100010091B11AB23561C227F083424C0162A38DA330B724B6E96C1BE6C5989BFDD5C1BA3E555D8F105DD352C2623FE6AF90F4FA3173C6120DD567283434513DA579728230E1697A156770A81B7FBF5535ECDB96D2737E74181A4D980647AE33CDFB6E0C1FF63065AE8E33BB27374090393685FF265563655DE4829B0E5C996B1CF9A3E3")]
diff --git a/protobuf-net/Serializers/WillSetFieldWireType/NetObjectValueDecorator.cs b/protobuf-net/Serializers/WillSetFieldWireType/NetObjectValueDecorator.cs
index c37b9e3d..7adf6c14 100644
--- a/protobuf-net/Serializers/WillSetFieldWireType/NetObjectValueDecorator.cs
+++ b/protobuf-net/Serializers/WillSetFieldWireType/NetObjectValueDecorator.cs
@@ -305,8 +305,7 @@ public void EmitRead(CompilerContext ctx, Local valueFrom)
                     var shouldRead = readReturnValue.AsOperand.Field(nameof(NetObjectHelpers.ReadReturnValue.ShouldRead)).SetNotLeaked();
                     var isLateReference = readReturnValue.AsOperand.Field(nameof(NetObjectHelpers.ReadReturnValue.IsLateReference)).SetNotLeaked();
                     var isDynamic = readReturnValue.AsOperand.Field(nameof(NetObjectHelpers.ReadReturnValue.IsDynamic)).SetNotLeaked();
-                    var token = readReturnValue.AsOperand.Field(nameof(NetObjectHelpers.ReadReturnValue.Token)).SetNotLeaked();
-
+                    
                     g.Assign(options, _options);
                     if (!RequiresOldValue)
                         g.Assign(inputValueBoxed, null);