@@ -26,8 +26,8 @@ public static bool TryGetValueSynchronized<TKey, TValue>(
2626 this IDictionary < TKey , TValue > target ,
2727 TKey key , out TValue value )
2828 {
29- if ( target == null ) throw new NullReferenceException ( ) ;
30- if ( key == null ) throw new ArgumentNullException ( nameof ( key ) ) ;
29+ if ( target is null ) throw new NullReferenceException ( ) ;
30+ if ( key is null ) throw new ArgumentNullException ( nameof ( key ) ) ;
3131 Contract . EndContractBlock ( ) ;
3232
3333 TValue result = default ;
@@ -47,8 +47,8 @@ public static bool TryGetValueSynchronized<TKey, TValue>(
4747 /// </summary>
4848 public static TValue GetValueSynchronized < TKey , TValue > ( this IDictionary < TKey , TValue > target , TKey key , bool throwIfNotExists = true )
4949 {
50- if ( target == null ) throw new NullReferenceException ( ) ;
51- if ( key == null ) throw new ArgumentNullException ( nameof ( key ) ) ;
50+ if ( target is null ) throw new NullReferenceException ( ) ;
51+ if ( key is null ) throw new ArgumentNullException ( nameof ( key ) ) ;
5252 Contract . EndContractBlock ( ) ;
5353
5454 var exists = target . TryGetValueSynchronized ( key , out var value ) ;
@@ -65,7 +65,7 @@ public static TValue GetValueSynchronized<TKey, TValue>(this IDictionary<TKey, T
6565 /// </summary>
6666 public static void RegisterSynchronized < T > ( this ICollection < T > target , T value )
6767 {
68- if ( target == null ) throw new NullReferenceException ( ) ;
68+ if ( target is null ) throw new NullReferenceException ( ) ;
6969 Contract . EndContractBlock ( ) ;
7070
7171 ThreadSafety . SynchronizeReadWriteKeyAndObject ( target , value ,
@@ -82,9 +82,9 @@ public static void RegisterSynchronized<T>(this ICollection<T> target, T value)
8282 public static T AddOrUpdateSynchronized < TKey , T > ( this IDictionary < TKey , T > target , TKey key , T value ,
8383 Func < TKey , T , T > updateValueFactory )
8484 {
85- if ( target == null ) throw new NullReferenceException ( ) ;
86- if ( key == null ) throw new ArgumentNullException ( nameof ( key ) ) ;
87- if ( updateValueFactory == null ) throw new ArgumentNullException ( nameof ( updateValueFactory ) ) ;
85+ if ( target is null ) throw new NullReferenceException ( ) ;
86+ if ( key is null ) throw new ArgumentNullException ( nameof ( key ) ) ;
87+ if ( updateValueFactory is null ) throw new ArgumentNullException ( nameof ( updateValueFactory ) ) ;
8888 Contract . EndContractBlock ( ) ;
8989
9090 T valueUsed = default ;
@@ -120,10 +120,10 @@ public static T AddOrUpdateSynchronized<TKey, T>(this IDictionary<TKey, T> targe
120120 Func < TKey , T > newValueFactory ,
121121 Func < TKey , T , T > updateValueFactory )
122122 {
123- if ( target == null ) throw new NullReferenceException ( ) ;
124- if ( key == null ) throw new ArgumentNullException ( nameof ( key ) ) ;
125- if ( newValueFactory == null ) throw new ArgumentNullException ( nameof ( newValueFactory ) ) ;
126- if ( updateValueFactory == null ) throw new ArgumentNullException ( nameof ( updateValueFactory ) ) ;
123+ if ( target is null ) throw new NullReferenceException ( ) ;
124+ if ( key is null ) throw new ArgumentNullException ( nameof ( key ) ) ;
125+ if ( newValueFactory is null ) throw new ArgumentNullException ( nameof ( newValueFactory ) ) ;
126+ if ( updateValueFactory is null ) throw new ArgumentNullException ( nameof ( updateValueFactory ) ) ;
127127 Contract . EndContractBlock ( ) ;
128128
129129 T valueUsed = default ;
@@ -163,7 +163,7 @@ public static T AddOrUpdateSynchronized<TKey, T>(this IDictionary<TKey, T> targe
163163
164164 public static void AddSynchronized < T > ( this ICollection < T > target , T value )
165165 {
166- if ( target == null ) throw new NullReferenceException ( ) ;
166+ if ( target is null ) throw new NullReferenceException ( ) ;
167167 ThreadSafety . SynchronizeWrite ( target , ( ) => target . Add ( value ) ) ;
168168 }
169169
@@ -172,8 +172,8 @@ public static void AddSynchronized<T>(this ICollection<T> target, T value)
172172 /// </summary>
173173 public static void AddToSynchronized < TKey , TValue > ( this IDictionary < TKey , IList < TValue > > c , TKey key , TValue value )
174174 {
175- if ( c == null ) throw new NullReferenceException ( ) ;
176- if ( key == null ) throw new ArgumentNullException ( nameof ( key ) ) ;
175+ if ( c is null ) throw new NullReferenceException ( ) ;
176+ if ( key is null ) throw new ArgumentNullException ( nameof ( key ) ) ;
177177 Contract . EndContractBlock ( ) ;
178178
179179 var list = c . GetOrAddSynchronized ( key , k => new List < TValue > ( ) ) ;
@@ -185,8 +185,8 @@ public static void AddToSynchronized<TKey, TValue>(this IDictionary<TKey, IList<
185185 /// </summary>
186186 public static void EnsureDefaultSynchronized < TKey , T > ( this IDictionary < TKey , T > target , TKey key , T defaultValue )
187187 {
188- if ( target == null ) throw new NullReferenceException ( ) ;
189- if ( key == null ) throw new ArgumentNullException ( nameof ( key ) ) ;
188+ if ( target is null ) throw new NullReferenceException ( ) ;
189+ if ( key is null ) throw new ArgumentNullException ( nameof ( key ) ) ;
190190 Contract . EndContractBlock ( ) ;
191191
192192 ThreadSafety . SynchronizeReadWrite ( target ,
@@ -200,9 +200,9 @@ public static void EnsureDefaultSynchronized<TKey, T>(this IDictionary<TKey, T>
200200 public static void EnsureDefaultSynchronized < TKey , T > ( this IDictionary < TKey , T > target , TKey key ,
201201 Func < TKey , T > defaultValueFactory )
202202 {
203- if ( target == null ) throw new NullReferenceException ( ) ;
204- if ( key == null ) throw new ArgumentNullException ( nameof ( key ) ) ;
205- if ( defaultValueFactory == null ) throw new ArgumentNullException ( nameof ( defaultValueFactory ) ) ;
203+ if ( target is null ) throw new NullReferenceException ( ) ;
204+ if ( key is null ) throw new ArgumentNullException ( nameof ( key ) ) ;
205+ if ( defaultValueFactory is null ) throw new ArgumentNullException ( nameof ( defaultValueFactory ) ) ;
206206 Contract . EndContractBlock ( ) ;
207207
208208 ThreadSafety . SynchronizeReadWrite ( target , key ,
@@ -223,8 +223,8 @@ public static T GetOrAddSynchronized<TKey, T>(
223223 int millisecondsTimeout = SYNC_TIMEOUT_DEFAULT_MILLISECONDS ,
224224 bool throwsOnTimeout = true )
225225 {
226- if ( target == null ) throw new NullReferenceException ( ) ;
227- if ( key == null ) throw new ArgumentNullException ( nameof ( key ) ) ;
226+ if ( target is null ) throw new NullReferenceException ( ) ;
227+ if ( key is null ) throw new ArgumentNullException ( nameof ( key ) ) ;
228228 ValidateMillisecondsTimeout ( millisecondsTimeout ) ;
229229 Contract . EndContractBlock ( ) ;
230230
@@ -252,9 +252,9 @@ public static T GetOrAddSynchronized<TKey, T>(
252252 Func < TKey , T > valueFactory ,
253253 int millisecondsTimeout = SYNC_TIMEOUT_DEFAULT_MILLISECONDS )
254254 {
255- if ( target == null ) throw new NullReferenceException ( ) ;
256- if ( key == null ) throw new ArgumentNullException ( nameof ( key ) ) ;
257- if ( valueFactory == null ) throw new ArgumentNullException ( nameof ( valueFactory ) ) ;
255+ if ( target is null ) throw new NullReferenceException ( ) ;
256+ if ( key is null ) throw new ArgumentNullException ( nameof ( key ) ) ;
257+ if ( valueFactory is null ) throw new ArgumentNullException ( nameof ( valueFactory ) ) ;
258258 ValidateMillisecondsTimeout ( millisecondsTimeout ) ;
259259 Contract . EndContractBlock ( ) ;
260260
@@ -294,8 +294,8 @@ public static bool TryAddSynchronized<TKey, T>(
294294 T value ,
295295 int millisecondsTimeout = SYNC_TIMEOUT_DEFAULT_MILLISECONDS )
296296 {
297- if ( target == null ) throw new NullReferenceException ( ) ;
298- if ( key == null ) throw new ArgumentNullException ( nameof ( key ) ) ;
297+ if ( target is null ) throw new NullReferenceException ( ) ;
298+ if ( key is null ) throw new ArgumentNullException ( nameof ( key ) ) ;
299299 Contract . EndContractBlock ( ) ;
300300
301301 var added = false ;
@@ -323,8 +323,8 @@ public static bool TryAddSynchronized<TKey, T>(
323323 Func < T > valueFactory ,
324324 int millisecondsTimeout = SYNC_TIMEOUT_DEFAULT_MILLISECONDS )
325325 {
326- if ( target == null ) throw new NullReferenceException ( ) ;
327- if ( key == null ) throw new ArgumentNullException ( nameof ( key ) ) ;
326+ if ( target is null ) throw new NullReferenceException ( ) ;
327+ if ( key is null ) throw new ArgumentNullException ( nameof ( key ) ) ;
328328 Contract . EndContractBlock ( ) ;
329329
330330 var added = false ;
@@ -351,8 +351,8 @@ public static bool TryRemoveSynchronized<TKey, T>(
351351 TKey key ,
352352 int millisecondsTimeout = SYNC_TIMEOUT_DEFAULT_MILLISECONDS )
353353 {
354- if ( target == null ) throw new NullReferenceException ( ) ;
355- if ( key == null ) throw new ArgumentNullException ( nameof ( key ) ) ;
354+ if ( target is null ) throw new NullReferenceException ( ) ;
355+ if ( key is null ) throw new ArgumentNullException ( nameof ( key ) ) ;
356356 Contract . EndContractBlock ( ) ;
357357
358358 var removed = false ;
@@ -376,8 +376,8 @@ public static bool TryRemoveSynchronized<TKey, T>(
376376 out T value ,
377377 int millisecondsTimeout = SYNC_TIMEOUT_DEFAULT_MILLISECONDS )
378378 {
379- if ( target == null ) throw new NullReferenceException ( ) ;
380- if ( key == null ) throw new ArgumentNullException ( nameof ( key ) ) ;
379+ if ( target is null ) throw new NullReferenceException ( ) ;
380+ if ( key is null ) throw new ArgumentNullException ( nameof ( key ) ) ;
381381 Contract . EndContractBlock ( ) ;
382382
383383 value = default ;
0 commit comments