Add Missing Constructors

Purpose

Adds all constructors declared in the parent types to the current class. Use this Code Provider to add all required constructors at once.

Availability

Available when the caret is on the name of the class, assuming it misses one or more inherited constructors.

Usage

  1. Place the caret on a class name.

    Note

    The blinking cursor shows the caret's position at which the Code Provider is available.

    public class Person {
        public Person(string FullName) { }
        public Person(string FirstName, string LastName) { }
    }
    class Customer: Person {
    
    }
    
  2. Use the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions Menu.
  3. Select Add Missing Constructors from the menu.

After execution, the Code Provider adds all missing constructors to the class.

public class Person {
    public Person(string FullName) { }
    public Person(string FirstName, string LastName) { }
}
class Customer: Person {
    public Customer(string FullName) : base(FullName) {

    }

    public Customer(string FirstName, string LastName) : base(FirstName, LastName) {

    }
}