3295ec367cb30d50d7997cfe9c4888ff2fa9c5b9
[platform/upstream/dotnet/runtime.git] /
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3
4 using System;
5 using System.Collections.Immutable;
6 using System.Linq;
7 using Microsoft.CodeAnalysis;
8 using Microsoft.CodeAnalysis.CSharp.Syntax;
9
10 namespace Microsoft.Interop
11 {
12     public sealed record MethodSignatureDiagnosticLocations(string MethodIdentifier, ImmutableArray<CodeAnalysis.Location> ManagedParameterLocations, CodeAnalysis.Location FallbackLocation)
13     {
14         public MethodSignatureDiagnosticLocations(MethodDeclarationSyntax syntax)
15             : this(syntax.Identifier.Text, syntax.ParameterList.Parameters.Select(p => p.Identifier.GetLocation()).ToImmutableArray(), syntax.Identifier.GetLocation())
16         {
17         }
18
19         public bool Equals(MethodSignatureDiagnosticLocations other)
20         {
21             return MethodIdentifier == other.MethodIdentifier
22                 && ManagedParameterLocations.SequenceEqual(other.ManagedParameterLocations)
23                 && FallbackLocation.Equals(other.FallbackLocation);
24         }
25
26         public override int GetHashCode() => throw new UnreachableException();
27     }
28 }