mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C#: Log number of restored dotnet framework variants
This commit is contained in:
@@ -24,6 +24,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
|||||||
private readonly IDictionary<string, string> unresolvedReferences = new ConcurrentDictionary<string, string>();
|
private readonly IDictionary<string, string> unresolvedReferences = new ConcurrentDictionary<string, string>();
|
||||||
private readonly List<string> nonGeneratedSources;
|
private readonly List<string> nonGeneratedSources;
|
||||||
private readonly List<string> generatedSources;
|
private readonly List<string> generatedSources;
|
||||||
|
private int dotnetFrameworkVersionVariantCount = 0;
|
||||||
private int conflictedReferences = 0;
|
private int conflictedReferences = 0;
|
||||||
private readonly IDependencyOptions options;
|
private readonly IDependencyOptions options;
|
||||||
private readonly DirectoryInfo sourceDir;
|
private readonly DirectoryInfo sourceDir;
|
||||||
@@ -123,15 +124,15 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
|||||||
const int align = 6;
|
const int align = 6;
|
||||||
logger.LogInfo("");
|
logger.LogInfo("");
|
||||||
logger.LogInfo("Build analysis summary:");
|
logger.LogInfo("Build analysis summary:");
|
||||||
logger.LogInfo($"{this.nonGeneratedSources.Count,align} source files in the filesystem");
|
logger.LogInfo($"{nonGeneratedSources.Count,align} source files in the filesystem");
|
||||||
logger.LogInfo($"{this.generatedSources.Count,align} generated source files");
|
logger.LogInfo($"{generatedSources.Count,align} generated source files");
|
||||||
logger.LogInfo($"{allSolutions.Count,align} solution files");
|
logger.LogInfo($"{allSolutions.Count,align} solution files");
|
||||||
logger.LogInfo($"{allProjects.Count,align} project files in the filesystem");
|
logger.LogInfo($"{allProjects.Count,align} project files in the filesystem");
|
||||||
logger.LogInfo($"{usedReferences.Keys.Count,align} resolved references");
|
logger.LogInfo($"{usedReferences.Keys.Count,align} resolved references");
|
||||||
logger.LogInfo($"{unresolvedReferences.Count,align} unresolved references");
|
logger.LogInfo($"{unresolvedReferences.Count,align} unresolved references");
|
||||||
logger.LogInfo($"{conflictedReferences,align} resolved assembly conflicts");
|
logger.LogInfo($"{conflictedReferences,align} resolved assembly conflicts");
|
||||||
|
logger.LogInfo($"{dotnetFrameworkVersionVariantCount,align} restored .NET framework variants");
|
||||||
logger.LogInfo($"Build analysis completed in {DateTime.Now - startTime}");
|
logger.LogInfo($"Build analysis completed in {DateTime.Now - startTime}");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashSet<string> AddFrameworkDlls(HashSet<string> dllPaths)
|
private HashSet<string> AddFrameworkDlls(HashSet<string> dllPaths)
|
||||||
@@ -241,11 +242,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
|||||||
|
|
||||||
private void SelectNewestFrameworkPath(string frameworkPath, string frameworkType, ISet<string> dllPaths, ISet<string> frameworkLocations)
|
private void SelectNewestFrameworkPath(string frameworkPath, string frameworkType, ISet<string> dllPaths, ISet<string> frameworkLocations)
|
||||||
{
|
{
|
||||||
var versionFolders = new DirectoryInfo(frameworkPath)
|
var versionFolders = GetPackageVersionSubDirectories(frameworkPath);
|
||||||
.EnumerateDirectories("*", new EnumerationOptions { MatchCasing = MatchCasing.CaseInsensitive, RecurseSubdirectories = false })
|
|
||||||
.OrderByDescending(d => d.Name) // TODO: Improve sorting to handle pre-release versions.
|
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
if (versionFolders.Length > 1)
|
if (versionFolders.Length > 1)
|
||||||
{
|
{
|
||||||
var versions = string.Join(", ", versionFolders.Select(d => d.Name));
|
var versions = string.Join(", ", versionFolders.Select(d => d.Name));
|
||||||
@@ -264,18 +261,34 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
|||||||
logger.LogInfo($"Found {frameworkType} DLLs in NuGet packages at {selectedFrameworkFolder}.");
|
logger.LogInfo($"Found {frameworkType} DLLs in NuGet packages at {selectedFrameworkFolder}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static DirectoryInfo[] GetPackageVersionSubDirectories(string packagePath)
|
||||||
|
{
|
||||||
|
return new DirectoryInfo(packagePath)
|
||||||
|
.EnumerateDirectories("*", new EnumerationOptions { MatchCasing = MatchCasing.CaseInsensitive, RecurseSubdirectories = false })
|
||||||
|
.OrderByDescending(d => d.Name) // TODO: Improve sorting to handle pre-release versions.
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
private void AddNetFrameworkDlls(ISet<string> dllPaths, ISet<string> frameworkLocations)
|
private void AddNetFrameworkDlls(ISet<string> dllPaths, ISet<string> frameworkLocations)
|
||||||
{
|
{
|
||||||
// Multiple dotnet framework packages could be present.
|
// Multiple dotnet framework packages could be present.
|
||||||
// The order of the packages is important, we're adding the first one that is present in the nuget cache.
|
// The order of the packages is important, we're adding the first one that is present in the nuget cache.
|
||||||
var packagesInPrioOrder = FrameworkPackageNames.NetFrameworks;
|
var packagesInPrioOrder = FrameworkPackageNames.NetFrameworks;
|
||||||
|
|
||||||
var frameworkPath = packagesInPrioOrder
|
var frameworkPaths = packagesInPrioOrder
|
||||||
.Select((s, index) => (Index: index, Path: GetPackageDirectory(s)))
|
.Select((s, index) => (Index: index, Path: GetPackageDirectory(s)))
|
||||||
.FirstOrDefault(pair => pair.Path is not null);
|
.Where(pair => pair.Path is not null)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
var frameworkPath = frameworkPaths.FirstOrDefault();
|
||||||
|
|
||||||
if (frameworkPath.Path is not null)
|
if (frameworkPath.Path is not null)
|
||||||
{
|
{
|
||||||
|
foreach (var fp in frameworkPaths)
|
||||||
|
{
|
||||||
|
dotnetFrameworkVersionVariantCount += GetPackageVersionSubDirectories(fp.Path!).Length;
|
||||||
|
}
|
||||||
|
|
||||||
SelectNewestFrameworkPath(frameworkPath.Path, ".NET Framework", dllPaths, frameworkLocations);
|
SelectNewestFrameworkPath(frameworkPath.Path, ".NET Framework", dllPaths, frameworkLocations);
|
||||||
|
|
||||||
for (var i = frameworkPath.Index + 1; i < packagesInPrioOrder.Length; i++)
|
for (var i = frameworkPath.Index + 1; i < packagesInPrioOrder.Length; i++)
|
||||||
|
|||||||
Reference in New Issue
Block a user