Skip to content

Commit 77e67f0

Browse files
committed
Revert " Warning CA2013 : Do not pass an argument with value type 'Foundatio.Repositories.Id' to 'ReferenceEquals'. Due to value boxing, this call to 'ReferenceEquals' can return an unexpected result. Consider using 'Equals' instead, or pass reference type arguments if you intend to use 'ReferenceEquals'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2013)"
This reverts commit 40c1aa8.
1 parent b3d2386 commit 77e67f0

File tree

1 file changed

+5
-4
lines changed
  • src/Foundatio.Repositories

1 file changed

+5
-4
lines changed

src/Foundatio.Repositories/Id.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace Foundatio.Repositories;
77

88
public struct Id : IEquatable<Id>
99
{
10+
1011
public static readonly Id Null = new();
1112

1213
public Id(string id, string routing = null)
@@ -31,15 +32,15 @@ public override string ToString()
3132

3233
public bool Equals(Id other)
3334
{
34-
if (Equals(null, other)) return false;
35-
if (Equals(this, other)) return true;
35+
if (ReferenceEquals(null, other)) return false;
36+
if (ReferenceEquals(this, other)) return true;
3637
return Equals(Value, other.Value) && Equals(Routing, other.Routing);
3738
}
3839

3940
public override bool Equals(object obj)
4041
{
41-
if (Equals(null, obj)) return false;
42-
if (Equals(this, obj)) return true;
42+
if (ReferenceEquals(null, obj)) return false;
43+
if (ReferenceEquals(this, obj)) return true;
4344
return obj.GetType() == GetType() && Equals((Id)obj);
4445
}
4546

0 commit comments

Comments
 (0)