Mages 4.0.0-alpha-101

This is a prerelease version of Mages.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Mages --version 4.0.0-alpha-101
                    
NuGet\Install-Package Mages -Version 4.0.0-alpha-101
                    
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="Mages" Version="4.0.0-alpha-101" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mages" Version="4.0.0-alpha-101" />
                    
Directory.Packages.props
<PackageReference Include="Mages" />
                    
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 Mages --version 4.0.0-alpha-101
                    
#r "nuget: Mages, 4.0.0-alpha-101"
                    
#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 Mages@4.0.0-alpha-101
                    
#: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=Mages&version=4.0.0-alpha-101&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Mages&version=4.0.0-alpha-101&prerelease
                    
Install as a Cake Tool

MAGES

MAGES (Mages: Another Generalized Expression Simplifier) is a lightweight, ultra-fast expression parser, compiler, and interpreter for .NET. It lets you embed a sandboxed scripting engine into your application without any external runtime dependencies.

This package contains the MAGES library (Mages.Core). If you are looking for the command-line tool and REPL, install Mages.Compiler instead.

Installation

dotnet add package Mages

The library targets .NET Standard 2.1 and therefore runs on .NET Core 3.0+, .NET 5+, Mono 6.4+, and Unity 2021.2+.

Usage

Create an engine to hold a global scope and start interpreting:

using Mages.Core;

var engine = new Engine();
var result = engine.Interpret("sin(2) * cos(pi / 4)"); // 0.642970376623918

Trigonometric functions use radians by default. To use degrees for direct trigonometric arguments and inverse-trigonometric results, configure the engine. The setting is local to that engine instance:

var engine = new Engine(new Configuration { AngleUnit = AngleUnit.Degrees });
var result = engine.Interpret("sin(90) + arcsin(1)"); // 91.0

Compile once, run many times:

var expOne = engine.Compile("exp(1)");
var result = expOne(); // 2.71828182845905

Expose your own data and functions to scripts:

engine.Scope["x"] = 4.0;
engine.SetFunction("sq", (Double v) => v * v);

var result = engine.Interpret("sq(x) + 1"); // 17.0

Get functions defined in MAGES back into C#:

var func = engine.Interpret("(x, y) => x * y + 3 * sqrt(x)") as Function;
var result = func.Call(4, 3); // 18.0

Features

  • Numbers, complex numbers, strings, booleans, matrices, objects, and first-class functions
  • Interpolated strings, JSX syntax, pattern matching, pipes, and placeholders for currying
  • No IL emitted at runtime, so it also works on platforms with AOT restrictions
  • Full control over the exposed API, which makes sandboxing user scripts straightforward
  • Editor tooling support such as auto-completion (GetCompletionAt) and AST validation

Documentation

License

MIT - see the license file for details.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Mages:

Package Downloads
LisaCore

CSharp dynamic runtime code execution

OmicronLab.VectorNetworkAnalysis.MidLayer

This package contains all the Mid-Layer components needed to measure with a VNA device.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Mages:

Repository Stars
Flow-Launcher/Flow.Launcher
:mag: Quick file search & app launcher for Windows with community-made plugins
Version Downloads Last Updated
4.0.0-alpha-98 112 10/20/2026
4.0.0-alpha-95 103 10/13/2026
4.0.0-alpha-94 103 10/13/2026
4.0.0-alpha-93 98 10/13/2026
4.0.0-alpha-92 98 10/13/2026
4.0.0-alpha-83 102 10/13/2026
4.0.0-alpha-80 113 9/15/2026
4.0.0-alpha-79 111 9/14/2026
4.0.0-alpha-78 106 9/14/2026
4.0.0-alpha-77 116 9/14/2026
4.0.0-alpha-76 121 9/14/2026
4.0.0-alpha-122 94 11/14/2026
4.0.0-alpha-119 93 10/29/2026
4.0.0-alpha-118 87 10/29/2026
4.0.0-alpha-113 97 10/29/2026
4.0.0-alpha-110 92 10/29/2026
4.0.0-alpha-109 89 10/29/2026
4.0.0-alpha-104 88 10/29/2026
4.0.0-alpha-101 98 10/20/2026
3.0.1 23,999 11/13/2025
Loading failed