CodingSeb.ExpressionEvaluator
1.4.40
See the version list below for details.
dotnet add package CodingSeb.ExpressionEvaluator --version 1.4.40
NuGet\Install-Package CodingSeb.ExpressionEvaluator -Version 1.4.40
<PackageReference Include="CodingSeb.ExpressionEvaluator" Version="1.4.40" />
paket add CodingSeb.ExpressionEvaluator --version 1.4.40
#r "nuget: CodingSeb.ExpressionEvaluator, 1.4.40"
// Install CodingSeb.ExpressionEvaluator as a Cake Addin #addin nuget:?package=CodingSeb.ExpressionEvaluator&version=1.4.40 // Install CodingSeb.ExpressionEvaluator as a Cake Tool #tool nuget:?package=CodingSeb.ExpressionEvaluator&version=1.4.40
ExpressionEvaluator
⚠️ For now, I don't have time to maintain this repository. So if you have PR to fix some bugs. I'll be happy to review and merge it. Otherwise, I will no longer actively develop ExpressionEvaluator. If the current state of the lib do not suite your needs I suggest you look the list of great alternative projects below. |
---|
A Simple Math and Pseudo C# Expression Evaluator in One C# File.
And from version 1.2.0 can execute small C# like scripts
It is largely based on and inspired by the following resources this post on stackoverflow, NCalc, C# Operators and C# Statement Keywords
Status
Branch | Status |
---|---|
master | |
dev | |
nuget |
Features
- Basic mathematical and logical expression evaluation
- System.Math methods and constants directly available (some like Max, Min, Avg are improved)
- Some useful functions for example to create List and Arrays
- Custom variables definition
- On the fly variables and functions evaluation (To easily extend possibilities, Manage also on instance Property and Methods)
- A large set of C# operators availables
- Instance and static methods and properties access like as in C#
- You can call Methods and/or Properties on your own classes (just pass a object as custom variables)
- C# primary types
- Use strings as in C# (
@""
,$""
,$@""
available) - Lambda expressions
- Classes like File, Directory, Regex, List ... available (You can extend the list of Namespaces)
- Create instance with new(MyClassName, constructorArgs) or new MyClassName(constructorArgs)
- Call void methods with fluid prefix convention to chain operations
- Manage ExpandoObject
- Create custom Operators or change the parsing process
And with ScriptEvaluate method
- Small C# like script evaluation (Multi expressions separated by ; )
- Some conditional and loop blocks keywords (if, while, for, foreach ...)
- Multi-line (multi expression) Lambda expressions. (Can be use as method See #72 Declare methods in scripts and the doc)
Resources
Similar projects
Free
- NCalc
- Jint Support scripting but with Javascript
- NLua use Lua language in C#
- MoonSharp
- DynamicExpresso
- Flee
- Jace.Net
- Calculator
- Westwind.Scripting
- CS-Script Best alternative (I use it some times) → Real C# scripts better than ExpressionEvaluator (But everything is compiled. Read the doc. Execution is faster but compilation can make it very slow. And if not done the right way, it can lead to memory leaks)
- Roslyn The Microsoft official solution (For scripting see)
- MathParser expression tree compiler and interpreter for math expressions. Heavily inspired by Roslyn.
- YoowzxCalc
- Scriban
- WattleScript
- AngouriMath For advanced Math in C#
- Fluid
- ClearScript
- Expressive
- IronPython to execute python in .Net or .Net in python
Commercial
- Eval Expression.NET
- mXparser (dual licensing) (Free for open source)
Projects that could help you build your own expression/script evaluator
Reading and resources
- Crafting interpreters
- Building a compiler An excellent Youtube tutorial
- Search for LEX, YACC, AST, Syntaxic trees...
I would say every C# evaluation libraries have drawbacks and benefits, ExpressionEvaluator is not an exception so choose wisely (Read docs and licences).
The biggest difference of ExpressionEvaluator is that everything is evaluated on the fly, nothing is compiled or transpile nor in CLR/JIT/IL nor in lambda expressions nor in javascript or other languages stuffs. So it can be slower in some cases (sometimes not) but it also avoid a lot of memory leaks. It is clearly not optimized for big reuse of expressions as the expression is reevaluated every time (Filtering on big dataset for example). It already allow to evaluate some small scripts. If you don't want an another .dll file in your project, you only need to copy one C# file in your project. And it's MIT licence
Donate
Expression Evaluator is free and will always be.
But if you want to say thanks for this lib with a donation or small sponsoring here you can :
Donate
Thank you anyway for using ExpressionEvaluator
Product | Versions 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Microsoft.CSharp (>= 4.7.0)
- System.Dynamic.Runtime (>= 4.3.0)
-
.NETStandard 2.0
- Microsoft.CSharp (>= 4.7.0)
- System.Dynamic.Runtime (>= 4.3.0)
NuGet packages (12)
Showing the top 5 NuGet packages that depend on CodingSeb.ExpressionEvaluator:
Package | Downloads |
---|---|
Hd.Utility
Package Description |
|
VL.Addons
Various VL addons provided by the community. |
|
Pose.Customer.Services
Package Description |
|
Viya.RuleEngine
Express conditions to modify an object |
|
CodingSeb.Converters
Some Converters to use in WPF |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.5.0-alpha0004 | 1,770 | 9/13/2021 |
1.5.0-alpha0003 | 333 | 8/3/2021 |
1.5.0-alpha0002 | 437 | 6/29/2021 |
1.5.0-alpha0001 | 8,286 | 5/25/2021 |
1.4.40 | 142,924 | 9/22/2023 |
1.4.39 | 214,736 | 8/26/2022 |
1.4.38 | 37,287 | 6/10/2022 |
1.4.37 | 47,845 | 2/22/2022 |
1.4.36 | 44,960 | 1/20/2022 |
1.4.35 | 102,805 | 10/28/2021 |
1.4.34 | 33,053 | 10/1/2021 |
1.4.33 | 10,089 | 9/21/2021 |
1.4.32 | 1,114 | 9/13/2021 |
1.4.31 | 17,604 | 8/3/2021 |
1.4.30 | 9,346 | 6/29/2021 |
1.4.29 | 11,925 | 5/19/2021 |
1.4.28 | 1,494 | 5/7/2021 |
1.4.27 | 518 | 5/5/2021 |
1.4.26 | 2,821 | 4/20/2021 |
1.4.25 | 24,298 | 3/14/2021 |
1.4.24 | 731 | 3/10/2021 |
1.4.23 | 4,244 | 3/3/2021 |
1.4.22 | 487 | 3/2/2021 |
1.4.21 | 4,339 | 2/27/2021 |
1.4.20 | 552 | 2/24/2021 |
1.4.19 | 32,447 | 2/3/2021 |
1.4.18 | 29,359 | 1/4/2021 |
1.4.17 | 23,717 | 12/11/2020 |
1.4.16 | 45,342 | 9/23/2020 |
1.4.15 | 77,927 | 9/2/2020 |
1.4.14 | 5,383 | 8/14/2020 |
1.4.13 | 4,048 | 7/15/2020 |
1.4.12 | 725 | 7/11/2020 |
1.4.11 | 11,144 | 6/16/2020 |
1.4.10 | 1,098 | 6/4/2020 |
1.4.9 | 16,022 | 3/6/2020 |
1.4.8 | 667 | 2/25/2020 |
1.4.7 | 1,072 | 2/12/2020 |
1.4.6 | 713 | 2/7/2020 |
1.4.5 | 9,667 | 11/25/2019 |
1.4.4 | 2,934 | 10/3/2019 |
1.4.3 | 607 | 10/2/2019 |
1.4.2 | 686 | 9/24/2019 |
1.4.1 | 1,672 | 9/18/2019 |
1.4.0 | 6,726 | 5/28/2019 |
1.3.7 | 803 | 4/10/2019 |
1.3.6 | 710 | 4/2/2019 |
1.3.5 | 687 | 3/28/2019 |
1.3.4 | 2,064 | 3/14/2019 |
1.3.3 | 736 | 2/15/2019 |
1.3.2 | 901 | 1/19/2019 |
1.3.1 | 798 | 1/10/2019 |
1.3.0 | 2,718 | 12/6/2018 |
1.2.2 | 1,582 | 10/31/2018 |
1.2.1 | 1,073 | 8/2/2018 |
1.2.0 | 1,940 | 7/31/2018 |
1.0.2 | 2,979 | 5/16/2018 |
1.0.1 | 1,049 | 5/7/2018 |
1.0.0 | 1,223 | 5/7/2018 |
* Make shared cache for types resolution thread safe
* Add ScriptEvaluating and ScriptEvaluated events
* Add unaryOperatorsDictionary to manage custom operators that are both unaries and binaries better