Tip
Call this method with significantVersionParts = 3 and simplify =
to get the default string representation of the version range in NuGet.
Describes a range of plug-in versions.
The format of string representation of the range is generally the same as for NuGet <PackageReference> element, see Version ranges in the NuGet documentation.
There are the following differences in behavior from NuGet:
Semantic Versioning is not supported by DependencyVersionRange because plug-in versions are represented by the standard System.Version class and IComponentInfo.Version properties.
Retrieval of plug-in version from AssemblyVersionAttribute and FileVersionInfo is also the reason why the ranges of versions are validated using only full 4-part versions. For example, version range [1.*, 1.0.0.0) is considered invalid on parse because it can denote only inconsistent range [1.0.0.0, 1.0.0.0) during load of the plug-in assemblies.
Lower bound must always be specified in DependencyVersionRange and it must be inclusive, i.e., version ranges like (1.3.0, 2.0] or [,1.5] are considered invalid on parse.
The reason of this behavior is NuGet Warning NU1604 which says that project dependency should contain an inclusive lower bound. In fact an inclusive lower bound always exists for dependencies between plug-ins because the actual version of dependency is resolved during compiltation of the depending plug-in.
However, the use of pattern as inclusive lower bound is allowed: [1.*, 2.0) is considered a valid range.
public sealed class DependencyVersionRange : IEquatable<DependencyVersionRange>Public NotInheritable Class DependencyVersionRange
Implements IEquatable(Of DependencyVersionRange)public ref class DependencyVersionRange sealed : IEquatable<DependencyVersionRange^>[<SealedAttribute>]
type DependencyVersionRange =
class
interface IEquatable<DependencyVersionRange>
endThe following types of input strings are considered valid by both NuGet.Versioning and parser of DependencyVersionRange:
| <version or pattern> |
| [<version>] |
| [<version or pattern>,) |
| [<min version or pattern>,<max version>] if at least one full (4-part) version falls into the range. |
| [<min version or pattern>,<max version>) if at least one full (4-part) version falls into the range. |
The following types of input strings are considered invalid by both NuGet.Versioning and parser of DependencyVersionRange:
| [<version>) because it always matches an empty set of versions. |
| (<version>] because it always matches an empty set of versions. |
| (<version>) because it always matches an empty set of versions. |
| [<pattern>] because upper bound must not be a pattern. |
| [<pattern>) because upper bound must not be a pattern. |
| (<pattern>] because upper bound must not be a pattern. |
| (<pattern>) because upper bound must not be a pattern. |
| [<min version or pattern>,<max version>] when none of full (4-part) versions fall into the range. |
| [<min version or pattern>,<max version>) when none of full (4-part) versions fall into the range. |
| [<min version or pattern>,<max pattern>] because upper bound must not be a pattern. |
| [<min version or pattern>,<max pattern>) because upper bound must not be a pattern. |
| (<min version or pattern>,<max pattern>] because upper bound must not be a pattern. |
| (<min version or pattern>,<max pattern>) because upper bound must not be a pattern. |
The following types of input strings are considered valid by NuGet.Versioning, however they are considered invalid by parser of DependencyVersionRange:
| [<version or pattern>,] because infinite upper bound must be exclusive. |
| (<version or pattern>,] because lower bound must be inclusive and infinite upper bound must be exclusive. |
| (<version or pattern>,) because lower bound must be inclusive. |
| (<min version or pattern>,<max version>] because lower bound must be inclusive. |
| (<min version or pattern>,<max version>) because lower bound must be inclusive. |
| DependencyVersionRange | Constructs an instance of DependencyVersionRange. |
| IsMaxInclusive | Determines whether MaxVersion is included into the range. |
| IsMaxLimited | Returns when the range has upper limit, i.e., when MaxVersion is not . |
| MaxVersion | Maximal version in the range or if the version has no upper limit. This value is never a pattern. |
| MinVersion | Minimal version in the range or a pattern of the minimal version. This value is never . |
| OriginalString | The original string value which has been parsed during construction of the range or if the range is not parsed from string. |
| Contains | Checks whether the specified version is within the range. | ||||||||||||
| Equals(DependencyVersionRange) | Indicates whether the current object is equal to another object of the same type. | ||||||||||||
| Equals(Object) | Determines whether the specified object is equal to the current object. (Overrides ObjectEquals(Object)) | ||||||||||||
| GetHashCode | Serves as the default hash function. (Overrides ObjectGetHashCode) | ||||||||||||
| GetType | Gets the Type of the current instance. (Inherited from Object) | ||||||||||||
| Parse | Parses DependencyVersionRange from the specified string. Throws ArgumentException if the input string cannot be parsed. See details on format of input which is supported by this method in the Remarks section for DependencyVersionRange. | ||||||||||||
| ToString | Returns a string that represents the current object. (Overrides ObjectToString) | ||||||||||||
| ToString(Int32, Boolean) | Returns string representation of DependencyVersionRange using the specified number of significant version parts and with optional simplification. The significantVersionParts argument is handled in the following way:
When the simplify argument is the resulting string is simplified in the following way:
| ||||||||||||
| TryParse | Attempts to parse DependencyVersionRange from the specified string. See details on format of input which is supported by this method in the Remarks section for DependencyVersionRange. |