[+] AquaMai.Config.ApiVersion (#91)

* Add ApiVersion

* Fix SectionNameOrder
pull/92/head
Menci 2024-11-27 00:19:37 +08:00 committed by GitHub
parent 436bdde60a
commit 2646f642b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 3 deletions

View File

@ -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)

View File

@ -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";
}

View File

@ -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 =>

View File

@ -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,