WasmAI.AutoGenerator
1.1.1
dotnet add package WasmAI.AutoGenerator --version 1.1.1
NuGet\Install-Package WasmAI.AutoGenerator -Version 1.1.1
<PackageReference Include="WasmAI.AutoGenerator" Version="1.1.1" />
<PackageVersion Include="WasmAI.AutoGenerator" Version="1.1.1" />
<PackageReference Include="WasmAI.AutoGenerator" />
paket add WasmAI.AutoGenerator --version 1.1.1
#r "nuget: WasmAI.AutoGenerator, 1.1.1"
#:package WasmAI.AutoGenerator@1.1.1
#addin nuget:?package=WasmAI.AutoGenerator&version=1.1.1
#tool nuget:?package=WasmAI.AutoGenerator&version=1.1.1
π WasmAI.AutoGenerator
WasmAI.AutoGenerator is a powerful code-generation library for .NET 8 that automates the scaffolding of backend components like models, services, controllers, and moreβbased on a flexible folder configuration.
β¨ Features
βοΈ Automatic Generation of Backend Layers:
- DTOs (Data Transfer Objects)
- DSOs (Domain Service Objects)
- Repositories
- Services
- Controllers
- Validators
- Schedulers
ποΈ Dynamic Folder and File Generation: Uses
folderStructure.jsonto generate nested folders and files.ποΈ Architecture Pattern Support: Built-in templates:
Country,Plug,Share,Builder,Service, andScope.π οΈ Customizable & Modular: Easily adapt to any backend architecture style.
π Service Lifetime Support: Scoped, singleton, and transient services supported.
π Built-in Notification Provider: Supports Email, SMS, Push, and In-App notifications.
π§± Architecture Overview
βββββββββββββββ ββββββββββββββββββββββ ββββββββββββββββββ
β Models ββββββββΆβ Marker Interfaces ββββββββΆβ AutoGenerator β
βββββββββββββββ ββββββββββββββββββββββ ββββββββ¬βββββββββββ
βΌ
ββββββββββββββ¬ββββββββββββββ¬βββββββββββββββ¬ββββββββββββββ¬βββββββββββββββ
β DTOs β Repositoriesβ Services β Controllers β Validators β
ββββββββββββββ΄ββββββββββββββ΄βββββββββββββββ΄ββββββββββββββ΄βββββββββββββββ
π¦ Installation
dotnet add package WasmAI.AutoGenerator --version 1.1.0
π After installation, add the necessary namespace:
using AutoGenerator.ApiFolder;
π Folder Structure Configuration (folderStructure.json)
Here's an example:
{
"Controllers": [ "Api", "Auth", "Admin" ],
"Repositories": [ "Base", "Builder", "Share" ],
"Services": [ "Email", "Logging" ],
"DyModels": [
{
"VM": [],
"Dto": {
"Build": [ "Request", "Response", "ResponseFilter" ],
"Share": [ "Request", "Response", "ResponseFilter" ]
},
"Dso": [ "Request", "Response", "ResponseFilter" ]
}
],
"Config": [ "Mappers", "Scopes", "Singletons", "Transients" ],
"Models": [],
"Builders": [ "Db" ],
"Helper": [],
"Data": [],
"Enums": [],
"Validators": [ "Conditions" ],
"Schedulers": []
}
ποΈ How to Generate Your Backend Architecture
β Option 1: Programmatically
using AutoGenerator.ApiFolder;
using System;
class Program
{
static void Main(string[] args)
{
string projectPath = "path_to_your_project";
ApiFolderGenerator.Build(projectPath);
Console.WriteLine("β
All folders have been created successfully!");
}
}
β‘ Option 2: Command Line (Recommended)
dotnet run generate
This command reads the folderStructure.json and creates all required folders and files instantly.
Steps to Implement DataContext and CategoryModel with ITModel and ITAutoDbContext
1. Create Your DataContext
First, you need to make sure that DataContext inherits from AutoIdentityDataContext and implements ITAutoDbContext. This allows you to manage identity operations and database access in a simple and automated way.
Code:
public class DataContext : AutoIdentityDataContext<ApplicationUser, IdentityRole, string>, ITAutoDbContext
{
// Add properties like DbSet for your models
public DbSet<CategoryModel> Categories { get; set; }
public DataContext(DbContextOptions<DataContext> options) : base(options)
{
}
// You can add any custom functions for DbContext here
}
Explanation:
DataContextinherits fromAutoIdentityDataContext<ApplicationUser, IdentityRole, string>because you need to work with identity management usingApplicationUserandIdentityRole.ITAutoDbContextensures that theDataContextcan handle automatic operations.DbSet<CategoryModel>is an example of adding a model toDataContextso it can be interacted with in the database.
2. Create CategoryModel and Implement ITModel
Now, you need to implement the ITModel interface in your models like CategoryModel to take advantage of automatic operations.
Code:
public class CategoryModel : ITModel
{
[Key]
public string? Id { get; set; } = $"catm_{Guid.NewGuid():N}"; // Automatically generates a unique value
[Required]
[ToTranslation] // Mark to ensure the field is translated automatically
public string? Name { get; set; }
[ToTranslation] // Mark to ensure the field is translated automatically
public string? Description { get; set; }
}
Explanation:
- The
CategoryModelclass implementsITModel, which means it includes anIdproperty that gets automatically generated usingGuid.NewGuid(). - The
NameandDescriptionproperties have the[ToTranslation]attribute to indicate that they should be translated automatically.
π§ API Builder Configuration
Hereβs how to configure it in your project:
builder.Services
. AddAutoBuilderApiCore<DataContext,ApplicationUser>(new()
{
Arags = args,
NameRootApi = "V1",
IsMapper = true,
Assembly = Assembly.GetExecutingAssembly(),
DbConnectionString = builder.Configuration.GetConnectionString("DefaultConnection"),
ProjectPath= "folderStructure.json"
})
.AddAutoValidator()
.AddAutoConfigScheduler()
.AddAutoNotifier(new()
{
MailConfiguration = new MailConfig()
{
SmtpUsername = "user@gmail.com",
SmtpPassword = "your_smtp_password", // π Secure this!
SmtpHost = "smtp.gmail.com",
SmtpPort = 587,
FromEmail = "user@gmail.com",
NameApp = "app"
},
// sms
// push web any platforms
});
β οΈ Notes
- π Secure Credentials: Store SMTP passwords and sensitive data in environment variables or a secrets vault.
- π Dynamic Architecture: Automatically generates structure, services, schedulers, and validators from the config file.
- π§ Built-in Notifier: Easily enable Email/SMS/Push notifications for your app.
β Conclusion
WasmAI.AutoGenerator supercharges your .NET development by reducing boilerplate and enforcing clean, modular architecture. Whether you're building an admin panel, a complex API, or a service-oriented backendβthis tool lets you build your project architecture in seconds with:
dotnet run generate
dotnet run generate /bpr
Start building smarter. π‘
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
-
net8.0
- Quartz (>= 3.14.0)
- Quartz.AspNetCore (>= 3.14.0)
- WasmAI.AutoGenerator.Coder (>= 1.0.4)
- WasmAI.AutoGenerator.Patterns (>= 1.0.3)
- WasmAI.AutoNotificationService (>= 1.0.0)
- WasmAI.ConditionChecker (>= 1.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.1 | 274 | 5/25/2025 |
| 1.1.0 | 9,760,751 | 5/17/2025 |
| 1.0.9 | 3,805,108 | 5/15/2025 |
| 1.0.8 | 271 | 5/15/2025 |
| 1.0.7 | 978,536 | 5/12/2025 |
| 1.0.6 | 284 | 5/12/2025 |
| 1.0.5 | 267 | 5/12/2025 |
| 1.0.4 | 257 | 5/12/2025 |
| 1.0.4-q | 261 | 5/12/2025 |
| 1.0.3 | 217 | 5/8/2025 |
| 1.0.2 | 200 | 5/1/2025 |
| 1.0.2-q | 206 | 5/1/2025 |
| 1.0.2-p | 194 | 5/1/2025 |
| 1.0.1-e | 216 | 4/27/2025 |
| 1.0.1-d | 207 | 4/27/2025 |
| 1.0.1-c | 185 | 4/27/2025 |
| 1.0.1-b | 221 | 4/24/2025 |