From 62a6b5985d14a4f501ec146bf1e3bdb325da36b5 Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Fri, 6 Feb 2026 14:37:11 +0100 Subject: [PATCH] C#: Add test cases for lambda parameter modifiers. --- .../parameters/LambdaParameterModifiers.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 csharp/ql/test/library-tests/parameters/LambdaParameterModifiers.cs diff --git a/csharp/ql/test/library-tests/parameters/LambdaParameterModifiers.cs b/csharp/ql/test/library-tests/parameters/LambdaParameterModifiers.cs new file mode 100644 index 00000000000..fa5bd7c7ce9 --- /dev/null +++ b/csharp/ql/test/library-tests/parameters/LambdaParameterModifiers.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; + +public class LambdaParameterModifiers +{ + delegate void MyRef(ref int i1); + delegate void MyOut(out int i2); + delegate void MyIn(in int i3); + delegate void MyRefReadonly(ref readonly int i4); + + delegate void MyScopedRef(scoped ref int i5); + + public void M() + { + // Explicitly typed lambda parameters with modifiers. + var l1 = (ref int x1) => x1; + var l2 = (out int x2) => x2 = 0; + var l3 = (in int x3) => x3; + var l4 = (ref readonly int x4) => x4; + var l5 = (scoped ref int x5) => x5; + var l6 = (params IEnumerable x6) => x6; + + // Implicitly typed lambda parameters with modifiers. + MyRef l7 = (ref i1) => { }; + MyOut l8 = (out i2) => i2 = 0; + MyIn l9 = (in i3) => { }; + MyRefReadonly l10 = (ref readonly i4) => { }; + MyScopedRef l11 = (scoped ref i5) => { }; + } +}