Skip to content

Add regression tests for the remaining open LINQ issues - #1307

Merged
GrahamTheCoder merged 3 commits into
icsharpcode:masterfrom
GrahamTheCoder:claude/linq-open-issues
Nov 10, 2026
Merged

GrahamTheCoder merged 3 commits into
icsharpcode:masterfrom
GrahamTheCoder:claude/linq-open-issues

Conversation

@GrahamTheCoder

@GrahamTheCoder GrahamTheCoder commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Fixes #932
Fixes #1302
Fixes #895

All three already convert correctly on master since #1305. This PR only adds tests to pin that.

#932: Group By keys named differently from their members

  • New conversion test Issue932_GroupByKeysNamedDifferentlyFromTheirMembersAsync, using the issue's query. The keys keep their names (new { Agent_First_Name = agent.First_Name, ... }) and the output compiles.
  • New self-verifying test TestGroupByKeysNamedDifferentlyFromTheirMembers. It runs a joined Group By with renamed keys in both VB and C# and compares the results.

#1302: generic method inference with a contravariant base-type comparer

VB infers an extension method's type arguments from the receiver first, then converts the other arguments; C# infers from all arguments together, so would infer BaseValue here. Where an argument only fits its generic parameter via a variance conversion, the converter now states the type arguments VB inferred: values.Distinct<DerivedValue>(EqualityComparer<BaseValue>.Default).

  • Conversion test Issue1302_GenericMethodInferenceWithBaseTypeComparerAsync (the issue's code) and self-verifying test TestGenericMethodInferenceWithBaseTypeComparer.
  • GenericMethodWithInterfaceConversionKeepsTypeArgumentsInferredAsync checks an ordinary interface conversion doesn't add type arguments.
  • The first version of this PR expected a cast that only some environments produced, which is why CI failed.

#895: Where after Group By

Already covered:

  • by the conversion test Issue895_LinqWhereAfterGroupAsync, which now expects where Group.Count() > 1 select new { x = Group.Key, Group };
  • by the self-verifying test TestWhereAfterGroup, which runs the issue's query in VB and C#.

The conversions for icsharpcode#932 (Group By keys named differently from their members) and
icsharpcode#1302 (generic method inference with a contravariant base-type comparer) are
already correct; these tests pin them, including running the VB and converted C#.
icsharpcode#895 is already covered by Issue895_LinqWhereAfterGroupAsync and TestWhereAfterGroup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FEr8GSsdfh4WNGNkwrb9G
…eeds a variance conversion

VB infers an extension method's type arguments from the receiver first, then
converts the other arguments, whereas C# infers from all of them together:
`values.Distinct(EqualityComparer(Of BaseValue).Default)` makes C# infer BaseValue.

The test for icsharpcode#1302 previously passed only because, in some environments, the
converter happened to cast the comparer; CI's references don't produce that cast.

Fixes icsharpcode#1302

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FEr8GSsdfh4WNGNkwrb9G
…access

The icsharpcode#1302 fix skipped any inferred type parameter, including the caller's own
nameable ones, and only handled member access, not ?. member binding, so both
shapes still made C# infer the base type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FEr8GSsdfh4WNGNkwrb9G
@GrahamTheCoder
GrahamTheCoder merged commit 624ffc9 into icsharpcode:master Nov 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants