RedundantOverridenMember warning

Not always overriding properties is redundant.This can be a way of turning off attributes on base properties. For example:
public class Base
{
     [XmlIgnore]
     public virtual int Boo { get; set; }
}

public class Derived : Base
{
     public override Boo
     {
          get { return base.Boo; }
          set { base.Boo = value; }
      }
}

and then typeof(Derived).GetProperty("Boo").GetCustomAttributes(typeof(XmlIgnoreAttribute), false) will not return the XmlIgnore attribute on the base class.

I think R# should check for presence of attributes before marking it as redundant.

1 comment

Hello Roman,

I've filed a bug-report: http://youtrack.jetbrains.net/issue/RSRP-208921
and you're welcome to monitor its status. Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Not always overriding properties is redundant.This can be a way of
turning off attributes on base properties. For example:
public class Base
{

public virtual int Boo { get; set; }
}
public class Derived : Base
{
public override Boo
{
get { return base.Boo; }
set { base.Boo = value; }
}
}
and then
typeof(Derived).GetProperty("Boo").GetCustomAttributes(typeof(XmlIgnor
eAttribute), false) will not return the XmlIgnore attribute on the
base class.

I think R# should check for presence of attributes before marking it
as redundant.



0

Please sign in to leave a comment.