Dependency Class
Represents a dependency discovered during scanning, including its name, version, type, and location information.
public sealed class DependencyConstructors
| Name | Description |
|---|---|
| Dependency(string?, string?, DependencyType, Location?, Location?) | Initializes a new instance of the Dependency class. |
Dependency(string?, string?, DependencyType, Location?, Location?)
Dependency.csInitializes a new instance of the Dependency class.
public Dependency(string? name, string? version, DependencyType type, Location? nameLocation, Location? versionLocation)Parameters
namestring?- The name of the dependency.
versionstring?- The version of the dependency.
typeDependencyType- The type of the dependency.
nameLocationLocation?- The location of the name. Unless it already knows the value it holds, it records
nameas the value an update expects to find. versionLocationLocation?- The location of the version. Unless it already knows the value it holds, it records
versionas the value an update expects to find.
Properties
| Name | Description |
|---|---|
| Metadata | Gets a dictionary of metadata associated with this dependency for storing additional scanner-specific information. |
| Name | Gets the name of the dependency, as found by the scan. It does not change when the name is updated. |
| NameLocation | Gets the location of the dependency name in the source file, or null if not available. |
| Tags | Gets a collection of tags associated with this dependency, such as the scanner type that discovered it. |
| Type | Gets the type of the dependency. |
| Version | Gets the version of the dependency, as found by the scan. It does not change when the version is updated. |
| VersionLocation | Gets the location of the dependency version in the source file, or null if not available. |
Metadata
Dependency.csGets a dictionary of metadata associated with this dependency for storing additional scanner-specific information.
public IDictionary<string, object?> Metadata { get; }Property value
Name
Dependency.csNameLocation
Dependency.csTags
Dependency.csGets a collection of tags associated with this dependency, such as the scanner type that discovered it.
Property value
Type
Dependency.csVersion
Dependency.csVersionLocation
Dependency.csMethods
| Name | Description |
|---|---|
| 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.csUpdateNameAsync(string, CancellationToken)
Dependency.csUpdates the dependency name in the source file.
public Task UpdateNameAsync(string newValue, CancellationToken cancellationToken = default)Parameters
newValuestring- The new name value to write.
cancellationTokenCancellationToken- A token to cancel the operation.
Returns
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.csUpdates the dependency version in the source file.
public Task UpdateVersionAsync(string newValue, CancellationToken cancellationToken = default)Parameters
newValuestring- The new version value to write.
cancellationTokenCancellationToken- A token to cancel the operation.
Returns
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.