The documentation of the expression parameter of Expression.PropertyOrField states that it can be null for static members:
An Expression whose
Typecontains a property or field namedpropertyOrFieldName. This can benullfor static members.
(Emphasis mine)
However, whenever I pass null I get an ArgumentNullException.
The documentation of this method is contradictory:
expression parameter states that it can be null for static membersArgumentNullException states that it is thrown if expression is null
Fact is:
This method can't be used to get access to static members, the documentation of the expression parameter is incorrect.
Even when an expression with the correct Type is supplied, this method doesn't work as expected, because it only ever looks for instance members.
To access a static field or property, use Expression.MakeMemberAccess instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With