RegexScanner Class
A configurable scanner that uses regular expressions to extract dependencies from files.
var scanner = new RegexScanner
{
FilePatterns = [Glob.Parse("**/*.custom", GlobDialect.Standard, GlobOptions.IgnoreCase)],
DependencyType = DependencyType.DockerImage,
Regex = new Regex(@"image:\s*(?<name>[a-z/]+)(:(?<version>[0-9.]+))?", RegexOptions.ExplicitCapture, TimeSpan.FromSeconds(10)),
};
var options = new ScannerOptions { Scanners = [scanner] };
var dependencies = await DependencyScanner.ScanDirectoryAsync("C:\\MyProject", options, cancellationToken);public sealed class RegexScanner : DependencyScanner- Inheritance
DependencyScannerRegexScanner
Constructors
| Name | Description |
|---|---|
| RegexScanner() |
RegexScanner()
public RegexScanner()No documentation is available.
Properties
| Name | Description |
|---|---|
| DependencyType | Gets or sets the type of dependency to report when a match is found. |
| FilePatterns | Gets or sets the glob patterns specifying which files to scan. Patterns are matched against the path relative to the root directory of the scan (for instance build/*.yml). If null, all files are scanned. |
| Regex | Gets or sets the regular expression used to match dependencies. The expression must include named groups 'name' and optionally 'version'. |
DependencyType
RegexScanner.csGets or sets the type of dependency to report when a match is found.
public DependencyType DependencyType { get; set; }Property value
FilePatterns
RegexScanner.csGets or sets the glob patterns specifying which files to scan. Patterns are matched against the path relative to the root directory of the scan (for instance build/*.yml). If null, all files are scanned.
public GlobCollection? FilePatterns { get; set; }Property value
Regex
RegexScanner.csMethods
| Name | Description |
|---|---|
| ScanAsync(ScanFileContext) |
ScanAsync(ScanFileContext)
RegexScanner.csnet10.0
public override ValueTask ScanAsync(ScanFileContext context)net11.0
public override ValueTask ScanAsync(ScanFileContext context)No documentation is available.