C#: Use groups and rename to trap.compression instead. Various changes to description to align with Ruby.

This commit is contained in:
Michael Nebel
2022-03-01 12:01:44 +01:00
parent 3e898a1b09
commit 8312fc6895
5 changed files with 21 additions and 15 deletions

View File

@@ -17,9 +17,15 @@ file_types:
- .cs
legacy_qltest_extraction: true
options:
compression:
title: The type of compression.
description: >
A value indicating, which type of compression that should be used for the TRAP archive.
Allowed values are 'brotli', 'gzip' or 'none'. The default is 'brotli'.
type: string
trap:
title: Options pertaining to TRAP.
type: object
properties:
compression:
title: Controls compression for the TRAP files written by the extractor.
description: >
This option is only intended for use in debugging the extractor. Accepted
values are 'brotli' (the default, to write brotli-compressed TRAP), 'gzip', and 'none'
(to write uncompressed TRAP).
type: string
pattern: "^(none|gzip|brotli)$"

View File

@@ -210,19 +210,19 @@ namespace Semmle.Extraction.Tests
[Fact]
public void CompressionTests()
{
Environment.SetEnvironmentVariable("CODEQL_EXTRACTOR_CSHARP_OPTION_COMPRESSION", "gzip");
Environment.SetEnvironmentVariable("CODEQL_EXTRACTOR_CSHARP_OPTION_TRAP_COMPRESSION", "gzip");
options = CSharp.Options.CreateWithEnvironment(Array.Empty<string>());
Assert.Equal(TrapWriter.CompressionMode.Gzip, options.TrapCompression);
Environment.SetEnvironmentVariable("CODEQL_EXTRACTOR_CSHARP_OPTION_COMPRESSION", "brotli");
Environment.SetEnvironmentVariable("CODEQL_EXTRACTOR_CSHARP_OPTION_TRAP_COMPRESSION", "brotli");
options = CSharp.Options.CreateWithEnvironment(Array.Empty<string>());
Assert.Equal(TrapWriter.CompressionMode.Brotli, options.TrapCompression);
Environment.SetEnvironmentVariable("CODEQL_EXTRACTOR_CSHARP_OPTION_COMPRESSION", "none");
Environment.SetEnvironmentVariable("CODEQL_EXTRACTOR_CSHARP_OPTION_TRAP_COMPRESSION", "none");
options = CSharp.Options.CreateWithEnvironment(Array.Empty<string>());
Assert.Equal(TrapWriter.CompressionMode.None, options.TrapCompression);
Environment.SetEnvironmentVariable("CODEQL_EXTRACTOR_CSHARP_OPTION_COMPRESSION", null);
Environment.SetEnvironmentVariable("CODEQL_EXTRACTOR_CSHARP_OPTION_TRAP_COMPRESSION", null);
options = CSharp.Options.CreateWithEnvironment(Array.Empty<string>());
Assert.Equal(TrapWriter.CompressionMode.Brotli, options.TrapCompression);
}

View File

@@ -66,7 +66,7 @@ namespace Semmle.Extraction
case "verbosity":
Verbosity = (Verbosity)int.Parse(value);
return true;
case "compression":
case "trap_compression":
if (Enum.TryParse<TrapWriter.CompressionMode>(value, true, out var mode))
{
TrapCompression = mode;

View File

@@ -47,10 +47,10 @@ namespace Semmle.Util
{
var extractorOptions = new List<string>();
var compressionMode = GetExtractorOption("compression");
if (!string.IsNullOrEmpty(compressionMode))
var trapCompression = GetExtractorOption("trap_compression");
if (!string.IsNullOrEmpty(trapCompression))
{
extractorOptions.Add($"--compression:{compressionMode}");
extractorOptions.Add($"--trap_compression:{trapCompression}");
}
return extractorOptions;

View File

@@ -1,5 +1,5 @@
---
category: minorAnalysis
---
* The C# extractor now accepts an extractor option `compression`, which is used to decide the compression format for TRAP files. The legal options are `brotli` (default), `gzip` or `none`.
* The C# extractor now accepts an extractor option `trap.compression`, which is used to decide the compression format for TRAP files. The legal options are `brotli` (default), `gzip` or `none`.
* The C# extractor no longer accepts `--no-brotli` or `--brotli` flags to switch between `gzip` and `brotli` as compression method for TRAP files.