AssemblyBlast 1.2.0
dotnet add package AssemblyBlast --version 1.2.0
NuGet\Install-Package AssemblyBlast -Version 1.2.0
<PackageReference Include="AssemblyBlast" Version="1.2.0" />
<PackageVersion Include="AssemblyBlast" Version="1.2.0" />
<PackageReference Include="AssemblyBlast" />
paket add AssemblyBlast --version 1.2.0
#r "nuget: AssemblyBlast, 1.2.0"
#:package AssemblyBlast@1.2.0
#addin nuget:?package=AssemblyBlast&version=1.2.0
#tool nuget:?package=AssemblyBlast&version=1.2.0
AssemblyBlast 🧩
![]()
AssemblyBlast is a sibling in the Blast family of NuGet packages. It works in both directions:
- Forward — produce .NET types and assemblies at runtime from JSON definitions or programmatic property metadata, using Roslyn for source-to-IL compilation and
System.Reflection.Emitfor in-process type building. - Backward (since 1.1) — read existing assemblies into the same
ClassDefinition/EnumDefinitionshapes, so a downstream tool (UI generator, schema exporter, doc tool) can describe a DLL the same way it describes a synthetic type. - Round-trip (since 1.2) — render those shapes back to C# source with
AssemblyWriter, optionally writing a folder tree (Acme.Domain.Crm→Acme/Domain/Crm/). Closes the loop Assembly → ClassDefinition → C# source, so a design surface that owns theClassDefinitionshapes can regenerate the project's.csfiles.
It is the codegen pack split out of the legacy Mnemonics.CodingTools package. The runtime entity-store and dynamic EF registry layer that used to live alongside it now lives in EntityBlast. AssemblyBlast and EntityBlast are independent and neither depends on the other.
What it gives you
IDynamicClassBuilder— define properties at runtime and produce a freshTypeviaReflection.Emit. Properties are decorated withFieldWithAttributesso a downstream UI or store layer can introspect them.IDynamicClassGenerator— feed in a JSON definition (namespaces, classes, properties, constructors, methods) and get back a compiled.dllplus the list of namespaces it contains.AssemblyReader(1.1+) — reflect over an existingAssemblyand produceClassDefinition[]/EnumDefinition[], including base type, interfaces, constructors, ctor-fed property detection, nullability / collection unwrapping,[Flags]enums, and XML-doc summaries when the sibling.xmlis present.AssemblyWriter(1.2+) — mirror of the reader. Render anyClassDefinition/EnumDefinitionback to C# source, with file-scoped namespaces, ctor body assignments derived from case-insensitive param/property matching, the right accessor shape per property,[Flags]and underlying-type emission for enums, and XML-doc summaries preserved.WriteToFolderlays out files under a namespace-as-path tree.DynamicAssemblyCache— load a generated assembly once per path; subsequent loads return the cachedAssemblyso reference identity is preserved.AssemblyHelper— utilities for collectingMetadataReferences and probing the currentAppDomain.
Install
dotnet add package AssemblyBlast
Quick start — IDynamicClassBuilder
var builder = new DynamicClassBuilder("Person");
builder.AddProperty(new DynamicPropertyMetadata
{
Name = "FirstName",
TypeName = "System.String",
ControlType = "TextBox",
IsRequired = true
});
var personType = builder.Build();
Quick start — IDynamicClassGenerator
var json = """
[
{
"Namespace": "Generated",
"Classes": [
{
"Name": "User",
"Properties": [
{ "Name": "Id", "Type": "string" },
{ "Name": "Username", "Type": "string" }
]
}
]
}
]
""";
var generator = new DynamicClassGenerator();
var (dllPath, namespaces) = generator.GenerateAssemblyFromJson(json, "Generated/User.dll");
var assembly = DynamicAssemblyCache.LoadOrGet(dllPath!);
var userType = assembly.GetType("Generated.User");
Quick start — AssemblyReader (1.1+)
using AssemblyBlast;
var classes = AssemblyReader.ReadClasses(typeof(MyDomainType).Assembly);
var enums = AssemblyReader.ReadEnums(typeof(MyDomainType).Assembly);
foreach (var c in classes)
{
Console.WriteLine($"{c.Kind} {c.Namespace}.{c.Name}");
foreach (var p in c.Properties)
Console.WriteLine($" {p.Type}{(p.IsNullable ? "?" : "")} {p.Name}" +
$" [key={p.IsKey} required={p.IsRequired} collection={p.IsCollection} derived={p.IsDerived}]");
}
What gets surfaced:
- Kind:
class/record/struct/interface. Static classes (sealed + abstract) and compiler-generated types are skipped. - Properties: instance, public-getter properties. The classic OOP shape — private backing field + public ctor + read-only
public T Foo { get; }— is recognised: properties whose name matches a public-ctor parameter are flagged as ctor-fed (IsDerived = false), while expression-bodied / truly computed properties (no matching ctor param) are flaggedIsDerived = true. Records' positional parameters fall under the same rule. Private setters carryAccessorVisibility = "private"so consumers can tell them apart from public setters and from get-only properties. - Auto-implemented record interfaces (
IEquatable<TSelf>on records) are filtered — they're compiler artefacts, not user-authored. - Constructors: parameter list captured per public ctor, with nullability annotations preserved (
string?,int?) — both reference-type NRT and value-typeNullable<T>. Bodies aren't recovered (would require IL decompilation). - Enums: underlying numeric type as a C# keyword (
byte,int,ulong…),[Flags]attribution, and members with values normalised tolong. - XML-doc summaries: if
<assembly-name>.xmlsits next to the.dll, summaries on types, properties, and enum members are attached.
Dependency injection
builder.Services.AddAssemblyBlast();
Registers IDynamicClassGenerator as a singleton and a Func<string, IDynamicClassBuilder> factory so callers can create per-class builders. AssemblyReader is a static helper, no registration needed.
License
MIT, see LICENSE.txt.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Microsoft.CodeAnalysis.CSharp (>= 5.3.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.