Browse Source

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
pull/3878/head
Siegfried Pammer 2 months ago committed by Siegfried Pammer
parent
commit
5a6e1515eb
  1. 19
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/OutVariables.cs

19
ICSharpCode.Decompiler.Tests/TestCases/Pretty/OutVariables.cs

@ -111,5 +111,24 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -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);
}
}
}

Loading…
Cancel
Save