using System; using System.Linq; using System.Collections.Generic; using Semmle.Util; namespace Semmle.Extraction.CSharp.DependencyFetching { /// /// Dependency fetching related options. /// public interface IDependencyOptions { /// /// Directories to search DLLs in. /// IList DllDirs { get; } /// /// Files/patterns to exclude. /// IList Excludes { get; } /// /// Whether to analyse NuGet packages. /// bool UseNuGet { get; } /// /// The solution file to analyse, or null if not specified. /// string? SolutionFile { get; } /// /// Whether to use the packaged dotnet runtime. /// bool UseSelfContainedDotnet { get; } /// /// Whether to search the .Net framework directory. /// bool ScanNetFrameworkDlls { get; } /// /// Determine whether the given path should be excluded. /// /// The path to query. /// True iff the path matches an exclusion. bool ExcludesFile(string path); /// /// The number of threads to use. /// int Threads { get; } /// /// The path to the local ".dotnet" directory, if any. /// string? DotNetPath { get; } } public class DependencyOptions : IDependencyOptions { public static IDependencyOptions Default => new DependencyOptions(); public IList DllDirs { get; set; } = new List(); public IList Excludes { get; set; } = new List(); public bool UseNuGet { get; set; } = true; public string? SolutionFile { get; set; } public bool UseSelfContainedDotnet { get; set; } = false; public bool ScanNetFrameworkDlls { get; set; } = true; public bool ExcludesFile(string path) => Excludes.Any(path.Contains); public int Threads { get; set; } = EnvironmentVariables.GetDefaultNumberOfThreads(); public string? DotNetPath { get; set; } = null; } }