Mages 3.0.1-alpha-67

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

MAGES Logo

MAGES

GitHub CI NuGet Issues

Mages: Another Generalized Expression Simplifier

MAGES is the official successor to YAMP. It is a very simple, yet powerful, expression parser and interpreter. You can use MAGES to include a sophisticated, easy to customize, and lightweight scripting engine to your application.

Among other applications, MAGES has been used in Microsoft's PowerToys.

Current Status

2024:

MAGES was just updated (v3.0.0) with object metadata, direct list support, and JSX syntax.

JSX as you know it - stringified via html:

<div class={"hello" + "," + "there"}><h1>Hi</h1><p>World.</p></div> | html
// result: <div class="hello,there"><h1>Hi</h1><p>World.</p></div>

Object metadata reflected via type:

new { a: "foo", b: 42 } | type | json
// {
//   "name": "Object",
//   "create": "[Function]",
//   "keys": {
//     "0": "a",
//     "1": "b"
//   }
// }

((x, y, z) => x + y + z) | type | json
// {
//   "name": "Function",
//   "create": "[Function]",
//   "parameters": {
//     "0": "x",
//     "1": "y",
//     "2": "z"
//   }
// }

Placeholders for calling functions / specifying what should be curry'ed:

var f = (x, y, z) => x + 2 * y + 3 * z;
5 | f(1, _, 2)
// 17, by computing 1 + 2 * 5 + 3 * 2

Previous Status

2023:

MAGES was updated (v2.0.0) with support for complex numbers. Also, the build target and runtime has been updated to make use of modern possibilities.

2018:

The first stable version has been released. The current version 1.6.0 contains an improved REPL. The library contains everything to perform lightweight scripting operations in C#. A CodeProject article about the library (also containing some background and performance comparisons) is also available.

Installation

MAGES itself does not have any dependencies, however, the tests are dependent on NUnit and the benchmarks use BenchmarkDotNet. Usually, MAGES should be installed via the NuGet package source. If this does not work for you, then clone the source and build MAGES yourself. Make sure that all unit tests pass.

The whole library was designed to be consumed from .NET Core 3.0 (or higher) / .NET 5.0 (or higher) applications. This means it is (amongst others) compatible with Unity 2021.2 or Mono 6.4. The NuGet package is available via the official package feed.

Get Me Started!

In the most simple case you are creating a new engine to hold a global scope (for variables and functions) and launch the interpretation.

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

You can also go-ahead and make reusable blocks from snippets.

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

Or you can interact with elements created by MAGES.

var func = engine.Interpret("(x, y) => x * y + 3 * sqrt(x)") as Mages.Core.Function;
var result = func.Invoke(new Object[] { 4.0, 3.0 }); // 18.0

Or even simpler (details are explained in the getting started document):

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

These are just some of the more basic examples. More information can be found in the documentation.

Documentation

The documentation is given in form of Markdown documents being placed in the doc folder of this repository. The following links are worth checking out:

If anything is missing, unclear, or wrong then either submit a PR or file an issue. See the following section on contributions for more information.

Contributions

Contributions in form of feature implementations or bug fixes are highly welcome, but need to be performed in an organized and consistent way. The contribution guidelines should be read before starting any work.

Contributions may also be taken in form of bug reports and feature requests. Long live open-source development!

Versioning

The rules of semver are our bread and butter. In short this means:

  1. MAJOR versions at maintainers' discretion following significant changes to the codebase (e.g., breaking API changes)
  2. MINOR versions for backwards-compatible enhancements (e.g., performance improvements, additional extensions)
  3. PATCH versions for backwards-compatible bug fixes (e.g., specification compliance bugs, support issues)

Hence: Do not expect any breaking changes within the same major version.

Sponsors

The following companies sponsored part of the development of MAGES.

<div style="display:flex;justify-content:space-evenly;align-items:center"> <img width="150" height="150" src="https://raw.githubusercontent.com/polytroper/polytroper.github.io/master/favicon.png"> <img width="200" height="200" src="https://smapiot.com/smapiot_green.03d1162a.svg"> <img width="200" height="200" src="https://www.omicron-lab.com/fileadmin/website/images/OMICRON-LAB.svg"> </div>

Thanks for all the support and trust in the project!

License

This code is released using the MIT license. For more information see the LICENSE file.

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
OmicronLab.VectorNetworkAnalysis.MidLayer

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

LisaCore

CSharp dynamic runtime code execution

GitHub repositories (2)

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

Repository Stars
microsoft/PowerToys
Microsoft PowerToys is a collection of utilities that help you customize Windows and streamline everyday tasks
Flow-Launcher/Flow.Launcher
:mag: Quick file search & app launcher for Windows with community-made plugins
Version Downloads Last Updated
3.0.1 383 11/13/2025
3.0.1-alpha-67 261 11/13/2025
3.0.0 14,021 12/24/2024
3.0.0-alpha-61 152 12/24/2024
3.0.0-alpha-59 150 12/24/2024
3.0.0-alpha-57 137 12/24/2024
3.0.0-alpha-55 149 12/24/2024
3.0.0-alpha-53 147 12/21/2024
3.0.0-alpha-52 142 12/21/2024
3.0.0-alpha-51 167 12/21/2024
3.0.0-alpha-50 153 12/21/2024
3.0.0-alpha-49 164 9/5/2024
3.0.0-alpha-45 173 8/7/2024
3.0.0-alpha-44 125 7/28/2024
3.0.0-alpha-41 138 7/28/2024
2.0.3-alpha-31 277 1/7/2024
2.0.2 19,236 1/7/2024
2.0.2-alpha-28 191 1/7/2024
2.0.1 29,394 6/17/2022
2.0.1-alpha-24 347 6/17/2022
2.0.0 40,386 6/8/2021
2.0.0-alpha-9 436 5/19/2021
2.0.0-alpha-8 476 5/19/2021
2.0.0-alpha-7 435 5/19/2021
2.0.0-alpha-6 461 5/19/2021
2.0.0-alpha-18 461 6/7/2021
2.0.0-alpha-17 439 6/3/2021
2.0.0-alpha-16 483 6/1/2021
2.0.0-alpha-15 496 5/31/2021
2.0.0-alpha-14 483 5/21/2021
2.0.0-alpha-13 420 5/20/2021
2.0.0-alpha-12 428 5/20/2021
2.0.0-alpha-11 440 5/20/2021
1.6.0 32,681 7/8/2018
1.5.0 5,774 1/4/2017
1.4.0 1,475 11/25/2016
1.3.0 1,627 10/6/2016
1.2.0 1,655 8/16/2016
1.1.0 1,473 8/1/2016
1.0.0 1,917 7/11/2016
0.9.0 1,725 6/23/2016
0.8.0 2,004 6/17/2016
0.7.0 1,702 6/13/2016
0.6.0 1,637 6/5/2016
0.5.0 1,651 6/1/2016
0.4.0 1,626 5/29/2016
0.3.0 1,624 5/26/2016
0.2.0 1,638 5/23/2016
0.1.0 1,766 5/22/2016