11namespace 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