AppTo.CodeGen
1.0.1
There is a newer version of this package available.
See the version list below for details.
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
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package AppTo.CodeGen --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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:
- src/ folder: Uses the first directory name in the
src/folder - Manual override: Use
--projectNameparameter 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 | Versions 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.