Skip to content

Commit

Permalink
Support types that provide DisposeAsync without implementing IAsyncDi…
Browse files Browse the repository at this point in the history
…sposable.
  • Loading branch information
siegfriedpammer committed Jul 19, 2024
1 parent 783c934 commit a5ed5ec
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions ICSharpCode.Decompiler/IL/Transforms/UsingTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,9 @@ bool MatchDisposeCheck(ILVariable objVar, ILInstruction checkInst, bool isRefere
}
disposeCall = cv;
}
if (disposeCall.Method.FullName != disposeMethodFullName)
if (disposeCall.Method.IsStatic)
return false;
if (disposeCall.Method.Name != "DisposeAsync")
return false;
if (disposeCall.Method.Parameters.Count > 0)
return false;
Expand Down Expand Up @@ -505,9 +507,14 @@ bool UnwrapAwait(ref ILInstruction awaitInstruction)
return false;
if (!awaitInstruction.MatchAwait(out var arg))
return false;
if (!arg.MatchAddressOf(out awaitInstruction, out var type))
return false;
// TODO check type: does it match the structural 'Awaitable' pattern?
if (arg.MatchAddressOf(out var awaitInstructionInAddressOf, out var type))
{
awaitInstruction = awaitInstructionInAddressOf;
}
else
{
awaitInstruction = arg;
}
return true;
}
}
Expand Down

0 comments on commit a5ed5ec

Please sign in to comment.