From d5f7d0979b606b681a21314fda815279d10c7cdc Mon Sep 17 00:00:00 2001 From: salarcode Date: Fri, 19 Aug 2016 12:25:05 +0430 Subject: [PATCH] * tabfix Version 2.2.2 --- .gitignore | 1 + Salar.Bois.Tests/CollectionsTest.cs | 54 ++++++++++++++--------------- Salar.Bois.nuspec | 5 +-- Salar.Bois/BoisContractAttribute.cs | 2 +- Salar.Bois/BoisMemberAttribute.cs | 6 ++-- Salar.Bois/BoisSerializer.cs | 32 ++++++++--------- Salar.Bois/ReflectionHelper.cs | 4 +-- 7 files changed, 53 insertions(+), 51 deletions(-) diff --git a/.gitignore b/.gitignore index f74073d..ae63f96 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ $tf*/ /Salar.Bois-Before-REVERT.7z /CreateNuget-Push.cmd /CreateNuget-Pack.cmd +*.nupkg diff --git a/Salar.Bois.Tests/CollectionsTest.cs b/Salar.Bois.Tests/CollectionsTest.cs index a270e18..bb7fa58 100644 --- a/Salar.Bois.Tests/CollectionsTest.cs +++ b/Salar.Bois.Tests/CollectionsTest.cs @@ -53,7 +53,7 @@ public void WriteBytes_Normal() { ResetStream(); var init = new byte[] { 10, 50, 0, 250, 98 }; - bion.WriteBytes(bionWriter,init); + bion.WriteBytes(bionWriter, init); ResetStream(); var final = (byte[])bion.ReadBytes(bionReader); @@ -80,14 +80,14 @@ public void WriteDictionary_StringNormal() { ResetStream(); var init = new Dictionary() - { - {"man", "down"}, - {"Random chars", "~!@# $ %^& * ()"} - }; + { + {"man", "down"}, + {"Random chars", "~!@# $ %^& * ()"} + }; bion.WriteDictionary(bionWriter, init); ResetStream(); - var final = (Dictionary)bion.ReadDictionary(bionReader,typeof(Dictionary)); + var final = (Dictionary)bion.ReadDictionary(bionReader, typeof(Dictionary)); final.Should().Have.SameSequenceAs(init); } @@ -109,11 +109,11 @@ public void WriteDictionary_NumberNormal() { ResetStream(); var init = new Dictionary() - { - {50, 177}, - {10, 42677}, - {25000000, 90L}, - }; + { + {50, 177}, + {10, 42677}, + {25000000, 90L}, + }; bion.WriteDictionary(bionWriter, init); ResetStream(); @@ -125,11 +125,11 @@ public void WriteDictionary_NullableNormal() { ResetStream(); var init = new Dictionary() - { - {50, null}, - {10, null}, - {25000000, 90L}, - }; + { + {50, null}, + {10, null}, + {25000000, 90L}, + }; bion.WriteDictionary(bionWriter, init); ResetStream(); @@ -250,12 +250,12 @@ public void WriteStringDictionary_StringNormal() { ResetStream(); var init = new Dictionary() - { - {"Bion", 100}, - {"Salar", 20}, - {"", 0}, - {"Khalilzadeh", -100} - }; + { + {"Bion", 100}, + {"Salar", 20}, + {"", 0}, + {"Khalilzadeh", -100} + }; bion.WriteStringDictionary(bionWriter, init); ResetStream(); @@ -269,11 +269,11 @@ public void WriteStringDictionary_StringNullable() { ResetStream(); var init = new Dictionary() - { - {"Bion", null}, - {"Salar", null}, - {"Khalilzadeh", -100} - }; + { + {"Bion", null}, + {"Salar", null}, + {"Khalilzadeh", -100} + }; bion.WriteStringDictionary(bionWriter, init); ResetStream(); diff --git a/Salar.Bois.nuspec b/Salar.Bois.nuspec index 956e7bd..14b2aaf 100644 --- a/Salar.Bois.nuspec +++ b/Salar.Bois.nuspec @@ -2,7 +2,7 @@ Salar.Bois - 2.2.1.0 + 2.2.2.0 BOIS (Binary Object Indexed Serialization) Salar Khalilzadeh Salar Khalilzadeh @@ -15,7 +15,8 @@ More info: https://github.com/salarcode/Bois - + Bug#5 fixed: wont serialize private setter/getter properties. + + Bug#8 fixed: Deseriealize problem when child object is null. + * Due to bugfix #8, this version is not compatible with previous versions. Copyright 2016 Binary Serializer Serialization Serialize BOIS JSON BON diff --git a/Salar.Bois/BoisContractAttribute.cs b/Salar.Bois/BoisContractAttribute.cs index 31985dc..99d3b36 100644 --- a/Salar.Bois/BoisContractAttribute.cs +++ b/Salar.Bois/BoisContractAttribute.cs @@ -19,7 +19,7 @@ public class BoisContractAttribute : Attribute /// Specifies that fields should be serialized or not. /// public bool Fields { get; set; } - + /// /// Specifies that properties should be serialized or not. /// diff --git a/Salar.Bois/BoisMemberAttribute.cs b/Salar.Bois/BoisMemberAttribute.cs index 6615452..1c92edf 100644 --- a/Salar.Bois/BoisMemberAttribute.cs +++ b/Salar.Bois/BoisMemberAttribute.cs @@ -40,7 +40,7 @@ public BoisMemberAttribute(int index, bool included) /// Specifies a field or peroperty settings for serialization. /// public BoisMemberAttribute() - : this(-1, true) + : this(-1, true) { } /// @@ -48,7 +48,7 @@ public BoisMemberAttribute() /// /// In which order should this member be serialized. public BoisMemberAttribute(int index) - : this(index, true) + : this(index, true) { } /// @@ -56,7 +56,7 @@ public BoisMemberAttribute(int index) /// /// Specifies that should this member be included in serialization. public BoisMemberAttribute(bool included) - : this(-1, included) + : this(-1, included) { } } } \ No newline at end of file diff --git a/Salar.Bois/BoisSerializer.cs b/Salar.Bois/BoisSerializer.cs index 261de34..7604dd9 100644 --- a/Salar.Bois/BoisSerializer.cs +++ b/Salar.Bois/BoisSerializer.cs @@ -176,9 +176,9 @@ private void WriteObject(BinaryWriter writer, BoisMemberInfo boisMemInfo, object { if (obj == null) { - // null indicator - WriteNullableType(writer, true); - return; + // null indicator + WriteNullableType(writer, true); + return; } var type = obj.GetType(); @@ -187,15 +187,15 @@ private void WriteObject(BinaryWriter writer, BoisMemberInfo boisMemInfo, object var boisTypeInfo = boisType as BoisTypeInfo; _serializeDepth++; - // Use this member info if avaiable. it is more accurate because it came from the object holder, - // not the object itseld. - if (boisMemInfo.IsContainerObject && boisMemInfo.IsNullable) - { - //This is a nullable struct and is not null - WriteNullableType(writer, false); - } - - if (boisTypeInfo != null) + // Use this member info if avaiable. it is more accurate because it came from the object holder, + // not the object itseld. + if (boisMemInfo.IsContainerObject && boisMemInfo.IsNullable) + { + //This is a nullable struct and is not null + WriteNullableType(writer, false); + } + + if (boisTypeInfo != null) { // writing the members for (int i = 0; i < boisTypeInfo.Members.Length; i++) @@ -846,10 +846,10 @@ private object ReadMember(BinaryReader reader, Type memType) private object ReadMember(BinaryReader reader, BoisMemberInfo memInfo, Type memType) { - if ((memInfo.IsNullable && memInfo.IsContainerObject) || - (memInfo.IsNullable && !memInfo.IsSupportedPrimitive && (!memInfo.IsContainerObject || memInfo.IsStruct))) - { - bool isNull = reader.ReadByte() != 0; + if ((memInfo.IsNullable && memInfo.IsContainerObject) || + (memInfo.IsNullable && !memInfo.IsSupportedPrimitive && (!memInfo.IsContainerObject || memInfo.IsStruct))) + { + bool isNull = reader.ReadByte() != 0; if (isNull) { diff --git a/Salar.Bois/ReflectionHelper.cs b/Salar.Bois/ReflectionHelper.cs index d152f8a..6d07ffb 100644 --- a/Salar.Bois/ReflectionHelper.cs +++ b/Salar.Bois/ReflectionHelper.cs @@ -70,7 +70,7 @@ public static Type[] FindUnderlyingGenericDictionaryElementType(Type type) public static Type FindUnderlyingIEnumerableElementType(Type type) { if (type.BaseType == null) - return null; + return null; var enumType = typeof(IEnumerable<>); foreach (var inter in type.GetInterfaces()) { @@ -206,6 +206,6 @@ public static bool IsNullable(T obj) return false; // value-type } - + } }