mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C#: Add a script for generating stubs for all packages needed for testing.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Generate stubs
|
||||
# Generate stubs for a single NuGet package
|
||||
|
||||
Stubs can be generated from Nuget packages with the `make_stubs_nuget.py` script.
|
||||
|
||||
@@ -16,4 +16,17 @@ The output stubs are found in the `[DIR]/output/stubs` folder and can be copied
|
||||
In some more involved cases the output files need to be edited. For example `ServiceStack` has Nuget dependencies, which
|
||||
are included in the `Microsoft.NETCore.App` framework stub. These dependencies generate empty packages, which can be
|
||||
removed. The `ProjectReference` entries referencing these removed empty packages also need to be deleted from the
|
||||
`.csproj` files.
|
||||
`.csproj` files.
|
||||
|
||||
# Generate stubs for all packages needed for tests.
|
||||
|
||||
Stubs needed for all C# Code QL tests can be generated by
|
||||
```
|
||||
python3 make_stubs_all.py
|
||||
python3 make_stubs_all.py /Users/tmp/working-dir
|
||||
```
|
||||
The script contains a hardcoded list of `packages`. If a new package is needed for test purposes, it should be added to the `packages` list in the script.
|
||||
|
||||
The generated stubs require some manual changes before they are compilable.
|
||||
|
||||
The output stubs are found in the `[DIR]/output/stubs` folder and can be copied over to `csharp/ql/test/resources/stubs`.
|
||||
|
||||
36
csharp/scripts/stubs/make_stubs_all.py
Normal file
36
csharp/scripts/stubs/make_stubs_all.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import sys
|
||||
import os
|
||||
import helpers
|
||||
import json
|
||||
import shutil
|
||||
|
||||
print('Script to generate stub files for all C# packages relevant for tests.')
|
||||
print('Please extend the `packages` list in this script to add more packages when relevant.')
|
||||
print(' Usage: python3 ' + sys.argv[0] + ' ' + '[WORK_DIR=tempDir]')
|
||||
|
||||
# List of packages to create stubs for.
|
||||
packages = [
|
||||
"Amazon.Lambda.Core",
|
||||
"Amazon.Lambda.APIGatewayEvents",
|
||||
"Dapper",
|
||||
"Newtonsoft.Json",
|
||||
"NHibernate",
|
||||
"ServiceStack",
|
||||
"ServiceStack.OrmLite.SqlServer",
|
||||
"System.Data.SqlClient",
|
||||
"System.Data.SQLite",
|
||||
]
|
||||
|
||||
thisScript = sys.argv[0]
|
||||
template = "webapp"
|
||||
relativeWorkDir = helpers.get_argv(1, "tempDir")
|
||||
|
||||
|
||||
generator = helpers.Generator(thisScript, relativeWorkDir, template)
|
||||
|
||||
for package in packages:
|
||||
generator.add_nuget(package)
|
||||
|
||||
generator.make_stubs()
|
||||
|
||||
exit(0)
|
||||
Reference in New Issue
Block a user