Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[+] AquaMai.Config.ApiVersion #91

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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