VB -> C#: InvalidOperationException caused by LINQ GroupBy with multiple properties
まだ誰も着手していません。
評価
調査の方向性
issue 内の QueryConverter のスタックトレースから始め、複数の GroupBy プロパティを使用する VB LINQ クエリを再現します。失敗に関係するサブクエリおよびクエリセグメントの変換を追跡します。再現ケースが InvalidOperationException なしで変換され、グループ化されたクエリに対して有効な C# を生成すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
VB.Net input code
Public Class ConversionTest4
Private Class MyEntity
Property FavoriteNumber As Integer
Property FavoriteColor As String
Property Name As String
End Class
Private Sub BugRepro()
Dim entities As New List(Of MyEntity)
Dim result As IEnumerable(Of String) = From e In entities
Group e By e.FavoriteNumber, e.FavoriteColor Into g1 = Group
Select g1.FirstOrDefault().Name
End Sub
End Class
Erroneous output
public class ConversionTest4
{
private class MyEntity
{
public int FavoriteNumber { get; set; }
public string FavoriteColor { get; set; }
public string Name { get; set; }
}
private void BugRepro()
{
var entities = new List<MyEntity>();
var result = default
#error Cannot convert QueryExpressionSyntax - see comment for details
/* Cannot convert QueryExpressionSyntax, System.InvalidOperationException: Sequence contains more than one element
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
at ICSharpCode.CodeConverter.CSharp.QueryConverter.<ConvertSubQueryAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at ICSharpCode.CodeConverter.CSharp.QueryConverter.<ConvertQueryWithContinuationAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at ICSharpCode.CodeConverter.CSharp.QueryConverter.<ConvertQuerySegmentsAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at ICSharpCode.CodeConverter.CSharp.QueryConverter.<ConvertClausesAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at ICSharpCode.CodeConverter.CSharp.ExpressionNodeVisitor.<VisitQueryExpression>d__68.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at ICSharpCode.CodeConverter.CSharp.CommentConvertingVisitorWrapper.<ConvertHandledAsync>d__8`1.MoveNext()
Input:
From e In entities
Group e By e.FavoriteNumber, e.FavoriteColor Into g1 = Group
Select g1.FirstOrDefault().Name
*/;
}
}
Details
- Product in use: VS extension
- Version in use: 9.2.2.0
- This is a simplified repro code
- I believe this exception happens because the "Group e By" line contains multiple properties to group on.
- 主要言語
- C#
- スター
- 913
- フォーク
- 243
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
icsharpcode/CodeConverter のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
icsharpcode/CodeConverter#1271 · コメント 1 件 ·
-
C# -> VB: most pattern matching fails to convert対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンC# -> VB
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
icsharpcode/CodeConverter#1281 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
icsharpcode/CodeConverter#1275 ·
-
VB -> C#: Handleres of sub properties being untracked対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンVB -> C#
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
icsharpcode/CodeConverter#1273 ·
-
VB -> C#: "Group By Into" Linq queries supressing aggregations ("Into" part) in the converted codeオープンDifficult area VB -> C#
難易度 3/5 1〜2日 初心者へのやさしさ 74/100
icsharpcode/CodeConverter#1272 ·
icsharpcode/CodeConverter の issue をすべて見る
似ている issue
-
[Doc Gap] Document new --enable-public-network-access breaking change for azurebackup vault createオープンcopilot documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
area-dashboard
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
0 - Backlog Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
BrighterCommand/Brighter#4539 ·
メンテナーはふだん 1 日以内に返信
-
area-networking
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
dotnet/aspnetcore#69671 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Ignored test: FileLocalDataSourceTests.retries_loading_file対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンtest
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
NethermindEth/nethermind#14274 ·
メンテナーはふだん 1 日以内に返信