@@ -29,29 +29,29 @@ public ref struct RefEnumerable<T>
29
29
/// The <see cref="Span{T}"/> instance pointing to the first item in the target memory area.
30
30
/// </summary>
31
31
/// <remarks>The <see cref="Span{T}.Length"/> field maps to the total available length.</remarks>
32
- private readonly Span < T > span ;
32
+ internal readonly Span < T > Span ;
33
33
#else
34
34
/// <summary>
35
35
/// The target <see cref="object"/> instance, if present.
36
36
/// </summary>
37
- private readonly object ? instance ;
37
+ internal readonly object ? Instance ;
38
38
39
39
/// <summary>
40
- /// The initial offset within <see cref="instance "/>.
40
+ /// The initial offset within <see cref="Instance "/>.
41
41
/// </summary>
42
- private readonly IntPtr offset ;
42
+ internal readonly IntPtr Offset ;
43
43
44
44
/// <summary>
45
45
/// The total available length for the sequence.
46
46
/// </summary>
47
- private readonly int length ;
47
+ internal readonly int Length ;
48
48
#endif
49
49
50
50
/// <summary>
51
51
/// The distance between items in the sequence to enumerate.
52
52
/// </summary>
53
53
/// <remarks>The distance refers to <typeparamref name="T"/> items, not byte offset.</remarks>
54
- private readonly int step ;
54
+ internal readonly int Step ;
55
55
56
56
/// <summary>
57
57
/// The current position in the sequence.
@@ -68,8 +68,9 @@ public ref struct RefEnumerable<T>
68
68
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
69
69
internal RefEnumerable ( ref T reference , int length , int step )
70
70
{
71
- this . span = MemoryMarshal . CreateSpan ( ref reference , length ) ;
72
- this . step = step ;
71
+ Span = MemoryMarshal . CreateSpan ( ref reference , length ) ;
72
+ Step = step ;
73
+
73
74
this . position = - 1 ;
74
75
}
75
76
#else
@@ -83,10 +84,11 @@ internal RefEnumerable(ref T reference, int length, int step)
83
84
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
84
85
internal RefEnumerable ( object ? instance , IntPtr offset , int length , int step )
85
86
{
86
- this . instance = instance ;
87
- this . offset = offset ;
88
- this . length = length ;
89
- this . step = step ;
87
+ Instance = instance ;
88
+ Offset = offset ;
89
+ Length = length ;
90
+ Step = step ;
91
+
90
92
this . position = - 1 ;
91
93
}
92
94
#endif
@@ -101,9 +103,9 @@ internal RefEnumerable(object? instance, IntPtr offset, int length, int step)
101
103
public bool MoveNext ( )
102
104
{
103
105
#if SPAN_RUNTIME_SUPPORT
104
- return ++ this . position < this . span . Length ;
106
+ return ++ this . position < this . Span . Length ;
105
107
#else
106
- return ++ this . position < this . length ;
108
+ return ++ this . position < this . Length ;
107
109
#endif
108
110
}
109
111
@@ -114,9 +116,9 @@ public readonly ref T Current
114
116
get
115
117
{
116
118
#if SPAN_RUNTIME_SUPPORT
117
- ref T r0 = ref this . span . DangerousGetReference ( ) ;
119
+ ref T r0 = ref this . Span . DangerousGetReference ( ) ;
118
120
#else
119
- ref T r0 = ref RuntimeHelpers . GetObjectDataAtOffsetOrPointerReference < T > ( this . instance , this . offset ) ;
121
+ ref T r0 = ref RuntimeHelpers . GetObjectDataAtOffsetOrPointerReference < T > ( this . Instance , this . Offset ) ;
120
122
#endif
121
123
122
124
// Here we just offset by shifting down as if we were traversing a 2D array with a
@@ -125,7 +127,7 @@ public readonly ref T Current
125
127
// being inspected. We can perform all the indexing operations in this type as nint,
126
128
// as the maximum offset is guaranteed never to exceed the maximum value, since on
127
129
// 32 bit architectures it's not possible to allocate that much memory anyway.
128
- nint offset = ( nint ) ( uint ) this . position * ( nint ) ( uint ) this . step ;
130
+ nint offset = ( nint ) ( uint ) this . position * ( nint ) ( uint ) this . Step ;
129
131
ref T ri = ref Unsafe . Add ( ref r0 , offset ) ;
130
132
131
133
return ref ri ;
@@ -139,21 +141,21 @@ public readonly void Clear()
139
141
{
140
142
#if SPAN_RUNTIME_SUPPORT
141
143
// Fast path for contiguous items
142
- if ( this . step == 1 )
144
+ if ( this . Step == 1 )
143
145
{
144
- this . span . Clear ( ) ;
146
+ this . Span . Clear ( ) ;
145
147
146
148
return ;
147
149
}
148
150
149
- ref T r0 = ref this . span . DangerousGetReference ( ) ;
150
- int length = this . span . Length ;
151
+ ref T r0 = ref this . Span . DangerousGetReference ( ) ;
152
+ int length = this . Span . Length ;
151
153
#else
152
- ref T r0 = ref RuntimeHelpers . GetObjectDataAtOffsetOrPointerReference < T > ( this . instance , this . offset ) ;
153
- int length = this . length ;
154
+ ref T r0 = ref RuntimeHelpers . GetObjectDataAtOffsetOrPointerReference < T > ( this . Instance , this . Offset ) ;
155
+ int length = this . Length ;
154
156
#endif
155
157
156
- RefEnumerableHelper . Clear ( ref r0 , ( nint ) ( uint ) length , ( nint ) ( uint ) this . step ) ;
158
+ RefEnumerableHelper . Clear ( ref r0 , ( nint ) ( uint ) length , ( nint ) ( uint ) this . Step ) ;
157
159
}
158
160
159
161
/// <summary>
@@ -166,18 +168,18 @@ public readonly void Clear()
166
168
public readonly void CopyTo ( Span < T > destination )
167
169
{
168
170
#if SPAN_RUNTIME_SUPPORT
169
- if ( this . step == 1 )
171
+ if ( this . Step == 1 )
170
172
{
171
- this . span . CopyTo ( destination ) ;
173
+ this . Span . CopyTo ( destination ) ;
172
174
173
175
return ;
174
176
}
175
177
176
- ref T sourceRef = ref this . span . DangerousGetReference ( ) ;
177
- int length = this . span . Length ;
178
+ ref T sourceRef = ref this . Span . DangerousGetReference ( ) ;
179
+ int length = this . Span . Length ;
178
180
#else
179
- ref T sourceRef = ref RuntimeHelpers . GetObjectDataAtOffsetOrPointerReference < T > ( this . instance , this . offset ) ;
180
- int length = this . length ;
181
+ ref T sourceRef = ref RuntimeHelpers . GetObjectDataAtOffsetOrPointerReference < T > ( this . Instance , this . Offset ) ;
182
+ int length = this . Length ;
181
183
#endif
182
184
if ( ( uint ) destination . Length < ( uint ) length )
183
185
{
@@ -186,7 +188,7 @@ public readonly void CopyTo(Span<T> destination)
186
188
187
189
ref T destinationRef = ref destination . DangerousGetReference ( ) ;
188
190
189
- RefEnumerableHelper . CopyTo ( ref sourceRef , ref destinationRef , ( nint ) ( uint ) length , ( nint ) ( uint ) this . step ) ;
191
+ RefEnumerableHelper . CopyTo ( ref sourceRef , ref destinationRef , ( nint ) ( uint ) length , ( nint ) ( uint ) this . Step ) ;
190
192
}
191
193
192
194
/// <summary>
@@ -197,9 +199,9 @@ public readonly void CopyTo(Span<T> destination)
197
199
public readonly bool TryCopyTo ( Span < T > destination )
198
200
{
199
201
#if SPAN_RUNTIME_SUPPORT
200
- int length = this . span . Length ;
202
+ int length = this . Span . Length ;
201
203
#else
202
- int length = this . length ;
204
+ int length = this . Length ;
203
205
#endif
204
206
205
207
if ( destination . Length >= length )
@@ -222,18 +224,18 @@ public readonly bool TryCopyTo(Span<T> destination)
222
224
internal readonly void CopyFrom ( ReadOnlySpan < T > source )
223
225
{
224
226
#if SPAN_RUNTIME_SUPPORT
225
- if ( this . step == 1 )
227
+ if ( this . Step == 1 )
226
228
{
227
- source . CopyTo ( this . span ) ;
229
+ source . CopyTo ( this . Span ) ;
228
230
229
231
return ;
230
232
}
231
233
232
- ref T destinationRef = ref this . span . DangerousGetReference ( ) ;
233
- int destinationLength = this . span . Length ;
234
+ ref T destinationRef = ref this . Span . DangerousGetReference ( ) ;
235
+ int destinationLength = this . Span . Length ;
234
236
#else
235
- ref T destinationRef = ref RuntimeHelpers . GetObjectDataAtOffsetOrPointerReference < T > ( this . instance , this . offset ) ;
236
- int destinationLength = this . length ;
237
+ ref T destinationRef = ref RuntimeHelpers . GetObjectDataAtOffsetOrPointerReference < T > ( this . Instance , this . Offset ) ;
238
+ int destinationLength = this . Length ;
237
239
#endif
238
240
ref T sourceRef = ref source . DangerousGetReference ( ) ;
239
241
int sourceLength = source . Length ;
@@ -243,7 +245,7 @@ internal readonly void CopyFrom(ReadOnlySpan<T> source)
243
245
ThrowArgumentExceptionForDestinationTooShort ( ) ;
244
246
}
245
247
246
- RefEnumerableHelper . CopyFrom ( ref sourceRef , ref destinationRef , ( nint ) ( uint ) sourceLength , ( nint ) ( uint ) this . step ) ;
248
+ RefEnumerableHelper . CopyFrom ( ref sourceRef , ref destinationRef , ( nint ) ( uint ) sourceLength , ( nint ) ( uint ) this . Step ) ;
247
249
}
248
250
249
251
/// <summary>
@@ -254,9 +256,9 @@ internal readonly void CopyFrom(ReadOnlySpan<T> source)
254
256
public readonly bool TryCopyFrom ( ReadOnlySpan < T > source )
255
257
{
256
258
#if SPAN_RUNTIME_SUPPORT
257
- int length = this . span . Length ;
259
+ int length = this . Span . Length ;
258
260
#else
259
- int length = this . length ;
261
+ int length = this . Length ;
260
262
#endif
261
263
262
264
if ( length >= source . Length )
@@ -280,21 +282,21 @@ public readonly bool TryCopyFrom(ReadOnlySpan<T> source)
280
282
public readonly void Fill ( T value )
281
283
{
282
284
#if SPAN_RUNTIME_SUPPORT
283
- if ( this . step == 1 )
285
+ if ( this . Step == 1 )
284
286
{
285
- this . span . Fill ( value ) ;
287
+ this . Span . Fill ( value ) ;
286
288
287
289
return ;
288
290
}
289
291
290
- ref T r0 = ref this . span . DangerousGetReference ( ) ;
291
- int length = this . span . Length ;
292
+ ref T r0 = ref this . Span . DangerousGetReference ( ) ;
293
+ int length = this . Span . Length ;
292
294
#else
293
- ref T r0 = ref RuntimeHelpers . GetObjectDataAtOffsetOrPointerReference < T > ( this . instance , this . offset ) ;
294
- int length = this . length ;
295
+ ref T r0 = ref RuntimeHelpers . GetObjectDataAtOffsetOrPointerReference < T > ( this . Instance , this . Offset ) ;
296
+ int length = this . Length ;
295
297
#endif
296
298
297
- RefEnumerableHelper . Fill ( ref r0 , ( nint ) ( uint ) length , ( nint ) ( uint ) this . step , value ) ;
299
+ RefEnumerableHelper . Fill ( ref r0 , ( nint ) ( uint ) length , ( nint ) ( uint ) this . Step , value ) ;
298
300
}
299
301
300
302
/// <summary>
@@ -311,9 +313,9 @@ public readonly void Fill(T value)
311
313
public readonly T [ ] ToArray ( )
312
314
{
313
315
#if SPAN_RUNTIME_SUPPORT
314
- int length = this . span . Length ;
316
+ int length = this . Span . Length ;
315
317
#else
316
- int length = this . length ;
318
+ int length = this . Length ;
317
319
#endif
318
320
319
321
// Empty array if no data is mapped
0 commit comments