Skip to content

Commit

Permalink
Process input files in parallel (#26)
Browse files Browse the repository at this point in the history
Signed-off-by: ricekot <[email protected]>
  • Loading branch information
ricekot authored Nov 8, 2024
1 parent ab9ce61 commit 8e95368
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions DotNetAstGen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,13 @@ private static void _ParseSourceCode(DirectoryInfo inputDirPath, DirectoryInfo r
{
_logger?.LogInformation("Parsing directory {dirName}", inputPath);
var rootDirectory = new DirectoryInfo(inputPath);
foreach (var inputFile in new DirectoryInfo(inputPath).EnumerateFiles("*.cs",
SearchOption.AllDirectories))
{
_AstForFile(rootDirectory, rootOutputPath, inputFile, exclusionRegex);
}
rootDirectory
.EnumerateFiles("*.cs", SearchOption.AllDirectories)
.AsParallel()
.ForAll(inputFile => _AstForFile(rootDirectory, rootOutputPath, inputFile, exclusionRegex));
}
else if (File.Exists(inputPath))
{
_logger?.LogInformation("Parsing file {fileName}", inputPath);
var file = new FileInfo(inputPath);
Debug.Assert(file.Directory != null, "Given file has a null parent directory!");
_AstForFile(file.Directory, rootOutputPath, file, exclusionRegex);
Expand Down Expand Up @@ -185,17 +183,12 @@ private static void _ParseByteCode(string inputPath, DirectoryInfo rootOutputPat
if (Directory.Exists(inputPath))
{
_logger?.LogInformation("Parsing directory {dirName}", inputPath);

foreach (var inputFile in new DirectoryInfo(inputPath).EnumerateFiles("*.dll",
SearchOption.AllDirectories))
{
_logger?.LogInformation("Parsing file {fileName}", inputPath);
_SummaryForDLLFile(inputFile, exclusionRegex);
}
new DirectoryInfo(inputPath).EnumerateFiles("*.dll", SearchOption.AllDirectories)
.AsParallel()
.ForAll(inputFile => _SummaryForDLLFile(inputFile, exclusionRegex));
}
else if (File.Exists(inputPath))
{
_logger?.LogInformation("Parsing file {fileName}", inputPath);
var file = new FileInfo(inputPath);
Debug.Assert(file.Directory != null, "Given file has a null parent directory!");
_SummaryForDLLFile(file, exclusionRegex);
Expand All @@ -218,6 +211,8 @@ private static void _SummaryForDLLFile(FileInfo filePath, string? exclusionRegex
return;
}

_logger?.LogInformation("Parsing file {fileName}", fullPath);

var jsonName = Path.Combine(filePath.DirectoryName ?? "./",
$"{Path.GetFileNameWithoutExtension(fullPath)}_Symbols.json");

Expand Down

0 comments on commit 8e95368

Please sign in to comment.