2using System.ComponentModel.DataAnnotations;
3using System.Diagnostics;
49 throw new ArgumentNullException(nameof(input));
51 var splits = input.Split(
new char[] {
'-' }, StringSplitOptions.RemoveEmptyEntries);
54 if (splits.Length > 3)
58 var hasPrefix = splits.Length > 1;
61 if (!Enum.TryParse(splits[0], out engine))
69 int? customRev =
null;
72 if (!
Version.TryParse(splits.Last(), out version))
75 if (version.Build > 0)
77 customRev = version.Build;
78 version =
new Version(version.Major, version.Minor);
85 Debug.Assert(engine ==
EngineType.OpenDream,
"This does not support whatever ungodly new engine you've added");
87 var shaIndex = hasPrefix ? 1 : 0;
88 sha = splits[shaIndex];
94 if (splits.Length - 1 > shaIndex)
96 if (!Int32.TryParse(splits.Last(), out var customRevResult))
99 customRev = customRevResult;
122 throw new ArgumentNullException(nameof(input));
124 if (
TryParse(input, out var engineVersion))
125 return engineVersion!;
127 throw new InvalidOperationException($
"Invalid engine version: {input}");
144 throw new ArgumentNullException(nameof(other));
156#pragma warning disable CA1062
160 || (other.SourceSHA !=
null
164#pragma warning restore CA1062
177 var enginePrefix = !isByond
180 var displayedVersion = isByond
181 ? (CustomIteration.HasValue
185 var displayedCustomIteration = !isByond && CustomIteration.HasValue
186 ? $
"-{CustomIteration}"
188 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.
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.