Dependency Class

Represents a dependency discovered during scanning, including its name, version, type, and location information.

public sealed class Dependency

Constructors

NameDescription
Dependency(string?, string?, DependencyType, Location?, Location?)Initializes a new instance of the Dependency class.

Dependency(string?, string?, DependencyType, Location?, Location?)

Dependency.cs

Initializes a new instance of the Dependency class.

public Dependency(string? name, string? version, DependencyType type, Location? nameLocation, Location? versionLocation)

Parameters

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 name. Unless it already knows the value it holds, it records name as the value an update expects to find.
versionLocation Location?
The location of the version. Unless it already knows the value it holds, it records version as the value an update expects to find.

Properties

NameDescription
MetadataGets a dictionary of metadata associated with this dependency for storing additional scanner-specific information.
NameGets the name of the dependency, as found by the scan. It does not change when the name is updated.
NameLocationGets the location of the dependency name in the source file, or null if not available.
TagsGets a collection of tags associated with this dependency, such as the scanner type that discovered it.
TypeGets the type of the dependency.
VersionGets the version of the dependency, as found by the scan. It does not change when the version is updated.
VersionLocationGets the location of the dependency version in the source file, or null if not available.

Gets a dictionary of metadata associated with this dependency for storing additional scanner-specific information.

public IDictionary<string, object?> Metadata { get; }

Gets the name of the dependency, as found by the scan. It does not change when the name is updated.

public string? Name { get; }

Property value

string?

NameLocation

Dependency.cs

Gets the location of the dependency name in the source file, or null if not available.

public Location? NameLocation { get; }

Property value

Location?

Gets a collection of tags associated with this dependency, such as the scanner type that discovered it.

public ISet<string> Tags { get; }

Property value

ISet<string>

Gets the type of the dependency.

public DependencyType Type { get; }

Property value

DependencyType

Gets the version of the dependency, as found by the scan. It does not change when the version is updated.

public string? Version { get; }

Property value

string?

VersionLocation

Dependency.cs

Gets the location of the dependency version in the source file, or null if not available.

public Location? VersionLocation { get; }

Property value

Location?

Methods

NameDescription
ToString()
UpdateNameAsync(string, CancellationToken)Updates the dependency name in the source file.
UpdateVersionAsync(string, CancellationToken)Updates the dependency version in the source file.

ToString()

Dependency.cs
public override string ToString()

Returns

string

No documentation is available.

UpdateNameAsync(string, CancellationToken)

Dependency.cs

Updates the dependency name in the source file.

public Task UpdateNameAsync(string newValue, CancellationToken cancellationToken = default)

Parameters

newValue string
The new name value to write.
cancellationToken CancellationToken
A token to cancel the operation.

Returns

Task

Exceptions

InvalidOperationException
Thrown when the name location is not updatable.
ArgumentException
The file cannot hold newValue, such as a line break in a line of text, or a control character in an XML file.
DependencyScannerException
The file does not hold the expected name at the location anymore.

Remarks

The file must still hold the value the location holds: the scanned name, or the name written by the previous update. So the name can be updated several times, and the name and the version can be updated in any order.

UpdateVersionAsync(string, CancellationToken)

Dependency.cs

Updates the dependency version in the source file.

public Task UpdateVersionAsync(string newValue, CancellationToken cancellationToken = default)

Parameters

newValue string
The new version value to write.
cancellationToken CancellationToken
A token to cancel the operation.

Returns

Task

Exceptions

InvalidOperationException
Thrown when the version location is not updatable.
ArgumentException
The file cannot hold newValue, such as a line break in a line of text, or a control character in an XML file.
DependencyScannerException
The file does not hold the expected version at the location anymore.

Remarks

The file must still hold the value the location holds: the scanned version, or the version written by the previous update. So the version can be updated several times, and the name and the version can be updated in any order.