diff --git a/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt b/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt index 0ebff1a371642..4fbb99123b487 100644 --- a/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt @@ -9,6 +9,7 @@ override abstract Microsoft.CodeAnalysis.CSharp.InterceptableLocation.Equals(obj override abstract Microsoft.CodeAnalysis.CSharp.InterceptableLocation.GetHashCode() -> int static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetInterceptableLocation(this Microsoft.CodeAnalysis.SemanticModel? semanticModel, Microsoft.CodeAnalysis.CSharp.Syntax.InvocationExpressionSyntax! node, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.CSharp.InterceptableLocation? static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetInterceptsLocationAttributeSyntax(this Microsoft.CodeAnalysis.CSharp.InterceptableLocation! location) -> string! +abstract Microsoft.CodeAnalysis.CSharp.InterceptableLocation.Equals(Microsoft.CodeAnalysis.CSharp.InterceptableLocation? other) -> bool [RSEXPERIMENTAL003]Microsoft.CodeAnalysis.CSharp.SyntaxTokenParser [RSEXPERIMENTAL003]Microsoft.CodeAnalysis.CSharp.SyntaxTokenParser.Dispose() -> void [RSEXPERIMENTAL003]Microsoft.CodeAnalysis.CSharp.SyntaxTokenParser.ParseLeadingTrivia() -> Microsoft.CodeAnalysis.CSharp.SyntaxTokenParser.Result diff --git a/src/Compilers/CSharp/Portable/Utilities/InterceptableLocation.cs b/src/Compilers/CSharp/Portable/Utilities/InterceptableLocation.cs index 85c76ab47e0e4..049f6878cb7dc 100644 --- a/src/Compilers/CSharp/Portable/Utilities/InterceptableLocation.cs +++ b/src/Compilers/CSharp/Portable/Utilities/InterceptableLocation.cs @@ -18,7 +18,7 @@ namespace Microsoft.CodeAnalysis.CSharp; /// Denotes an interceptable call. Used by source generators to generate '[InterceptsLocation]' attributes. /// /// -public abstract class InterceptableLocation +public abstract class InterceptableLocation : IEquatable { private protected InterceptableLocation() { } @@ -40,6 +40,8 @@ private protected InterceptableLocation() { } public abstract override bool Equals(object? obj); public abstract override int GetHashCode(); + + public abstract bool Equals(InterceptableLocation? other); } #pragma warning disable RSEXPERIMENTAL002 // internal usage of experimental API @@ -167,12 +169,7 @@ public override bool Equals(object? obj) if ((object)this == obj) return true; - return obj is InterceptableLocation1 other - && _checksum.SequenceEqual(other._checksum) - && _path == other._path - && _position == other._position - && _lineNumberOneIndexed == other._lineNumberOneIndexed - && _characterNumberOneIndexed == other._characterNumberOneIndexed; + return obj is InterceptableLocation other && Equals(other); } public override int GetHashCode() @@ -183,4 +180,14 @@ public override int GetHashCode() BinaryPrimitives.ReadInt32LittleEndian(_checksum.AsSpan()), _position); } + + public override bool Equals(InterceptableLocation? obj) + { + return obj is InterceptableLocation1 other + && _checksum.SequenceEqual(other._checksum) + && _path == other._path + && _position == other._position + && _lineNumberOneIndexed == other._lineNumberOneIndexed + && _characterNumberOneIndexed == other._characterNumberOneIndexed; + } }