From 4e63b83fd321473aa5df629fcdc21aad716aa9d0 Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Fri, 27 Feb 2026 13:08:28 +0100 Subject: [PATCH] C#: Add struct source model example. --- .../dataflow/external-models/Sources.cs | 6 ++++++ .../dataflow/external-models/srcs.expected | 12 ++++++------ .../dataflow/external-models/srcs.ext.yml | 1 + 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/csharp/ql/test/library-tests/dataflow/external-models/Sources.cs b/csharp/ql/test/library-tests/dataflow/external-models/Sources.cs index 6f73f096ef9..10b8a37cc0f 100644 --- a/csharp/ql/test/library-tests/dataflow/external-models/Sources.cs +++ b/csharp/ql/test/library-tests/dataflow/external-models/Sources.cs @@ -21,6 +21,9 @@ namespace My.Qltest x = TaggedSrcPropertyGetter; x = this[0]; + + S s; + StructSrc(s); } [SourceAttribute] @@ -65,7 +68,10 @@ namespace My.Qltest [SourceAttribute] object this[int i] => null; + + void StructSrc(S s) { } } + struct S { } class SourceAttribute : System.Attribute { } } diff --git a/csharp/ql/test/library-tests/dataflow/external-models/srcs.expected b/csharp/ql/test/library-tests/dataflow/external-models/srcs.expected index 855e51fca56..d689f2b3f4c 100644 --- a/csharp/ql/test/library-tests/dataflow/external-models/srcs.expected +++ b/csharp/ql/test/library-tests/dataflow/external-models/srcs.expected @@ -11,9 +11,9 @@ invalidModelRow | Sources.cs:20:17:20:33 | call to method SrcTwoArg | local | | Sources.cs:22:17:22:39 | access to property TaggedSrcPropertyGetter | local | | Sources.cs:23:17:23:23 | access to indexer | local | -| Sources.cs:27:14:27:20 | this | local | -| Sources.cs:27:29:27:45 | taggedMethodParam | local | -| Sources.cs:31:47:31:60 | taggedSrcParam | local | -| Sources.cs:43:45:43:45 | p | local | -| Sources.cs:50:50:50:50 | p | local | -| Sources.cs:56:16:56:30 | this | local | +| Sources.cs:30:14:30:20 | this | local | +| Sources.cs:30:29:30:45 | taggedMethodParam | local | +| Sources.cs:34:47:34:60 | taggedSrcParam | local | +| Sources.cs:46:45:46:45 | p | local | +| Sources.cs:53:50:53:50 | p | local | +| Sources.cs:59:16:59:30 | this | local | diff --git a/csharp/ql/test/library-tests/dataflow/external-models/srcs.ext.yml b/csharp/ql/test/library-tests/dataflow/external-models/srcs.ext.yml index ca5103b1cd5..b4dcd75be26 100644 --- a/csharp/ql/test/library-tests/dataflow/external-models/srcs.ext.yml +++ b/csharp/ql/test/library-tests/dataflow/external-models/srcs.ext.yml @@ -19,3 +19,4 @@ extensions: - ["My.Qltest", "SourceAttribute", false, "", "", "Attribute", "", "local", "manual"] - ["My.Qltest", "SourceAttribute", false, "", "", "Attribute.Getter", "ReturnValue", "local", "manual"] - ["My.Qltest", "A", false, "SrcTwoArg", "(System.String,System.String)", "", "ReturnValue", "local", "manual"] + - ["My.Qltest", "A", false, "StructSrc", "", "", "Argument[0]", "local", "manual"]