You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit adds support for evaluating Nullable<T>.HasValue when the original nullable constant's HasValue is false.
Nullable<T> is tricky to use with reflection because of it's special runtime behavior. This manually determines if HasValue was false, and in that case returns a constant expression of false.
ealsur
changed the title
Linq: support constant evaluation of Nullable<T>.HasValue
Linq: Adds support constant evaluation of Nullable<T>.HasValue
Jun 21, 2022
@ccurrens It looks like the last commit is failing on the LinqTranslationBaselineTests.TestMemberAccess I'll try rerunning everything, but the error is:
@ccurrens It looks like the last commit is failing on the LinqTranslationBaselineTests.TestMemberAccess I'll try rerunning everything, but the error is:
Thanks for the heads up. I messed up the conversion of the first pattern expression back to what it needed to be. I'll post up the fix in just a minute.
targetConstant is { Value: null } was doing a null check on targetConstant and on targetConstant.Value. I only did the latter.
The property pattern for targetConstant is { Value: null } and the new check targetConstant != null && targetConstant.Value == null produce the same assembly (under x64 ryuJit at least), but I've leave it as discrete checks instead of the pattern match. Seemed safer since I don't know about other architectures.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This commit adds support for evaluating
Nullable<T>.HasValue
when the original nullable constant'sHasValue
is false.Nullable<T>
is tricky to use with reflection because of it's special runtime behavior. This manually determines ifHasValue
was false, and in that case returns a constant expression offalse
.More details are in #3272.
Type of change
Closing issues
closes #3272