using System;
using Newtonsoft.Json;
namespace StardewModdingAPI
{
/// A semantic mod version with an optional build tag.
public struct Version
{
/*********
** Accessors
*********/
/// The major version incremented for major API changes.
public int MajorVersion { get; set; }
/// The minor version incremented for backwards-compatible changes.
public int MinorVersion { get; set; }
/// The patch version for backwards-compatible bug fixes.
public int PatchVersion { get; set; }
/// An optional build tag.
public string Build { get; set; }
/// Obsolete.
[JsonIgnore]
[Obsolete("Use `Version.ToString()` instead.")]
public string VersionString => this.ToString();
/*********
** Public methods
*********/
/// Construct an instance.
/// The major version incremented for major API changes.
/// The minor version incremented for backwards-compatible changes.
/// The patch version for backwards-compatible bug fixes.
/// An optional build tag.
public Version(int major, int minor, int patch, string build)
{
this.MajorVersion = major;
this.MinorVersion = minor;
this.PatchVersion = patch;
this.Build = build;
}
/// Get a string representation of the version.
public override string ToString()
{
return $"{this.MajorVersion}.{this.MinorVersion}.{this.PatchVersion} {this.Build}".Trim();
}
}
}