Reading the Castle.Core documentation, in this link, they recommend that always overriding the Equals
and GetHashCode
methods of the classes that implement IProxyGenerationHook
.
I have a class called MiHook
that implements such interface, but this class doesn't have state. So, my question is, how should I override those two methods if I have a stateless class?
public class MiHook : IProxyGenerationHook {
public void MethodsInspected() { }
public void NonProxyableMemberNotification(Type type, MemberInfo memberInfo) { }
public bool ShouldInterceptMethod(Type type, MethodInfo methodInfo) {
return methodInfo.Name == nameof(IFoo.Bar);
}
// Should I implement both methods like this?
public override bool Equals(object? obj) => base.Equals(obj);
public override int GetHashCode() => base.GetHashCode();
}