Skip to content

Commit ef68e33

Browse files
committed
C#: Address review comments.
1 parent ff498f6 commit ef68e33

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/AssemblyLookupLocation.cs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
1010
/// Used to represent a path to an assembly or a directory containing assemblies
1111
/// and a selector function to determine which files to include, when indexing the assemblies.
1212
/// </summary>
13-
internal sealed class AssemblyLookupLocation(string p, Func<string, bool> includeFileName, bool indexSubdirectories = true)
13+
internal sealed class AssemblyLookupLocation(string path, Func<string, bool> includeFileName, bool indexSubdirectories = true)
1414
{
15-
public string Path => p;
15+
public string Path => path;
1616

17-
public AssemblyLookupLocation(string p) : this(p, _ => true) { }
17+
public AssemblyLookupLocation(string path) : this(path, _ => true) { }
1818

1919
public static implicit operator AssemblyLookupLocation(string path) => new(path);
2020

@@ -23,15 +23,16 @@ public AssemblyLookupLocation(string p) : this(p, _ => true) { }
2323
/// and adds them to the a list of assembly names to index.
2424
/// Indexing is performed at a later stage. This only collects the names.
2525
/// </summary>
26-
/// <param name="dir">The directory to index.</param>
26+
/// <param name="dllsToIndex">List of dlls to index.</param>
27+
/// <param name="logger">Logger.</param>
2728
private void AddReferenceDirectory(List<string> dllsToIndex, ILogger logger)
2829
{
2930
try
3031
{
31-
var dlls = new DirectoryInfo(p).EnumerateFiles("*.dll", new EnumerationOptions { RecurseSubdirectories = indexSubdirectories, MatchCasing = MatchCasing.CaseInsensitive, AttributesToSkip = FileAttributes.None });
32+
var dlls = new DirectoryInfo(path).EnumerateFiles("*.dll", new EnumerationOptions { RecurseSubdirectories = indexSubdirectories, MatchCasing = MatchCasing.CaseInsensitive, AttributesToSkip = FileAttributes.None });
3233
if (!dlls.Any())
3334
{
34-
logger.LogWarning($"AssemblyLookupLocation: No DLLs found in the path '{p}'.");
35+
logger.LogWarning($"AssemblyLookupLocation: No DLLs found in the path '{path}'.");
3536
return;
3637
}
3738
foreach (var dll in dlls)
@@ -48,47 +49,47 @@ private void AddReferenceDirectory(List<string> dllsToIndex, ILogger logger)
4849
}
4950
catch (Exception e)
5051
{
51-
logger.LogError($"AssemblyLookupLocation: Error while searching for DLLs in '{p}': {e.Message}");
52+
logger.LogError($"AssemblyLookupLocation: Error while searching for DLLs in '{path}': {e.Message}");
5253
}
5354
}
5455

5556
/// <summary>
56-
/// Returns a list of paths to all assemblies in `p` that should be indexed.
57+
/// Returns a list of paths to all assemblies in `path` that should be indexed.
5758
/// </summary>
5859
/// <param name="logger">Logger</param>
5960
public List<string> GetDlls(ILogger logger)
6061
{
6162
var dllsToIndex = new List<string>();
62-
if (File.Exists(p))
63+
if (File.Exists(path))
6364
{
64-
if (includeFileName(System.IO.Path.GetFileName(p)))
65+
if (includeFileName(System.IO.Path.GetFileName(path)))
6566
{
66-
dllsToIndex.Add(p);
67+
dllsToIndex.Add(path);
6768
}
6869
else
6970
{
70-
logger.LogInfo($"AssemblyLookupLocation: Skipping {p}.");
71+
logger.LogInfo($"AssemblyLookupLocation: Skipping {path}.");
7172
}
7273
return dllsToIndex;
7374
}
7475

75-
if (Directory.Exists(p))
76+
if (Directory.Exists(path))
7677
{
77-
logger.LogInfo($"AssemblyLookupLocation: Finding reference DLLs in {p}...");
78+
logger.LogInfo($"AssemblyLookupLocation: Finding reference DLLs in {path}...");
7879
AddReferenceDirectory(dllsToIndex, logger);
7980
}
8081
else
8182
{
82-
logger.LogInfo("AssemblyLookupLocation: Path not found: " + p);
83+
logger.LogInfo("AssemblyLookupLocation: Path not found: " + path);
8384
}
8485
return dllsToIndex;
8586
}
8687

8788
public override bool Equals(object? obj) =>
88-
obj is AssemblyLookupLocation ap && p.Equals(ap.Path);
89+
obj is AssemblyLookupLocation ap && path.Equals(ap.Path);
8990

90-
public override int GetHashCode() => p.GetHashCode();
91+
public override int GetHashCode() => path.GetHashCode();
9192

92-
public override string ToString() => p;
93+
public override string ToString() => path;
9394
}
9495
}

csharp/ql/integration-tests/posix-only/standalone_dependencies_executing_runtime/global.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)