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
DependencyScanner RegexScanner

Constructors

NameDescription
RegexScanner()

RegexScanner()

public RegexScanner()

No documentation is available.

Properties

NameDescription
DependencyTypeGets or sets the type of dependency to report when a match is found.
FilePatternsGets 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.
RegexGets or sets the regular expression used to match dependencies. The expression must include named groups 'name' and optionally 'version'.

DependencyType

RegexScanner.cs

Gets or sets the type of dependency to report when a match is found.

public DependencyType DependencyType { get; set; }

Property value

DependencyType

FilePatterns

RegexScanner.cs

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.

public GlobCollection? FilePatterns { get; set; }

Property value

GlobCollection?

Gets or sets the regular expression used to match dependencies. The expression must include named groups 'name' and optionally 'version'.

public Regex? Regex { get; set; }

Property value

Regex?

Methods

NameDescription
ScanAsync(ScanFileContext)

ScanAsync(ScanFileContext)

RegexScanner.cs

net10.0

public override ValueTask ScanAsync(ScanFileContext context)

net11.0

public override ValueTask ScanAsync(ScanFileContext context)

Parameters

context ScanFileContext

Returns

ValueTask

No documentation is available.