From d75379c0cf3677806d28f318bc5cd8de3c393567 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 4 Jul 2026 13:15:02 +0200 Subject: [PATCH] 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 --- .../TestCases/Pretty/UsingVariables.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/UsingVariables.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/UsingVariables.cs index e7a87435b..84cd63884 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/UsingVariables.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/UsingVariables.cs @@ -17,12 +17,25 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.Runtime.InteropServices; #if !NET40 using System.Threading.Tasks; #endif 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 IDisposable GetDisposable() @@ -96,5 +109,13 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty Use(asyncDisposable); } #endif + + public void UsingVarPatternBasedDispose() + { + Console.WriteLine("before using"); + using RefStructWithDispose refStructWithDispose = default(RefStructWithDispose); + Console.WriteLine("inside using"); + refStructWithDispose.Use(); + } } }