Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>C# Create Derived ClassNew to Visual Studio Code? Get it now.
C# Create Derived Class

C# Create Derived Class

Ilshat Mukminov

|
1 install
| (0) | Free
Adds a Code Action to create a derived class for a C# class declaration
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

C# Create Derived Class

Adds a Code Action for C# files that generates a derived class based on the selected base class.
The generated class includes constructors, abstract member overrides, generic handling, and cursor positioning for faster editing.


✨ Features

🔹 Create derived class

When the cursor is on a class declaration, a Code Action appears:

Create derived class MyBaseDerived

The extension will:

  • detect the class name automatically
  • suggest <BaseClassName>Derived as the default derived name
  • detect namespace
  • create a .cs file in the same folder
  • open the file and position cursor at the main implementation point

🔹 Generic class support

Works with:

class MyBase<T>

Generated:

class MyBaseDerived : MyBase<T>

Multi-cursor is automatically placed on generic parameters for batch editing.

🔹 Constructor generation

If the base class has constructors with parameters, corresponding constructors are generated:

Base:

public MyBase(int x, string name) { }

Generated:

public MyBaseDerived(int x, string name) : base(x, name)
{
}

Supports:

  • reference modifiers (ref, in, out)
  • default parameter values
  • constructors with different accessibility (public, protected, etc.)

🔹 Abstract method generation

Base:

public abstract Task ProcessAsync(int id);
protected abstract TResult Transform<T>(T data) where T : class;

Generated:

public override Task ProcessAsync(int id)
{
    throw new System.NotImplementedException();
}

protected override TResult Transform<T>(T data) where T : class
{
    throw new System.NotImplementedException();
}

Supports:

  • generic methods
  • constraints where T : ...
  • return types including generic return types

🔹 Abstract property generation

Base:

public abstract T Data { get; set; }
public abstract string Name { get; }
public abstract int Count { get; init; }

Generated:

public override T Data { get; set; }

public override string Name { get; }

public override int Count { init; }

▶ How to Use

  1. Open any .cs file
  2. Move the cursor to a line like:
public class MyBase
  1. Press:
  • Ctrl+.
  • Alt+Enter
  • or click the 💡 lightbulb
  1. Choose:

Create derived class 'MyBaseDerived'

  1. Enter name if necessary
  2. The extension will create and open a new file

🔧 Build and Debug

npm install
npm run compile

Press F5 to launch extension development host.


🧪 Installation from VSIX

After packaging:

vsce package

Then:

code --install-extension *.vsix

📄 License

MIT


📌 Changelog

0.0.5 — Minor fixes

0.0.4 — Added abstract property generation

  • Added support for generating overrides for abstract properties
  • Handles get, set, and init accessors
  • All NotImplemented blocks use expression bodies

0.0.3 — Added abstract method generation

  • Generates overrides for abstract methods
  • Supports generic abstract methods
  • Supports where constraints

0.0.2 — Constructor generation

  • Detects base constructors with arguments
  • Generates matching constructors with base(...) call
  • Preserves modifiers ref/out/in, and default values

0.0.1 — Initial release

  • Generates derived class from base class
  • Detects namespace automatically
  • Multi-cursor positioning on generic parameters
  • Suggestion for default derived class name
  • Cursor positioned at implementation location

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft