Here two samples:
1. Sample One:
public class BaseObject : DataObject {
///
/// Initializes a new instance of the BaseObject class.
///
public BaseObject() { }
private int m_Id = Int32.MinValue;
///
/// Gets or sets ID.
///
public virtual int Id {
get { return m_Id; }
set { m_Id = value; }
}
}
[ MapTable("concrete") ]
public class ConcreteObject : BaseObject {
///
/// Initializes a new instance of the ConcreteObject class.
///
public ConcreteObject() { }
///
/// Gets or sets ID.
///
[ MapField("concrete_id") ]
public override int Id {
get { return base.Id; }
set { base.Id = value; }
}
}
Overriden property assumed by ReSharper as reduant, but it is
wrong because it uses to attach attribute that cannnot be
attached at base class.
2. Sample Two:
[ MapTable("concrete") ]
public class ConcreteObject : BaseObject {
///
/// Initializes a new instance of the ConcreteObject class.
///
public ConcreteObject() { }
///
/// Determines whether the specified System.Object is equal to the current System.Object.
///
public override bool Equals(object obj) {
ConcreteObject xx = this as ConcreteObject;
ConcreteObject yy = obj as ConcreteObject;
if (yy != null) {
return xx.Id == yy.Id;
} else {
return base.Equals(obj);
}
}
///
/// Serves as a hash function for a particular type, suitable for use in hashing algorithms
/// and data structures like a hash table.
/// ]]>
public override int GetHashCode() {
return base.GetHashCode();
}
}
Overriden method GetHashCode assumed by ReSharper as reduant, but it is
wrong because it uses to prevent compiler warning about using overriden
Equals without overriden GetHashCode().
Hello Vlad,
In the first example ReSharper is wrong.
In the second you should override GetHashCode as
Id.GetHashCode()
Thanks,
Andrey Simanovsky