Parser.MethodHasPriority regression
See original GitHub issueMethod Parser.MethodHasPriority causes a regression in my tests. None of two possible methods is chosen.
methods:
0: {System.Collections.Generic.IEnumerable`1[System.Object] Select[TSource] System.Collections.Generic.IEnumerable`1[TSource], System.String)}
1: {System.Collections.Generic.IEnumerable`1[System.Object] Select(System.Collections.IEnumerable, System.String)}
and args passed:
0: {System.Collections.Generic.List`1[System.Object]}
1: {System.String}
See following test example…
namespace EvalTest
{
using System.Collections;
using System.Collections.Generic;
using DynamicExpresso;
using NUnit.Framework;
[TestFixture]
public class EvalTest
{
private Interpreter interpreter = new Interpreter();
[OneTimeSetUp]
public void Setup()
{
this.interpreter.Reference(typeof(Utils));
}
[Test]
public void EvaluateTest()
{
var list = new[] { 1, 2, 3 };
Assert.DoesNotThrow(() => { this.Evaluate("Utils.Array(1, 2, 3)"); });
Assert.DoesNotThrow(() => { this.Evaluate("Utils.Select(Utils.Array(\"a\", \"b\"), \"x+x\")"); });
}
private object Evaluate(string expression, params Parameter[] parameters)
{
return this.interpreter.Parse(expression, parameters).Invoke(parameters);
}
}
public class Utils
{
public static List<T> Array<T>(IEnumerable<T> collection)
{
return new List<T>(collection);
}
public static List<dynamic> Array(params dynamic[] array)
{
return Array((IEnumerable<dynamic>)array);
}
public static IEnumerable<dynamic> Select<TSource>(IEnumerable<TSource> collection, string expression)
{
return new List<dynamic>();
}
public static IEnumerable<dynamic> Select(IEnumerable collection, string expression)
{
return new List<dynamic>();
}
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
An Improved Kriging Model based on Differential Evolution
Abstract. Kriging model is a commonly interpolate approximation method which is widely used in the computer simulation in the past decade. The fitting....
Read more >pickle — Python object serialization | Docs4dev
The pickle module implements binary protocols for serializing and de-serializing a Python object structure. “Pickling” is the process whereby a ...
Read more >Annual Research Report
access method has priority but other methods with the applicability to each unit ... Straight line shows regression ... Heating Furnace for Thermal...
Read more >2015-December.txt - Python mailing list
+ +- Issue #25555: Fix parser and AST: fill lineno and col_offset of ... + +- Issue #25446: Fix regression in smtplib's AUTH...
Read more >berberine combined treatment: Topics by ...
Partial least square regression models based on these 268 OTUs were established ... so we can say that this method has priority compared...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@davideicardi no, it doesn’t solve the issue; I still have to fix the
MethodHasPriority
bug. It’s a bit tricky because I have to handle both the fix for this bug, while not breaking the lambda expression support.PR #192 is not really needed to fix this bug, but I found it weird to use dynamic instead of generics, which is how I realized that it was not possible to use generics with params array.
@waclaw66
Utils.Array
was indeed ok, but you’ll now be able to use generics to have a more strongly typed List:Note that the issue occurs because the
Select
method has two overloads that clash with the current resolution; removing either overload should solve the issue.