Skip to content

Commit a4e549d

Browse files
committed
fix dotnet 8 styling
1 parent c8a8d20 commit a4e549d

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

src/Microsoft.ComponentDetection.Detectors/pip/PipReportComponentDetector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private enum PipReportOverrideBehavior
8181

8282
protected override bool EnableParallelism { get; set; } = true;
8383

84-
protected override IList<string> CleanupPatterns => new List<string> { "*.egg", "*.egg-info", "*.pyc", "*.pyo", "*.pyd", "__pycache__" };
84+
protected override IList<string> CleanupPatterns => ["*.egg", "*.egg-info", "*.pyc", "*.pyo", "*.pyd", "__pycache__"];
8585

8686
protected override async Task<IObservable<ProcessRequest>> OnPrepareDetectionAsync(IObservable<ProcessRequest> processRequests, IDictionary<string, string> detectorArgs, CancellationToken cancellationToken = default)
8787
{

test/Microsoft.ComponentDetection.Contracts.Tests/FileComponentDetectorTests.cs

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,15 @@ public async Task WithCleanupAsync_CleansUpCreatedFile()
6363
CancellationToken cancellationToken = default;
6464
var detectorArgs = new Dictionary<string, string>();
6565
var cleanupCreatedFiles = true;
66-
var fileComponentDetector = new TestFileComponentDetector(new List<string> { "*.pyc" }, this.loggerMock.Object);
66+
var fileComponentDetector = new TestFileComponentDetector(["*.pyc"], this.loggerMock.Object);
6767
var createdFilePath = Path.Combine(this.testDirectory, "todelete.pyc");
6868

6969
// Act
7070
await fileComponentDetector.TestCleanupAsync(
71-
(process, args, token) =>
71+
async (process, args, token) =>
7272
{
7373
// creates a single file
74-
File.WriteAllText(createdFilePath, "test");
75-
return Task.CompletedTask;
74+
await File.WriteAllTextAsync(createdFilePath, "test", token).ConfigureAwait(false);
7675
},
7776
this.processRequest,
7877
detectorArgs,
@@ -92,18 +91,17 @@ public async Task WithCleanupAsync_CleansUpCreatedDirectory()
9291
CancellationToken cancellationToken = default;
9392
var detectorArgs = new Dictionary<string, string>();
9493
var cleanupCreatedFiles = true;
95-
var fileComponentDetector = new TestFileComponentDetector(new List<string> { "*.egg-info" }, this.loggerMock.Object);
94+
var fileComponentDetector = new TestFileComponentDetector(["*.egg-info"], this.loggerMock.Object);
9695
var createdDirectory = Path.Combine(this.testDirectory, "todelete.egg-info");
9796
var createdFilePath = Path.Combine(createdDirectory, "todelete.txt");
9897

9998
// Act
10099
await fileComponentDetector.TestCleanupAsync(
101-
(process, args, token) =>
100+
async (process, args, token) =>
102101
{
103102
// creates a single directory with a file in it
104103
Directory.CreateDirectory(createdDirectory);
105-
File.WriteAllText(createdFilePath, "test");
106-
return Task.CompletedTask;
104+
await File.WriteAllTextAsync(createdFilePath, "test", token).ConfigureAwait(false);
107105
},
108106
this.processRequest,
109107
detectorArgs,
@@ -124,18 +122,17 @@ public async Task WithCleanupAsync_CleanUpDisabled()
124122
CancellationToken cancellationToken = default;
125123
var detectorArgs = new Dictionary<string, string>();
126124
var cleanupCreatedFiles = false;
127-
var fileComponentDetector = new TestFileComponentDetector(new List<string> { "*.egg-info", "*.txt" }, this.loggerMock.Object);
125+
var fileComponentDetector = new TestFileComponentDetector(["*.egg-info", "*.txt"], this.loggerMock.Object);
128126
var createdDirectory = Path.Combine(this.testDirectory, "todelete.egg-info");
129127
var createdFilePath = Path.Combine(createdDirectory, "todelete.txt");
130128

131129
// Act
132130
await fileComponentDetector.TestCleanupAsync(
133-
(process, args, token) =>
131+
async (process, args, token) =>
134132
{
135133
// creates a single directory with a file in it
136134
Directory.CreateDirectory(createdDirectory);
137-
File.WriteAllText(createdFilePath, "test");
138-
return Task.CompletedTask;
135+
await File.WriteAllTextAsync(createdFilePath, "test", token).ConfigureAwait(false);
139136
},
140137
this.processRequest,
141138
detectorArgs,
@@ -156,7 +153,7 @@ public async Task WithCleanupAsync_CleanUpComplex()
156153
CancellationToken cancellationToken = default;
157154
var detectorArgs = new Dictionary<string, string>();
158155
var cleanupCreatedFiles = true;
159-
var fileComponentDetector = new TestFileComponentDetector(new List<string> { "*.egg-info", "*.pyc" }, this.loggerMock.Object);
156+
var fileComponentDetector = new TestFileComponentDetector(["*.egg-info", "*.pyc"], this.loggerMock.Object);
160157

161158
// creates following structure
162159
// - tokeep
@@ -177,17 +174,16 @@ public async Task WithCleanupAsync_CleanUpComplex()
177174

178175
// Act
179176
await fileComponentDetector.TestCleanupAsync(
180-
(process, args, token) =>
177+
async (process, args, token) =>
181178
{
182179
Directory.CreateDirectory(createdDirectoryKeep1);
183-
File.WriteAllText(createdFileKeep1, "test");
180+
await File.WriteAllTextAsync(createdFileKeep1, "test", token).ConfigureAwait(false);
184181
Directory.CreateDirectory(createdDirectoryKeep2);
185-
File.WriteAllText(createdFileKeep2, "test");
182+
await File.WriteAllTextAsync(createdFileKeep2, "test", token).ConfigureAwait(false);
186183

187184
Directory.CreateDirectory(createdDirectoryDelete1);
188-
File.WriteAllText(createdFileDelete1, "test");
189-
File.WriteAllText(createdFileDelete2, "test");
190-
return Task.CompletedTask;
185+
await File.WriteAllTextAsync(createdFileDelete1, "test", token).ConfigureAwait(false);
186+
await File.WriteAllTextAsync(createdFileDelete2, "test", token).ConfigureAwait(false);
191187
},
192188
this.processRequest,
193189
detectorArgs,
@@ -218,11 +214,11 @@ public TestFileComponentDetector(List<string> cleanupPatterns, ILogger logger)
218214

219215
public override string Id => "TestFileComponentDetector";
220216

221-
public override IList<string> SearchPatterns => new List<string> { "requirements.txt" };
217+
public override IList<string> SearchPatterns => ["requirements.txt"];
222218

223-
public override IEnumerable<string> Categories => new List<string> { "Test" };
219+
public override IEnumerable<string> Categories => ["Test"];
224220

225-
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = new[] { ComponentType.Pip };
221+
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = [ComponentType.Pip];
226222

227223
public override int Version { get; } = 1;
228224

0 commit comments

Comments
 (0)