using System.Linq; using System.Collections.Generic; 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; } /// /// Whether to use mscorlib as a reference. /// bool UseMscorlib { get; } /// /// Determine whether the given path should be excluded. /// /// The path to query. /// True iff the path matches an exclusion. bool ExcludesFile(string path); } 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 UseMscorlib { get; set; } = true; public bool ExcludesFile(string path) => Excludes.Any(path.Contains); } }