Skip to content

Commit 1f4b081

Browse files
committed
ran dotnet format for info severity
1 parent c6c617a commit 1f4b081

File tree

14 files changed

+110
-274
lines changed

14 files changed

+110
-274
lines changed

src/SystemTextJson.JsonDiffPatch/Diffs/DiffMatchPatch/DiffMatchPatch.cs

Lines changed: 59 additions & 118 deletions
Large diffs are not rendered by default.

src/SystemTextJson.JsonDiffPatch/Diffs/JsonDiffContext.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,9 @@ internal JsonDiffContext(JsonNode left, JsonNode right)
2222
/// <typeparam name="T">The type of left value.</typeparam>
2323
public T Left<T>()
2424
{
25-
if (_leftNode is T leftValue)
26-
{
27-
return leftValue;
28-
}
29-
30-
throw new InvalidOperationException($"Type must be '{nameof(JsonNode)}' or derived type.");
25+
return _leftNode is T leftValue
26+
? leftValue
27+
: throw new InvalidOperationException($"Type must be '{nameof(JsonNode)}' or derived type.");
3128
}
3229

3330
/// <summary>
@@ -36,12 +33,9 @@ public T Left<T>()
3633
/// <typeparam name="T">The type of right value.</typeparam>
3734
public T Right<T>()
3835
{
39-
if (_rightNode is T rightValue)
40-
{
41-
return rightValue;
42-
}
43-
44-
throw new InvalidOperationException($"Type must be '{nameof(JsonNode)}' or derived type.");
36+
return _rightNode is T rightValue
37+
? rightValue
38+
: throw new InvalidOperationException($"Type must be '{nameof(JsonNode)}' or derived type.");
4539
}
4640
}
4741
}

src/SystemTextJson.JsonDiffPatch/Diffs/JsonDiffDelta.cs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -428,25 +428,19 @@ private static DeltaKind GetDeltaKind(JsonNode? delta)
428428

429429
static DeltaKind GetDeltaKindFromJsonObject(JsonObject obj)
430430
{
431-
if (obj.TryGetPropertyValue(TypePropertyName, out var typeParam) &&
431+
return obj.TryGetPropertyValue(TypePropertyName, out var typeParam) &&
432432
typeParam is JsonValue typeParamValue &&
433433
typeParamValue.TryGetValue<string>(out var typeParamValueStr) &&
434-
string.Equals(ArrayType, typeParamValueStr, StringComparison.Ordinal))
435-
{
436-
return DeltaKind.Array;
437-
}
438-
439-
return DeltaKind.Object;
434+
string.Equals(ArrayType, typeParamValueStr, StringComparison.Ordinal)
435+
? DeltaKind.Array
436+
: DeltaKind.Object;
440437
}
441438

442439
static DeltaKind GetDeltaKindFromOpType(JsonValue opType)
443440
{
444-
if (!opType.TryGetValue<int>(out var opTypeValue))
445-
{
446-
return DeltaKind.None;
447-
}
448-
449-
return opTypeValue switch
441+
return !opType.TryGetValue<int>(out var opTypeValue)
442+
? DeltaKind.None
443+
: opTypeValue switch
450444
{
451445
OpTypeDeleted => DeltaKind.Deleted,
452446
OpTypeArrayMoved => DeltaKind.ArrayMove,

src/SystemTextJson.JsonDiffPatch/Diffs/JsonDiffPatcher.Array.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,7 @@ internal static bool MatchArrayItem(ref ArrayItemMatchContext context, JsonDiffO
214214
}
215215
}
216216

217-
if (options?.ArrayItemMatcher is not null)
218-
{
219-
return options.ArrayItemMatcher(ref context);
220-
}
221-
222-
return false;
217+
return options?.ArrayItemMatcher is not null ? options.ArrayItemMatcher(ref context) : false;
223218
}
224219

225220
internal static bool MatchArrayValueItem(
@@ -235,12 +230,7 @@ internal static bool MatchArrayValueItem(
235230
return true;
236231
}
237232

238-
if (options?.ArrayItemMatcher is not null)
239-
{
240-
return options.ArrayItemMatcher(ref context);
241-
}
242-
243-
return false;
233+
return options?.ArrayItemMatcher is not null ? options.ArrayItemMatcher(ref context) : false;
244234
}
245235

246236
private static bool FallbackMatchArrayItem(ref ArrayItemMatchContext context, JsonDiffOptions options,

src/SystemTextJson.JsonDiffPatch/Diffs/JsonDiffPatcher.Diff.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,7 @@ static partial class JsonDiffPatcher
208208
return formatter.Format(ref delta, left);
209209
}
210210

211-
if (delta.Document is TResult result)
212-
{
213-
return result;
214-
}
215-
216-
return (TResult?)(object?)delta.Document;
211+
return delta.Document is TResult result ? result : (TResult?)(object?)delta.Document;
217212
}
218213

219214
private static void DiffInternal(

src/SystemTextJson.JsonDiffPatch/Diffs/Lcs.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,21 +149,13 @@ public static Lcs Get(Span<JsonNode?> x, Span<JsonNode?> y, JsonDiffOptions? opt
149149
for (var j = 1; j < n; j++)
150150
{
151151
var matchContext = new ArrayItemMatchContext(x[i - 1], i - 1, y[j - 1], j - 1);
152-
bool itemMatched;
153-
154-
if (x[i - 1] is JsonValue && y[j - 1] is JsonValue)
155-
{
156-
itemMatched = JsonDiffPatcher.MatchArrayValueItem(ref matchContext,
152+
bool itemMatched = x[i - 1] is JsonValue && y[j - 1] is JsonValue
153+
? JsonDiffPatcher.MatchArrayValueItem(ref matchContext,
157154
ref wrapperCacheSpan[i - 1],
158155
ref wrapperCacheSpan[x.Length + j - 1],
159156
options,
160-
comparerOptions);
161-
}
162-
else
163-
{
164-
itemMatched = JsonDiffPatcher.MatchArrayItem(ref matchContext, options, comparerOptions);
165-
}
166-
157+
comparerOptions)
158+
: JsonDiffPatcher.MatchArrayItem(ref matchContext, options, comparerOptions);
167159
if (itemMatched)
168160
{
169161
matrix[i * n + j] = 1 + matrix[(i - 1) * n + (j - 1)];

src/SystemTextJson.JsonDiffPatch/JsonDiffPatcher.DeepEquals.cs

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,9 @@ internal static bool DeepEquals(this JsonNode? left, JsonNode? right, in JsonCom
5555
return true;
5656
}
5757

58-
if (left is null || right is null)
59-
{
60-
return false;
61-
}
62-
63-
return left switch
58+
return left is null || right is null
59+
? false
60+
: left switch
6461
{
6562
JsonValue val1 when right is JsonValue val2 => ValueEquals(val1, val2, comparerOptions),
6663
JsonObject obj1 when right is JsonObject obj2 => ObjectEquals(obj1, obj2, comparerOptions),
@@ -83,12 +80,7 @@ public static bool DeepEquals(this JsonDocument? left, JsonDocument? right,
8380
return true;
8481
}
8582

86-
if (left is null || right is null)
87-
{
88-
return false;
89-
}
90-
91-
return left.RootElement.DeepEquals(right.RootElement, elementComparison);
83+
return left is null || right is null ? false : left.RootElement.DeepEquals(right.RootElement, elementComparison);
9284
}
9385

9486
/// <summary>
@@ -219,10 +211,7 @@ static void EnumerateProperty(in JsonElement element, out Dictionary<string, Jso
219211

220212
foreach (var property in element.EnumerateObject())
221213
{
222-
if (properties is null)
223-
{
224-
properties = new Dictionary<string, JsonProperty>();
225-
}
214+
properties ??= new Dictionary<string, JsonProperty>();
226215

227216
properties[property.Name] = property;
228217
}
@@ -286,12 +275,7 @@ private static bool ValueEquals(JsonValue x, JsonValue y, in JsonComparerOptions
286275
var hash1 = valueComparer.GetHashCode(x);
287276
var hash2 = valueComparer.GetHashCode(y);
288277

289-
if (hash1 != hash2)
290-
{
291-
return false;
292-
}
293-
294-
return valueComparer.Equals(x, y);
278+
return hash1 != hash2 ? false : valueComparer.Equals(x, y);
295279
}
296280

297281
var wrapperX = new JsonValueWrapper(x);

src/SystemTextJson.JsonDiffPatch/JsonNumber.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -211,24 +211,16 @@ public int CompareTo(ref JsonNumber another)
211211
return GetDecimal().CompareTo(another.GetDecimal());
212212
}
213213

214-
if (DoubleValue.HasValue || FloatValue.HasValue ||
215-
another.DoubleValue.HasValue || another.FloatValue.HasValue)
216-
{
217-
return JsonValueComparer.CompareDouble(GetDouble(), another.GetDouble());
218-
}
219-
220-
return LongValue!.Value.CompareTo(another.LongValue!.Value);
214+
return DoubleValue.HasValue || FloatValue.HasValue ||
215+
another.DoubleValue.HasValue || another.FloatValue.HasValue
216+
? JsonValueComparer.CompareDouble(GetDouble(), another.GetDouble())
217+
: LongValue!.Value.CompareTo(another.LongValue!.Value);
221218
}
222219

223220
[MethodImpl(MethodImplOptions.AggressiveInlining)]
224221
public bool RawTextEquals(ref JsonNumber another)
225222
{
226-
if (!HasElement || HasElement != another.HasElement)
227-
{
228-
return false;
229-
}
230-
231-
return string.Equals(Element.GetRawText(), another.Element.GetRawText());
223+
return !HasElement || HasElement != another.HasElement ? false : string.Equals(Element.GetRawText(), another.Element.GetRawText());
232224
}
233225

234226
public static bool TryGetJsonNumber(JsonValue jsonValue, out JsonNumber result)

src/SystemTextJson.JsonDiffPatch/JsonString.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,7 @@ public bool Equals(ref JsonString another)
335335
[MethodImpl(MethodImplOptions.AggressiveInlining)]
336336
public bool ValueEquals(ref JsonString another)
337337
{
338-
if (!HasElement || HasElement != another.HasElement)
339-
{
340-
return false;
341-
}
342-
343-
return Element.ValueEquals(another.Element.GetString());
338+
return !HasElement || HasElement != another.HasElement ? false : Element.ValueEquals(another.Element.GetString());
344339
}
345340

346341
public static bool TryGetJsonString(JsonValue jsonValue, out JsonString result)

src/SystemTextJson.JsonDiffPatch/JsonValueComparer.Number.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ private static bool AreDoubleClose(double x, double y)
1414
var tolerance = (Math.Abs(x) + Math.Abs(y) + 10.0) * epsilon;
1515
var difference = x - y;
1616

17-
if (-tolerance < difference)
18-
return tolerance > difference;
19-
20-
return false;
17+
return -tolerance < difference ? tolerance > difference : false;
2118
}
2219

2320
internal static int CompareDouble(double x, double y)

0 commit comments

Comments
 (0)