-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Conversation
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs
Fixed
Show fixed
Hide fixed
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs
Fixed
Show fixed
Hide fixed
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs
Fixed
Show fixed
Hide fixed
a00f860
to
30095e3
Compare
succeededProjects + failedProjects, | ||
failedProjects, | ||
DateTime.Now - startTime); | ||
const int align = 6; |
Check warning
Code scanning / CodeQL
Useless assignment to local variable
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -162,9 +174,9 @@ private void RestoreNugetPackages(List<FileInfo> allNonBinaryFiles, IEnumerable< | |||
nugetPackageDllPaths.ExceptWith(excludedPaths); | |||
dllPaths.UnionWith(nugetPackageDllPaths); | |||
} | |||
catch (FileNotFoundException) | |||
catch (Exception) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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))) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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!
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, thedotnet restore
calls are also refactored to reduce the number of (out
) parameter of the corresponding methods.Commit-by-commit review is suggested.