PackageVersionRange

Namespace: AnyPackage.Provider

The PackageVersionRange.

public sealed class PackageVersionRange

Inheritance ObjectPackageVersionRange

Properties

MinVersion

Gets the minimum package version.

public PackageVersion MinVersion { get; }

Property Value

PackageVersion

MaxVersion

Gets the maximum package version.

public PackageVersion MaxVersion { get; }

Property Value

PackageVersion

IsMinInclusive

Gets if the minimum version is inclusive.

public bool IsMinInclusive { get; }

Property Value

Boolean

IsMaxInclusive

Gets if the maximum version is inclusive.

public bool IsMaxInclusive { get; }

Property Value

Boolean

Constructors

PackageVersionRange(String)

Constructs a version range using a PowerShell modified NuGet package version range syntax.

public PackageVersionRange(string versionRange)

Parameters

versionRange String
NuGet package version formatted string.

Exceptions

ArgumentNullException
Version range is null.

ArgumentException
Version range is not in correct format.

ArgumentOutOfRangeException
Min version is higher than max version.

Remarks:

To maintain type conversion compatibility with the PowerShell cmdlet parameters the default behavior is to change min version syntax into required. For example, 1.0 would become [1.0] since PowerShell users expect the version to be the exact version supplied instead of NuGet syntax of min version inclusive. To pass a min version inclusive use [1.0,] syntax.

This behavior is only used when constructing the version range. The standard NuGet syntax is used elsewhere. If you need to use NuGet syntax use the constructor with useNuGetSyntax parameter.

PackageVersionRange(String, Boolean)

Constructs a version range using a NuGet package version range syntax.

public PackageVersionRange(string versionRange, bool useNuGetSyntax)

Parameters

versionRange String
NuGet package version formatted string.

useNuGetSyntax Boolean

        If true use NuGet syntax otherwise false uses PowerShell modified syntax.

Exceptions

ArgumentNullException
Version range is null.

ArgumentException
Version range is not in correct format.

ArgumentOutOfRangeException
Min version is higher than max version.

Remarks:

To maintain type conversion compatibility with the PowerShell cmdlet parameters the default behavior is to change min version syntax into required. For example, 1.0 would become [1.0] since PowerShell users expect the version to be the exact version supplied instead of NuGet syntax of min version inclusive. To pass a min version inclusive use [1.0,] syntax.

This behavior is only used when constructing the version range. The standard NuGet syntax is used elsewhere. If you need to use NuGet syntax use the useNuGetSyntax parameter.

PackageVersionRange(PackageVersion, PackageVersion, Boolean, Boolean)

Constructs a version range using min and max version.

public PackageVersionRange(PackageVersion minVersion, PackageVersion maxVersion, bool isMinInclusive, bool isMaxInclusive)

Parameters

minVersion PackageVersion
Minimum version.

maxVersion PackageVersion
Maximum version.

isMinInclusive Boolean
If min version is inclusive.

isMaxInclusive Boolean
If max version is inclusive.

Exceptions

ArgumentOutOfRangeException
Min version is higher than max version.

Methods

Parse(String)

Converts the string representation of a version range to an equivalent PackageVersionRange object.

public static PackageVersionRange Parse(string versionRange)

Parameters

versionRange String
A string that contains a version range to convert.

Returns

PackageVersionRange

        An object that is equivalent to the version range specified in the versionRange parameter.

Exceptions

ArgumentNullException
Version range is null.

ArgumentException
Version range is not in correct format.

ArgumentOutOfRangeException
Min version is higher than max version.

Remarks:

To maintain type conversion compatibility with the PowerShell cmdlet parameters the default behavior is to change min version syntax into required. For example, 1.0 would become [1.0] since PowerShell users expect the version to be the exact version supplied instead of NuGet syntax of min version inclusive. To pass a min version inclusive use [1.0,] syntax.

This behavior is only used when constructing the version range. The standard NuGet syntax is used elsewhere. If you need to use NuGet syntax use the Parse method with useNuGetSyntax parameter.

Parse(String, Boolean)

Converts the string representation of a version range to an equivalent PackageVersionRange object.

public static PackageVersionRange Parse(string versionRange, bool useNuGetSyntax)

Parameters

versionRange String
A string that contains a version range to convert.

useNuGetSyntax Boolean

        If true use NuGet syntax otherwise false uses PowerShell modified syntax.

Returns

PackageVersionRange

        An object that is equivalent to the version range specified in the versionRange parameter.

Exceptions

ArgumentNullException
Version range is null.

ArgumentException
Version range is not in correct format.

ArgumentOutOfRangeException
Min version is higher than max version.

Remarks:

To maintain type conversion compatibility with the PowerShell cmdlet parameters the default behavior is to change min version syntax into required. For example, 1.0 would become [1.0] since PowerShell users expect the version to be the exact version supplied instead of NuGet syntax of min version inclusive. To pass a min version inclusive use [1.0,] syntax.

This behavior is only used when constructing the version range. The standard NuGet syntax is used elsewhere. If you need to use NuGet syntax use the useNuGetSyntax parameter.

TryParse(String, PackageVersionRange&)

Tries to convert the string representation of a version to an equivalent PackageVersionRange object, and returns a value that indicates whether the conversion succeeded.

public static bool TryParse(string versionRange, PackageVersionRange& result)

Parameters

versionRange String
A string that contains a version range to convert.

result PackageVersionRange&

        When this methods returns, contains the PackageVersionRange equivalent of the string, if the conversion succeeded.
        If version is null, Empty, or if the conversion fails, result is null when the method returns.

Returns

Boolean
true if the version parameter was converted successfully; otherwise, false.

TryParse(String, Boolean, PackageVersionRange&)

Tries to convert the string representation of a version to an equivalent PackageVersionRange object, and returns a value that indicates whether the conversion succeeded.

public static bool TryParse(string versionRange, bool useNuGetSyntax, PackageVersionRange& result)

Parameters

versionRange String
A string that contains a version range to convert.

useNuGetSyntax Boolean

        If true use NuGet syntax otherwise false uses PowerShell modified syntax.

result PackageVersionRange&

        When this methods returns, contains the PackageVersionRange equivalent of the string, if the conversion succeeded.
        If version is null, Empty, or if the conversion fails, result is null when the method returns.

Returns

Boolean
true if the version parameter was converted successfully; otherwise, false.

Remarks:

To maintain type conversion compatibility with the PowerShell cmdlet parameters the default behavior is to change min version syntax into required. For example, 1.0 would become [1.0] since PowerShell users expect the version to be the exact version supplied instead of NuGet syntax of min version inclusive. To pass a min version inclusive use [1.0,] syntax.

This behavior is only used when constructing the version range. The standard NuGet syntax is used elsewhere. If you need to use NuGet syntax use the useNuGetSyntax parameter.

Satisfies(PackageVersion)

Checks the supplied version satisfies the version range.

public bool Satisfies(PackageVersion version)

Parameters

version PackageVersion
The package version to check.

Returns

Boolean
Returns true if the version range is satisfied by the supplied version.

Satisfies(PackageVersion, IComparer<PackageVersion>)

Checks the supplied version satisfies the version range.

public bool Satisfies(PackageVersion version, IComparer<PackageVersion> comparer)

Parameters

version PackageVersion
The package version to check.

comparer IComparer<PackageVersion>
The custom comparer to use for version comparisons.

Returns

Boolean
Returns true if the version range is satisfied by the supplied version.

ToString()

Provides a ToString implementation.

public string ToString()

Returns

String
A NuGet package version reference string.

Remarks:

For more information refer to: https://docs.microsoft.com/en-us/nuget/concepts/package-versioning

ToString(Boolean)

Provides a ToString implementation.

public string ToString(bool shortNotation)

Parameters

shortNotation Boolean
Min version inclusive will return just the version.

Returns

String
A NuGet package version reference string with short notation.