Skip to content

Commit 812e0ce

Browse files
committed
.
1 parent a835ac8 commit 812e0ce

File tree

9 files changed

+22
-26
lines changed

9 files changed

+22
-26
lines changed

src/System.Linq.Dynamic.Core.NewtonsoftJson/Config/NewtonsoftJsonParsingConfig.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class NewtonsoftJsonParsingConfig : ParsingConfig
2828
/// <remarks>
2929
/// Use this property to control how the normalization process handles properties that are missing or undefined.
3030
/// The selected behavior may affect the output or error handling of normalization operations.
31-
/// The default value is <see cref="NormalizationNonExistingPropertyValueBehavior.UseDefaultValue"/>.
31+
/// The default value is <see cref="NormalizationNonExistingPropertyBehavior.UseDefaultValue"/>.
3232
/// </remarks>
33-
public NormalizationNonExistingPropertyValueBehavior NormalizationNonExistingPropertyValueBehavior { get; set; }
33+
public NormalizationNonExistingPropertyBehavior NormalizationNonExistingPropertyValueBehavior { get; set; }
3434
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// <summary>
44
/// Specifies the behavior to use when setting a property vlue that does not exist or is missing during normalization.
55
/// </summary>
6-
public enum NormalizationNonExistingPropertyValueBehavior
6+
public enum NormalizationNonExistingPropertyBehavior
77
{
88
/// <summary>
99
/// Specifies that the default value should be used.

src/System.Linq.Dynamic.Core.NewtonsoftJson/JsonValueInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using Newtonsoft.Json.Linq;
22

3-
namespace ConsoleApp3;
3+
namespace System.Linq.Dynamic.Core.NewtonsoftJson;
44

5-
internal struct JsonValueInfo(JTokenType type, object? value)
5+
internal readonly struct JsonValueInfo(JTokenType type, object? value)
66
{
77
public JTokenType Type { get; } = type;
88

src/System.Linq.Dynamic.Core.NewtonsoftJson/Utils/NormalizeUtils.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Collections.Generic;
22
using System.Linq.Dynamic.Core.NewtonsoftJson.Config;
3-
using ConsoleApp3;
43
using Newtonsoft.Json.Linq;
54

65
namespace System.Linq.Dynamic.Core.NewtonsoftJson.Utils;
@@ -11,7 +10,7 @@ internal static class NormalizeUtils
1110
/// Normalizes an array of JSON objects so that each object contains all properties found in the array,
1211
/// including nested objects. Missing properties will have null values.
1312
/// </summary>
14-
internal static JArray NormalizeArray(JArray jsonArray, NormalizationNonExistingPropertyValueBehavior normalizationBehavior)
13+
internal static JArray NormalizeArray(JArray jsonArray, NormalizationNonExistingPropertyBehavior normalizationBehavior)
1514
{
1615
if (jsonArray.Count(item => item is not JObject) > 0)
1716
{
@@ -68,7 +67,7 @@ private static void MergeSchema(Dictionary<string, JsonValueInfo> schema, JObjec
6867
}
6968
}
7069

71-
private static JObject NormalizeObject(JObject source, Dictionary<string, JsonValueInfo> schema, NormalizationNonExistingPropertyValueBehavior normalizationBehavior)
70+
private static JObject NormalizeObject(JObject source, Dictionary<string, JsonValueInfo> schema, NormalizationNonExistingPropertyBehavior normalizationBehavior)
7271
{
7372
var result = new JObject();
7473

@@ -86,15 +85,15 @@ private static JObject NormalizeObject(JObject source, Dictionary<string, JsonVa
8685
}
8786
else
8887
{
89-
result[key] = normalizationBehavior == NormalizationNonExistingPropertyValueBehavior.UseDefaultValue ? GetDefaultValue(schema[key]) : JValue.CreateNull();
88+
result[key] = normalizationBehavior == NormalizationNonExistingPropertyBehavior.UseDefaultValue ? GetDefaultValue(schema[key]) : JValue.CreateNull();
9089
}
9190
}
9291
}
9392

9493
return result;
9594
}
9695

97-
private static JObject CreateEmptyObject(Dictionary<string, JsonValueInfo> schema, NormalizationNonExistingPropertyValueBehavior normalizationBehavior)
96+
private static JObject CreateEmptyObject(Dictionary<string, JsonValueInfo> schema, NormalizationNonExistingPropertyBehavior normalizationBehavior)
9897
{
9998
var obj = new JObject();
10099
foreach (var key in schema.Keys)
@@ -105,7 +104,7 @@ private static JObject CreateEmptyObject(Dictionary<string, JsonValueInfo> schem
105104
}
106105
else
107106
{
108-
obj[key] = normalizationBehavior == NormalizationNonExistingPropertyValueBehavior.UseDefaultValue ? GetDefaultValue(schema[key]) : JValue.CreateNull();
107+
obj[key] = normalizationBehavior == NormalizationNonExistingPropertyBehavior.UseDefaultValue ? GetDefaultValue(schema[key]) : JValue.CreateNull();
109108
}
110109
}
111110

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// <summary>
44
/// Specifies the behavior to use when setting a property vlue that does not exist or is missing during normalization.
55
/// </summary>
6-
public enum NormalizationNonExistingPropertyValueBehavior
6+
public enum NormalizationNonExistingPropertyBehavior
77
{
88
/// <summary>
99
/// Specifies that the default value should be used.

src/System.Linq.Dynamic.Core.SystemTextJson/Config/SystemTextJsonParsingConfig.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class SystemTextJsonParsingConfig : ParsingConfig
2424
/// <remarks>
2525
/// Use this property to control how the normalization process handles properties that are missing or undefined.
2626
/// The selected behavior may affect the output or error handling of normalization operations.
27-
/// The default value is <see cref="NormalizationNonExistingPropertyValueBehavior.UseDefaultValue"/>.
27+
/// The default value is <see cref="NormalizationNonExistingPropertyBehavior.UseDefaultValue"/>.
2828
/// </remarks>
29-
public NormalizationNonExistingPropertyValueBehavior NormalizationNonExistingPropertyValueBehavior { get; set; }
29+
public NormalizationNonExistingPropertyBehavior NormalizationNonExistingPropertyValueBehavior { get; set; }
3030
}

src/System.Linq.Dynamic.Core.SystemTextJson/JsonValueInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Text.Json;
22

3-
internal struct JsonValueInfo(JsonValueKind type, object? value)
3+
internal readonly struct JsonValueInfo(JsonValueKind type, object? value)
44
{
55
public JsonValueKind Type { get; } = type;
66

src/System.Linq.Dynamic.Core.SystemTextJson/SystemTextJsonExtensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Linq.Dynamic.Core.SystemTextJson.Utils;
66
using System.Linq.Dynamic.Core.Validation;
77
using System.Text.Json;
8-
using ConsoleApp3;
98
using JetBrains.Annotations;
109

1110
namespace System.Linq.Dynamic.Core.SystemTextJson;

src/System.Linq.Dynamic.Core.SystemTextJson/Utils/NormalizeUtils.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
1+
using System.Collections.Generic;
42
using System.Linq.Dynamic.Core.SystemTextJson.Config;
53
using System.Text.Json;
64
using System.Text.Json.Nodes;
75

8-
namespace ConsoleApp3;
6+
namespace System.Linq.Dynamic.Core.SystemTextJson.Utils;
97

108
internal static class NormalizeUtils
119
{
1210
/// <summary>
1311
/// Normalizes an document that each object contains all properties found in the array, including nested objects.
1412
/// </summary>
15-
internal static JsonDocument NormalizeJsonDocument(JsonDocument jsonDocument, NormalizationNonExistingPropertyValueBehavior normalizationBehavior)
13+
internal static JsonDocument NormalizeJsonDocument(JsonDocument jsonDocument, NormalizationNonExistingPropertyBehavior normalizationBehavior)
1614
{
1715
if (jsonDocument.RootElement.ValueKind != JsonValueKind.Array)
1816
{
@@ -28,7 +26,7 @@ internal static JsonDocument NormalizeJsonDocument(JsonDocument jsonDocument, No
2826
/// <summary>
2927
/// Normalizes an array of JSON objects so that each object contains all properties found in the array, including nested objects.
3028
/// </summary>
31-
internal static JsonArray NormalizeJsonArray(JsonArray jsonArray, NormalizationNonExistingPropertyValueBehavior normalizationBehavior)
29+
internal static JsonArray NormalizeJsonArray(JsonArray jsonArray, NormalizationNonExistingPropertyBehavior normalizationBehavior)
3230
{
3331
if (jsonArray.Any(item => item != null && item.GetValueKind() != JsonValueKind.Object))
3432
{
@@ -88,7 +86,7 @@ private static void MergeSchema(Dictionary<string, JsonValueInfo> schema, JsonOb
8886
}
8987
}
9088

91-
private static JsonObject NormalizeObject(JsonObject source, Dictionary<string, JsonValueInfo> schema, NormalizationNonExistingPropertyValueBehavior normalizationBehavior)
89+
private static JsonObject NormalizeObject(JsonObject source, Dictionary<string, JsonValueInfo> schema, NormalizationNonExistingPropertyBehavior normalizationBehavior)
9290
{
9391
var result = new JsonObject();
9492

@@ -113,15 +111,15 @@ private static JsonObject NormalizeObject(JsonObject source, Dictionary<string,
113111
}
114112
else
115113
{
116-
result[key] = normalizationBehavior == NormalizationNonExistingPropertyValueBehavior.UseDefaultValue ? GetDefaultValue(jType) : null;
114+
result[key] = normalizationBehavior == NormalizationNonExistingPropertyBehavior.UseDefaultValue ? GetDefaultValue(jType) : null;
117115
}
118116
}
119117
}
120118

121119
return result;
122120
}
123121

124-
private static JsonObject CreateEmptyObject(Dictionary<string, JsonValueInfo> schema, NormalizationNonExistingPropertyValueBehavior normalizationBehavior)
122+
private static JsonObject CreateEmptyObject(Dictionary<string, JsonValueInfo> schema, NormalizationNonExistingPropertyBehavior normalizationBehavior)
125123
{
126124
var obj = new JsonObject();
127125
foreach (var kvp in schema)
@@ -135,7 +133,7 @@ private static JsonObject CreateEmptyObject(Dictionary<string, JsonValueInfo> sc
135133
}
136134
else
137135
{
138-
obj[key] = normalizationBehavior == NormalizationNonExistingPropertyValueBehavior.UseDefaultValue ? GetDefaultValue(jType) : null;
136+
obj[key] = normalizationBehavior == NormalizationNonExistingPropertyBehavior.UseDefaultValue ? GetDefaultValue(jType) : null;
139137
}
140138
}
141139

0 commit comments

Comments
 (0)