Skip to content

C#: Improve log messages in buildless mode + some cleanup/refactoring #15424

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

Merged
merged 4 commits into from
Jan 25, 2024

Conversation

tamasvajk
Copy link
Contributor

@tamasvajk tamasvajk commented Jan 24, 2024

This pull request mainly focuses on improving the log messages written during buildless extraction. Additionally code is refactored to remove the ProgressMonitor class and instead use the logger directly. Furthermore, the dotnet restore calls are also refactored to reduce the number of (out) parameter of the corresponding methods.

Commit-by-commit review is suggested.

@github-actions github-actions bot added the C# label Jan 24, 2024
succeededProjects + failedProjects,
failedProjects,
DateTime.Now - startTime);
const int align = 6;

Check warning

Code scanning / CodeQL

Useless assignment to local variable

This assignment to [align](1) is useless, since its value is never read.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll investigate this FP.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is already an issue for this - I will find it.

Copy link
Contributor

Choose a reason for hiding this comment

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

@tamasvajk tamasvajk marked this pull request as ready for review January 24, 2024 15:03
@tamasvajk tamasvajk requested a review from a team as a code owner January 24, 2024 15:03
@@ -162,9 +174,9 @@ private void RestoreNugetPackages(List<FileInfo> allNonBinaryFiles, IEnumerable<
nugetPackageDllPaths.ExceptWith(excludedPaths);
dllPaths.UnionWith(nugetPackageDllPaths);
}
catch (FileNotFoundException)
catch (Exception)
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you observed other exception types or is just to be on the safe side?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's only for safety. There's a lot going on in this try-catch, for example we're enumerating files to find packages.config files, and that logic could potentially throw many exceptions.

{
var sln = new SolutionFile(solutionFile);
progressMonitor.LogInfo($"Analyzing {solutionFile}...");
foreach (var proj in sln.Projects.Select(p => new FileInfo(p)))
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like the filter .Where(p => p.Exists) was removed as a part of the re-factor. Is that intentional?

Copy link
Contributor Author

@tamasvajk tamasvajk Jan 25, 2024

Choose a reason for hiding this comment

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

AnalyseProject checks and checked for the existence of the files. Now if they don't exist, we'll log a message, previously that part of the code was just never reached.

Copy link
Contributor

@michaelnebel michaelnebel left a comment

Choose a reason for hiding this comment

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

This is really excellent!
Very nice improvement of the code quality and the information being logged!

@tamasvajk tamasvajk merged commit 01b8950 into github:main Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants