diff --git a/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/Assemblies.expected b/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/Assemblies.expected new file mode 100644 index 00000000000..b676e41c184 --- /dev/null +++ b/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/Assemblies.expected @@ -0,0 +1 @@ +| test-db/working/packages/newtonsoft.json/13.0.4/lib/net6.0/Newtonsoft.Json.dll:0:0:0:0 | Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed | diff --git a/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/Assemblies.ql b/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/Assemblies.ql new file mode 100644 index 00000000000..0eb33b7ae37 --- /dev/null +++ b/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/Assemblies.ql @@ -0,0 +1,5 @@ +import csharp + +from Assembly a +where exists(a.getFile().getAbsolutePath().indexOf("newtonsoft.json")) +select a diff --git a/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/CompilationInfo.expected b/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/CompilationInfo.expected new file mode 100644 index 00000000000..ff0b29da33f --- /dev/null +++ b/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/CompilationInfo.expected @@ -0,0 +1,22 @@ +| All NuGet feeds reachable | 1.0 | +| Failed project restore with missing package error | 0.0 | +| Failed project restore with package source error | 0.0 | +| Failed solution restore with missing package error | 0.0 | +| Failed solution restore with package source error | 0.0 | +| Inherited NuGet feed count | 1.0 | +| NuGet feed responsiveness checked | 1.0 | +| Project files on filesystem | 1.0 | +| Reachable fallback NuGet feed count | 1.0 | +| Resolved assembly conflicts | 0.0 | +| Resource extraction enabled | 0.0 | +| Restored .NET framework variants | 1.0 | +| Restored projects through solution files | 0.0 | +| Solution files on filesystem | 0.0 | +| Source files generated | 0.0 | +| Source files on filesystem | 1.0 | +| Successfully restored project files | 1.0 | +| Successfully restored solution files | 0.0 | +| Unresolved references | 0.0 | +| UseWPF set | 0.0 | +| UseWindowsForms set | 0.0 | +| WebView extraction enabled | 1.0 | diff --git a/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/CompilationInfo.ql b/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/CompilationInfo.ql new file mode 100644 index 00000000000..073ffe3b224 --- /dev/null +++ b/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/CompilationInfo.ql @@ -0,0 +1,15 @@ +import csharp +import semmle.code.csharp.commons.Diagnostics + +query predicate compilationInfo(string key, float value) { + key != "Resolved references" and + not key.matches("Compiler diagnostic count for%") and + exists(Compilation c, string infoKey, string infoValue | infoValue = c.getInfo(infoKey) | + key = infoKey and + value = infoValue.toFloat() + or + not exists(infoValue.toFloat()) and + key = infoKey + ": " + infoValue and + value = 1 + ) +} diff --git a/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/clear/nuget.config b/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/clear/nuget.config new file mode 100644 index 00000000000..a3f3aea61c8 --- /dev/null +++ b/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/clear/nuget.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/global.json b/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/global.json new file mode 100644 index 00000000000..ed604974070 --- /dev/null +++ b/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "10.0.201" + } +} diff --git a/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/proj/Program.cs b/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/proj/Program.cs new file mode 100644 index 00000000000..c340f4c32fd --- /dev/null +++ b/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/proj/Program.cs @@ -0,0 +1 @@ +class Program { } diff --git a/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/proj/proj.csproj b/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/proj/proj.csproj new file mode 100644 index 00000000000..6010c6c7f37 --- /dev/null +++ b/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/proj/proj.csproj @@ -0,0 +1,16 @@ + + + + Exe + net10.0 + + + + + + + + + + + diff --git a/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/test.py b/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/test.py new file mode 100644 index 00000000000..cbbf2eb1d64 --- /dev/null +++ b/csharp/ql/integration-tests/posix/standalone_dependencies_nuget_clear/test.py @@ -0,0 +1,12 @@ +import os +import runs_on + + +@runs_on.posix +def test(codeql, csharp): + # Making sure the reachability test of `nuget.org` succeeds: + os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_FALLBACK_TIMEOUT"] = "1000" + os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_FALLBACK_LIMIT"] = "5" + + # This test checks that the nuget.config file in the clear folder is not applied to the restore of the project. + codeql.database.create(build_mode="none")