← All extensions

C# Snippets

v0.1.0 · by Kenneth Joshua Becaro · added 3 November 2026

C# snippets for Zed IDE.

Snippets

How to install

With Forge Super installed, the button above opens the app on this extension, where you press Install. Nothing is installed until you do.

You can also open the Extensions panel in the app and search for C# Snippets. The extension's id is csharp-snippets.

Don't have Forge Super yet? Download it here.

README

From the extension's repository, written by its authors and not by Mentenaz. See the source.

C# Snippets for Zed Editor

A collection of C# code snippets for the Zed editor.

Features

  • 100+ snippets covering various C# development scenarios
  • Support for ASP.NET Core (MVC, Razor Pages, Minimal APIs)
  • CQRS/MediatR patterns for clean architecture
  • Testing frameworks (xUnit, NUnit, MSTest)
  • Mocking with Moq
  • Common boilerplates for classes, interfaces, controllers, and more

Installation

Manual Installation

  1. Clone this repository
  2. Go to Extensions menu in Zed IDE
  3. Click "Install Dev Extension"
  4. Select the cloned folder e.g. (csharp-zed-snippets)

Usage

Type the snippet prefix and press Tab to expand the snippet. Use Tab to navigate between placeholders.

Complete snippet collection can be found in snippets.md

Snippet Categories

General Snippets

Basic C# constructs and common patterns:

PrefixDescription
classCreate a new class
recordCreates a C# record declaration
interfaceCreate a new interface
methodCreate a method

Boilerplate Snippets

Full file templates for common C# files:

PrefixDescription
bp_classBoilerplate for a new C# class
bp_interfaceBoilerplate for a new C# interface
bp_structBoilerplate for a new C# struct

Web / ASP.NET Core Snippets

Web development patterns for ASP.NET Core:

PrefixDescription
httpgetCreates an HTTP GET action method
httppostCreates an HTTP POST action method
httpputCreates an HTTP PUT action method
httpdeleteCreates an HTTP DELETE action method

CQRS/MediatR Snippets

Patterns for Command Query Responsibility Segregation with MediatR:

PrefixDescription
cqrs_commandCreates a CQRS command with MediatR IRequest
cqrs_handlerCreates a CQRS command handler with MediatR
cqrs_queryCreates a CQRS query with MediatR IRequest
cqrs_query_handlerCreates a CQRS query handler with MediatR
cqrs_command_validatorCreates a FluentValidation validator for command

Testing Snippets

Unit testing patterns for popular frameworks:

PrefixDescription
xclassBasic xUnit test class with constructor setup
factxUnit [Fact] test method with AAA pattern
factaxUnit async [Fact] test method
theoryxUnit [Theory] with InlineData

Examples

Creating a new API Controller

Type bp_apicontroller and press Tab:

using Microsoft.AspNetCore.Mvc;

namespace MyNamespace
{
    [ApiController]
    [Route("api/[controller]")]
    public class NewApiController : ControllerBase
    {

    }
}

Creating a CQRS Command

Type cqrs_command and press Tab:

public class CreateEntityCommand : IRequest<int>
{
    public string Name { get; set; }
}

Creating an xUnit Test

Type fact and press Tab:

[Fact]
public void MethodName_ShouldExpectedBehavior_WhenState()
{
    // Arrange

    // Act

    // Assert

}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project Structure

The snippets are organized in the src/ directory by category for easier maintenance:

  • src/boilerplate.json - Full file templates
  • src/cqrs.json - CQRS/MediatR patterns
  • src/general.json - Basic C# constructs
  • src/tests.json - Testing framework snippets
  • src/web.json - ASP.NET Core snippets

Build Scripts

To combine all snippet files into the final snippets/csharp.json file used by Zed, run:

node src/combine.js

The src/combine.js script is used by these shell scripts to merge all category files into a single snippet file. Always run the combine script after making changes to any files in the src/ directory.

License

This project is licensed under the MIT License - see the LICENSE.txt file for details.

Author

Kenneth Joshua Becaro (joshuabecaro@gmail.com)

Repository

https://github.com/kenBinary/csharp-zed-snippets

Feedback

If you have suggestions for new snippets or improvements, please open an issue on GitHub!