@ToString and inheritance
-------------------------

                 Key: ETCH-168
                 URL: https://issues.apache.org/jira/browse/ETCH-168
             Project: Etch
          Issue Type: Improvement
          Components: csharp-binding
    Affects Versions: 1.1
            Reporter: Michal Miksovic
            Priority: Minor


In inheritance tree of exceptions each exception has its GetMessage() method 
marked as 'new' which disables user from using polymorphism when having 
ancestor instance of ancestor exception cast to base type. Wouldn't it be 
better to use virtual GetMessage method on the base class and then have it 
overridden in ancestors?

example:

public class BaseException
{       
        public virtual string GetMessage() { return "Base exception message";}
        
        //currently
        //public string GetMessage(){...}
}

public class InheritedException : BaseException
{
        public override string GetMessage() { return "Inhertied exception 
message";}
        
        //currently hiding the method from base class
        //public new string GetMessage(){...}
}

so then

((new InheritedException())as BaseException).GetMessage(); //would return 
"Inherited exception message"

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to