First of all, thanks to all of the contributors for this project.
This is a very rare case, but it exists in our project. The issue happens when descendant class overrides indexer with new keyword and sets a different return type. In this case, Parserfinds two applicable methods, calls MethodHasPriority, and then fails here because MethodBase is null for IndexerData.
Unit test code to reproduce:
public class A
{
public string this[int index] => "some string";
}
public class B : A
{
public new int this[int index] => 25;
}
[Test]
public void Test()
{
var b = new B();
var interpreter = new Interpreter();
var lambda = interpreter.Parse("this[0]", new Parameter("this", b));
var res = lambda.Invoke(b);
Assert.AreEqual(25, res);
}
I investigated the code, and, if this is ok, I would like to create a pull request with suggested solution for this issue.
Hello!
First of all, thanks to all of the contributors for this project.
This is a very rare case, but it exists in our project. The issue happens when descendant class overrides indexer with
new
keyword and sets a different return type. In this case,Parser
finds two applicable methods, callsMethodHasPriority
, and then fails here becauseMethodBase
isnull
forIndexerData
.Unit test code to reproduce:
I investigated the code, and, if this is ok, I would like to create a pull request with suggested solution for this issue.