dotnet / dotNext

Next generation API for .NET
https://dotnet.github.io/dotNext/
MIT License
1.62k stars 121 forks source link

`ExpressionBuilder.Property(...)` returns `Expression` instead of `MemberExpression` #187

Closed alexrp closed 1 year ago

alexrp commented 1 year ago

See:

https://github.com/dotnet/dotNext/blob/fd2c4e08efb9a132c8a2f26ecb385e4133ca9a0d/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs#L766-L808

This makes it difficult to write something like thing.Property(...).Assign(...).

sakno commented 1 year ago

Hi @alexrp . That's correct, because then branch returns MemberExpression while else branch returns IndexExpression. Common parent for these types is Expression.

sakno commented 1 year ago

However, it is possible to split this method on two overloads and provide precise return type.

sakno commented 1 year ago

Could you please check a new API in commit? Is that what you expect?

alexrp commented 1 year ago

Yep, LGTM.