Create Descendant (with virtual overrides)

  • 2 min to read

Creates a descendant class, providing implementation stubs for abstract and virtual members of a base class. Selects the contents of the last generated descendant member, and drops a marker onto the base class declaration.

Availability

From the context menus or via shortcuts:

  • when the edit cursor or caret is on a class name within its declaration.

Notes

If a base class contains abstract or virtual members, their implementation stubs will be added to a descendant class.

Example

abstract class TestClass
{
    public int Doubler(int param)
    {
        return param*2;
    }
    public virtual string GetCaption()
    {
        return "Caption";
    }
    public abstract int Multiply(int param);
}
Public MustInherit Class TestClass
    Public Function Doubler(ByVal param As Integer) As Integer
        Return param * 2
    End Function
    Public Overridable Function GetCaption() As String
        Return "Caption"
    End Function
    Public MustOverride Function Multiply(ByVal param As Integer) As Integer
End Class

Result:

private class TestClassDescendant : TestClass
{
    public TestClassDescendant()
    {
        throw new NotImplementedException();
    }
    public override string GetCaption()
    {
        return base.GetCaption();
    }
    public override int Multiply(int param)
    {throw new NotImplementedException();
    }
}
abstract class TestClass
{
    public int Doubler(int param)
    {
         return param * 2;
    }
    public virtual string GetCaption()
    {
        return "Caption";
    }
    public abstract int Multiply(int param);
}
Public Class TestClassDescendant
    Inherits TestClass
    Public Sub New()
        Throw New NotImplementedException()
    End Sub
    Public Overrides Function GetCaption() As String
        Return MyBase.GetCaption()
    End Function
    Public Overrides Function Multiply(ByVal param As Integer) As IntegerThrow New NotImplementedException()
    End Function
End Class
Public MustInherit Class TestClass
    Public Function Doubler(ByVal param As Integer) As Integer
        Return param * 2
    End Function
    Public Overridable Function GetCaption() As String
        Return "Caption"
    End Function
    Public MustOverride Function Multiply(ByVal param As Integer) As Integer
End Class