BanksySan
BanksySan

Reputation: 28510

What is the search pattern NuGet uses called?

Reading the SemVer spec, this isn't actually part of SemVer. So what is the search syntax that NuGet uses actually called?

1.0  = 1.0 ≤ x
(,1.0]  = x ≤ 1.0
(,1.0)  = x < 1.0
[1.0] = x == 1.0
(1.0) = invalid
(1.0,) = 1.0 < x
(1.0,2.0) = 1.0 < x < 2.0
[1.0,2.0] = 1.0 ≤ x ≤ 2.0
empty = latest version.

Also, is there a .NET class that handles it so I can search for packages using this syntax?

Upvotes: 1

Views: 75

Answers (1)

jwdonahue
jwdonahue

Reputation: 6659

Nuget package versioning was loosely modeled on SemVer 1.0.0 and has since been updated to SemVer 2.0.0, which is the current recommended standard. While the tooling does accept some non-SemVer versioning schemes, the table included in the OP shows the accepted syntax for Version Ranges and Wildcards used as dependency version selectors in Nuget.

Though there have been proposals for a defined range spec, there is little agreement what form to use and fairly solid arguments to keep SemVer out of that business. There are essentially two main camps, one suggests that set notation (Nuget's current grammar) should be used and the other prefers operator expression sequences (>=1.0.0 && <2.0.0, for instance). The best argument for staying out of it all-together rests on the fact that different scripting/programming languages have varying capabilities for handling these expressions natively, and the spec should not limit the design space available to tool developers.

Note that the table describes the set notation in terms of operator sequences, which any green programmer can understand. Internally, most tools build up a set of candidates within the specified range and then either apply one or more heuristics or a set algebra, or some combination of math and heuristics to select dependency version.

Please let me know if you require any further edification on this matter.

Upvotes: 1

Related Questions