Skip to content

Commit

Permalink
Merge pull request #337 from NoiseStudio/fix/285/methods-as-span-shou…
Browse files Browse the repository at this point in the history
…ld-be-readonly

Add readonly attribute to AsSpan() methods in InteropArray<T>
  • Loading branch information
Xori7 committed Sep 22, 2023
2 parents f842218 + bc891fb commit d018c8e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions NoiseEngine/Interop/InteropArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public struct InteropArray<T> : IDisposable, IReadOnlyList<T> where T : unmanage
/// Creates a view into the native memory. Span becomes invalid when the object is disposed.
/// </summary>
/// <returns>Span with the view of the memory held by this object.</returns>
public unsafe Span<T> AsSpan() {
public readonly unsafe Span<T> AsSpan() {
return new Span<T>(pointer, Length);
}

Expand All @@ -96,7 +96,7 @@ public struct InteropArray<T> : IDisposable, IReadOnlyList<T> where T : unmanage
/// <param name="start">Start index of the span.</param>
/// <returns>Span with the view of the memory held by this object.</returns>
/// <throws cref="ArgumentOutOfRangeException"><paramref name="start"/> is out of range.</throws>
public unsafe Span<T> AsSpan(int start) {
public readonly unsafe Span<T> AsSpan(int start) {
if (start < 0 || start > Length) {
throw new ArgumentOutOfRangeException(nameof(start));
}
Expand All @@ -114,7 +114,7 @@ public struct InteropArray<T> : IDisposable, IReadOnlyList<T> where T : unmanage
/// <throws cref="ArgumentOutOfRangeException">
/// <paramref name="start"/> is out of range or <paramref name="length"/> is invalid.
/// </throws>
public unsafe Span<T> AsSpan(int start, int length) {
public readonly unsafe Span<T> AsSpan(int start, int length) {
if (start < 0 || start > Length) {
throw new ArgumentOutOfRangeException(nameof(start));
}
Expand Down

0 comments on commit d018c8e

Please sign in to comment.