Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade from CoreCLR-NCalc to the latest NCalc version #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions PanoramicData.NCalcExtensions/ExtendedExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ public class ExtendedExpression : Expression
private readonly CultureInfo _cultureInfo;
internal const string StorageDictionaryParameterName = "__storageDictionary";

public ExtendedExpression(string expression) : this(expression, EvaluateOptions.None, CultureInfo.InvariantCulture) { }
public ExtendedExpression(string expression) : this(expression, ExpressionOptions.None, CultureInfo.InvariantCulture) { }

public ExtendedExpression(
string expression,
EvaluateOptions evaluateOptions,
ExpressionOptions evaluateOptions,
CultureInfo cultureInfo) : base(expression, evaluateOptions, cultureInfo)
{
_cultureInfo = cultureInfo;
Parameters[StorageDictionaryParameterName] = _storageDictionary;
EvaluateFunction += Extend;
CacheEnabled = false;
Options |= ExpressionOptions.NoCache;

if (Parameters.ContainsKey("null"))
{
throw new InvalidOperationException("You may not set a parameter called 'null', as it is a reserved keyword.");
Expand Down
6 changes: 3 additions & 3 deletions PanoramicData.NCalcExtensions/Extensions/If.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal static void Evaluate(FunctionArgs functionArgs)
}
catch (Exception e) when (e is not NCalcExtensionsException or FormatException)
{
throw new FormatException($"Could not evaluate {ExtensionFunction.If} function parameter 1 '{functionArgs.Parameters[0].ParsedExpression}'.");
throw new FormatException($"Could not evaluate {ExtensionFunction.If} function parameter 1 '{functionArgs.Parameters[0].LogicalExpression}'.");
}

if (boolParam1)
Expand All @@ -47,7 +47,7 @@ internal static void Evaluate(FunctionArgs functionArgs)
}
catch (Exception e) when (e is not NCalcExtensionsException or FormatException)
{
throw new FormatException($"Could not evaluate {ExtensionFunction.If} function parameter 2 '{functionArgs.Parameters[1].ParsedExpression}' due to {e.Message}.", e);
throw new FormatException($"Could not evaluate {ExtensionFunction.If} function parameter 2 '{functionArgs.Parameters[1].LogicalExpression}' due to {e.Message}.", e);
}
}

Expand All @@ -57,7 +57,7 @@ internal static void Evaluate(FunctionArgs functionArgs)
}
catch (Exception e) when (e is not NCalcExtensionsException or FormatException)
{
throw new FormatException($"Could not evaluate {ExtensionFunction.If} function parameter 3 '{functionArgs.Parameters[2].ParsedExpression}' due to {e.Message}.", e);
throw new FormatException($"Could not evaluate {ExtensionFunction.If} function parameter 3 '{functionArgs.Parameters[2].LogicalExpression}' due to {e.Message}.", e);
}
}
}
2 changes: 1 addition & 1 deletion PanoramicData.NCalcExtensions/Extensions/Switch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal static void Evaluate(FunctionArgs functionArgs)
}
catch (Exception e) when (e is not NCalcExtensionsException or FormatException)
{
throw new FormatException($"Could not evaluate {ExtensionFunction.Switch} function parameter 1 '{functionArgs.Parameters[0].ParsedExpression}'.");
throw new FormatException($"Could not evaluate {ExtensionFunction.Switch} function parameter 1 '{functionArgs.Parameters[0].LogicalExpression}'.");
}

// Determine the pair count
Expand Down
2 changes: 2 additions & 0 deletions PanoramicData.NCalcExtensions/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
global using NCalc;
global using NCalc.Domain;
global using NCalc.Handlers;
global using Newtonsoft.Json.Linq;
global using PanoramicData.NCalcExtensions.Exceptions;
global using PanoramicData.NCalcExtensions.Extensions;
Expand Down
2 changes: 1 addition & 1 deletion PanoramicData.NCalcExtensions/Lambda.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace PanoramicData.NCalcExtensions;
public class Lambda(
string predicate,
string nCalcString,
Dictionary<string, object?> parameters)
IDictionary<string, object?> parameters)
{
public object? Evaluate<T>(T value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CoreCLR-NCalc" Version="3.1.253" />
<PackageReference Include="NCalcSync" Version="5.3.0" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.146">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down