Skip to content

Commit 2aa2535

Browse files
committed
Correction of a bug in method to call selection
1 parent f60cf63 commit 2aa2535

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

CodingSeb.ExpressionEvaluator.Tests/ExpressionEvaluatorTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,13 @@ public void TypeTesting(string expression, Type type)
985985

986986
#endregion
987987

988+
#region Bugs correction
989+
990+
[TestCase("new DateTime(1985,9,11).ToString(\"dd.MM.yyyy\")", ExpectedResult = "11.09.1985", Category = "Complex expression,Static method,Instance method,Lambda function,Cast")]
991+
992+
#endregion
993+
994+
988995
#endregion
989996
public object DirectExpressionEvaluation(string expression)
990997
{

CodingSeb.ExpressionEvaluator/ExpressionEvaluator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3180,10 +3180,10 @@ bool parameterValidate(ParameterInfo p) => p.Position >= modifiedArgs.Count
31803180
|| (p.ParameterType.IsByRef && argsWithKeywords.Any(a => a.Index == p.Position + (testForExtention ? 1 : 0)));
31813181

31823182
bool methodByNameFilter(MethodInfo m) => m.Name.Equals(func, StringComparisonForCasing)
3183-
&& (m.GetParameters().Length == modifiedArgs.Count
3184-
|| (m.GetParameters().Length > modifiedArgs.Count && m.GetParameters().Take(modifiedArgs.Count).All(p => modifiedArgs[p.Position] == null || IsCastable(modifiedArgs[p.Position].GetType(), p.ParameterType)) && m.GetParameters().Skip(modifiedArgs.Count).All(p => p.HasDefaultValue))
3185-
|| (m.GetParameters().Last().IsDefined(typeof(ParamArrayAttribute), false)
3186-
&& m.GetParameters().All(parameterValidate)));
3183+
&& (m.GetParameters().Length == modifiedArgs.Count
3184+
|| (m.GetParameters().Length > modifiedArgs.Count && m.GetParameters().Take(modifiedArgs.Count).All(p => modifiedArgs[p.Position] == null || IsCastable(modifiedArgs[p.Position].GetType(), p.ParameterType)) && m.GetParameters().Skip(modifiedArgs.Count).All(p => p.HasDefaultValue))
3185+
|| (m.GetParameters().Length > 0 && m.GetParameters().Last().IsDefined(typeof(ParamArrayAttribute), false)
3186+
&& m.GetParameters().All(parameterValidate)));
31873187

31883188
List<MethodInfo> methodInfos = type.GetMethods(flag)
31893189
.Where(methodByNameFilter)

0 commit comments

Comments
 (0)