Mnemonics.CodingTools
1.0.14
See the version list below for details.
dotnet add package Mnemonics.CodingTools --version 1.0.14
NuGet\Install-Package Mnemonics.CodingTools -Version 1.0.14
<PackageReference Include="Mnemonics.CodingTools" Version="1.0.14" />
<PackageVersion Include="Mnemonics.CodingTools" Version="1.0.14" />
<PackageReference Include="Mnemonics.CodingTools" />
paket add Mnemonics.CodingTools --version 1.0.14
#r "nuget: Mnemonics.CodingTools, 1.0.14"
#:package Mnemonics.CodingTools@1.0.14
#addin nuget:?package=Mnemonics.CodingTools&version=1.0.14
#tool nuget:?package=Mnemonics.CodingTools&version=1.0.14
Mnemonics.CodingTools
Mnemonics.CodingTools is a modular and extensible .NET library for dynamic class generation, runtime entity management, structured logging, and pluggable data storage — built with ASP.NET Core in mind.
✨ Features
⚙️ Dynamic Class Generation
Generate types at runtime from JSON schemas or programmatic definitions. Compile into assemblies and use immediately.📚 Runtime Entity Registration (EF Core)
Register types at runtime viaIDynamicTypeRegistry
. Automatically used byDynamicDbContext
.💾 Pluggable Entity Stores
Switch between multiple store implementations viaIEntityStore<T>
orIAdvancedEntityStore<T>
:- ✅ In-memory store
- ✅ File-based (JSON)
- ✅ EF Core-backed
- ✅ Dapper-based
All support composite keys and batch operations (viaIAdvancedEntityStore<T>
).
🪵 Structured Logging
UseNinjaLogger
as a drop-in structured logger based onMicrosoft.Extensions.Logging
.🔌 DI-Ready Architecture
Register everything withAddCodingTools()
. Customize per backend usingCodingToolsOptions
.
📦 Installation
dotnet add package Mnemonics.CodingTools --version 1.0.x
Or with the NuGet Package Manager:
Install-Package Mnemonics.CodingTools -Version 1.0.x
🚀 Quick Start
Register in Program.cs
/ Startup.cs
builder.Services.AddCodingTools(options =>
{
options.RegisterDynamicClassGenerator = true;
options.RegisterDynamicClassBuilder = true;
options.RegisterNinjaLogger = true;
options.RegisterDynamicEFCore = true;
options.ConfigureDynamicDb = db => db.UseSqlite("Data Source=app.db");
options.DbContextResolver = sp => sp.GetRequiredService<DynamicDbContext>();
// Choose one or more entity stores:
options.RegisterDbStore = true;
// options.RegisterDapperStore = true;
// options.RegisterFileStore = true;
// options.RegisterInMemoryStore = true;
// (Optional) Custom file store behavior:
options.FileStoreDirectory = "Data";
// options.CustomKeySelectors[typeof(MyType)] = (MyType x) => new[] { x.Id.ToString() };
// options.JsonOptionsPerEntity[typeof(MyType)] = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase };
});
🧱 Dynamic Class Generation
public class MyService
{
private readonly IDynamicClassGenerator _generator;
public MyService(IDynamicClassGenerator generator)
{
_generator = generator;
}
public void Generate(string json)
{
var (dllPath, namespaces) = _generator.GenerateAssemblyFromJson(json, "MyAssembly.dll");
}
}
🧠 Runtime EF Entity Registration
public class StartupAction
{
private readonly IDynamicTypeRegistry _registry;
public StartupAction(IDynamicTypeRegistry registry)
{
_registry = registry;
}
public void RegisterDynamicType(Type type)
{
_registry.RegisterType(type);
}
}
💾 Generic Entity Store Example
public class EntityService<T> where T : class
{
private readonly IAdvancedEntityStore<T> _store;
public EntityService(IAdvancedEntityStore<T> store)
{
_store = store;
}
public Task SaveAsync(T entity, params string[] keys)
=> _store.SaveAsync(keys, entity);
public Task<IEnumerable<T>> AllAsync()
=> _store.ListAsync();
}
📁 File Store Example
builder.Services.AddCodingTools(options =>
{
options.RegisterFileStore = true;
options.FileStoreDirectory = "EntityStore";
options.CustomKeySelectors[typeof(MyEntity)] = (MyEntity e) => new[] { e.Id };
});
🪵 Structured Logging with NinjaLogger
public class LogService
{
private readonly NinjaLogger _logger;
public LogService(NinjaLogger logger)
{
_logger = logger;
}
public void LogStuff()
{
_logger.Information("This ran at {time}", DateTime.UtcNow);
}
}
🧾 JSON Schema Example
[
{
"Namespace": "Dynamic.Models",
"Classes": [
{
"Name": "User",
"Properties": [
{ "Name": "Id", "Type": "string" },
{ "Name": "Username", "Type": "string" }
]
}
]
}
]
🧪 Designed for Testing
Interfaces like IDynamicClassGenerator
, INinjaLogger
, and IAdvancedEntityStore<T>
allow for seamless mocking and testing in unit test environments.
🤝 Contributing
Feedback, PRs, and issues are welcome. Fork the repo or file issues at
https://github.com/petervdpas/Mnemonics.CodingTools
📜 License
Licensed under the MIT License.
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
- Dapper (>= 2.1.66)
- Microsoft.CodeAnalysis (>= 4.13.0)
- Microsoft.EntityFrameworkCore (>= 9.0.3)
- Microsoft.Extensions.Logging (>= 9.0.3)
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.0.52 | 164 | 4/2/2025 |
1.0.50 | 153 | 4/2/2025 |
1.0.48 | 157 | 4/2/2025 |
1.0.46 | 160 | 4/2/2025 |
1.0.44 | 154 | 4/2/2025 |
1.0.42 | 152 | 4/2/2025 |
1.0.40 | 162 | 4/2/2025 |
1.0.38 | 156 | 4/2/2025 |
1.0.36 | 150 | 4/1/2025 |
1.0.34 | 158 | 4/1/2025 |
1.0.32 | 147 | 3/30/2025 |
1.0.30 | 141 | 3/30/2025 |
1.0.28 | 149 | 3/30/2025 |
1.0.26 | 150 | 3/29/2025 |
1.0.24 | 82 | 3/29/2025 |
1.0.22 | 79 | 3/29/2025 |
1.0.20 | 85 | 3/29/2025 |
1.0.18 | 86 | 3/29/2025 |
1.0.16 | 89 | 3/29/2025 |
1.0.14 | 94 | 3/29/2025 |
1.0.12 | 98 | 3/29/2025 |
1.0.10 | 132 | 3/27/2025 |
1.0.8 | 130 | 3/27/2025 |
1.0.6 | 238 | 3/21/2025 |