diff --git a/AquaMai/AquaMai.Config.HeadlessLoader/HeadlessConfigInterface.cs b/AquaMai/AquaMai.Config.HeadlessLoader/HeadlessConfigInterface.cs index ba7797d7..a86fcf64 100644 --- a/AquaMai/AquaMai.Config.HeadlessLoader/HeadlessConfigInterface.cs +++ b/AquaMai/AquaMai.Config.HeadlessLoader/HeadlessConfigInterface.cs @@ -12,6 +12,8 @@ public class HeadlessConfigInterface public IReflectionProvider ReflectionProvider { get; init; } public IReflectionManager ReflectionManager { get; init; } + public string ApiVersion { get; init; } + public HeadlessConfigInterface(Assembly loadedConfigAssembly, AssemblyDefinition modsAssembly) { this.loadedConfigAssembly = loadedConfigAssembly; @@ -20,6 +22,10 @@ public class HeadlessConfigInterface loadedConfigAssembly.GetType("AquaMai.Config.Reflection.MonoCecilReflectionProvider"), [modsAssembly]) as IReflectionProvider; ReflectionManager = Activator.CreateInstance( loadedConfigAssembly.GetType("AquaMai.Config.Reflection.ReflectionManager"), [ReflectionProvider]) as IReflectionManager; + ApiVersion = loadedConfigAssembly + .GetType("AquaMai.Config.ApiVersion") + .GetField("Version", BindingFlags.Public | BindingFlags.Static) + .GetRawConstantValue() as string; } public IConfigView CreateConfigView(string tomlString = null) diff --git a/AquaMai/AquaMai.Config/ApiVersion.cs b/AquaMai/AquaMai.Config/ApiVersion.cs new file mode 100644 index 00000000..35959b54 --- /dev/null +++ b/AquaMai/AquaMai.Config/ApiVersion.cs @@ -0,0 +1,9 @@ +namespace AquaMai.Config; + +public static class ApiVersion +{ + // Using a raw string for API version instead of a constant for maximum compatibility. + // When breaking changes are made, increment the major version. + // When new APIs are added in a backwards-compatible but non-forward-compatible manner, increment the minor version. + public const string Version = "1.0"; +} diff --git a/AquaMai/AquaMai.Config/Reflection/ReflectionManager.cs b/AquaMai/AquaMai.Config/Reflection/ReflectionManager.cs index f6b28477..7fb1ae0a 100644 --- a/AquaMai/AquaMai.Config/Reflection/ReflectionManager.cs +++ b/AquaMai/AquaMai.Config/Reflection/ReflectionManager.cs @@ -84,7 +84,7 @@ public class ReflectionManager : IReflectionManager sectionsByFullName.Add(type.FullName, section); } - var order = reflectionProvider.GetEnum("AquaMai.Mods.SetionNameOrder"); + var order = reflectionProvider.GetEnum("AquaMai.Mods.SectionNameOrder"); sections = sections .OrderBy(x => x.Key) .OrderBy(x => diff --git a/AquaMai/AquaMai.Mods/General.cs b/AquaMai/AquaMai.Mods/General.cs index 6c34191c..75c44b59 100644 --- a/AquaMai/AquaMai.Mods/General.cs +++ b/AquaMai/AquaMai.Mods/General.cs @@ -25,8 +25,8 @@ public class General public static readonly string locale = ""; } -// Please add/remove corresponding entries in SetionNameOrder enum when adding/removing sections. -public enum SetionNameOrder +// Please add/remove corresponding entries in SectionNameOrder enum when adding/removing sections. +public enum SectionNameOrder { DeprecationWarning, General,