diff --git a/src/SimpleInjector/InjectionConsumerInfo.cs b/src/SimpleInjector/InjectionConsumerInfo.cs index 97cad4d67..0446a4793 100644 --- a/src/SimpleInjector/InjectionConsumerInfo.cs +++ b/src/SimpleInjector/InjectionConsumerInfo.cs @@ -89,11 +89,12 @@ public Type ServiceType this.ImplementationType.GetHashCode() ^ this.Target.GetHashCode(); /// - public override bool Equals(object obj) => this.Equals(obj as InjectionConsumerInfo); + public override bool Equals(object obj) => obj is InjectionConsumerInfo info && this.Equals(info); /// public bool Equals(InjectionConsumerInfo other) => - this.ImplementationType.Equals(other.ImplementationType) + other != null + && this.ImplementationType.Equals(other.ImplementationType) && this.Target.Equals(other.Target); ///