ActDim.Emitron 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package ActDim.Emitron --version 1.0.1
                    
NuGet\Install-Package ActDim.Emitron -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ActDim.Emitron" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ActDim.Emitron" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="ActDim.Emitron" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ActDim.Emitron --version 1.0.1
                    
#r "nuget: ActDim.Emitron, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ActDim.Emitron@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ActDim.Emitron&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=ActDim.Emitron&version=1.0.1
                    
Install as a Cake Tool

ActDim.Emitron

ActDim.Emitron is a Roslyn-powered C# scripting evaluation engine and string template interpolation compiler for .NET.

Features

  • Roslyn-Based C# Script Compilation: Compile arbitrary C# code snippets or multi-statement blocks into highly efficient, reusable Func<object, T> delegates.
  • Collision-Free Property Binding: Pass any anonymous object, DTO, or dictionary as input. Properties are bound safely to a dynamic parameter variable (@params by default, fully customizable).
  • Template Interpolation Compiler: Parse and compile natural C# interpolated string templates (e.g., $"Hello, {Name}! You have {Count} messages.") into fast formatting delegates (Interpolator).
  • Concurrent Script Caching: Script compilation occurs once per unique tuple (code, inputParameterName, returnType). Compiled delegates are cached in memory for zero-overhead re-execution.
  • Fluent String Extension Helpers: Execute template interpolation directly via template.Interpolate(input).

Installation

Install via the .NET CLI:

dotnet add package ActDim.Emitron

Or via Package Manager Console:

Install-Package ActDim.Emitron

Quick Start Examples

1. Evaluating C# Expressions

using ActDim.Emitron;

// Compile expression operating on @params
Func<object, string> greet = ScriptEngine.Compile<string>("@params.Name.ToUpper() + \"!\"");

// Execute cached delegate
string result = greet(new { Name = "world" });
Console.WriteLine(result); // Output: WORLD!

2. Multi-Statement Script Blocks

using ActDim.Emitron;

var calculateTax = ScriptEngine.Compile<decimal>("""
    var price = (decimal)@params.Price;
    var rate = (decimal)@params.TaxRate;
    var total = price * (1 + rate);
    return Math.Round(total, 2);
""");

decimal taxResult = calculateTax(new { Price = 100.00m, TaxRate = 0.20m });
Console.WriteLine(taxResult); // Output: 120.00

3. Template Interpolation (Runtime C# String Templating)

In standard C#, string interpolation ($"Hello, {Name}!") is hardcoded at compile-time directly in source code — it cannot be loaded dynamically from a database, config file, or external request at runtime.

ActDim.Emitron solves this by bringing true C# string interpolation to runtime templates with near-native performance:

  • Native C# Syntax & Rules: Use the exact same interpolation syntax, format specifiers ({Date:yyyy-MM-dd}, {Amount,8:C2}), method calls, and property chains you already know in C#.
  • Lightning-Fast Compilation & Caching: The template is compiled into native executable IL via Roslyn once on first use and cached. Subsequent executions run directly as compiled delegates without regex parsing or reflection interpretation overhead — delivering execution speeds comparable to compiled C# code.
using ActDim.Emitron;

// Dynamic runtime template loaded from database, config, or user input
// Standard C# interpolated string — no special prefixes needed in placeholders!
string template = "$\"Order #{OrderId} for {Customer} is {Status} on {Date:yyyy-MM-dd}.\"";

// 1. Fluent execution: automatically compiles and caches on first call
string output1 = template.Interpolate(new 
{ 
    OrderId = 1001, 
    Customer = "Acme Corp", 
    Status = "SHIPPED", 
    Date = DateTime.UtcNow 
});

// 2. Or compile explicitly into a reusable, high-performance delegate
var formatter = Interpolator.Compile(template);

string output2 = formatter(new 
{ 
    OrderId = 1002, 
    Customer = "Globex", 
    Status = "PENDING", 
    Date = DateTime.UtcNow 
});

4. Custom Parameter Variable Name

using ActDim.Emitron;

// Use 'model' instead of default '@params'
var eval = ScriptEngine.Compile<int>("model.A + model.B", inputParameterName: "model");
int sum = eval(new { A = 10, B = 20 });

License

This project is licensed under the MIT License.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ActDim.Emitron:

Package Downloads
ActDim.Emitron.Razor

Razor template compilation and execution engine powered by Emitron Roslyn evaluation.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.10 64 8/26/2026
1.0.9 71 8/25/2026
1.0.8 71 8/25/2026
1.0.7 93 8/20/2026
1.0.6 82 8/19/2026
1.0.5 82 8/19/2026
1.0.4 85 8/19/2026
1.0.3 86 8/18/2026
1.0.2 95 8/18/2026
1.0.1 94 8/17/2026
1.0.0 89 8/17/2026