ScanFileContext Struct

Provides context information and methods for scanning a file and reporting discovered dependencies.

public readonly struct ScanFileContext : IAsyncDisposable
Implements

Properties

NameDescription
CancellationTokenGets the cancellation token for the scanning operation.
ContentGets a seekable stream containing the file content. The stream is lazily opened on first access.
FileSystemGets the file system implementation for accessing files.
FullPathGets the full path of the file being scanned.

CancellationToken

ScanFileContext.cs

Gets the cancellation token for the scanning operation.

public CancellationToken CancellationToken { get; }

Property value

CancellationToken

Gets a seekable stream containing the file content. The stream is lazily opened on first access.

public Stream Content { get; }

Property value

Stream

Remarks

When the file system returns a stream that cannot seek, the content is read into memory. An exception thrown while opening the file makes the scan skip the file, and is reported to ScannerOptions.OnFileScanFailed.

Gets the file system implementation for accessing files.

public IFileSystem FileSystem { get; }

Property value

IFileSystem

Gets the full path of the file being scanned.

public string FullPath { get; }

Property value

string

Methods

NameDescription
DisposeAsync()
ReportDependency(DependencyScanner, string?, string?, DependencyType, Location?, Location?)Reports a discovered dependency to the scanning framework.
ReportDependency(DependencyScanner, string?, string?, DependencyType, Location?, Location?, ReadOnlySpan<string>, ReadOnlySpan<KeyValuePair<string, object?>>)Reports a discovered dependency with additional tags and metadata to the scanning framework.

DisposeAsync()

ScanFileContext.cs
public ValueTask DisposeAsync()

Returns

ValueTask

No documentation is available.

ReportDependency overloads

ReportDependency(DependencyScanner, string?, string?, DependencyType, Location?, Location?)

ScanFileContext.cs

Reports a discovered dependency to the scanning framework.

public void ReportDependency(DependencyScanner scanner, string? name, string? version, DependencyType type, Location? nameLocation, Location? versionLocation)
Parameters
scanner DependencyScanner
The scanner that discovered the dependency.
name string?
The name of the dependency.
version string?
The version of the dependency.
type DependencyType
The type of the dependency.
nameLocation Location?
The location of the dependency name in the source file.
versionLocation Location?
The location of the dependency version in the source file.

ReportDependency(DependencyScanner, string?, string?, DependencyType, Location?, Location?, ReadOnlySpan<string>, ReadOnlySpan<KeyValuePair<string, object?>>)

ScanFileContext.cs

Reports a discovered dependency with additional tags and metadata to the scanning framework.

public void ReportDependency(DependencyScanner scanner, string? name, string? version, DependencyType type, Location? nameLocation, Location? versionLocation, ReadOnlySpan<string> tags, ReadOnlySpan<KeyValuePair<string, object?>> metadata)
Parameters
scanner DependencyScanner
The scanner that discovered the dependency.
name string?
The name of the dependency.
version string?
The version of the dependency.
type DependencyType
The type of the dependency.
nameLocation Location?
The location of the dependency name in the source file.
versionLocation Location?
The location of the dependency version in the source file.
tags ReadOnlySpan<string>
Additional tags to associate with the dependency.
metadata ReadOnlySpan<KeyValuePair<string, object?>>
Additional metadata to associate with the dependency.