Enhance NCalc extensions with async support and tests#18
Open
gregbowyer84 wants to merge 7 commits intopanoramicdata:mainfrom
Open
Enhance NCalc extensions with async support and tests#18gregbowyer84 wants to merge 7 commits intopanoramicdata:mainfrom
gregbowyer84 wants to merge 7 commits intopanoramicdata:mainfrom
Conversation
- Updated `InterClassTests` to expect `double` instead of `decimal` and added `StringConcat` option. - Modified `IsSetTests` to check for null or whitespace instead of empty strings. - Changed expected exception in `ToDateTimeTests` from `ArgumentException` to `NCalcParameterNotDefinedException`. - Refactored `ExtendedExpression` constructor for readability and introduced `TidyExpression()`. - Replaced `FunctionArgs` with `IFunctionArgs` across multiple files for consistency. - Introduced `AsyncExpressionWrapper`, `AsyncExtendedExpression`, and `AsyncFunctionArgsWrapper` for async evaluation. - Enhanced `ExpressionHelper` for better parameter configuration and count checking. - Updated project dependencies to use `NCalc.Core`, `NCalcAsync`, and `NCalcSync`. - Added `MaxTestsAsync` for testing maximum value calculations with async expressions. - Updated `GlobalUsings.cs` to include new namespaces for async functionality.
- Changed `_expression` and `_args` fields to readonly in `AsyncExpressionWrapper`, `AsyncFunctionArgsWrapper`, `ExpressionWrapper`, and `FunctionArgsWrapper` classes to prevent reassignment after initialization. - Updated error handling for reserved keywords in `ExpressionHelper` to improve readability. - Removed commented-out generic `Evaluate` method in `Lambda` class for code cleanup.
Author
|
Decided to make support for the new Official NCalc nugets Async and Sync in my fork. Created this PR in case you were keen to bring this into your's? The async implementation is currently just calling into the sync functions now for compatibility. I wanted to make support for it first to support the new nuget, and then change the functions to fully support async. |
- Replaced `ExtendAsync` with synchronous `Extend` method in `ExpressionHelper`. - Added new constructors to `AsyncExtendedExpression` and `ExtendedExpression` to accept context parameters for `CultureInfo`. - Updated event handlers to use the new `Extend` method with context's `CultureInfo`. - Incremented version number from `3.2` to `3.3` in `version.json`.
Introduces `AsyncExtendedExpressionTests` with two tests to validate the behavior of adding reserved keywords in expressions. Refactors the `Configure` method in `ExpressionHelper.cs` to use a centralized dictionary for managing reserved keywords, improving clarity and maintainability. Updates `using` directives to include `System.Threading.Tasks` for potential asynchronous operations.
Updated test methods in AsyncExtendedExpressionTests.cs to simplify implementations and adjust static parameters for reserved keywords. Enhanced error handling in ExpressionHelper.cs by adding an exception for reserved keyword usage in parameters.
Introduce asynchronous functionality in the NCalc library, enhancing the `AsyncExtendedExpressionTests` and `ExtendedExpressionTests` with tests for custom async functions. Modify `AsyncExpressionWrapper` to improve async expression evaluation and update `ExpressionHelper` for better async function handling. These changes improve the library's flexibility and usability in non-blocking scenarios.
Added braces around return statements in if conditions to enhance code clarity and explicitly define scope.
|
@davidnmbond, can you please review this PR as |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
InterClassTeststo expectdoubleinstead ofdecimaland addedStringConcatoption.IsSetTeststo check for null or whitespace instead of empty strings.ToDateTimeTestsfromArgumentExceptiontoNCalcParameterNotDefinedException.ExtendedExpressionconstructor for readability and introducedTidyExpression().FunctionArgswithIFunctionArgsacross multiple files for consistency.AsyncExpressionWrapper,AsyncExtendedExpression, andAsyncFunctionArgsWrapperfor async evaluation.ExpressionHelperfor better parameter configuration and count checking.NCalc.Core,NCalcAsync, andNCalcSync.MaxTestsAsyncfor testing maximum value calculations with async expressions.GlobalUsings.csto include new namespaces for async functionality.