Browse Source

Add pretty test for pattern-based Dispose of a ref struct

Only interface-based disposal was covered; a using declaration over
a ref struct with a pattern-based Dispose exercises the recognition
heuristic without IDisposable.

Assisted-by: Claude:claude-fable-5:Claude Code
pull/3857/head
Siegfried Pammer 3 days ago committed by Siegfried Pammer
parent
commit
d75379c0cf
  1. 21
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/UsingVariables.cs

21
ICSharpCode.Decompiler.Tests/TestCases/Pretty/UsingVariables.cs

@ -17,12 +17,25 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Runtime.InteropServices;
#if !NET40 #if !NET40
using System.Threading.Tasks; using System.Threading.Tasks;
#endif #endif
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{ {
[StructLayout(LayoutKind.Sequential, Size = 1)]
internal ref struct RefStructWithDispose
{
public void Use()
{
}
public void Dispose()
{
}
}
public class UsingVariables public class UsingVariables
{ {
public IDisposable GetDisposable() public IDisposable GetDisposable()
@ -96,5 +109,13 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Use(asyncDisposable); Use(asyncDisposable);
} }
#endif #endif
public void UsingVarPatternBasedDispose()
{
Console.WriteLine("before using");
using RefStructWithDispose refStructWithDispose = default(RefStructWithDispose);
Console.WriteLine("inside using");
refStructWithDispose.Use();
}
} }
} }

Loading…
Cancel
Save