diff --git a/src/AsmResolver.DotNet/MethodImplementation.cs b/src/AsmResolver.DotNet/MethodImplementation.cs
index bd4a18fc2..13ed8b7ac 100644
--- a/src/AsmResolver.DotNet/MethodImplementation.cs
+++ b/src/AsmResolver.DotNet/MethodImplementation.cs
@@ -1,9 +1,11 @@
+using System;
+
namespace AsmResolver.DotNet
{
///
/// Defines an explicit implementation of a method defined by an interface.
///
- public readonly struct MethodImplementation
+ public readonly struct MethodImplementation : IEquatable
{
///
/// Creates a new explicit implementation of a method.
@@ -33,7 +35,31 @@ public MethodImplementation(IMethodDefOrRef? declaration, IMethodDefOrRef? body)
}
///
- public override string ToString() =>
- $".override {Declaration} with {Body}";
+ public override string ToString() => $".override {Declaration} with {Body}";
+
+ ///
+ /// Determines whether two method implementations record are equal.
+ ///
+ /// The other implementation record.
+ /// true if they are considered equal, false otherwise.
+ public bool Equals(MethodImplementation other)
+ {
+ return Equals(Declaration, other.Declaration) && Equals(Body, other.Body);
+ }
+
+ ///
+ public override bool Equals(object? obj)
+ {
+ return obj is MethodImplementation other && Equals(other);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return ((Declaration != null ? Declaration.GetHashCode() : 0) * 397) ^ (Body != null ? Body.GetHashCode() : 0);
+ }
+ }
}
}