numeric-only zero check, unambiguous overload lookups - #89
Open
koenbeuk wants to merge 1 commit into
Open
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Two moderate issues remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR improves ConvertLoopsToLinq numeric-zero detection and LINQ overload selection.
Changes:
- Narrows numeric constant handling.
- Disambiguates
Where,Select, and Min/Max overloads. - Adds regression and overload-selection tests.
File summaries
| File | Summary and findings |
|---|---|
src/ExpressiveSharp/Transformers/ConvertLoopsToLinq.cs |
Updates zero detection and LINQ method resolution. Moderate (3 votes): Make the guard type-aware and reject nullable/reference defaults before matching Sum. |
tests/ExpressiveSharp.Tests/Transformers/ConvertLoopsToLinqTests.cs |
Adds regression and overload-shape tests. Moderate (1 vote): Add transformer-level assertions covering selected delegate parameter types, including Min/Max selectors. |
Review details
Suppressed comments (1)
tests/ExpressiveSharp.Tests/Transformers/ConvertLoopsToLinqTests.cs:325
- This test only counts
Enumerablemethods using the same reflection predicate as production; it would pass even if the transformer still used the old unfilteredFirst, and it never exercises the changed selector-based Min/Max lookup. Add transformer-level assertions that inspect the selected delegate parameter type (including a Min/Max selector case) so the overload-resolution change is actually covered.
var whereMatches = typeof(Enumerable).GetMethods(BindingFlags.Public | BindingFlags.Static)
.Count(m => m.Name == "Where" && m.IsGenericMethodDefinition && m.GetParameters().Length == 2
&& m.GetParameters()[1].ParameterType.GetGenericArguments().Length == 2);
var selectMatches = typeof(Enumerable).GetMethods(BindingFlags.Public | BindingFlags.Static)
.Count(m => m.Name == "Select" && m.IsGenericMethodDefinition
&& m.GetParameters().Length == 2
&& m.GetGenericArguments().Length == 2
&& m.GetParameters()[1].ParameterType.GetGenericArguments().Length == 2);
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+543
to
+547
| if (expr is ConstantExpression { Value: not null } constant) | ||
| { | ||
| return Convert.ToDouble(constant.Value) == 0.0; | ||
| return constant.Value switch | ||
| { | ||
| byte v => v == 0, |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.