Skip to content

Commit

Permalink
- Fixed #193
Browse files Browse the repository at this point in the history
Signed-off-by: rpgmaker <olamide.bakre@gmail.com>
  • Loading branch information
rpgmaker committed May 3, 2018
1 parent a912f6a commit 9f38088
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 46 deletions.
2 changes: 1 addition & 1 deletion NetJSON.Core.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Hewlett-Packard")]
[assembly: AssemblyCompany("Phoenix Service Bus")]
[assembly: AssemblyProduct("NetJSON.Core.Tests")]
[assembly: AssemblyTrademark("")]

Expand Down
4 changes: 2 additions & 2 deletions NetJSON.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
// 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("1.2.3")]
[assembly: AssemblyFileVersion("1.2.3")]
[assembly: AssemblyVersion("1.2.4")]
[assembly: AssemblyFileVersion("1.2.4")]
[assembly: InternalsVisibleTo(NetJSON.NetJSON.NET_JSON_GENERATED_ASSEMBLY_NAME)]
4 changes: 2 additions & 2 deletions NetJSON.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,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("1.2.3")]
[assembly: AssemblyFileVersion("1.2.3")]
[assembly: AssemblyVersion("1.2.4")]
[assembly: AssemblyFileVersion("1.2.4")]
37 changes: 37 additions & 0 deletions NetJSON.Tests/SerializeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,29 @@ public void CanDeserializeLargeNumbers()
Assert.AreEqual(test["test"], 9999999999);
}

[TestMethod]
public void CanDeserializeKeyAndValueProperly()
{
var xy = new A();
xy.Details.Add(666, null);

var json = NetJSON.Serialize(xy);
var obj = NetJSON.Deserialize<A>(json);

Assert.IsTrue(xy.Details.ContainsKey(666));
}

[TestMethod]
public void CanDeserilizeDictionaryKeyAndValue()
{
var dict = new Dictionary<int, B>();
dict.Add(666, new B());
var json = NetJSON.Serialize(dict);
var obj = NetJSON.Deserialize<Dictionary<int, B>>(json);

Assert.IsTrue(obj.ContainsKey(666));
}

private static bool CanSerialize(MemberInfo memberInfo)
{
var attr = memberInfo.GetCustomAttribute<TestIgnoreAttribute>();
Expand All @@ -1268,6 +1291,20 @@ private static bool CanSerialize(MemberInfo memberInfo)
}
}

public class A
{
public A()
{
Details = new Dictionary<int, B>();
}

public Dictionary<int, B> Details { get; set; }
}

public class B
{
}

struct SimpleObjectStruct
{
public int ID;
Expand Down
4 changes: 2 additions & 2 deletions NetJSON.V3_5.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,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("1.2.3")]
[assembly: AssemblyFileVersion("1.2.3")]
[assembly: AssemblyVersion("1.2.4")]
[assembly: AssemblyFileVersion("1.2.4")]
35 changes: 0 additions & 35 deletions NetJSON/NetJSON.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5206,15 +5206,6 @@ private static void GenerateGetClassOrDictStringType(TypeBuilder typeBuilder, Ty
IncrementIndexRef(il);

if (isDict) {


var isStringBasedLabel1 = il.DefineLabel();
var isStringBasedLabel2 = il.DefineLabel();

il.Emit(OpCodes.Ldloc, isStringBasedLocal);
il.Emit(OpCodes.Brfalse, isStringBasedLabel1);

#region true
il.Emit(OpCodes.Ldloc, obj);
if (isExpandoObject)
il.Emit(OpCodes.Isinst, _idictStringObject);
Expand All @@ -5229,32 +5220,6 @@ private static void GenerateGetClassOrDictStringType(TypeBuilder typeBuilder, Ty
il.Emit(OpCodes.Newobj, _genericKeyValuePairType.MakeGenericType(keyType, valueType).GetConstructor(new[] { keyType, valueType }));
}
il.Emit(OpCodes.Callvirt, dictSetItem);
#endregion

il.MarkLabel(isStringBasedLabel1);


il.Emit(OpCodes.Ldloc, isStringBasedLocal);
il.Emit(OpCodes.Brtrue, isStringBasedLabel2);

#region false
il.Emit(OpCodes.Ldloc, obj);
if (isExpandoObject)
il.Emit(OpCodes.Isinst, _idictStringObject);

il.Emit(OpCodes.Ldloc, keyLocal);

il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Ldarg_1);
il.Emit(OpCodes.Ldarg_2);
il.Emit(OpCodes.Call, GenerateExtractValueFor(typeBuilder, valueType));
if (isKeyValuePair && !isExpandoObject) {
il.Emit(OpCodes.Newobj, _genericKeyValuePairType.MakeGenericType(keyType, valueType).GetConstructor(new[] { keyType, valueType }));
}
il.Emit(OpCodes.Callvirt, dictSetItem);
#endregion

il.MarkLabel(isStringBasedLabel2);
} else {
if (!isTuple) {
//Set property based on key
Expand Down
4 changes: 2 additions & 2 deletions NetJSON/NetJSON.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<id>NetJSON</id>
<title>NetJSON</title>
<tags>json json-serializer javascript JSON serializer binary</tags>
<version>1.2.3</version>
<version>1.2.4</version>
<authors>TJ Bakre</authors>
<description>Faster than Any Binary?</description>
<releaseNotes>
Fixed issue with Deserializing large integer in object type
Fixed issue with not deserializing dictionary that uses integer as key properly
</releaseNotes>
<language>en-US</language>
<licenseUrl>https://github.com/rpgmaker/NetJSON/blob/master/LICENSE.text</licenseUrl>
Expand Down
4 changes: 2 additions & 2 deletions NetJSON/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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("1.2.3")]
[assembly: AssemblyFileVersion("1.2.3")]
[assembly: AssemblyVersion("1.2.4")]
[assembly: AssemblyFileVersion("1.2.4")]
#if !NET_35
[assembly: SecurityRules(SecurityRuleSet.Level2, SkipVerificationInFullTrust = true)]
#endif
Expand Down
Binary file modified NetJSON/lib/net35/NetJSON.dll
Binary file not shown.
Binary file modified NetJSON/lib/net40/NetJSON.dll
Binary file not shown.
Binary file modified NetJSON/lib/netstandard1.6/NetJSON.Core.dll
Binary file not shown.

0 comments on commit 9f38088

Please sign in to comment.