Skip to content

Commit 9a8c31b

Browse files
Copilotagocke
andcommitted
Address PR feedback: move comment, remove FIXME from Array.CoreCLR.cs, refactor Delegate.CoreCLR.cs, add clarifying comments
Co-authored-by: agocke <[email protected]>
1 parent f2e66af commit 9a8c31b

File tree

4 files changed

+5
-11
lines changed

4 files changed

+5
-11
lines changed

src/coreclr/System.Private.CoreLib/src/System/Array.CoreCLR.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,6 @@ internal IEnumerator<T> GetEnumerator<T>()
402402
// ! Warning: "this" is an array, not an SZArrayHelper. See comments above
403403
// ! or you may introduce a security hole!
404404
T[] @this;
405-
// FIXME: review unsafe to confirm correct annotation
406405
unsafe
407406
{
408407
@this = Unsafe.As<T[]>(this);
@@ -417,7 +416,6 @@ private void CopyTo<T>(T[] array, int index)
417416
// ! or you may introduce a security hole!
418417

419418
T[] @this;
420-
// FIXME: review unsafe to confirm correct annotation
421419
unsafe
422420
{
423421
@this = Unsafe.As<T[]>(this);
@@ -430,7 +428,6 @@ internal int get_Count<T>()
430428
// ! Warning: "this" is an array, not an SZArrayHelper. See comments above
431429
// ! or you may introduce a security hole!
432430
T[] @this;
433-
// FIXME: review unsafe to confirm correct annotation
434431
unsafe
435432
{
436433
@this = Unsafe.As<T[]>(this);
@@ -443,7 +440,6 @@ internal T get_Item<T>(int index)
443440
// ! Warning: "this" is an array, not an SZArrayHelper. See comments above
444441
// ! or you may introduce a security hole!
445442
T[] @this;
446-
// FIXME: review unsafe to confirm correct annotation
447443
unsafe
448444
{
449445
@this = Unsafe.As<T[]>(this);
@@ -461,7 +457,6 @@ internal void set_Item<T>(int index, T value)
461457
// ! Warning: "this" is an array, not an SZArrayHelper. See comments above
462458
// ! or you may introduce a security hole!
463459
T[] @this;
464-
// FIXME: review unsafe to confirm correct annotation
465460
unsafe
466461
{
467462
@this = Unsafe.As<T[]>(this);
@@ -485,7 +480,6 @@ private bool Contains<T>(T value)
485480
// ! Warning: "this" is an array, not an SZArrayHelper. See comments above
486481
// ! or you may introduce a security hole!
487482
T[] @this;
488-
// FIXME: review unsafe to confirm correct annotation
489483
unsafe
490484
{
491485
@this = Unsafe.As<T[]>(this);
@@ -511,7 +505,6 @@ private int IndexOf<T>(T value)
511505
// ! Warning: "this" is an array, not an SZArrayHelper. See comments above
512506
// ! or you may introduce a security hole!
513507
T[] @this;
514-
// FIXME: review unsafe to confirm correct annotation
515508
unsafe
516509
{
517510
@this = Unsafe.As<T[]>(this);

src/coreclr/System.Private.CoreLib/src/System/Delegate.CoreCLR.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,13 +435,11 @@ private bool BindToMethodInfo(object? target, IRuntimeMethodInfo method, Runtime
435435
private static MulticastDelegate InternalAlloc(RuntimeType type)
436436
{
437437
Debug.Assert(type.IsAssignableTo(typeof(MulticastDelegate)));
438-
MulticastDelegate result;
439438
// FIXME: review unsafe to confirm correct annotation
440439
unsafe
441440
{
442-
result = Unsafe.As<MulticastDelegate>(RuntimeTypeHandle.InternalAlloc(type));
441+
return Unsafe.As<MulticastDelegate>(RuntimeTypeHandle.InternalAlloc(type));
443442
}
444-
return result;
445443
}
446444

447445
[MethodImpl(MethodImplOptions.AggressiveInlining)]

src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public void OnCompleted(Action continuation)
6060
}
6161
else if (obj != null)
6262
{
63+
// obj is either Task, null, or IValueTaskSource and the other cases are checked
6364
IValueTaskSource source;
6465
unsafe
6566
{
@@ -87,6 +88,7 @@ public void UnsafeOnCompleted(Action continuation)
8788
}
8889
else if (obj != null)
8990
{
91+
// obj is either Task, null, or IValueTaskSource and the other cases are checked
9092
IValueTaskSource source;
9193
unsafe
9294
{
@@ -112,6 +114,7 @@ void IStateMachineBoxAwareAwaiter.AwaitUnsafeOnCompleted(IAsyncStateMachineBox b
112114
}
113115
else if (obj != null)
114116
{
117+
// obj is either Task, null, or IValueTaskSource and the other cases are checked
115118
IValueTaskSource source;
116119
unsafe
117120
{

src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MemoryMarshal.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,13 @@ public static bool TryGetArray<T>(ReadOnlyMemory<T> memory, out ArraySegment<T>
285285
// or a U[] which is blittable to a T[] (e.g., int[] and uint[]).
286286

287287
// The array may be prepinned, so remove the high bit from the start index in the line below.
288-
// The ArraySegment<T> ctor will perform bounds checking on index & length.
289288

290289
T[] array;
291290
unsafe
292291
{
293292
array = Unsafe.As<T[]>(obj);
294293
}
294+
// The ArraySegment<T> ctor will perform bounds checking on index & length.
295295
segment = new ArraySegment<T>(array, index & ReadOnlyMemory<T>.RemoveFlagsBitMask, length);
296296
return true;
297297
}

0 commit comments

Comments
 (0)