Four await shapes decompile to uncompilable C#
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
Direzione di ricerca
Inizia con i quattro membri che falliscono in ICSharpCode.Decompiler.Tests/TestCases/Pretty/AsyncAwaitPatternsBugs.cs sul branch tests/async-await-patterns. Esegui i test async-await-patterns, poi esamina VisitAwait e la gestione di LdObjIfRef in ExpressionBuilder insieme ai controlli dynamic-call e record-with. Il lavoro è completato quando tutti e quattro i casi vengono decompilati in C# compilabile e i test del fixture passano.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Four await shapes decompile to C# that does not compile. All four reproduce on
master @ 40e6f2cf2 and still reproduce after 257c96711 ("Avoid allowImplicitConversion: true
for await expressions"), which fixed a different set of await defects.
Each of them is covered by a member of ICSharpCode.Decompiler.Tests/TestCases/Pretty/AsyncAwaitPatternsBugs.cs
on the tests/async-await-patterns branch, where the fixture is written as the C# that should
come out; the test is red for exactly these four.
1. Extension GetAwaiter taking its receiver by in
public struct ByRefReceiver
{
public long A;
public long B;
public TaskAwaiter Self() => default(TaskAwaiter);
}
public static class ByRefExtensions
{
public static TaskAwaiter GetAwaiter(this in ByRefReceiver receiver) => receiver.Self();
}
public async Task InReceiverExtensionAwaiter(ByRefReceiver value)
{
await value;
}
decompiles to:
public unsafe async Task InReceiverExtensionAwaiter(ByRefReceiver value)
{
await (ref *(ByRefReceiver*)value);
}
error CS1525: Invalid expression term 'ref'. The method also acquires an unsafe modifier it
did not have. The in parameter makes the awaited expression's expected type a
ByReferenceType; VisitAwait strips the DirectionExpression off the operand before
converting it.
2. await on a type parameter constrained to an awaitable interface
public interface IAwaitable
{
TaskAwaiter GetAwaiter();
}
public async Task TypeParameterWithInterfaceConstraint<T>(T value) where T : IAwaitable
{
await value;
}
decompiles to:
await (IAwaitable)/*OpCode not supported: LdObjIfRef*/;
error CS0119: 'IAwaitable' is a type, which is not valid in the given context. The operand is
not merely wrong, it is dropped: the constrained. callvirt lowers to an LdObjIfRef that
ExpressionBuilder has no case for.
3. dynamic await inside the argument list of a static call
public async Task DynamicAwaitInStaticCall(dynamic value)
{
Console.WriteLine("x" + await value);
}
decompiles to:
Type typeFromHandle = typeof(Console);
typeFromHandle.WriteLine("x" + await value);
error CS1061: 'Type' does not contain a definition for 'WriteLine'. The call site's
typeof(TargetType) marker argument becomes the receiver. Isolated against two controls: the
same call without the await, and an instance dynamic call with an await, both decompile
correctly.
4. await inside a record with initializer
public record Record(int X);
public async Task<Record> WithExpressionContainingAwait(Record value)
{
return value with { X = await Get() };
}
decompiles to:
Record record = value._003CClone_003E_0024();
Record record2 = record;
record2.X = await Get();
return record;
which does not compile. Isolated against two controls: value with { X = 1 } and
value with { X = Compute() } both round-trip as with expressions, so the await is what
defeats the transform.
Posted by an AI agent (Claude) on Siegfried's behalf.
- Lingua principale
- C#
- Stelle
- 27.1k
- Fork
- 3.8k
- Merge medio
- 1g 23h
- PR unite (30g)
- 44
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi 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/ILSpy
-
AvaloniaEdit Issues to dateApertaExternal UI
Difficoltà 1/5 1-3 ore Idoneità per principianti 75/100
icsharpcode/ILSpy#4284 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
icsharpcode/ILSpy#4357 ·
I maintainer di solito rispondono entro 1 giorno
-
Misdecompilation of a lazy initialization patternForse già presa @siegfriedpammer l’ha presa 5 giorni fa. ApertaBug Decompiler
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
icsharpcode/ILSpy#4349 ·
I maintainer di solito rispondono entro 1 giorno
-
Bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
icsharpcode/ILSpy#4343 ·
I maintainer di solito rispondono entro 1 giorno
-
AI
Difficoltà 4/5 1-2 giorni Idoneità per principianti 55/100
icsharpcode/ILSpy#4300 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di icsharpcode/ILSpy
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
umbraco/Umbraco.Automate#612 ·
I maintainer di solito rispondono entro 1 giorno
-
崩溃日志只按 CRLF 分行Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
PCL-Community/PCL-CE#3872 ·
I maintainer di solito rispondono entro 1 giorno
-
type:task ux
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
elsa-workflows/elsa-foundation#5253 ·
I maintainer di solito rispondono entro 1 giorno