Skip to content

Commit cec7640

Browse files
committed
applied ConfigureAwait(false)
1 parent 074a06a commit cec7640

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

src/LineCount.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static class LineCount
2222
var excludeFilePatterns = PathPatterns.Create(path, excludeFiles);
2323
var excludeDirectoryPatterns = PathPatterns.Create(path, excludeDirectories);
2424

25-
return await GetLineCount(path, data, excludeFilePatterns, excludeDirectoryPatterns, cancellationToken);
25+
return await GetLineCount(path, data, excludeFilePatterns, excludeDirectoryPatterns, cancellationToken).ConfigureAwait(false);
2626
}
2727
catch (OperationCanceledException)
2828
{
@@ -38,17 +38,17 @@ static async Task<ReportResult> GetLineCount(string path, LineCountData data, Pa
3838

3939
if(!attributes.HasFlag(FileAttributes.Directory))
4040
{
41-
return await GetSingleFileLineCount(path, data, cancellationToken);
41+
return await GetSingleFileLineCount(path, data, cancellationToken).ConfigureAwait(false);
4242
}
4343

44-
var filesReportResult = await CountInFiles(path, data, excludeFilePatterns, cancellationToken);
44+
var filesReportResult = await CountInFiles(path, data, excludeFilePatterns, cancellationToken).ConfigureAwait(false);
4545

4646
if(!filesReportResult.TryGetValue(out var filesReport))
4747
{
4848
return filesReportResult;
4949
}
5050

51-
var directoriesReportResult = await CountInDirectories(path, data, excludeFilePatterns, excludeDirectoryPatterns, cancellationToken);
51+
var directoriesReportResult = await CountInDirectories(path, data, excludeFilePatterns, excludeDirectoryPatterns, cancellationToken).ConfigureAwait(false);
5252

5353
if (!directoriesReportResult.TryGetValue(out var directoriesReport))
5454
{
@@ -169,7 +169,6 @@ static async Task<ReportResult> CountInFiles(string path, LineCountData data, Pa
169169
{
170170
List<Task<Result<FileStats, IError>>> filetasks = [];
171171
try
172-
173172
{
174173
IEnumerable<string> files = GetFilterFilePaths(path, data);
175174

@@ -181,7 +180,8 @@ static async Task<ReportResult> CountInFiles(string path, LineCountData data, Pa
181180
}
182181

183182
Task<Result<FileStats, IError>> task = GetSingleFileLineCount(file, data, cancellationToken)
184-
.ContinueWith(task => task.Result.Map(report => new FileStats(file, report.Lines)), cancellationToken, TaskContinuationOptions.NotOnCanceled, TaskScheduler.Current);
183+
.ContinueWith(task => task.Result.Map(
184+
report => new FileStats(file, report.Lines)), cancellationToken, TaskContinuationOptions.NotOnCanceled, TaskScheduler.Current);
185185
filetasks.Add(task);
186186
}
187187
}
@@ -266,7 +266,7 @@ static async Task<ReportResult> GetSingleFileLineCount(string path, LineCountDat
266266
{
267267
try
268268
{
269-
return await GetSingleFileLineCountReport(path, data, cancellationToken);
269+
return await GetSingleFileLineCountReport(path, data, cancellationToken).ConfigureAwait(false);
270270
}
271271
catch (FileNotFoundException)
272272
{
@@ -315,7 +315,7 @@ public static async Task<int> GetFilteredFileLineCount(string path, Predicate<st
315315
using FileStream stream = File.OpenRead(path);
316316
using StreamReader reader = new StreamReader(stream);
317317

318-
string? line = await reader.ReadLineAsync(cancellationToken);
318+
string? line = await reader.ReadLineAsync(cancellationToken).ConfigureAwait(false);
319319
int count = 0;
320320

321321
while (line is not null && !cancellationToken.IsCancellationRequested)
@@ -325,7 +325,7 @@ public static async Task<int> GetFilteredFileLineCount(string path, Predicate<st
325325
count++;
326326
}
327327

328-
line = await reader.ReadLineAsync(cancellationToken);
328+
line = await reader.ReadLineAsync(cancellationToken).ConfigureAwait(false);
329329
}
330330

331331
cancellationToken.ThrowIfCancellationRequested();
@@ -338,13 +338,13 @@ public static async Task<int> GetFileLineCount(string path, CancellationToken ca
338338
using FileStream stream = File.OpenRead(path);
339339
using StreamReader reader = new StreamReader(stream);
340340

341-
string? line = await reader.ReadLineAsync(cancellationToken);
341+
string? line = await reader.ReadLineAsync(cancellationToken).ConfigureAwait(false);
342342
int count = 0;
343343

344344
while (line is not null && !cancellationToken.IsCancellationRequested)
345345
{
346346
count++;
347-
line = await reader.ReadLineAsync(cancellationToken);
347+
line = await reader.ReadLineAsync(cancellationToken).ConfigureAwait(false);
348348
}
349349

350350
cancellationToken.ThrowIfCancellationRequested();

0 commit comments

Comments
 (0)