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

System.Collections.* missed Equals nullable annotations #52164

Merged
merged 2 commits into from
May 24, 2021
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 @@ -143,7 +143,7 @@ public void CopyTo(int sourceIndex, T[] destination, int destinationIndex, int l
public void CopyTo(T[] destination) { }
public void CopyTo(T[] destination, int destinationIndex) { }
public bool Equals(System.Collections.Immutable.ImmutableArray<T> other) { throw null; }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public System.Collections.Immutable.ImmutableArray<T>.Enumerator GetEnumerator() { throw null; }
public override int GetHashCode() { throw null; }
public int IndexOf(T item) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public override int GetHashCode()
/// <returns>
/// <c>true</c> if the specified <see cref="object"/> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
public override bool Equals(object? obj)
public override bool Equals([NotNullWhen(true)] object? obj)
{
return obj is IImmutableArray other && this.array == other.Array;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public partial struct BitVector32
public static int CreateMask(int previous) { throw null; }
public static System.Collections.Specialized.BitVector32.Section CreateSection(short maxValue) { throw null; }
public static System.Collections.Specialized.BitVector32.Section CreateSection(short maxValue, System.Collections.Specialized.BitVector32.Section previous) { throw null; }
public override bool Equals(object? o) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? o) { throw null; }
public override int GetHashCode() { throw null; }
public override string ToString() { throw null; }
public static string ToString(System.Collections.Specialized.BitVector32 value) { throw null; }
Expand All @@ -28,7 +28,7 @@ public readonly partial struct Section
public short Mask { get { throw null; } }
public short Offset { get { throw null; } }
public bool Equals(System.Collections.Specialized.BitVector32.Section obj) { throw null; }
public override bool Equals(object? o) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? o) { throw null; }
public override int GetHashCode() { throw null; }
public static bool operator ==(System.Collections.Specialized.BitVector32.Section a, System.Collections.Specialized.BitVector32.Section b) { throw null; }
public static bool operator !=(System.Collections.Specialized.BitVector32.Section a, System.Collections.Specialized.BitVector32.Section b) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Diagnostics;
using System.Text;
using System.Diagnostics.CodeAnalysis;

namespace System.Collections.Specialized
{
Expand Down Expand Up @@ -184,7 +185,7 @@ private static Section CreateSectionHelper(short maxValue, short priorMask, shor
return new Section(CreateMaskFromHighValue(maxValue), offset);
}

public override bool Equals(object? o)
public override bool Equals([NotNullWhen(true)] object? o)
{
if (!(o is BitVector32))
{
Expand Down Expand Up @@ -253,7 +254,7 @@ public short Offset
}
}

public override bool Equals(object? o)
public override bool Equals([NotNullWhen(true)] object? o)
{
if (o is Section)
return Equals((Section)o);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;

namespace System.Collections.Generic
{
/// <summary>
Expand Down Expand Up @@ -47,7 +49,7 @@ public int GetHashCode(SortedSet<T> obj)
}

// Equals method for the comparer itself.
public override bool Equals(object? obj)
public override bool Equals([NotNullWhen(true)] object? obj)
{
SortedSetEqualityComparer<T>? comparer = obj as SortedSetEqualityComparer<T>;
return comparer != null && _comparer == comparer._comparer;
Expand Down