Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit a9155cf

Browse files
ahsonkhansafern
authored andcommitted
Adding Unsafe API Add nuint that is used by SpanHelpers (#15527)
* Adding Unsafe API Add nuint that is used by SpanHelpers * Change elementOffset to IntPtr in method signature. Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
1 parent e46b11e commit a9155cf

File tree

1 file changed

+16
-0
lines changed
  • src/Common/src/CoreLib/Internal/Runtime/CompilerServices

1 file changed

+16
-0
lines changed

src/Common/src/CoreLib/Internal/Runtime/CompilerServices/Unsafe.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,22 @@ public static ref T Add<T>(ref T source, int elementOffset)
109109
#endif
110110
}
111111

112+
/// <summary>
113+
/// Adds an element offset to the given reference.
114+
/// </summary>
115+
[Intrinsic]
116+
[NonVersionable]
117+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
118+
public static ref T Add<T>(ref T source, IntPtr elementOffset)
119+
{
120+
#if CORECLR
121+
typeof(T).ToString(); // Type token used by the actual method body
122+
throw new PlatformNotSupportedException();
123+
#else
124+
return ref AddByteOffset(ref source, (IntPtr)(elementOffset * (nint)SizeOf<T>()));
125+
#endif
126+
}
127+
112128
/// <summary>
113129
/// Adds an element offset to the given pointer.
114130
/// </summary>

0 commit comments

Comments
 (0)