Skip to content

Commit 8fe8c46

Browse files
committed
Fixed some nullability warnings
1 parent da5264d commit 8fe8c46

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

Microsoft.Toolkit.HighPerformance/Extensions/ArrayExtensions.2D.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static ref T DangerousGetReference<T>(this T[,] array)
6363
public static ref T DangerousGetReferenceAt<T>(this T[,] array, int i, int j)
6464
{
6565
#if NETCORE_RUNTIME
66-
var arrayData = Unsafe.As<RawArray2DData>(array);
66+
var arrayData = Unsafe.As<RawArray2DData>(array)!;
6767
nint offset = ((nint)(uint)i * (nint)(uint)arrayData.Width) + (nint)(uint)j;
6868
ref T r0 = ref Unsafe.As<byte, T>(ref arrayData.Data);
6969
ref T ri = ref Unsafe.Add(ref r0, offset);

Microsoft.Toolkit.HighPerformance/Extensions/ArrayExtensions.3D.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static partial class ArrayExtensions
3232
public static ref T DangerousGetReference<T>(this T[,,] array)
3333
{
3434
#if NETCORE_RUNTIME
35-
var arrayData = Unsafe.As<RawArray3DData>(array);
35+
var arrayData = Unsafe.As<RawArray3DData>(array)!;
3636
ref T r0 = ref Unsafe.As<byte, T>(ref arrayData.Data);
3737

3838
return ref r0;
@@ -63,7 +63,7 @@ public static ref T DangerousGetReference<T>(this T[,,] array)
6363
public static ref T DangerousGetReferenceAt<T>(this T[,,] array, int i, int j, int k)
6464
{
6565
#if NETCORE_RUNTIME
66-
var arrayData = Unsafe.As<RawArray3DData>(array);
66+
var arrayData = Unsafe.As<RawArray3DData>(array)!;
6767
nint offset =
6868
((nint)(uint)i * (nint)(uint)arrayData.Height * (nint)(uint)arrayData.Width) +
6969
((nint)(uint)j * (nint)(uint)arrayData.Width) + (nint)(uint)k;

Microsoft.Toolkit.HighPerformance/Memory/Memory2D{T}.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ public bool TryGetMemory(out Memory<T> memory)
772772
}
773773
else if (typeof(T) == typeof(char) && this.instance.GetType() == typeof(string))
774774
{
775-
string text = Unsafe.As<string>(this.instance);
775+
string text = Unsafe.As<string>(this.instance)!;
776776
int index = text.AsSpan().IndexOf(in text.DangerousGetObjectDataReferenceAt<char>(this.offset));
777777
ReadOnlyMemory<char> temp = text.AsMemory(index, (int)Length);
778778

@@ -795,7 +795,7 @@ public bool TryGetMemory(out Memory<T> memory)
795795
else if (this.instance.GetType() == typeof(T[]))
796796
{
797797
// If it's a T[] array, also handle the initial offset
798-
T[] array = Unsafe.As<T[]>(this.instance);
798+
T[] array = Unsafe.As<T[]>(this.instance)!;
799799
int index = array.AsSpan().IndexOf(ref array.DangerousGetObjectDataReferenceAt<T>(this.offset));
800800

801801
memory = array.AsMemory(index, this.height * this.width);

Microsoft.Toolkit.HighPerformance/Memory/ReadOnlyMemory2D{T}.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ public bool TryGetMemory(out ReadOnlyMemory<T> memory)
794794
// difference between the start of the Span<char> (which directly wraps just the actual character data
795795
// within the string), and the input reference, which we can get from the byte offset in use. The result
796796
// is the character index which we can use to create the final Memory<char> instance.
797-
string text = Unsafe.As<string>(this.instance);
797+
string text = Unsafe.As<string>(this.instance)!;
798798
int index = text.AsSpan().IndexOf(in text.DangerousGetObjectDataReferenceAt<char>(this.offset));
799799
ReadOnlyMemory<char> temp = text.AsMemory(index, (int)Length);
800800

@@ -811,7 +811,7 @@ public bool TryGetMemory(out ReadOnlyMemory<T> memory)
811811
else if (this.instance.GetType() == typeof(T[]))
812812
{
813813
// If it's a T[] array, also handle the initial offset
814-
T[] array = Unsafe.As<T[]>(this.instance);
814+
T[] array = Unsafe.As<T[]>(this.instance)!;
815815
int index = array.AsSpan().IndexOf(ref array.DangerousGetObjectDataReferenceAt<T>(this.offset));
816816

817817
memory = array.AsMemory(index, this.height * this.width);

0 commit comments

Comments
 (0)