ScanFileContext Struct
Provides context information and methods for scanning a file and reporting discovered dependencies.
public readonly struct ScanFileContext : IAsyncDisposable- Implements
Properties
| Name | Description |
|---|---|
| CancellationToken | Gets the cancellation token for the scanning operation. |
| Content | Gets a seekable stream containing the file content. The stream is lazily opened on first access. |
| FileSystem | Gets the file system implementation for accessing files. |
| FullPath | Gets the full path of the file being scanned. |
CancellationToken
ScanFileContext.csGets the cancellation token for the scanning operation.
public CancellationToken CancellationToken { get; }Property value
Content
ScanFileContext.csGets a seekable stream containing the file content. The stream is lazily opened on first access.
public Stream Content { get; }Property value
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.
FileSystem
ScanFileContext.csGets the file system implementation for accessing files.
public IFileSystem FileSystem { get; }Property value
FullPath
ScanFileContext.csMethods
| Name | Description |
|---|---|
| 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.csReportDependency overloads
ReportDependency(DependencyScanner, string?, string?, DependencyType, Location?, Location?)
ScanFileContext.csReports a discovered dependency to the scanning framework.
public void ReportDependency(DependencyScanner scanner, string? name, string? version, DependencyType type, Location? nameLocation, Location? versionLocation)Parameters
scannerDependencyScanner- The scanner that discovered the dependency.
namestring?- The name of the dependency.
versionstring?- The version of the dependency.
typeDependencyType- The type of the dependency.
nameLocationLocation?- The location of the dependency name in the source file.
versionLocationLocation?- The location of the dependency version in the source file.
ReportDependency(DependencyScanner, string?, string?, DependencyType, Location?, Location?, ReadOnlySpan<string>, ReadOnlySpan<KeyValuePair<string, object?>>)
ScanFileContext.csReports 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
scannerDependencyScanner- The scanner that discovered the dependency.
namestring?- The name of the dependency.
versionstring?- The version of the dependency.
typeDependencyType- The type of the dependency.
nameLocationLocation?- The location of the dependency name in the source file.
versionLocationLocation?- The location of the dependency version in the source file.
tagsReadOnlySpan<string>- Additional tags to associate with the dependency.
metadataReadOnlySpan<KeyValuePair<string, object?>>- Additional metadata to associate with the dependency.