Open voroninp opened 2 months ago
Tagging subscribers to this area: @dotnet/area-system-reflection See info in area-owners.md if you want to be subscribed.
Tagging subscribers to this area: @cston See info in area-owners.md if you want to be subscribed.
Description
Method
public static MemberExpression Property(Expression? expression, MethodInfo propertyAccessor)
throwsSystem.ArgumentException: 'The method 'X' is not a property accessor (Parameter 'propertyAccessor')'
for getters reflected via descendant class.Internally this method looks for the property having same getter as passed method:
The only problem is that getters reflected via ancestor and descendant differ!
Type? type =mi.DeclaringType;
is the core thing.It should be
Type? type = mi.ReflectedType
;Reproduction Steps
See this repo to reproduce.
Method
public static MemberExpression Property(Expression? expression, MethodInfo propertyAccessor)
Expected behavior
It should just work.
Actual behavior
If fails.
Regression?
I have no clue.
Known Workarounds
If I use an overload version:
it works ok. And it's obviously faster because there's no search for the property. But anyway...
Configuration
No response
Other information
No response