Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address warnings for possibly null array elements #41046

Merged
merged 3 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ internal static ref T AddByteOffset<T>(ref T source, nuint byteOffset)
[Intrinsic]
[NonVersionable]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool AreSame<T>(ref T left, ref T right)
public static bool AreSame<T>([AllowNull] ref T left, [AllowNull] ref T right)
{
throw new PlatformNotSupportedException();

Expand All @@ -172,7 +172,7 @@ public static bool AreSame<T>(ref T left, ref T right)
[Intrinsic]
[NonVersionable]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsAddressGreaterThan<T>(ref T left, ref T right)
public static bool IsAddressGreaterThan<T>([AllowNull] ref T left, [AllowNull] ref T right)
{
throw new PlatformNotSupportedException();

Expand All @@ -192,7 +192,7 @@ public static bool IsAddressGreaterThan<T>(ref T left, ref T right)
[Intrinsic]
[NonVersionable]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsAddressLessThan<T>(ref T left, ref T right)
public static bool IsAddressLessThan<T>([AllowNull] ref T left, [AllowNull] ref T right)
{
throw new PlatformNotSupportedException();

Expand Down Expand Up @@ -368,7 +368,7 @@ public static ref T AsRef<T>(in T source)
[Intrinsic]
[NonVersionable]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static IntPtr ByteOffset<T>(ref T origin, ref T target)
public static IntPtr ByteOffset<T>([AllowNull] ref T origin, [AllowNull] ref T target)
{
throw new PlatformNotSupportedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ private static void InsertionSort(Span<T> keys)
j--;
}

Unsafe.Add(ref MemoryMarshal.GetReference(keys), j + 1) = t;
Unsafe.Add(ref MemoryMarshal.GetReference(keys), j + 1) = t!;
}
}

Expand Down Expand Up @@ -1054,7 +1054,7 @@ private static void InsertionSort(Span<TKey> keys, Span<TValue> values)
j--;
}

keys[j + 1] = t;
keys[j + 1] = t!;
values[j + 1] = tValue;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static partial class Unsafe
public unsafe static void* Add<T>(void* source, int elementOffset) { throw null; }
public static ref T Add<T>(ref T source, int elementOffset) { throw null; }
public static ref T Add<T>(ref T source, System.IntPtr elementOffset) { throw null; }
public static bool AreSame<T>(ref T left, ref T right) { throw null; }
public static bool AreSame<T>([System.Diagnostics.CodeAnalysis.AllowNull] ref T left, [System.Diagnostics.CodeAnalysis.AllowNull] ref T right) { throw null; }
public unsafe static void* AsPointer<T>(ref T value) { throw null; }
public unsafe static ref T AsRef<T>(void* source) { throw null; }
public static ref T AsRef<T>(in T source) { throw null; }
Expand All @@ -21,7 +21,7 @@ public static partial class Unsafe
#endif
public static T? As<T>(object? o) where T : class? { throw null; }
public static ref TTo As<TFrom, TTo>(ref TFrom source) { throw null; }
public static System.IntPtr ByteOffset<T>(ref T origin, ref T target) { throw null; }
public static System.IntPtr ByteOffset<T>([System.Diagnostics.CodeAnalysis.AllowNull] ref T origin, [System.Diagnostics.CodeAnalysis.AllowNull] ref T target) { throw null; }
public static void CopyBlock(ref byte destination, ref byte source, uint byteCount) { }
public unsafe static void CopyBlock(void* destination, void* source, uint byteCount) { }
public static void CopyBlockUnaligned(ref byte destination, ref byte source, uint byteCount) { }
Expand All @@ -32,8 +32,8 @@ public static void InitBlock(ref byte startAddress, byte value, uint byteCount)
public unsafe static void InitBlock(void* startAddress, byte value, uint byteCount) { }
public static void InitBlockUnaligned(ref byte startAddress, byte value, uint byteCount) { }
public unsafe static void InitBlockUnaligned(void* startAddress, byte value, uint byteCount) { }
public static bool IsAddressGreaterThan<T>(ref T left, ref T right) { throw null; }
public static bool IsAddressLessThan<T>(ref T left, ref T right) { throw null; }
public static bool IsAddressGreaterThan<T>([System.Diagnostics.CodeAnalysis.AllowNull] ref T left, [System.Diagnostics.CodeAnalysis.AllowNull] ref T right) { throw null; }
public static bool IsAddressLessThan<T>([System.Diagnostics.CodeAnalysis.AllowNull] ref T left, [System.Diagnostics.CodeAnalysis.AllowNull] ref T right) { throw null; }
public static bool IsNullRef<T>(ref T source) { throw null; }
public static ref T NullRef<T>() { throw null; }
public static T ReadUnaligned<T>(ref byte source) { throw null; }
Expand Down