VB -> C#: Cannot convert QueryExpressionSyntax, System.InvalidOperationException: Sequence contains more than one element when converting a specific Linq query
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Usa la query VB segnalata come riproduzione e inizia da QueryConverter.ConvertSelectClauseAsync, identificato nello stack trace. Confronta la sua conversione delle clausole Select e Order By con l'output C# previsto, quindi verifica che la query venga convertita senza l'errore Sequence contains more than one element.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
VB.Net input code
Dim fields = (From v In _DisplayFields Select Value = v, Name = [Enum].GetName(GetType(Field), v) Order By Value Ascending).ToArray
note that the following works fine, which is functionally identical:
Dim fields = _DisplayFields.Select(Function(v) New With {.Value = v, .Name = [Enum].GetName(GetType(Field), v)}).OrderBy(Function(x) x.Value).ToArray
Erroneous output
var fields = 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](IEnumerable1 source) at ICSharpCode.CodeConverter.CSharp.QueryConverter.<ConvertSelectClauseAsync>d__34.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at ICSharpCode.CodeConverter.Common.EnumerableExtensions.<YieldAsync>d__61.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at ICSharpCode.CodeConverter.CSharp.QueryConverter.d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at ICSharpCode.CodeConverter.CSharp.QueryConverter.d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at ICSharpCode.CodeConverter.CSharp.QueryConverter.d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at ICSharpCode.CodeConverter.CSharp.QueryConverter.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.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.d__12`1.MoveNext()
Input:
From v In _DisplayFields Select Value = v, Name = [Enum].GetName(GetType(Field), v) Order By Value Ascending
*/
.ToArray();
Expected output
var fields = (from v in _DisplayFields select new {Value = v, Name = Enum.GetName(typeof(Field), v)} orderby Value).ToArray();
Details
VS extension 9.2.7.0
- Lingua principale
- C#
- Stelle
- 913
- Fork
- 244
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di icsharpcode/CodeConverter
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
icsharpcode/CodeConverter#1271 · 1 commento ·
-
C# -> VB
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
icsharpcode/CodeConverter#1281 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
icsharpcode/CodeConverter#1275 ·
-
VB -> C#
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
icsharpcode/CodeConverter#1273 ·
-
VB -> C#: "Group By Into" Linq queries supressing aggregations ("Into" part) in the converted code ApertaDifficult area VB -> C#
Difficoltà 3/5 1-2 giorni Idoneità per principianti 74/100
icsharpcode/CodeConverter#1272 ·
Tutte le issue di icsharpcode/CodeConverter
Issue simili
-
type/automation type/tech-debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
t/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
ci-failure-cause test-failure
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
area:auth FE mvp P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
klasolsson81/jobbliggaren#1788 ·