C#: Add an integration test for setting the dependency directory in BMN.

This commit is contained in:
Michael Nebel
2025-11-17 12:01:59 +01:00
parent 1256ccf2eb
commit 2700843a9c
6 changed files with 43 additions and 0 deletions

View File

@@ -0,0 +1 @@
| dependencies/packages/newtonsoft.json/13.0.1/lib/netstandard2.0/Newtonsoft.Json.dll:0:0:0:0 | Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed |

View File

@@ -0,0 +1,7 @@
import csharp
from Assembly a
where
not a.getCompilation().getOutputAssembly() = a and
a.getName().matches("%Newtonsoft%")
select a

View File

@@ -0,0 +1,6 @@
class Program
{
static void Main(string[] args)
{
}
}

View File

@@ -0,0 +1,5 @@
{
"sdk": {
"version": "9.0.304"
}
}

View File

@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net9.0</TargetFrameworks>
</PropertyGroup>
<Target Name="DeleteBinObjFolders" BeforeTargets="Clean">
<RemoveDir Directories=".\bin" />
<RemoveDir Directories=".\obj" />
</Target>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,8 @@
import os
def test(codeql, csharp, cwd):
path = os.path.join(cwd, "dependencies")
os.environ["CODEQL_EXTRACTOR_CSHARP_OPTION_BUILDLESS_DEPENDENCY_DIR"] = path
# The Assemblies.ql query shows that the Newtonsoft assembly is found in the
# dependency directory set above.
codeql.database.create(source_root="proj", build_mode="none")