ScannerOptions Class
Provides configuration options for dependency scanning operations.
var options = new ScannerOptions
{
DegreeOfParallelism = 8,
RecurseSubdirectories = true,
IncludedDependencyTypes = [DependencyType.NuGet, DependencyType.Npm],
};
var dependencies = await DependencyScanner.ScanDirectoryAsync("C:\\MyProject", options, cancellationToken);public sealed class ScannerOptionsConstructors
| Name | Description |
|---|---|
| ScannerOptions() |
ScannerOptions()
ScannerOptions.cspublic ScannerOptions()No documentation is available.
Properties
| Name | Description |
|---|---|
| DegreeOfParallelism | Gets or sets the maximum number of parallel scanning tasks, or -1 to use Environment.ProcessorCount. Default is 16. |
| ExcludedDependencyTypes | Gets or sets the set of dependency types to exclude from scanning. Default is empty (no types excluded). |
| FileSystem | Gets or sets the file system implementation to use for file access. |
| IncludedDependencyTypes | Gets or sets the set of dependency types to include. When set, only these types will be scanned. Default is empty (all types included). |
| OnFileScanFailed | Gets or sets the callback invoked when a file cannot be scanned. Default is null: the file is silently skipped. |
| RecurseSubdirectories | Gets or sets a value indicating whether to recurse into subdirectories. Default is true. |
| Scanners | Gets or sets the collection of scanners to use. Defaults to all built-in scanners. |
| ShouldRecursePredicate | Gets or sets a predicate to filter which subdirectories to recurse into. |
| ShouldScanFilePredicate | Gets or sets a predicate to filter which files to scan. |
DegreeOfParallelism
ScannerOptions.csGets or sets the maximum number of parallel scanning tasks, or -1 to use Environment.ProcessorCount. Default is 16.
public int DegreeOfParallelism { get; set; }ExcludedDependencyTypes
ScannerOptions.csGets or sets the set of dependency types to exclude from scanning. Default is empty (no types excluded).
public ImmutableHashSet<DependencyType> ExcludedDependencyTypes { get; set; }Property value
FileSystem
ScannerOptions.csGets or sets the file system implementation to use for file access.
public IFileSystem FileSystem { get; set; }Property value
Remarks
With a custom file system, a directory scan lists the files with IFileSystem.GetFiles using the * pattern, and does not support ScannerOptions.ShouldScanFilePredicate and ScannerOptions.ShouldRecursePredicate.
IncludedDependencyTypes
ScannerOptions.csGets or sets the set of dependency types to include. When set, only these types will be scanned. Default is empty (all types included).
public ImmutableHashSet<DependencyType> IncludedDependencyTypes { get; set; }Property value
OnFileScanFailed
ScannerOptions.csGets or sets the callback invoked when a file cannot be scanned. Default is null: the file is silently skipped.
public FileScanFailed? OnFileScanFailed { get; set; }Property value
Remarks
A file that cannot be opened or read, or that a scanner fails to scan, is skipped and the scan continues with the next file. The callback receives the path of the file and the exception. It can be invoked concurrently, and an exception it throws stops the scan. Cancellation is not a failure: the scan methods throw an OperationCanceledException when their cancellation token is canceled.
RecurseSubdirectories
ScannerOptions.csScanners
ScannerOptions.csGets or sets the collection of scanners to use. Defaults to all built-in scanners.
public ImmutableArray<DependencyScanner> Scanners { get; set; }Property value
ShouldRecursePredicate
ScannerOptions.csGets or sets a predicate to filter which subdirectories to recurse into.
public FileSystemEntryPredicate? ShouldRecursePredicate { get; set; }Property value
Remarks
Symbolic links and other reparse points to directories are never followed, whatever the predicate returns. The predicate is only supported with the default ScannerOptions.FileSystem: a directory scan with a custom file system throws a NotSupportedException when it is set.
ShouldScanFilePredicate
ScannerOptions.csGets or sets a predicate to filter which files to scan.
public FileSystemEntryPredicate? ShouldScanFilePredicate { get; set; }Property value
Remarks
The predicate is only supported with the default ScannerOptions.FileSystem: a directory scan with a custom file system throws a NotSupportedException when it is set.