2using System.ComponentModel.DataAnnotations;
3using System.Diagnostics;
54 throw new ArgumentNullException(nameof(input));
56 var splits = input.Split(
DashChar, StringSplitOptions.RemoveEmptyEntries);
59 if (splits.Length > 3)
63 var hasPrefix = splits.Length > 1;
66 if (!Enum.TryParse(splits[0], out engine))
74 int? customRev =
null;
77 if (!
Version.TryParse(splits.Last(), out version))
80 if (version.Build > 0)
82 customRev = version.Build;
83 version =
new Version(version.Major, version.Minor);
90 Debug.Assert(engine ==
EngineType.OpenDream,
"This does not support whatever ungodly new engine you've added");
92 var shaIndex = hasPrefix ? 1 : 0;
93 sha = splits[shaIndex];
99 if (splits.Length - 1 > shaIndex)
101 if (!Int32.TryParse(splits.Last(), out var customRevResult))
104 customRev = customRevResult;
127 throw new ArgumentNullException(nameof(input));
129 if (
TryParse(input, out var engineVersion))
130 return engineVersion!;
132 throw new InvalidOperationException($
"Invalid engine version: {input}");
149 throw new ArgumentNullException(nameof(other));
161#pragma warning disable CA1062
165 || (other.SourceSHA !=
null
169#pragma warning restore CA1062
182 var enginePrefix = !isByond
185 var displayedVersion = isByond
186 ? (CustomIteration.HasValue
190 var displayedCustomIteration = !isByond && CustomIteration.HasValue
191 ? $
"-{CustomIteration}"
193 return $
"{enginePrefix}{displayedVersion}{displayedCustomIteration}";
Information about an engine installation.
Version? Version
The System.Version of the engine. Currently only valid when Engine is EngineType.Byond.
override string ToString()
static bool TryParse(string input, out EngineVersion? engineVersion)
Attempts to parse a stringified EngineVersion.
static EngineVersion Parse(string input)
Parses a stringified EngineVersion.
override int GetHashCode()
override bool Equals(object obj)
EngineVersion()
Initializes a new instance of the EngineVersion class.
bool Equals(EngineVersion other)
EngineVersion(EngineVersion other)
Initializes a new instance of the EngineVersion class.
string? SourceSHA
The git commit SHA of the engine. Currently only valid when Engine is EngineType.OpenDream.
EngineType? Engine
The EngineType.
int? CustomIteration
The revision of the custom build.
static readonly char[] DashChar
An array of a single '-' char.
Sanity limits to prevent users from overloading.
const int MaximumCommitShaLength
Length limit for git commit SHAs.
FieldPresence
Indicates whether a request field is Required or Ignored.
EngineType
The type of engine the codebase is using.