Skip to content

Commit a695e27

Browse files
committed
Address build warning xUnit1030
warning xUnit1030: Test methods should not call ConfigureAwait(false), as it may bypass parallelization limits. Omit ConfigureAwait, or use ConfigureAwait(true) to avoid CA2007. (https://xunit.net/xunit.analyzers/rules/xUnit1030) Signed-off-by: Patrick Dwyer <coderpatros@outlook.com>
1 parent 5d4ade0 commit a695e27

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

tests/cyclonedx.tests/ConvertTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public async Task Convert(string inputFilename, ConvertFormat inputFormat, strin
9999
InputFormat = inputFormat,
100100
OutputFormat = outputFormat,
101101
OutputVersion = outputVersion,
102-
}).ConfigureAwait(false);
102+
}).ConfigureAwait(true);
103103

104104
Assert.Equal(0, exitCode);
105105
var bom = File.ReadAllText(fullOutputPath);
@@ -122,7 +122,7 @@ public async Task ConvertToSpdxJson(ConvertFormat outputFormat)
122122
InputFormat = ConvertFormat.autodetect,
123123
OutputFormat = outputFormat
124124

125-
}).ConfigureAwait(false);
125+
}).ConfigureAwait(true);
126126

127127
Assert.Equal(0, exitCode);
128128
var bom = File.ReadAllText(outputFilename);
@@ -146,7 +146,7 @@ public async Task ConvertFromSpdxJson(ConvertFormat inputFormat)
146146
InputFormat = inputFormat,
147147
OutputFormat = ConvertFormat.xml,
148148

149-
}).ConfigureAwait(false);
149+
}).ConfigureAwait(true);
150150

151151
Assert.Equal(0, exitCode);
152152
var bom = File.ReadAllText(outputFilename);

tests/cyclonedx.tests/MergeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public async Task Merge(
7171
options.InputFiles.Add(Path.Combine("Resources", "Merge", inputFilename));
7272
}
7373

74-
var exitCode = await MergeCommand.Merge(options).ConfigureAwait(false);
74+
var exitCode = await MergeCommand.Merge(options).ConfigureAwait(true);
7575

7676
Assert.Equal(0, exitCode);
7777
var bom = File.ReadAllText(fullOutputPath);

tests/cyclonedx.tests/SignBomTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public async Task SignXmlBom()
3939
{
4040
BomFile = testFilename,
4141
KeyFile = Path.Combine("Resources", "private.key"),
42-
}).ConfigureAwait(false);
42+
}).ConfigureAwait(true);
4343

4444
Assert.Equal(ExitCode.Ok, (ExitCode)exitCode);
4545

tests/cyclonedx.tests/SignFileTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ public async Task SignFile()
3333
using (var tempDirectory = new TempDirectory())
3434
{
3535
var testFilename = Path.Combine(tempDirectory.DirectoryPath, "bom.xml");
36-
var fileContents = await File.ReadAllTextAsync(Path.Combine("Resources", "bom-1.3.xml")).ConfigureAwait(false);
36+
var fileContents = await File.ReadAllTextAsync(Path.Combine("Resources", "bom-1.3.xml")).ConfigureAwait(true);
3737
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
3838
{
3939
fileContents = fileContents.Replace("\r\n", "\n");
4040
}
41-
await File.WriteAllTextAsync(testFilename, fileContents).ConfigureAwait(false);
41+
await File.WriteAllTextAsync(testFilename, fileContents).ConfigureAwait(true);
4242

4343
var exitCode = await SignFileCommand.SignFile(new SignFileCommandOptions
4444
{
4545
File = testFilename,
4646
KeyFile = Path.Combine("Resources", "private.key"),
47-
}).ConfigureAwait(false);
47+
}).ConfigureAwait(true);
4848

4949
Assert.Equal(ExitCode.Ok, (ExitCode)exitCode);
5050

tests/cyclonedx.tests/ValidateTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public async Task Validate(string inputFilename, ValidationBomFormat inputFormat
7878
InputFormat = inputFormat,
7979
InputVersion = inputVersion,
8080
FailOnErrors = true,
81-
}).ConfigureAwait(false);
81+
}).ConfigureAwait(true);
8282

8383
if (valid)
8484
{

tests/cyclonedx.tests/VerifyAllTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public async Task OriginalBomSignatureVerifies()
3232
{
3333
BomFile = Path.Combine("Resources", "signed-bom.xml"),
3434
KeyFile = Path.Combine("Resources", "public.key")
35-
}).ConfigureAwait(false);
35+
}).ConfigureAwait(true);
3636

3737
Assert.Equal(ExitCode.Ok, (ExitCode)exitCode);
3838
}
@@ -44,7 +44,7 @@ public async Task ModifiedBomFailsSignatureVerification()
4444
{
4545
BomFile = Path.Combine("Resources", "signed-bom-modified.xml"),
4646
KeyFile = Path.Combine("Resources", "public.key")
47-
}).ConfigureAwait(false);
47+
}).ConfigureAwait(true);
4848

4949
Assert.Equal(ExitCode.SignatureFailedVerification, (ExitCode)exitCode);
5050
}

tests/cyclonedx.tests/VerifyFileTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ public async Task ValidSignatureVerifies()
3232
{
3333
var testFilename = Path.Combine(tempDirectory.DirectoryPath, "bom.xml");
3434

35-
var fileContents = await File.ReadAllTextAsync(Path.Combine("Resources", "bom-1.3.xml")).ConfigureAwait(false);
35+
var fileContents = await File.ReadAllTextAsync(Path.Combine("Resources", "bom-1.3.xml")).ConfigureAwait(true);
3636
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
3737
{
3838
fileContents = fileContents.Replace("\r\n", "\n");
3939
}
40-
await File.WriteAllTextAsync(testFilename, fileContents).ConfigureAwait(false);
40+
await File.WriteAllTextAsync(testFilename, fileContents).ConfigureAwait(true);
4141

4242
var exitCode = await VerifyFileCommand.VerifyFile(new VerifyFileCommandOptions
4343
{
4444
File = testFilename,
4545
KeyFile = Path.Combine("Resources", "public.key"),
4646
SignatureFile = Path.Combine("Resources", "bom-1.3.xml.valid.sig"),
47-
}).ConfigureAwait(false);
47+
}).ConfigureAwait(true);
4848

4949
Assert.Equal(ExitCode.Ok, (ExitCode)exitCode);
5050
}
@@ -57,19 +57,19 @@ public async Task InvalidSignatureFailsVerification()
5757
{
5858
var testFilename = Path.Combine(tempDirectory.DirectoryPath, "bom.xml");
5959

60-
var fileContents = await File.ReadAllTextAsync(Path.Combine("Resources", "bom-1.3.xml")).ConfigureAwait(false);
60+
var fileContents = await File.ReadAllTextAsync(Path.Combine("Resources", "bom-1.3.xml")).ConfigureAwait(true);
6161
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
6262
{
6363
fileContents = fileContents.Replace("\r\n", "\n");
6464
}
65-
await File.WriteAllTextAsync(testFilename, fileContents).ConfigureAwait(false);
65+
await File.WriteAllTextAsync(testFilename, fileContents).ConfigureAwait(true);
6666

6767
var exitCode = await VerifyFileCommand.VerifyFile(new VerifyFileCommandOptions
6868
{
6969
File = testFilename,
7070
KeyFile = Path.Combine("Resources", "public.key"),
7171
SignatureFile = Path.Combine("Resources", "bom-1.3.xml.invalid.sig"),
72-
}).ConfigureAwait(false);
72+
}).ConfigureAwait(true);
7373

7474
Assert.Equal(ExitCode.SignatureFailedVerification, (ExitCode)exitCode);
7575
}

0 commit comments

Comments
 (0)