Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process input files in parallel #26

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for moving this? Would this not end up logging all types of files?

Copy link
Contributor Author

@ricekot ricekot Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the existing behaviour too I believe, see line 192 which logs the file name in the loop.
https://github.com/joernio/DotNetAstGen/pull/26/files#diff-600f8abdf835e81e081c02e55f3bed18ecb1fdd2c80333c77184fefc67c6ad92L192

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see the looping has changed, my bad. Looks all good to me then


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

Expand Down