VB -> C#: "Group By Into" Linq queries supressing aggregations ("Into" part) in the converted code

Open
#1,272 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
csharp
Domain
devtools

Research direction

Run the supplied VB.NET LINQ input through codeconv.exe and compare its output with the expected C# query. Trace the LINQ Group By/Into conversion entry point and add coverage for the grouped key properties and Max aggregation; done means the reproduced input emits the expected Group.Key and Group.Max expressions.

Written by the indexing model from the issue text.

Description

Difficult area VB -> C#
VB.Net input code
   Public Class Entity
      Public Property Property1 As String
      Public Property Property2 As String
      Public Property Value As Decimal    
   End Class
   
   Dim entityCollection As IEnumerable(Of Entity)
   Dim queryMax = From item In entityCollection
                       Where item.Property1 = "dummy"
                       Group By item.Property1, item.Property2
                       Into ValueMax = Max(item.Value)
                       Select New With {
                           Property1, Property2, ValueMax
                       }
Erroneous output
   var queryMax = from item in entityCollection
                  where item.Property1 == "dummy"
                  group item by new { item.Property1, item.Property2 } into Group
                  select new { Property1, Property2, ValueMax };
Expected output
   var queryMax = from item in entityCollection
                  where item.Property1 == "dummy"
                  group item by new { item.Property1, item.Property2 } into Group
                  select new { Property1 = Group.Key.Property1, Property2 = Group.Key.Property2, ValueMax = Group.Max(i => i.Value) };

Details
  • Product in use: codeconv.exe (dotnet tool)
  • Version in use: 10.0.1.92
  • Did you see it working in a previous version, which? No
Dominant language
C#
Stars
913
Forks
244
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from icsharpcode/CodeConverter

All issues in icsharpcode/CodeConverter

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.