Skip to content

Query: Make our reflection info selection logic deterministic #8060

@divega

Description

@divega

We often need to query reflection to find a specific MethodInfo, e.g. to generate the right expressions or to identify expressions that we can translate.

Currently we have places that uses patterns that are not resilient to the introduction of new overloads. E.g. issue #8021 is about the introduction of new overloads of String.Replace() breaking an assumption in our code that only one overload would matched certain conditions.

In other words, we should use reflection in a way that doesn't break when non-breaking changes (such as introducing new overloads) happen 😄

The general approach is to fully specify method parameter types when we query. We can also look at using GetMethod(string, Type[]) when we can (as they do it in https://github.com/dotnet/corefx/blob/master/src/System.Linq.Expressions/src/System/Linq/Expressions/Common/CachedReflectionInfo.cs for Queryable) since it results in simpler looking code when you are fully specifying parameter types.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions