ActDim.Emitron
1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package ActDim.Emitron --version 1.0.0
NuGet\Install-Package ActDim.Emitron -Version 1.0.0
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.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ActDim.Emitron" Version="1.0.0" />
<PackageReference Include="ActDim.Emitron" />
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.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ActDim.Emitron, 1.0.0"
#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.0
#: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.0
#tool nuget:?package=ActDim.Emitron&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 (
@paramsby default, fully customizable). - Template Interpolation Compiler: Parse and compile templates with embedded expression placeholders (e.g.,
"Hello { @params.Name }!") 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
using ActDim.Emitron;
using ActDim.Emitron.Extensions;
string template = "Order #{ @params.OrderId } for { @params.Customer } is { @params.Status }.";
// Using Interpolator delegate
var formatter = Interpolator.Compile(template);
string output1 = formatter(new { OrderId = 1001, Customer = "Acme Corp", Status = "SHIPPED" });
// Using fluent string extension method
string output2 = template.Interpolate(new { OrderId = 1002, Customer = "Globex", Status = "PENDING" });
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 | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Ardalis.GuardClauses (>= 5.0.0)
- Microsoft.CodeAnalysis.CSharp.Scripting (>= 5.6.0)
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.