Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zzzprojects/Eval-Expression.NET
C# Eval Expression | Evaluate, Compile, and Execute C# code and expression at runtime.
https://github.com/zzzprojects/Eval-Expression.NET
csharp dotnet eval eval-expression evaluation evaluator
Last synced: 6 days ago
JSON representation
C# Eval Expression | Evaluate, Compile, and Execute C# code and expression at runtime.
- Host: GitHub
- URL: https://github.com/zzzprojects/Eval-Expression.NET
- Owner: zzzprojects
- License: other
- Created: 2015-10-26T20:43:50.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2024-07-22T21:16:16.000Z (3 months ago)
- Last Synced: 2024-08-01T09:24:33.402Z (3 months ago)
- Topics: csharp, dotnet, eval, eval-expression, evaluation, evaluator
- Language: C#
- Homepage: https://eval-expression.net/
- Size: 904 KB
- Stars: 438
- Watchers: 30
- Forks: 85
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - zzzprojects/Eval-Expression.NET - C# Eval Expression | Evaluate, Compile, and Execute C# code and expression at runtime. (C\#)
README
# What's Eval Expression.NET?
Eval Expression.NET improves performance dramatically to access public and private methods, field, property value, or create object instances overusing C# reflection.It allows you to evaluate, Compile and Execute dynamic C# code and expression at runtime.
*From simple C# math expression...*
```csharp
int result = Eval.Execute("X + Y", new { X = 1, Y = 2});
```
*To complex code to parse.*
```csharp
int result = Eval.Execute(@"
var list = new List() { 1, 2, 3, 4, 5 };
var filter = list.Where(x => x < 4);
return filter.Sum(x => x);");
``````
PM> Install-Package Z.Expressions.Eval
```_* PRO Version unlocked for the current month_
## Eval.Execute
**Evaluate and execute the code or expression.****Support:**
_Anonymous Class_
```csharp
// using Z.Expressions; // Don't forget to include this.
int result = Eval.Execute("X + Y", new { X = 1, Y = 2});
```_Argument Position_
```csharp
// using Z.Expressions; // Don't forget to include this.
int result = Eval.Execute("{0} + {1}", 1, 2);
```_Class Member_
```csharp
// using Z.Expressions; // Don't forget to include this.
dynamic expandoObject = new ExpandoObject();
expandoObject.X = 1;
expandoObject.Y = 2;
int result = Eval.Execute("X + Y", expandoObject);
```_Extension Methods_
```csharp
// using Z.Expressions; // Don't forget to include this.
string s = "X + Y";
int result = s.Execute(new { X = 1, Y = 2 });
```
**[Learn more](https://eval-expression.net/eval-execute)**## Eval.Compile
**Compile the code or expression and return a delegate.****Support:**
*Custom Delegate*
```csharp
// using Z.Expressions; // Don't forget to include this.
var compiled = Eval.Compile>("X + Y", "X", "Y");
foreach(var item in list)
{
int result = compiled(item.Value1, item.Value2);
}
```*Extension Methods*
```csharp
// using Z.Expressions; // Don't forget to include this.
string s = "X + Y";
var compiled = s.Compile>("X", "Y");
foreach(var item in list)
{
int result = compiled(item.Value1, item.Value2);
}
```
**[Learn more](https://eval-expression.net/eval-compile)**## What's supported?
Eval Expression.NET supports all C# Syntax:
- All C# Keywords ([MSDN Documentation](https://msdn.microsoft.com/en-us/library/x53a06bb.aspx))
- All C# Operators ([MSDN Documentation](https://msdn.microsoft.com/en-CA/library/6a71f45d.aspx))
- Constant Folding
- Extension Methods
- Generic Type
- Lambda Expression
- Number SuffixYou can even access C# 6.0 features even if you are using C# 4.0.
- string interpolation
- typename
- null conditional member access## PRO
Every month, a new monthly trial of the PRO Version is available to let you evaluate all its features without limitations.Features | [PRO Version](https://eval-expression.net/#pro)
------------ | :-------------:
Maximum Characters | Unlimited
Commercial License | Yes
Royalty-Free | Yes
Support & Upgrades (1 year) | Yes
Learn more about the **[PRO Version](https://eval-expression.net/#pro)**- Starting from version 2.x, there is no longer a free limited version.
- `LINQ` extension method is free with [EF Classic - Community](https://entityframework-classic.net/)## Contribute
The best way to contribute is by **spreading the word** about the library:
- Blog it
- Comment it
- Star it
- Share it
A **HUGE THANKS** for your help.## More Projects
- Projects:
- [EntityFramework Extensions](https://entityframework-extensions.net/)
- [Dapper Plus](https://dapper-plus.net/)
- [C# Eval Expression](https://eval-expression.net/)
- Learn Websites
- [Learn EF Core](https://www.learnentityframeworkcore.com/)
- [Learn Dapper](https://www.learndapper.com/)
- Online Tools:
- [.NET Fiddle](https://dotnetfiddle.net/)
- [SQL Fiddle](https://sqlfiddle.com/)
- [ZZZ Code AI](https://zzzcode.ai/)
- and much more!To view all our free and paid projects, visit our website [ZZZ Projects](https://zzzprojects.com/).