https://github.com/bigbuildbench/nreco_lambdaparser
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.5%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: BigBuildBench
- License: mit
- Language: C#
- Default Branch: master
- Size: 101 KB
Statistics
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
NReco LambdaParser
Runtime parser for string expressions (formulas, method calls, properties/fields/arrays accessors). LambdaParser builds dynamic LINQ expression tree and compiles it to the lambda delegate. Types are resolved at run-time like in dynamic languages.
NuGet | Windows x64 | Linux
--- | --- | ---
|
|
- can be used in any .NET app: net45 (legacy .NET Framework apps), netstandard1.3 (.NET Core apps), netstandard2.0 (all modern .NET apps).
- any number of expression arguments (values can be provided as dictionary or by callback delegate)
- supports arithmetic operations (+, -, *, /, %), comparisons (==, !=, >, <, >=, <=), conditionals including (ternary) operator ( boolVal ? whenTrue : whenFalse )
- access object properties, call methods and indexers, invoke delegates
- dynamic typed variables: performs automatic type conversions to match method signature or arithmetic operations
- create arrays and dictionaries with simplified syntax:
new dictionary{ {"a", 1}, {"b", 2} },new []{ 1, 2, 3} - local variables that may go before main expression:
var a = 5; var b = contextVar/total*100;(disabled by default, to enable useLambdaParser.AllowVarsproperty)
Nuget package: NReco.LambdaParser
``` var lambdaParser = new NReco.Linq.LambdaParser();
var varContext = new Dictionary
Custom values comparison
By default LambdaParser uses ValueComparer for values comparison. You can provide your own implementation or configure its option to get desired behaviour:
* ValueComparer.NullComparison determines how comparison with null is handled. 2 options:
* MinValue: null is treated as minimal possible value for any type - like .NET IComparer
* Sql: null is not comparable with any type, including another null - like in SQL
* ValueComparer.SuppressErrors allows to avoid convert exception. If error appears during comparison exception is not thrown and this means that values are not comparable (= any condition leads to false).
var valComparer = new ValueComparer() { NullComparison = ValueComparer.NullComparisonMode.Sql };
var lambdaParser = new LambdaParser(valComparer);
Caching Expressions
The UseCache property determines whether the LambdaParser should cache parsed expressions. By default, UseCache is set to true, meaning expressions are cached to improve performance for repeated evaluations of the same expression.
Therefore, using a singleton instance of LambdaParser is recommended, rather than creating a new instance each time.
You can disable caching by setting UseCache to false if you want to save memory, especially when evaluating a large number of unique expressions.
csharp
var lambdaParser = new LambdaParser();
lambdaParser.UseCache = false;
Who is using this?
NReco.LambdaParser is in production use at SeekTable.com and PivotData microservice (used for user-defined calculated cube members: formulas, custom formatting).
License
Copyright 2016-2024 Vitaliy Fedorchenko and contributors
Distributed under the MIT license
Owner
- Name: BigBuildBench
- Login: BigBuildBench
- Kind: organization
- Repositories: 1
- Profile: https://github.com/BigBuildBench
abbr. B3, benchmarking the repo-level understanding capability of your LLMs by reconstructing project build-file.
GitHub Events
Total
- Create event: 5
Last Year
- Create event: 5
Dependencies
- actions/checkout v3 composite
- actions/setup-dotnet v2 composite