mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C#: Recognize options to dotnet run in tracer when injecting -p:UseSharedCompilation=false
This commit is contained in:
@@ -21,8 +21,8 @@ function RegisterExtractorPack(id)
|
|||||||
-- if that's `build`, we append `-p:UseSharedCompilation=false` to the command line,
|
-- if that's `build`, we append `-p:UseSharedCompilation=false` to the command line,
|
||||||
-- otherwise we do nothing.
|
-- otherwise we do nothing.
|
||||||
local match = false
|
local match = false
|
||||||
local needsSeparator = false;
|
local dotnetRunNeedsSeparator = false;
|
||||||
local injectionIndex = nil;
|
local dotnetRunInjectionIndex = nil;
|
||||||
local argv = compilerArguments.argv
|
local argv = compilerArguments.argv
|
||||||
if OperatingSystem == 'windows' then
|
if OperatingSystem == 'windows' then
|
||||||
-- let's hope that this split matches the escaping rules `dotnet` applies to command line arguments
|
-- let's hope that this split matches the escaping rules `dotnet` applies to command line arguments
|
||||||
@@ -34,7 +34,9 @@ function RegisterExtractorPack(id)
|
|||||||
-- dotnet options start with either - or / (both are legal)
|
-- dotnet options start with either - or / (both are legal)
|
||||||
local firstCharacter = string.sub(arg, 1, 1)
|
local firstCharacter = string.sub(arg, 1, 1)
|
||||||
if not (firstCharacter == '-') and not (firstCharacter == '/') then
|
if not (firstCharacter == '-') and not (firstCharacter == '/') then
|
||||||
Log(1, 'Dotnet subcommand detected: %s', arg)
|
if (not match) then
|
||||||
|
Log(1, 'Dotnet subcommand detected: %s', arg)
|
||||||
|
end
|
||||||
if arg == 'build' or arg == 'msbuild' or arg == 'publish' or arg == 'pack' or arg == 'test' then
|
if arg == 'build' or arg == 'msbuild' or arg == 'publish' or arg == 'pack' or arg == 'test' then
|
||||||
match = true
|
match = true
|
||||||
break
|
break
|
||||||
@@ -43,22 +45,29 @@ function RegisterExtractorPack(id)
|
|||||||
-- for `dotnet run`, we need to make sure that `-p:UseSharedCompilation=false` is
|
-- for `dotnet run`, we need to make sure that `-p:UseSharedCompilation=false` is
|
||||||
-- not passed in as an argument to the program that is run
|
-- not passed in as an argument to the program that is run
|
||||||
match = true
|
match = true
|
||||||
needsSeparator = true
|
dotnetRunNeedsSeparator = true
|
||||||
injectionIndex = i + 1
|
dotnetRunInjectionIndex = i + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- if we see a separator to `dotnet run`, inject just prior to the existing separator
|
||||||
if arg == '--' then
|
if arg == '--' then
|
||||||
needsSeparator = false
|
dotnetRunNeedsSeparator = false
|
||||||
injectionIndex = i
|
dotnetRunInjectionIndex = i
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
-- if we see an option to `dotnet run` (e.g., `--project`), inject just prior
|
||||||
|
-- to the last option
|
||||||
|
if firstCharacter == '-' then
|
||||||
|
dotnetRunNeedsSeparator = false
|
||||||
|
dotnetRunInjectionIndex = i
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if match then
|
if match then
|
||||||
local injections = { '-p:UseSharedCompilation=false' }
|
local injections = { '-p:UseSharedCompilation=false' }
|
||||||
if needsSeparator then
|
if dotnetRunNeedsSeparator then
|
||||||
table.insert(injections, '--')
|
table.insert(injections, '--')
|
||||||
end
|
end
|
||||||
if injectionIndex == nil then
|
if dotnetRunInjectionIndex == nil then
|
||||||
-- Simple case; just append at the end
|
-- Simple case; just append at the end
|
||||||
return {
|
return {
|
||||||
order = ORDER_REPLACE,
|
order = ORDER_REPLACE,
|
||||||
@@ -69,7 +78,7 @@ function RegisterExtractorPack(id)
|
|||||||
|
|
||||||
-- Complex case; splice injections into the middle of the command line
|
-- Complex case; splice injections into the middle of the command line
|
||||||
for i, injectionArg in ipairs(injections) do
|
for i, injectionArg in ipairs(injections) do
|
||||||
table.insert(argv, injectionIndex + i - 1, injectionArg)
|
table.insert(argv, dotnetRunInjectionIndex + i - 1, injectionArg)
|
||||||
end
|
end
|
||||||
|
|
||||||
if OperatingSystem == 'windows' then
|
if OperatingSystem == 'windows' then
|
||||||
|
|||||||
Reference in New Issue
Block a user