Reporter | Olga Lobacheva (olka) |
---|---|
Created | Mar 4, 2011 9:21:12 PM |
Updated | Dec 27, 2011 7:37:00 PM |
Priority | Critical |
Type | Bug |
Fix versions | Mirabile Futurum |
State | Open |
Assignee | Alexander Shvedov (shvedov) |
Subsystem | Generate Action |
Affected versions | No Affected versions |
Fixed in build | No Fixed in build |
All equality members in this piece of code are generated by ReSharper. Now 'x' which has type 'Parent' equals 'y' which has type 'Child'. This is strange.
using System; public class P { public static void Main(string[] args) { Parent x = new Parent(); Child y = new Child(); Console.Out.WriteLine(x.Equals(y)); } } public class Parent { private string Name; public bool Equals(Parent other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(other.Name, Name); } public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; if (obj.GetType() != typeof (Parent)) return false; return Equals((Parent) obj); } public override int GetHashCode() { return (Name != null ? Name.GetHashCode() : 0); } } class Child : Parent { public bool Equals(Child other) { return base.Equals(other); } public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; return Equals(obj as Child); } public override int GetHashCode() { return base.GetHashCode(); } }