Skip to content

Commit

Permalink
Fixed #379
Browse files Browse the repository at this point in the history
  • Loading branch information
liiir1985 committed Oct 10, 2020
1 parent 33a082c commit 1c9f07f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
4 changes: 3 additions & 1 deletion LitJson/JsonMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,9 @@ private static object ReadValue (Type inst_type, JsonReader reader)

if (t_data.IsArray) {
int n = list.Count;
instance = Array.CreateInstance (elem_type, n);
var rt = elem_type is ILRuntime.Reflection.ILRuntimeWrapperType ? ((ILRuntime.Reflection.ILRuntimeWrapperType)elem_type).RealType : elem_type;
rt = elem_type is ILRuntime.Reflection.ILRuntimeType ? ((ILRuntime.Reflection.ILRuntimeType)elem_type).ILType.TypeForCLR : elem_type;
instance = Array.CreateInstance (rt, n);

for (int i = 0; i < n; i++)
((Array) instance).SetValue (list[i], i);
Expand Down
10 changes: 10 additions & 0 deletions TestCases/JsonTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,15 @@ public static void JsonTest6()
Console.WriteLine("Fail");
}
}

public static void JsonTest7()
{
JsonTestEnum[] arr = new JsonTestEnum[] { JsonTestEnum.Test2, JsonTestEnum.Test3 };
string json = JsonMapper.ToJson(arr);

JsonTestEnum[] arr2 = JsonMapper.ToObject<JsonTestEnum[]>(json);
if (arr2[0] != JsonTestEnum.Test2)
throw new Exception();
}
}
}
21 changes: 21 additions & 0 deletions TestCases/LightTester1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,27 @@ public static void UnitTest_1013()
testClass.Print();
}

public static void UnitTest_1014()
{
int a = 0;
UnitTest_1014Sub(ref a);
if (a != 1)
throw new Exception();
}

static void UnitTest_1014Sub(ref int a)
{
try
{
a = 2;
return;
}
finally
{
a = 1;
}
}

public class TestClass<T> where T : class, new()
{
public T tValue;
Expand Down

0 comments on commit 1c9f07f

Please sign in to comment.