Skip to content

Commit 834db65

Browse files
author
Sébastien Geiser
committed
Merge branch 'master' into dev
2 parents cc08607 + d5b780a commit 834db65

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

CodingSeb.ExpressionEvaluator/ExpressionEvaluator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
using System;
1111
using System.Collections;
12+
using System.Collections.Concurrent;
1213
using System.Collections.Generic;
1314
using System.ComponentModel;
1415
using System.Dynamic;
@@ -474,7 +475,7 @@ protected enum TryBlockEvaluatedState
474475
/// <summary>
475476
/// A shared cache for types resolution.
476477
/// </summary>
477-
public static IDictionary<string, Type> TypesResolutionCaching { get; set; } = new Dictionary<string, Type>();
478+
public static IDictionary<string, Type> TypesResolutionCaching { get; set; } = new ConcurrentDictionary<string, Type>();
478479

479480
/// <summary>
480481
/// Clear all ExpressionEvaluator caches

README.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
![ExpressionEvaluator Icon](https://github.com/codingseb/ExpressionEvaluator/blob/master/Icon.png?raw=true "ExpressionEvaluator A Simple Math and Pseudo C# Expression Evaluator in One C# File")
22
# ExpressionEvaluator
33

4+
| :warning: 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](#similar-projects) below.
5+
| --- |
6+
47
A Simple Math and Pseudo C# Expression Evaluator in One [C# File](./CodingSeb.ExpressionEvaluator/ExpressionEvaluator.cs).
58

69
And from version 1.2.0 can execute small C# like scripts
@@ -44,27 +47,52 @@ It is largely based on and inspired by the following resources [this post on st
4447
* [Live Demos](https://dotnetfiddle.net/Packages/41132/CodingSeb_ExpressionEvaluator)
4548
* [Try it](https://dotnetfiddle.net/up4x3W)
4649

47-
## And more is coming
48-
* [The Todo List](https://github.com/codingseb/ExpressionEvaluator/wiki/ExpressionEvaluator-Todo-List)
49-
5050
## Similar projects
5151
### Free
5252
* [NCalc](https://github.com/pitermarx/NCalc-Edge)
5353
* [Jint](https://github.com/sebastienros/jint) Support scripting but with Javascript
5454
* [NLua](https://github.com/NLua/NLua) use Lua language in C#
55+
* [MoonSharp](https://github.com/moonsharp-devs/moonsharp/)
5556
* [DynamicExpresso](https://github.com/davideicardi/DynamicExpresso/)
5657
* [Flee](https://github.com/mparlak/Flee)
58+
* [Jace.Net](https://github.com/pieterderycke/Jace)
59+
* [Calculator](https://github.com/loresoft/Calculator)
60+
* [Westwind.Scripting](https://github.com/RickStrahl/Westwind.Scripting)
5761
* [CS-Script](https://github.com/oleg-shilo/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](https://en.wikipedia.org/wiki/Memory_leak))
5862
* [Roslyn](https://github.com/dotnet/roslyn) The Microsoft official solution (For scripting [see](https://github.com/dotnet/roslyn/wiki/Scripting-API-Samples))
5963
* [MathParser](https://github.com/KirillOsenkov/MathParser) expression tree compiler and interpreter for math expressions. Heavily inspired by Roslyn.
64+
* [YoowzxCalc](https://github.com/MarkusSecundus/YoowzxCalc)
65+
* [Scriban](https://github.com/scriban/scriban)
66+
* [WattleScript](https://github.com/WattleScript/wattlescript)
67+
* [AngouriMath](https://github.com/asc-community/AngouriMath) For advanced Math in C#
68+
* [Fluid](https://github.com/sebastienros/fluid)
69+
* [ClearScript](https://github.com/microsoft/ClearScript)
70+
* [Expressive](https://github.com/bijington/expressive)
71+
* [IronPython](https://github.com/IronLanguages/ironpython3) to execute python in .Net or .Net in python
6072

6173
### Commercial
6274
* [Eval Expression.NET](http://eval-expression.net/)
75+
* [mXparser](https://mathparser.org) (dual licensing) (Free for open source)
76+
77+
### Projects that could help you build your own expression/script evaluator
78+
* [SuperPower](https://github.com/datalust/superpower)
79+
* [Sprache](https://github.com/sprache/Sprache)
80+
* [CSLY : C# lex and yacc](https://github.com/b3b00/csly)
81+
* [Lexepars](https://github.com/DNemtsov/Lexepars)
82+
* [Parlot](https://github.com/sebastienros/parlot)
83+
* [Irony](https://github.com/IronyProject/Irony)
84+
* [Pidgin](https://github.com/benjamin-hodgson/Pidgin)
6385

86+
### Reading and resources
87+
* [Crafting interpreters](http://www.craftinginterpreters.com)
88+
* [Building a compiler](https://www.youtube.com/playlist?list=PLRAdsfhKI4OWNOSfS7EUu5GRAVmze1t2y) An excellent Youtube tutorial
89+
* Search for LEX, YACC, AST, Syntaxic trees...
90+
91+
6492
I would say every C# evaluation libraries have drawbacks and benefits, ExpressionEvaluator is not an exception so choose wisely (Read docs and licences).
6593

6694
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.
67-
So it can be slower in some cases (sometimes not) but it also avoid a lot of memory leaks.
95+
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).
6896
It already allow to evaluate some small scripts.
6997
If you don't want an another .dll file in your project, you only need to copy one [C# file](./CodingSeb.ExpressionEvaluator/ExpressionEvaluator.cs) in your project. And it's [MIT licence](./LICENSE.md)
7098

TryWindow/TryWindow.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>WinExe</OutputType>
5-
<TargetFrameworks>net48;net6.0-windows</TargetFrameworks>
5+
<TargetFrameworks>net48</TargetFrameworks>
66
<Nullable>disable</Nullable>
77
<UseWPF>true</UseWPF>
88
</PropertyGroup>

0 commit comments

Comments
 (0)