Skip to content

Commit

Permalink
[+] AquaMai.Config.ApiVersion (#91)
Browse files Browse the repository at this point in the history
* Add ApiVersion

* Fix SectionNameOrder
  • Loading branch information
Menci authored Nov 26, 2024
1 parent 436bdde commit 2646f64
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,6 +22,10 @@ public HeadlessConfigInterface(Assembly loadedConfigAssembly, AssemblyDefinition
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)
Expand Down
9 changes: 9 additions & 0 deletions AquaMai/AquaMai.Config/ApiVersion.cs
Original file line number Diff line number Diff line change
@@ -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";
}
2 changes: 1 addition & 1 deletion AquaMai/AquaMai.Config/Reflection/ReflectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public ReflectionManager(IReflectionProvider reflectionProvider)
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 =>
Expand Down
4 changes: 2 additions & 2 deletions AquaMai/AquaMai.Mods/General.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Mod 界面的语言,支持 en 和 zh
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,
Expand Down

0 comments on commit 2646f64

Please sign in to comment.