mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C#: Prefer framework assemblies over arbitrary nuget equivalents
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
@@ -20,7 +19,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||
/// assembly cache.
|
||||
/// </param>
|
||||
/// <param name="progressMonitor">Callback for progress.</param>
|
||||
public AssemblyCache(IEnumerable<string> paths, ProgressMonitor progressMonitor)
|
||||
public AssemblyCache(IEnumerable<string> paths, IEnumerable<string> frameworkPaths, ProgressMonitor progressMonitor)
|
||||
{
|
||||
foreach (var path in paths)
|
||||
{
|
||||
@@ -40,7 +39,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||
progressMonitor.LogInfo("AssemblyCache: Path not found: " + path);
|
||||
}
|
||||
}
|
||||
IndexReferences();
|
||||
IndexReferences(frameworkPaths);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -57,13 +56,11 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Version emptyVersion = new Version(0, 0, 0, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Indexes all DLLs we have located.
|
||||
/// Because this is a potentially time-consuming operation, it is put into a separate stage.
|
||||
/// </summary>
|
||||
private void IndexReferences()
|
||||
private void IndexReferences(IEnumerable<string> frameworkPaths)
|
||||
{
|
||||
// Read all of the files
|
||||
foreach (var filename in pendingDllsToIndex)
|
||||
@@ -71,13 +68,9 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||
IndexReference(filename);
|
||||
}
|
||||
|
||||
// Index "assemblyInfo" by version string
|
||||
// The OrderBy is used to ensure that we by default select the highest version number.
|
||||
foreach (var info in assemblyInfoByFileName.Values
|
||||
.OrderBy(info => info.Name)
|
||||
.ThenBy(info => info.NetCoreVersion ?? emptyVersion)
|
||||
.ThenBy(info => info.Version ?? emptyVersion)
|
||||
.ThenBy(info => info.Filename))
|
||||
.OrderAssemblyInfosByPreference(frameworkPaths))
|
||||
{
|
||||
foreach (var index in info.IndexStrings)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user