vendredi 3 août 2018

What changed in Asp.Net Core 2.1 to introduce an abigous match for getting the contains method with reflection

In Asp.Net Core 2.0 the following method worked without any exceptions:

    private static Expression Contains(Expression member, ConstantExpression constant)
    {
        return Expression.Call(member, typeof(String).GetMethod("Contains"), constant);
    }

But as soon as we moved to 2.1 it threw an ambiguous match exception. We where able to correct the issue by providing a type argument. Shown in the message below:

        private static Expression Contains(Expression member, ConstantExpression constant)
        {
            return Expression.Call(member, typeof(String).GetMethod("Contains", new Type[] {typeof(string) }), constant);
        }

We haven't had any other issues like this since the switch, but I was curios if there was a change that will make this issue occur in other places.





Aucun commentaire:

Enregistrer un commentaire