Browse Source

Support types that provide DisposeAsync without implementing IAsyncDisposable.

pull/3243/head
Siegfried Pammer 1 year ago
parent
commit
a5ed5ec5cb
  1. 15
      ICSharpCode.Decompiler/IL/Transforms/UsingTransform.cs

15
ICSharpCode.Decompiler/IL/Transforms/UsingTransform.cs

@ -367,7 +367,9 @@ namespace ICSharpCode.Decompiler.IL.Transforms
} }
disposeCall = cv; disposeCall = cv;
} }
if (disposeCall.Method.FullName != disposeMethodFullName) if (disposeCall.Method.IsStatic)
return false;
if (disposeCall.Method.Name != "DisposeAsync")
return false; return false;
if (disposeCall.Method.Parameters.Count > 0) if (disposeCall.Method.Parameters.Count > 0)
return false; return false;
@ -505,9 +507,14 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return false; return false;
if (!awaitInstruction.MatchAwait(out var arg)) if (!awaitInstruction.MatchAwait(out var arg))
return false; return false;
if (!arg.MatchAddressOf(out awaitInstruction, out var type)) if (arg.MatchAddressOf(out var awaitInstructionInAddressOf, out var type))
return false; {
// TODO check type: does it match the structural 'Awaitable' pattern? awaitInstruction = awaitInstructionInAddressOf;
}
else
{
awaitInstruction = arg;
}
return true; return true;
} }
} }

Loading…
Cancel
Save