Skip to content

Commit

Permalink
* tabfix
Browse files Browse the repository at this point in the history
Version 2.2.2
  • Loading branch information
salarcode committed Aug 19, 2016
1 parent 4f10e24 commit d5f7d09
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 51 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ $tf*/
/Salar.Bois-Before-REVERT.7z
/CreateNuget-Push.cmd
/CreateNuget-Pack.cmd
*.nupkg
54 changes: 27 additions & 27 deletions Salar.Bois.Tests/CollectionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -80,14 +80,14 @@ public void WriteDictionary_StringNormal()
{
ResetStream();
var init = new Dictionary<string, string>()
{
{"man", "down"},
{"Random chars", "~!@# $ %^& * ()"}
};
{
{"man", "down"},
{"Random chars", "~!@# $ %^& * ()"}
};
bion.WriteDictionary(bionWriter, init);
ResetStream();

var final = (Dictionary<string, string>)bion.ReadDictionary(bionReader,typeof(Dictionary<string, string>));
var final = (Dictionary<string, string>)bion.ReadDictionary(bionReader, typeof(Dictionary<string, string>));
final.Should().Have.SameSequenceAs(init);
}

Expand All @@ -109,11 +109,11 @@ public void WriteDictionary_NumberNormal()
{
ResetStream();
var init = new Dictionary<int, long>()
{
{50, 177},
{10, 42677},
{25000000, 90L},
};
{
{50, 177},
{10, 42677},
{25000000, 90L},
};
bion.WriteDictionary(bionWriter, init);
ResetStream();

Expand All @@ -125,11 +125,11 @@ public void WriteDictionary_NullableNormal()
{
ResetStream();
var init = new Dictionary<int?, long?>()
{
{50, null},
{10, null},
{25000000, 90L},
};
{
{50, null},
{10, null},
{25000000, 90L},
};
bion.WriteDictionary(bionWriter, init);
ResetStream();

Expand Down Expand Up @@ -250,12 +250,12 @@ public void WriteStringDictionary_StringNormal()
{
ResetStream();
var init = new Dictionary<string, int>()
{
{"Bion", 100},
{"Salar", 20},
{"", 0},
{"Khalilzadeh", -100}
};
{
{"Bion", 100},
{"Salar", 20},
{"", 0},
{"Khalilzadeh", -100}
};
bion.WriteStringDictionary(bionWriter, init);
ResetStream();

Expand All @@ -269,11 +269,11 @@ public void WriteStringDictionary_StringNullable()
{
ResetStream();
var init = new Dictionary<string, int?>()
{
{"Bion", null},
{"Salar", null},
{"Khalilzadeh", -100}
};
{
{"Bion", null},
{"Salar", null},
{"Khalilzadeh", -100}
};
bion.WriteStringDictionary(bionWriter, init);
ResetStream();

Expand Down
5 changes: 3 additions & 2 deletions Salar.Bois.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>Salar.Bois</id>
<version>2.2.1.0</version>
<version>2.2.2.0</version>
<title>BOIS (Binary Object Indexed Serialization)</title>
<authors>Salar Khalilzadeh</authors>
<owners>Salar Khalilzadeh</owners>
Expand All @@ -15,7 +15,8 @@
More info: https://github.com/salarcode/Bois
</description>
<releaseNotes>
+ 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.
</releaseNotes>
<copyright>Copyright 2016</copyright>
<tags>Binary Serializer Serialization Serialize BOIS JSON BON</tags>
Expand Down
2 changes: 1 addition & 1 deletion Salar.Bois/BoisContractAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class BoisContractAttribute : Attribute
/// Specifies that fields should be serialized or not.
/// </summary>
public bool Fields { get; set; }

/// <summary>
/// Specifies that properties should be serialized or not.
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions Salar.Bois/BoisMemberAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,23 @@ public BoisMemberAttribute(int index, bool included)
/// Specifies a field or peroperty settings for serialization.
/// </summary>
public BoisMemberAttribute()
: this(-1, true)
: this(-1, true)
{ }

/// <summary>
/// Specifies a field or peroperty settings for serialization.
/// </summary>
/// <param name="index">In which order should this member be serialized.</param>
public BoisMemberAttribute(int index)
: this(index, true)
: this(index, true)
{ }

/// <summary>
/// Specifies a field or peroperty settings for serialization.
/// </summary>
/// <param name="included">Specifies that should this member be included in serialization.</param>
public BoisMemberAttribute(bool included)
: this(-1, included)
: this(-1, included)
{ }
}
}
32 changes: 16 additions & 16 deletions Salar.Bois/BoisSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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++)
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions Salar.Bois/ReflectionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down Expand Up @@ -206,6 +206,6 @@ public static bool IsNullable<T>(T obj)
return false; // value-type
}


}
}

0 comments on commit d5f7d09

Please sign in to comment.