From 5a6e1515eb788fb7d7d676de71d70cd70b75c16c Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Mon, 6 Jul 2026 22:24:16 +0200 Subject: [PATCH] Add test for out-var reference nested within another argument CS8196 also fires when the second reference sits inside a nested call in another argument of the declaring call, e.g. OutAndValue(out var a, UseAndReturn(out a)). The existing check already covers this because it walks all descendants of the sibling arguments; this fixture pins that behavior. Assisted-by: Claude:claude-fable-5:Claude Code --- .../TestCases/Pretty/OutVariables.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/OutVariables.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/OutVariables.cs index 45cb081ab..a7cfc0d42 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/OutVariables.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/OutVariables.cs @@ -111,5 +111,24 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty GetTwo(out int a, out a); return a; } + + private static void OutAndValue(out int a, int b) + { + a = b; + } + + private static int UseAndReturn(out int a) + { + a = 1; + return a; + } + + public static void SameVariableUsedInNestedCallArgument() + { + // CS8196 also applies when the second reference is nested within + // another argument of the declaring call. + OutAndValue(out int a, UseAndReturn(out a)); + Console.WriteLine(a); + } } }