Skip to content

Commit 36d2056

Browse files
committed
chore: cleanup Sanitizer
1 parent 6bbd484 commit 36d2056

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

Intersect (Core)/Collections/Sanitizer.cs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
namespace Intersect.Collections;
22

3-
4-
public partial struct Sanitizer
3+
public struct Sanitizer
54
{
5+
private Dictionary<string, SanitizedValue<object>>? _sanitizedValues;
66

7-
private Dictionary<string, SanitizedValue<object>> mSanitizedValues;
8-
9-
public Dictionary<string, SanitizedValue<object>> Sanitized => mSanitizedValues?.ToDictionary();
7+
public Dictionary<string, SanitizedValue<object>> Sanitized => _sanitizedValues?.ToDictionary() ?? [];
108

119
public Sanitizer Add<T>(string name, T before, T after)
1210
{
@@ -15,12 +13,9 @@ public Sanitizer Add<T>(string name, T before, T after)
1513
throw new ArgumentNullException(nameof(name));
1614
}
1715

18-
if (mSanitizedValues == null)
19-
{
20-
mSanitizedValues = new Dictionary<string, SanitizedValue<object>>(8);
21-
}
16+
_sanitizedValues ??= new Dictionary<string, SanitizedValue<object>>(8);
2217

23-
mSanitizedValues.Add(name, new SanitizedValue<object>(before, after));
18+
_sanitizedValues.Add(name, new SanitizedValue<object>(before, after));
2419

2520
return this;
2621
}
@@ -47,7 +42,7 @@ public T IsNull<T>(string name, T value) where T : class
4742

4843
public T Is<T>(string name, T actualValue, T expectedValue)
4944
{
50-
if (expectedValue == null && actualValue == null || (expectedValue?.Equals(actualValue) ?? false))
45+
if ((expectedValue == null && actualValue == null) || (expectedValue?.Equals(actualValue) ?? false))
5146
{
5247
return actualValue;
5348
}
@@ -59,7 +54,7 @@ public T Is<T>(string name, T actualValue, T expectedValue)
5954

6055
public T IsNot<T>(string name, T actualValue, T expectedValue)
6156
{
62-
if (expectedValue == null && actualValue != null || !(expectedValue?.Equals(actualValue) ?? false))
57+
if ((expectedValue == null && actualValue != null) || !(expectedValue?.Equals(actualValue) ?? false))
6358
{
6459
return actualValue;
6560
}
@@ -214,5 +209,4 @@ T expectedMaximum
214209

215210
return expectedMaximum;
216211
}
217-
218-
}
212+
}

0 commit comments

Comments
 (0)