chr
2026-04-05 fe750b791d5b517cc4e9bc8e99a9a75139a0cfba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
//            Copyright Keysight Technologies 2012-2019
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at http://mozilla.org/MPL/2.0/.
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
 
namespace OpenTap.Package
{
    /// <summary>
    /// Holds search parameters that specifies a range of packages in the OpenTAP package system.
    /// </summary>
    public class PackageSpecifier
    {
        /// <summary> Gets a readable string for this package specifier. </summary>
        public override string ToString()
        {
            var versionString = Version == VersionSpecifier.AnyRelease ? "Any Release" : Version.ToString();
            return $"[{Name} ({versionString})]";
        }
 
        /// <summary>
        /// Search for parameters that specifies a range of packages in the OpenTAP package system. Unset parameters will be treated as 'any'.
        /// </summary>
        public PackageSpecifier(string name = null, VersionSpecifier version = default(VersionSpecifier), CpuArchitecture architecture = CpuArchitecture.Unspecified, string os = null)
        {
            Name = name;
            Version = version ?? VersionSpecifier.Any;
            Architecture = architecture;
            OS = os;
        }
 
        /// <summary>
        /// Search parameters that specify an exact or a version compatible match to the given package/identifier.
        /// </summary>
        public PackageSpecifier(IPackageIdentifier package, VersionMatchBehavior versionMatchBehavior = VersionMatchBehavior.Exact)
            : this(package.Name, new VersionSpecifier(package.Version, versionMatchBehavior), package.Architecture, package.OS)
        {
        }
 
        /// <summary>
        /// The name of the package. Can be null to indicate "any name".
        /// </summary>
        public string Name { get; }
 
        /// <summary>
        /// Specifying requirements to the version the package. Never null.
        /// </summary>
        public VersionSpecifier Version { get; }
 
        /// <summary>
        /// The CPU Architechture of the package. 
        /// </summary>
        public CpuArchitecture Architecture { get; }
 
        /// <summary>
        /// Comma seperated list of operating systems that this package can run on.
        /// </summary>
        public string OS { get; }
    }
 
    /// <summary>
    /// Specifies parts of a semantic version. This is used in <see cref="PackageSpecifier"/> to represent the part of a <see cref="SemanticVersion"/> to search for.
    /// E.g. the VersionSpecifier "9.0" may match the semantic version "9.0.4+abcdef" and also "9.1.x" if <see cref="MatchBehavior"/> is set to "Compatible".
    /// </summary>
    public class VersionSpecifier : IComparable
    {
        /// <summary>
        /// The VersionSpecifier that will match any version. VersionSpecifier.Any.IsCompatible always returns true.
        /// </summary>
        public static readonly VersionSpecifier Any = new VersionSpecifier(null, null, null, null, null,  VersionMatchBehavior.Exact | VersionMatchBehavior.AnyPrerelease);
 
        /// <summary>
        /// The VersionSpecifier that will match any version. VersionSpecifier.Any.IsCompatible always returns true.
        /// </summary>
        public static readonly VersionSpecifier AnyRelease = new VersionSpecifier(null, null, null, null, null, VersionMatchBehavior.Exact);
 
        
        /// <summary>
        /// Major version. When not null, <see cref="SemanticVersion.IsCompatible"/> will return false for <see cref="SemanticVersion"/>s with a Major version different from this.
        /// </summary>
        public readonly int? Major;
        /// <summary>
        /// Minor version. When not null, <see cref="SemanticVersion.IsCompatible"/> will return false for <see cref="SemanticVersion"/>s with a Minor version less than this (with <see cref="VersionMatchBehavior.Compatible"/>) or different from this (with <see cref="VersionMatchBehavior.Exact"/>).
        /// </summary>
        public readonly int? Minor;
        /// <summary>
        /// Patch version. When not null, <see cref="SemanticVersion.IsCompatible"/> will return false for <see cref="SemanticVersion"/>s with a Patch version different from this if <see cref="MatchBehavior"/> is <see cref="VersionMatchBehavior.Exact"/>.
        /// </summary>
        public readonly int? Patch;
        /// <summary>
        /// PreRelease identifier. <see cref="SemanticVersion.IsCompatible"/> will return false for <see cref="SemanticVersion"/>s with a PreRelease less than this (with <see cref="VersionMatchBehavior.Compatible"/>) or different from this (with <see cref="VersionMatchBehavior.Exact"/>).
        /// </summary>
        public readonly string PreRelease;
        /// <summary>
        /// BuildMetadata identifier. When not null, <see cref="SemanticVersion.IsCompatible"/> will return false for <see cref="SemanticVersion"/>s with a BuildMetadata different from this if <see cref="MatchBehavior"/> is <see cref="VersionMatchBehavior.Exact"/>.
        /// </summary>
        public readonly string BuildMetadata;
 
        /// <summary>
        /// The way matching is done. This affects the behavior of <see cref="SemanticVersion.IsCompatible(SemanticVersion)"/>.
        /// </summary>
        public readonly VersionMatchBehavior MatchBehavior;
        /// <summary>
        /// Specifies parts of a semantic version. Unset parameters will be treated as 'any'.
        /// </summary>
        /// 
        public VersionSpecifier(int? major, int? minor, int? patch, string prerelease, string buildMetadata, VersionMatchBehavior matchBehavior)
        {
            if (major == null && minor != null)
                throw new ArgumentException();
            if (minor == null && patch != null)
                throw new ArgumentException();
            Major = major;
            Minor = minor;
            Patch = patch;
            PreRelease = prerelease;
            BuildMetadata = buildMetadata;
            MatchBehavior = matchBehavior;
        }
 
        /// <summary>
        /// Creates a VersionSpecifier from a <see cref="SemanticVersion"/>.
        /// </summary>
        public VersionSpecifier(SemanticVersion ver, VersionMatchBehavior matchBehavior) : this(ver?.Major, ver?.Minor, ver?.Patch, ver?.PreRelease, ver?.BuildMetadata, matchBehavior)
        {
        }
 
        static Regex parser = new Regex(@"^(?<compatible>\^)?((?<major>\d+)(\.(?<minor>\d+)(\.(?<patch>\d+))?)?)?(-(?<prerelease>([a-zA-Z0-9-\.]+)))?(\+(?<metadata>[a-zA-Z0-9-\.]+))?$", RegexOptions.Compiled);
        static Regex semVerPrereleaseRegex = new Regex(@"^(?<compatible>\^)?(?<prerelease>([a-zA-Z0-9-\.]+))$", RegexOptions.Compiled);
 
        /// <summary>
        /// Parses a string as a VersionSpecifier.
        /// </summary>
        public static bool TryParse(string version, out VersionSpecifier ver)
        {
            if (version != null)
            {
                if (version.Equals("Any", StringComparison.OrdinalIgnoreCase))
                {
                    ver = VersionSpecifier.Any;
                    return true;
                }
 
                if (string.IsNullOrEmpty(version))
                {
                    ver = AnyRelease;
                    return true;
                }
 
                var m = parser.Match(version);
                if (m.Success)
                {
                    ver = new VersionSpecifier(
                        m.Groups["major"].Success ? (int?)int.Parse(m.Groups["major"].Value) : null,
                        m.Groups["minor"].Success ? (int?)int.Parse(m.Groups["minor"].Value) : null,
                        m.Groups["patch"].Success ? (int?)int.Parse(m.Groups["patch"].Value) : null,
                        m.Groups["prerelease"].Success ? m.Groups["prerelease"].Value : null,
                        m.Groups["metadata"].Success ? m.Groups["metadata"].Value : null,
                         m.Groups["compatible"].Success ? VersionMatchBehavior.Compatible : VersionMatchBehavior.Exact
                    );
                    return true;
                }
 
                var prerelease = semVerPrereleaseRegex.Match(version);
                if (prerelease.Success)
                {
                    var matchBehaviour = prerelease.Groups["compatible"].Success ? VersionMatchBehavior.Compatible : VersionMatchBehavior.Exact;
                    var pre = prerelease.Groups["prerelease"].Success ? prerelease.Groups["prerelease"].Value : null;
                    ver = new VersionSpecifier(null, null, null, pre, null, matchBehaviour);
                    return true;
                }
            }
            ver = default(VersionSpecifier);
            return false;
        }
 
        /// <summary>
        /// Parses a string as a VersionSpecifier.
        /// </summary>
        /// <exception cref="FormatException">The string is not a valid version specifier.</exception>
        public static VersionSpecifier Parse(string version)
        {
            if (TryParse(version, out var ver))
                return ver;
            throw new FormatException($"The string '{version}' is not a valid version specifier.");
        }
 
        /// <summary>
        /// Converts this value to a string. This string can be parsed by <see cref="Parse(string)"/> and <see cref="TryParse(string, out VersionSpecifier)"/>.
        /// </summary>
        public override string ToString()
        {
            if (this == VersionSpecifier.Any)
                return "Any";
            if (this == VersionSpecifier.AnyRelease)
                return "";
 
            var formatter = versionFormatter.Value;
            formatter.Clear();
 
            if (MatchBehavior.HasFlag(VersionMatchBehavior.Compatible))
                formatter.Append('^');
            if (Major.HasValue)
                formatter.Append(Major);
            if (Minor.HasValue)
            {
                formatter.Append('.');
                formatter.Append(Minor);
            }
 
            if (Patch.HasValue)
            {
                formatter.Append('.');
                formatter.Append(Patch);
            }
            if (!string.IsNullOrEmpty(PreRelease))
            {
                if (formatter.Length != 0)
                    formatter.Append('-');
                formatter.Append(PreRelease);
            }
            if (!string.IsNullOrEmpty(BuildMetadata))
            {
                formatter.Append('+');
                formatter.Append(BuildMetadata);
            }
 
            return formatter.ToString();
        }
 
        static ThreadLocal<StringBuilder> versionFormatter = new ThreadLocal<StringBuilder>(() => new StringBuilder(), false);
 
        /// <summary>
        /// Prints the string in version format. It should be parsable from the same string.
        /// </summary>
        /// <param name="fieldCount">Number of values to return. Must be 1, 2, 4 or 5.</param>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        /// <returns></returns>
        public string ToString(int fieldCount)
        {
            if (fieldCount < 1 || fieldCount > 5)
                throw new ArgumentOutOfRangeException();
 
            var formatter = versionFormatter.Value;
            formatter.Clear();
 
            if (this == VersionSpecifier.Any)
                return "Any";
            if (MatchBehavior.HasFlag(VersionMatchBehavior.Compatible))
                formatter.Append('^');
 
            if (Major.HasValue)
                formatter.Append(Major);
 
            if (Minor.HasValue && fieldCount >= 2)
            {
                formatter.Append('.');
                formatter.Append(Minor);
            }
            if (Patch.HasValue && fieldCount >= 3)
            {
                formatter.Append('.');
                formatter.Append(Patch);
            }
            if (!string.IsNullOrWhiteSpace(PreRelease) && fieldCount >= 4)
            {
                formatter.Append('-');
                formatter.Append(PreRelease);
            }
            if (!string.IsNullOrWhiteSpace(BuildMetadata) && fieldCount == 5)
            {
                formatter.Append('+');
                formatter.Append(BuildMetadata);
            }
 
            return formatter.ToString();
        }
 
        /// <summary>
        /// Compatibility comparison that returns true if the given version can fulfil this specification. I.e. 'actualVersion' can replace 'this' in every respect.
        /// </summary>
        /// <param name="actualVersion"></param>
        /// <returns></returns>
        public bool IsCompatible(SemanticVersion actualVersion)
        {
            if (ReferenceEquals(this, VersionSpecifier.Any))
                return true; // this is just a small performance shortcut. The below logic would have given the same result.
            if (ReferenceEquals(this, VersionSpecifier.AnyRelease))
                return actualVersion.PreRelease == null; // this is just a small performance shortcut. The below logic would have given the same result.
 
            if (MatchBehavior == VersionMatchBehavior.Exact)
                return MatchExact(actualVersion);
            if (MatchBehavior.HasFlag(VersionMatchBehavior.Compatible))
                return MatchCompatible(actualVersion);
 
            return false;
        }
 
        private bool MatchExact(SemanticVersion actualVersion)
        {
            if (actualVersion == null)
                return false;
            if (Major.HasValue && Major.Value != actualVersion.Major)
                return false;
            if (Minor.HasValue && Minor.Value != actualVersion.Minor)
                return false;
            if (Patch.HasValue && Patch.Value != actualVersion.Patch)
                return false;
            if (MatchBehavior.HasFlag(VersionMatchBehavior.AnyPrerelease))
                return true;
            if (PreRelease != actualVersion.PreRelease)
            {
                if (PreRelease is null || actualVersion.PreRelease is null)
                    return false;
 
                string[] actualPreReleaseIdentifiers = actualVersion.PreRelease.Split('.');
                string[] preReleaseIdentifiers = PreRelease.Split('.');
 
                if (actualPreReleaseIdentifiers.Length < preReleaseIdentifiers.Length)
                    return false;
 
                for (int i = 0; i < preReleaseIdentifiers.Length; i++)
                    if (!actualPreReleaseIdentifiers[i].Equals(preReleaseIdentifiers[i]))
                        return false;
            }
            if (string.IsNullOrEmpty(BuildMetadata) == false && BuildMetadata != actualVersion.BuildMetadata)
                return false;
            return true;
        }
 
        private bool MatchCompatible(SemanticVersion actualVersion)
        {
            if (actualVersion == null)
                return true;
            if (Major.HasValue && Major.Value != actualVersion.Major)
                return false;
            if (Minor.HasValue && Minor.Value > actualVersion.Minor)
                return false;
            if (Minor.HasValue && Minor.Value == actualVersion.Minor)
                if (Patch.HasValue && Patch.Value > actualVersion.Patch)
                    return false;
 
 
            if (MatchBehavior.HasFlag(VersionMatchBehavior.AnyPrerelease))
                return true;
 
            // We want ^1.0.0 to accept 1.0.1-beta or 1.1.0-beta as compatible versions
            if(actualVersion.PreRelease != null)
            {
                if (Minor.HasValue && Minor.Value < actualVersion.Minor)
                    return true;
                if (Minor.HasValue && Minor.Value == actualVersion.Minor)
                    if (Patch.HasValue && Patch.Value < actualVersion.Patch)
                        return true;
 
                // In short: We want ^1 to accept 1.x.x-beta
                // In long: If minor and patch are not specified, then this version specifier is underdetermined.
                // If the prerelease is also not specified that means the version specifier should be satisfiable by
                // any prerelease within the appropriate major.
                if (PreRelease == null && !Minor.HasValue && !Patch.HasValue && Major.HasValue &&
                    Major.Value == actualVersion.Major)
                    return true;
            }
 
            if (0 < ComparePreRelease(PreRelease, actualVersion.PreRelease))
                return false;
            return true;
        }
 
        /// <summary>
        /// Gets the hash code of this value.
        /// </summary>
        public override int GetHashCode()
        {
            return ToString().GetHashCode();
        }
 
        /// <summary>
        /// Compares this VersionSpecifier with another object.
        /// </summary>
        public override bool Equals(object obj)
        {
            if (obj is VersionSpecifier other)
            {
                if (Major != other.Major)
                    return false;
                if (Minor != other.Minor)
                    return false;
                if (Patch != other.Patch)
                    return false;
                if (PreRelease != other.PreRelease)
                    return false;
                if (MatchBehavior != other.MatchBehavior)
                    return false;
                return true;
            }
            return false;
        }
 
        /// <summary>
        /// Returns -1 if obj is greater than this version, 0 if they are the same, and 1 if this is greater than obj
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int CompareTo(object obj)
        {
            if (!(obj is VersionSpecifier))
                throw new ArgumentException("Object is not a TapVersion");
 
            VersionSpecifier other = (VersionSpecifier)obj;
            if (Major > other.Major) return 1;
            if (Major < other.Major) return -1;
            if (Minor.HasValue && !other.Minor.HasValue || Minor > other.Minor) return 1;
            if (!Minor.HasValue && other.Minor.HasValue || Minor < other.Minor) return -1;
            if (Patch.HasValue && !other.Patch.HasValue || Patch > other.Patch) return 1;
            if (!Patch.HasValue && other.Patch.HasValue || Patch < other.Patch) return -1;
 
            return ComparePreRelease(PreRelease, other.PreRelease);
        }
        
        class PartialComparer : IComparer<SemanticVersion>
        {
            readonly VersionSpecifier pkg;
            public PartialComparer(VersionSpecifier pkg) => this.pkg = pkg;
            
            public int Compare(SemanticVersion a, SemanticVersion b)
            {
                // If pre-releases are not wanted, order them according to stability. E.g. alphas go at the end
                if (pkg.PreRelease == null && (a.PreRelease != null || b.PreRelease != null))
                {
                    if (a.PreRelease == null && b.PreRelease != null) return -1;
                    if (a.PreRelease != null && b.PreRelease == null) return 1;
                }
                
                if (pkg.Major.HasValue)
                {
                    var m = a.Major.CompareTo(b.Major);
                    if (m != 0) return m;
                }
                if (pkg.Minor.HasValue)
                {
                    var m = a.Minor.CompareTo(b.Minor);
                    if (m != 0) return m;
                }
                
                if (pkg.Patch.HasValue)
                {
                    var m = a.Patch.CompareTo(b.Patch);
                    if (m != 0) return m;
                } 
 
                // If no prerelease is specified, prefer the most "stable" version
                // e.g. release > rc > beta > alpha, preferring newer versions
                if (pkg.PreRelease == null)
                    return CompareStability(a, b); 
                
                // Otherwise just sort by prerelease
                if (a.PreRelease == b.PreRelease) return 0;
                if (a.PreRelease == null && b.PreRelease != null) return 1;
                if (a.PreRelease != null && b.PreRelease == null) return -1; 
                return ComparePreRelease(a.PreRelease, b.PreRelease);
            }
        }
 
        private static int CompareStability(SemanticVersion a, SemanticVersion b)
        {
            // If neither is a prerelease, assume the newest version is the most stable
            if (a.PreRelease == null && b.PreRelease == null) return b.CompareTo(a);
            
            // Prefer releases over everything else
            if (a.PreRelease == null && b.PreRelease != null) return -1;
            if (a.PreRelease != null && b.PreRelease == null) return 1;
            
            string kind(string prerelease)
            {
                var idx = prerelease.IndexOf('.');
                if (idx == -1) idx = prerelease.Length;
                return prerelease.Substring(0, idx);
            }
 
            // Prefer rc > beta > alpha
            var k1 = kind(a.PreRelease);
            var k2 = kind(b.PreRelease);
            var c = string.Compare(k2, k1, StringComparison.Ordinal);
            if (c != 0) return c;
 
            // Otherwise prefer the highest version number
            return b.CompareTo(a);
        }
 
        /// <summary>
        /// This sorts versions based on a partially defined version set. For example ^1 would sort based on major version only, but ignore the rest.
        /// This is useful when using in connection with other stable sortings. 
        /// </summary>
        internal IComparer<SemanticVersion> SortPartial => new PartialComparer(this);
 
        ///<summary> A version is exact if the match behavior is exact and all version fields are specified. </summary>
        internal bool IsExact => MatchBehavior == VersionMatchBehavior.Exact && Major.HasValue && Minor.HasValue &&
                               Patch.HasValue;
 
        internal static int ComparePreRelease(string p1, string p2)
        {
            if (p1 == p2) return 0;
 
            if (string.IsNullOrEmpty(p1) && string.IsNullOrEmpty(p2)) return 0;
            if (string.IsNullOrEmpty(p1)) return 1;
            if (string.IsNullOrEmpty(p2)) return -1;
 
            var identifiers1 = p1.Split('.');
            var identifiers2 = p2.Split('.');
 
            for (int i = 0; i < Math.Min(identifiers1.Length, identifiers2.Length); i++)
            {
                var id1 = identifiers1[i];
                var id2 = identifiers2[i];
 
                int v1, v2;
 
                if (int.TryParse(id1, out v1) && int.TryParse(id2, out v2))
                {
                    if (v1 != v2)
                        return v1.CompareTo(v2);
                }
                else
                {
                    var res = string.Compare(id1, id2);
 
                    if (res != 0)
                        return res;
                }
            }
 
            if (identifiers1.Length > identifiers2.Length) return 1;
            if (identifiers1.Length < identifiers2.Length) return -1;
 
            return 0;
        }
 
        /// <summary>
        /// Overloaded == operator that provides value equality (instead of the default reference equality)
        /// </summary>
        public static bool operator ==(VersionSpecifier a, VersionSpecifier b)
        {
            return Object.Equals(a, b);
        }
 
        /// <summary>
        /// Overloaded != operator that provides value equality (instead of the default reference equality)
        /// </summary>
        public static bool operator !=(VersionSpecifier a, VersionSpecifier b)
        {
            return !(a == b);
        }
 
        
        internal bool TryAsExactSemanticVersion(out SemanticVersion semver)
        {
            if (MatchBehavior == VersionMatchBehavior.Exact && Major.HasValue && Minor.HasValue && Patch.HasValue)
            {
                semver = new SemanticVersion(Major.Value, Minor.Value, Patch.Value, PreRelease, BuildMetadata);
                return true;
            }
 
            semver = default;
            return false;
        }
 
        internal VersionSpecifier WithMatchBehavior(VersionMatchBehavior matchBehavior) => new VersionSpecifier(Major, Minor, Patch, PreRelease, BuildMetadata, matchBehavior);
        
    }
 
    /// <summary>
    /// Describes the behavior of <see cref="VersionSpecifier.IsCompatible(SemanticVersion)"/>.
    /// </summary>
    [Flags]
    public enum VersionMatchBehavior
    {
        /// <summary>
        /// The <see cref="SemanticVersion"/> must match all (non-null) fields in the specified in a <see cref="VersionSpecifier"/> for <see cref="VersionSpecifier.IsCompatible(SemanticVersion)"/> to return true.
        /// </summary>
        Exact = 1,
        /// <summary>
        /// The <see cref="SemanticVersion"/> must be compatible with the version specified in a <see cref="VersionSpecifier"/> for <see cref="VersionSpecifier.IsCompatible(SemanticVersion)"/> to return true.
        /// </summary>
        Compatible = 2,
        /// <summary>
        /// Prerelease property of <see cref="VersionSpecifier"/> is ignored when looking for matching packages.
        /// </summary>
        AnyPrerelease = 4,
    }
}