Skip to content

Commit 8312fc6

Browse files
committed
C#: Use groups and rename to trap.compression instead. Various changes to description to align with Ruby.
1 parent 3e898a1 commit 8312fc6

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

csharp/codeql-extractor.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@ file_types:
1717
- .cs
1818
legacy_qltest_extraction: true
1919
options:
20-
compression:
21-
title: The type of compression.
22-
description: >
23-
A value indicating, which type of compression that should be used for the TRAP archive.
24-
Allowed values are 'brotli', 'gzip' or 'none'. The default is 'brotli'.
25-
type: string
20+
trap:
21+
title: Options pertaining to TRAP.
22+
type: object
23+
properties:
24+
compression:
25+
title: Controls compression for the TRAP files written by the extractor.
26+
description: >
27+
This option is only intended for use in debugging the extractor. Accepted
28+
values are 'brotli' (the default, to write brotli-compressed TRAP), 'gzip', and 'none'
29+
(to write uncompressed TRAP).
30+
type: string
31+
pattern: "^(none|gzip|brotli)$"

csharp/extractor/Semmle.Extraction.Tests/Options.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,19 +210,19 @@ public void ArchiveArguments()
210210
[Fact]
211211
public void CompressionTests()
212212
{
213-
Environment.SetEnvironmentVariable("CODEQL_EXTRACTOR_CSHARP_OPTION_COMPRESSION", "gzip");
213+
Environment.SetEnvironmentVariable("CODEQL_EXTRACTOR_CSHARP_OPTION_TRAP_COMPRESSION", "gzip");
214214
options = CSharp.Options.CreateWithEnvironment(Array.Empty<string>());
215215
Assert.Equal(TrapWriter.CompressionMode.Gzip, options.TrapCompression);
216216

217-
Environment.SetEnvironmentVariable("CODEQL_EXTRACTOR_CSHARP_OPTION_COMPRESSION", "brotli");
217+
Environment.SetEnvironmentVariable("CODEQL_EXTRACTOR_CSHARP_OPTION_TRAP_COMPRESSION", "brotli");
218218
options = CSharp.Options.CreateWithEnvironment(Array.Empty<string>());
219219
Assert.Equal(TrapWriter.CompressionMode.Brotli, options.TrapCompression);
220220

221-
Environment.SetEnvironmentVariable("CODEQL_EXTRACTOR_CSHARP_OPTION_COMPRESSION", "none");
221+
Environment.SetEnvironmentVariable("CODEQL_EXTRACTOR_CSHARP_OPTION_TRAP_COMPRESSION", "none");
222222
options = CSharp.Options.CreateWithEnvironment(Array.Empty<string>());
223223
Assert.Equal(TrapWriter.CompressionMode.None, options.TrapCompression);
224224

225-
Environment.SetEnvironmentVariable("CODEQL_EXTRACTOR_CSHARP_OPTION_COMPRESSION", null);
225+
Environment.SetEnvironmentVariable("CODEQL_EXTRACTOR_CSHARP_OPTION_TRAP_COMPRESSION", null);
226226
options = CSharp.Options.CreateWithEnvironment(Array.Empty<string>());
227227
Assert.Equal(TrapWriter.CompressionMode.Brotli, options.TrapCompression);
228228
}

csharp/extractor/Semmle.Extraction/Options.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public virtual bool HandleOption(string key, string value)
6666
case "verbosity":
6767
Verbosity = (Verbosity)int.Parse(value);
6868
return true;
69-
case "compression":
69+
case "trap_compression":
7070
if (Enum.TryParse<TrapWriter.CompressionMode>(value, true, out var mode))
7171
{
7272
TrapCompression = mode;

csharp/extractor/Semmle.Util/CommandLineOptions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ private static List<string> GetExtractorOptions()
4747
{
4848
var extractorOptions = new List<string>();
4949

50-
var compressionMode = GetExtractorOption("compression");
51-
if (!string.IsNullOrEmpty(compressionMode))
50+
var trapCompression = GetExtractorOption("trap_compression");
51+
if (!string.IsNullOrEmpty(trapCompression))
5252
{
53-
extractorOptions.Add($"--compression:{compressionMode}");
53+
extractorOptions.Add($"--trap_compression:{trapCompression}");
5454
}
5555

5656
return extractorOptions;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
category: minorAnalysis
33
---
4-
* 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`.
4+
* 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`.
55
* The C# extractor no longer accepts `--no-brotli` or `--brotli` flags to switch between `gzip` and `brotli` as compression method for TRAP files.

0 commit comments

Comments
 (0)