@@ -62,39 +62,38 @@ public virtual IEnumerator<T> GetEnumerator ()
62
62
internal static void CheckArrayCopy ( int sourceIndex , int sourceLength , int destinationIndex , int destinationLength , int length )
63
63
{
64
64
if ( sourceIndex < 0 )
65
- throw new ArgumentOutOfRangeException ( " sourceIndex" , $ "source index must be >= 0; was { sourceIndex } .") ;
65
+ throw new ArgumentOutOfRangeException ( nameof ( sourceIndex ) , $ "source index must be >= 0; was { sourceIndex } .") ;
66
66
if ( sourceIndex != 0 && sourceIndex >= sourceLength )
67
- throw new ArgumentException ( "source index is > source length." , " sourceIndex" ) ;
67
+ throw new ArgumentException ( "source index is > source length." , nameof ( sourceIndex ) ) ;
68
68
if ( checked ( sourceIndex + length ) > sourceLength )
69
- throw new ArgumentException ( "source index + length >= source length" , " length" ) ;
69
+ throw new ArgumentException ( "source index + length >= source length" , nameof ( length ) ) ;
70
70
if ( destinationIndex < 0 )
71
- throw new ArgumentOutOfRangeException ( " destinationIndex" , $ "destination index must be >= 0; was { destinationIndex } .") ;
71
+ throw new ArgumentOutOfRangeException ( nameof ( destinationIndex ) , $ "destination index must be >= 0; was { destinationIndex } .") ;
72
72
if ( destinationIndex != 0 && destinationIndex >= destinationLength )
73
- throw new ArgumentException ( "destination index is > destination length." , " destinationIndex" ) ;
73
+ throw new ArgumentException ( "destination index is > destination length." , nameof ( destinationIndex ) ) ;
74
74
if ( checked ( destinationIndex + length ) > destinationLength )
75
- throw new ArgumentException ( "destination index + length >= destination length" , " length" ) ;
75
+ throw new ArgumentException ( "destination index + length >= destination length" , nameof ( length ) ) ;
76
76
}
77
77
78
78
internal static int CheckLength ( int length )
79
79
{
80
80
if ( length < 0 )
81
- throw new ArgumentException ( "'length' cannot be negative." , " length" ) ;
81
+ throw new ArgumentException ( "'length' cannot be negative." , nameof ( length ) ) ;
82
82
return length ;
83
83
}
84
84
85
85
internal static int CheckLength ( IList < T > value )
86
86
{
87
87
if ( value == null )
88
- throw new ArgumentNullException ( " value" ) ;
88
+ throw new ArgumentNullException ( nameof ( value ) ) ;
89
89
return value . Count ;
90
90
}
91
91
92
92
internal static IList < T > ToList ( IEnumerable < T > value )
93
93
{
94
94
if ( value == null )
95
- throw new ArgumentNullException ( "value" ) ;
96
- IList < T > list = value as IList < T > ;
97
- if ( list != null )
95
+ throw new ArgumentNullException ( nameof ( value ) ) ;
96
+ if ( value is IList < T > list )
98
97
return list ;
99
98
return value . ToList ( ) ;
100
99
}
@@ -138,8 +137,7 @@ internal static JniValueMarshalerState CreateArgumentState<TArray> (IList<T
138
137
{
139
138
if ( value == null )
140
139
return new JniValueMarshalerState ( ) ;
141
- var v = value as TArray ;
142
- if ( v != null ) {
140
+ if ( value is TArray v ) {
143
141
return new JniValueMarshalerState ( v ) ;
144
142
}
145
143
var list = value as IList < T > ;
@@ -227,7 +225,7 @@ object IList.this [int index] {
227
225
void ICollection . CopyTo ( Array array , int index )
228
226
{
229
227
if ( array == null )
230
- throw new ArgumentNullException ( " array" ) ;
228
+ throw new ArgumentNullException ( nameof ( array ) ) ;
231
229
CheckArrayCopy ( 0 , Length , index , array . Length , Length ) ;
232
230
int len = Length ;
233
231
for ( int i = 0 ; i < len ; i ++ )
@@ -301,7 +299,7 @@ public abstract class JniArrayElements : IDisposable {
301
299
internal JniArrayElements ( IntPtr elements )
302
300
{
303
301
if ( elements == IntPtr . Zero )
304
- throw new ArgumentException ( "'elements' must not be IntPtr.Zero." , " elements" ) ;
302
+ throw new ArgumentException ( "'elements' must not be IntPtr.Zero." , nameof ( elements ) ) ;
305
303
this . elements = elements ;
306
304
}
307
305
@@ -327,7 +325,7 @@ public void CopyToJava ()
327
325
public void Release ( JniReleaseArrayElementsMode releaseMode )
328
326
{
329
327
if ( IsDisposed )
330
- throw new ObjectDisposedException ( GetType ( ) . FullName ) ; ;
328
+ throw new ObjectDisposedException ( GetType ( ) . FullName ) ;
331
329
Synchronize ( releaseMode ) ;
332
330
elements = IntPtr . Zero ;
333
331
}
@@ -360,7 +358,7 @@ public override T this [int index] {
360
358
}
361
359
set {
362
360
if ( index >= Length )
363
- throw new ArgumentOutOfRangeException ( " index" , "index >= Length" ) ;
361
+ throw new ArgumentOutOfRangeException ( nameof ( index ) , "index >= Length" ) ;
364
362
var buf = new T [ ] { value } ;
365
363
CopyFrom ( buf , 0 , index , buf . Length ) ;
366
364
}
@@ -378,8 +376,7 @@ public override void CopyTo (T[] array, int arrayIndex)
378
376
379
377
internal static T [ ] ToArray ( IEnumerable < T > value )
380
378
{
381
- var array = value as T [ ] ;
382
- if ( array != null )
379
+ if ( value is T [ ] array )
383
380
return array ;
384
381
return value . ToArray ( ) ;
385
382
}
0 commit comments