Skip to content

Commit 02455ba

Browse files
committed
array
1 parent f3d3e58 commit 02455ba

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/System.Linq.Dynamic.Core.NewtonsoftJson/Extensions/JObjectExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private sealed class JTokenResolvers : Dictionary<JTokenType, Func<JToken, Dynam
5757

5858
internal static IEnumerable ToDynamicJsonClassArray(this JArray? src, DynamicJsonClassOptions? options = null)
5959
{
60-
return src == null ? new object?[0] : ConvertJTokenArray(src, options);
60+
return src == null ? EmptyArray<object?>.Value : ConvertJTokenArray(src, options);
6161
}
6262

6363
private static object? ConvertJObject(JToken arg, DynamicJsonClassOptions? options = null)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// ReSharper disable once CheckNamespace
2+
namespace System;
3+
4+
internal static class EmptyArray<T>
5+
{
6+
#if NET35 || NET40 || NET45 || NET452
7+
public static readonly T[] Value = [];
8+
#else
9+
public static readonly T[] Value = Array.Empty<T>();
10+
#endif
11+
}

0 commit comments

Comments
 (0)