AppTo.CodeGen 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global AppTo.CodeGen --version 1.0.1
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local AppTo.CodeGen --version 1.0.1
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=AppTo.CodeGen&version=1.0.1
                    
nuke :add-package AppTo.CodeGen --version 1.0.1
                    

AppTo.CodeGen

A powerful .NET global tool for generating CQRS (Command Query Responsibility Segregation) pattern code following Clean Architecture principles.

πŸš€ Features

  • Command & Query Generation: Generate Command, CommandHandler, Query, and QueryHandler classes
  • Request & Response Models: Automatically create Request and Response classes
  • API Endpoints: Generate REST API endpoints with proper HTTP methods
  • Smart Project Detection: Automatically detect project structure and naming
  • Flexible Configuration: Support for custom project names and endpoint controllers
  • Clean Architecture: Follows Clean Architecture folder structure conventions

πŸ“¦ Installation

dotnet tool install --global AppTo.CodeGen

🎯 Usage

Basic Command Generation

# Generate a command with automatic project detection
codegen add feature QrSale --type command --ep Sale

# Generate a query
codegen add feature GetUser --type query --ep User

Advanced Usage

# Specify custom project name
codegen add feature AddCard --type command --ep Card --projectName Metropol.LUKE

# Generate query with custom project name
codegen add feature GetProducts --type query --ep Product --projectName MyCompany.API

πŸ“ Generated Structure

When you run codegen add feature QrSale --type command --ep Sale, it creates:

Application/
└── QrSale/
    └── Commands/
        β”œβ”€β”€ QrSaleCommand.cs
        └── QrSaleCommandHandler.cs

Abstraction/
└── QrSale/
    β”œβ”€β”€ Request/
    β”‚   └── QrSaleRequest.cs
    └── Response/
        └── QrSaleResponse.cs

Controllers/
└── SaleController.cs (endpoint added)

πŸ”§ Command Options

Option Description Example
featureName Name of the feature to generate QrSale
--type Type: command or query --type command
--ep Endpoint controller name --ep Sale
--projectName Custom project name (optional) --projectName Metropol.LUKE

πŸ“ Generated Code Examples

Command Class

using MyProject.Infrastructure.CQRS.Concrete;
using MyProject.Abstraction.QrSale.Response;

namespace MyProject.Application.QrSale.Commands;

public class QrSaleCommand : MetropolCommand<QrSaleResponse>
{
    // TODO: Command ΓΆzelliklerini buraya ekleyin
}

Command Handler

using MyProject.Infrastructure.CQRS.Concrete;
using MyProject.Abstraction.QrSale.Response;

namespace MyProject.Application.QrSale.Commands;

public class QrSaleCommandHandler : MetropolCommandHandler<QrSaleCommand, QrSaleResponse>
{
    public override async Task<QrSaleResponse?> Handle(QrSaleCommand request, CancellationToken cancellationToken)
    {
        // TODO: İş mantığını burada uygula...
        return new QrSaleResponse();
    }
}

API Endpoint

[HttpPost]
[Route("qr-sale")]
[ProducesResponseType(typeof(MetropolApiResponse<QrSaleResponse>), (int)System.Net.HttpStatusCode.OK)]
public async Task<MetropolApiResponse<QrSaleResponse>> QrSale(
    [FromBody] QrSaleRequest request,
    CancellationToken cancellationToken)
{
    var response = await _cqrsProcessor.ProcessAsync(new QrSaleCommand(), cancellationToken);
    return SetResponse(response);
}

πŸ—οΈ Project Structure Requirements

The tool expects the following folder structure:

YourProject/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ YourProject.Application/
β”‚   β”œβ”€β”€ YourProject.Abstraction/
β”‚   └── YourProject.Controllers/
└── YourProject.sln

πŸ” Project Name Detection

The tool automatically detects your project name using this priority:

  1. src/ folder: Uses the first directory name in the src/ folder
  2. Manual override: Use --projectName parameter to specify custom name

🎨 Supported Patterns

  • CQRS Pattern: Commands and Queries with separate handlers
  • Clean Architecture: Application, Abstraction, and Controllers layers
  • REST API: HTTP POST for commands, HTTP GET for queries
  • MediatR Integration: Compatible with MediatR pattern

πŸ› οΈ Requirements

  • .NET 9.0 or later
  • Clean Architecture project structure
  • CQRS pattern implementation

Made with ❀️ by Batuhan Kayaoğlu

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
1.1.0 174 10/16/2025
1.0.1 176 10/13/2025
1.0.0 169 10/13/2025