Back to Devexpress

Pull Member Up

coderushforroslyn-400442-refactoring-assistance-pull-member-up.md

latest1.2 KB
Original Source

Pull Member Up

  • Aug 19, 2021
  • 2 minutes to read

Purpose

Moves a member with its dependencies to a base type.

Availability

Available when the caret is in a type member. The base type code should exist in the current solution.

Note

This refactoring is not available for interfaces.

Usage

  1. Place the caret in a member declaration.

  2. Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.

  3. Select Pull Member Up from the menu. If there are several base types in the current solution, you can select the target type from the submenu.

After execution, the Refactoring moves a member with its dependencies to a base type.

csharp
class BaseClass {

    public void IncrementValue(int interval) {
        Value += interval;
    }

    public int Value { get; set; }

}
class MyBaseClass : BaseClass {

}
class MyClass : MyBaseClass {
}
vb
Class BaseClass
    Public Sub IncrementValue(ByVal interval As Integer)
        Value += interval
    End Sub

    Public Property Value As Integer
End Class

Class MyBaseClass
    Inherits BaseClass
End Class

Class [MyClass]
    Inherits MyBaseClass
End Class