mirror of
https://github.com/github/codeql.git
synced 2026-05-01 19:55:15 +02:00
C#: Add support to the extractor for getting the compression extractor option.
This commit is contained in:
@@ -46,7 +46,9 @@ namespace Semmle.Extraction.CSharp
|
||||
var argsList = new List<string>(arguments);
|
||||
|
||||
if (!string.IsNullOrEmpty(extractionOptions))
|
||||
{
|
||||
argsList.AddRange(extractionOptions.Split(' '));
|
||||
}
|
||||
|
||||
options.ParseArguments(argsList);
|
||||
return options;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using Semmle.Util.Logging;
|
||||
using Semmle.Util;
|
||||
|
||||
@@ -49,6 +50,7 @@ namespace Semmle.Extraction
|
||||
/// </summary>
|
||||
public bool QlTest { get; private set; } = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The compression algorithm used for trap files.
|
||||
/// </summary>
|
||||
@@ -64,6 +66,16 @@ namespace Semmle.Extraction
|
||||
case "verbosity":
|
||||
Verbosity = (Verbosity)int.Parse(value);
|
||||
return true;
|
||||
case "compression":
|
||||
try
|
||||
{
|
||||
TrapCompression = (TrapWriter.CompressionMode)Enum.Parse(typeof(TrapWriter.CompressionMode), value, true);
|
||||
return true;
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Semmle.Util
|
||||
@@ -39,8 +40,26 @@ namespace Semmle.Util
|
||||
|
||||
public static class OptionsExtensions
|
||||
{
|
||||
public static void ParseArguments(this ICommandLineOptions options, IReadOnlyList<string> arguments)
|
||||
private static string? GetExtractorOption(string name) =>
|
||||
Environment.GetEnvironmentVariable($"CODEQL_EXTRACTOR_CSHARP_OPTION_{name.ToUpper()}");
|
||||
|
||||
private static List<string> GetExtractorOptions()
|
||||
{
|
||||
var extractorOptions = new List<string>();
|
||||
|
||||
var compressionMode = GetExtractorOption("compression");
|
||||
if (!string.IsNullOrEmpty(compressionMode))
|
||||
{
|
||||
extractorOptions.Add($"--compression:{compressionMode}");
|
||||
}
|
||||
|
||||
return extractorOptions;
|
||||
}
|
||||
|
||||
public static void ParseArguments(this ICommandLineOptions options, IReadOnlyList<string> providedArguments)
|
||||
{
|
||||
var arguments = GetExtractorOptions();
|
||||
arguments.AddRange(providedArguments);
|
||||
for (var i = 0; i < arguments.Count; ++i)
|
||||
{
|
||||
var arg = arguments[i];
|
||||
|
||||
Reference in New Issue
Block a user