From 53eb753346b8f02e27a9a7eeeedc30f6e92dfea4 Mon Sep 17 00:00:00 2001 From: Tamas Vajk Date: Wed, 24 Apr 2024 11:50:43 +0200 Subject: [PATCH] C#: Add integration test with multiple versions of the same nuget package --- .../Assemblies.expected | 1 + .../Assemblies.ql | 18 ++++++++++++++++++ .../Program.cs | 6 ++++++ .../d1/test1.csproj | 16 ++++++++++++++++ .../d2/test2.csproj | 16 ++++++++++++++++ .../global.json | 5 +++++ .../test.py | 3 +++ 7 files changed, 65 insertions(+) create mode 100644 csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/Assemblies.expected create mode 100644 csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/Assemblies.ql create mode 100644 csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/Program.cs create mode 100644 csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/d1/test1.csproj create mode 100644 csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/d2/test2.csproj create mode 100644 csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/global.json create mode 100644 csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/test.py diff --git a/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/Assemblies.expected b/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/Assemblies.expected new file mode 100644 index 000000000000..987ec7c8d448 --- /dev/null +++ b/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/Assemblies.expected @@ -0,0 +1 @@ +| [...]/newtonsoft.json/13.0.1/lib/netstandard2.0/Newtonsoft.Json.dll | diff --git a/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/Assemblies.ql b/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/Assemblies.ql new file mode 100644 index 000000000000..cf7f8ef50fe8 --- /dev/null +++ b/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/Assemblies.ql @@ -0,0 +1,18 @@ +import csharp + +private string getPath(Assembly a) { + not a.getCompilation().getOutputAssembly() = a and + exists(string s | s = a.getFile().getAbsolutePath() | + exists(result.indexOf("Newtonsoft.Json")) and + result = + "[...]" + + s.substring(s.indexOf("test-db/working/") + "test-db/working/".length() + 16 + + "/packages".length(), s.length()) + or + result = s and + not exists(s.indexOf("test-db/working/")) + ) +} + +from Assembly a +select getPath(a) diff --git a/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/Program.cs b/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/Program.cs new file mode 100644 index 000000000000..39a9e95bb6e3 --- /dev/null +++ b/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/Program.cs @@ -0,0 +1,6 @@ +class Program +{ + static void Main(string[] args) + { + } +} \ No newline at end of file diff --git a/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/d1/test1.csproj b/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/d1/test1.csproj new file mode 100644 index 000000000000..1cce9e65b060 --- /dev/null +++ b/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/d1/test1.csproj @@ -0,0 +1,16 @@ + + + + Exe + net8.0 + + + + + + + + + + + diff --git a/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/d2/test2.csproj b/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/d2/test2.csproj new file mode 100644 index 000000000000..94772f7cc04d --- /dev/null +++ b/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/d2/test2.csproj @@ -0,0 +1,16 @@ + + + + Exe + net8.0 + + + + + + + + + + + diff --git a/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/global.json b/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/global.json new file mode 100644 index 000000000000..5c3fd64fbd12 --- /dev/null +++ b/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "8.0.101" + } +} diff --git a/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/test.py b/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/test.py new file mode 100644 index 000000000000..a17966e148a9 --- /dev/null +++ b/csharp/ql/integration-tests/posix-only/standalone_dependencies_nuget_versions/test.py @@ -0,0 +1,3 @@ +from create_database_utils import * + +run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none"])