Skip to content

Commit

Permalink
Parallelize file generation
Browse files Browse the repository at this point in the history
  • Loading branch information
meziantou committed Jul 31, 2023
1 parent fabe49c commit b37706b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tools/ConfigFilesGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
var rootFolder = GetRootFolderPath();

var writtenFiles = 0;
await foreach (var (packageId, packageVersion) in GetReferencedNuGetPackages())
await Parallel.ForEachAsync(GetReferencedNuGetPackages(), async (item, cancellationToken) =>
{
var (packageId, packageVersion) = item;
Console.WriteLine(packageId + "@" + packageVersion);
var configurationFilePath = rootFolder / "src" / "configuration" / ("Analyzer." + packageId + ".editorconfig");
Expand Down Expand Up @@ -91,12 +93,12 @@
if (File.Exists(configurationFilePath))
{
if (File.ReadAllText(configurationFilePath).ReplaceLineEndings() == sb.ToString().ReplaceLineEndings())
continue;
return;
}
configurationFilePath.CreateParentDirectory();
await File.WriteAllTextAsync(configurationFilePath, sb.ToString());
writtenFiles++;
await File.WriteAllTextAsync(configurationFilePath, sb.ToString(), cancellationToken);
Interlocked.Increment(ref writtenFiles);
static string GetSeverity(DiagnosticSeverity? severity)
{
Expand All @@ -108,7 +110,7 @@ static string GetSeverity(DiagnosticSeverity? severity)
};
}
}
}
});

return writtenFiles;

Expand Down

0 comments on commit b37706b

Please sign in to comment.