-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translate Math.PI #25219
Translate Math.PI #25219
Conversation
Check.NotNull(logger, nameof(logger)); | ||
|
||
if (member.Name == nameof(Math.PI) | ||
&& instance?.Type == typeof(double)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Math.PI
is a static member access. So the instance is always null hence this check fails.
Correct check (apart from matching member.Name) would be member.DeclaringType == typeof(Math)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(also check instance is null)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I will fix that but first I need to run it. To see that the translator at least runs
You will also need to mark it as non-evaluatable in parameter extraction. https://github.com/dotnet/efcore/blob/main/src/EFCore.SqlServer/Query/Internal/SqlServerEvaluatableExpressionFilter.cs |
@smitpatel thanks for the advice |
With that expression tree, we cannot add translation. That expression tree indicates that LINQ compiler inline the constant value when generating expression tree which happens even before the tree reaches EF Core. cc: @bricelam |
Lame. Probably not worth translating, then. |
Closing the PR. Will add notes on the issue. @Marusyk - Thanks for investigating this. |
Issue #25049
I've added a new member translator. I expected that it will run after this test
Could you please suggest what I am doing wrong?
It just translates
Math.PI
to constant without calling my translator. It seems I missed something 🤔