-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathCheck.IsSameAs.cs
More file actions
19 lines (17 loc) · 793 Bytes
/
Copy pathCheck.IsSameAs.cs
File metadata and controls
19 lines (17 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using System.Runtime.CompilerServices;
using JetBrains.Annotations;
namespace Light.GuardClauses;
public static partial class Check
{
/// <summary>
/// Checks if <paramref name="parameter" /> and <paramref name="other" /> point to the same object.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
// ReSharper disable StringLiteralTypo
[ContractAnnotation(
"parameter:notNull => true, other:notnull; parameter:notNull => false, other:canbenull; other:notnull => true, parameter:notnull; other:notnull => false, parameter:canbenull"
)]
// ReSharper restore StringLiteralTypo
public static bool IsSameAs<T>([NoEnumeration] this T? parameter, [NoEnumeration] T? other) where T : class =>
ReferenceEquals(parameter, other);
}