From 0b2d9a18d296e20d83fbf3da851508a3eefd92bc Mon Sep 17 00:00:00 2001 From: KillStr3aK Date: Wed, 9 Oct 2024 14:02:18 +0200 Subject: [PATCH] feat: priority order for plugin version --- .../Core/Plugin/PluginContext.cs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/managed/CounterStrikeSharp.API/Core/Plugin/PluginContext.cs b/managed/CounterStrikeSharp.API/Core/Plugin/PluginContext.cs index 5b6326a48..fa8689fef 100644 --- a/managed/CounterStrikeSharp.API/Core/Plugin/PluginContext.cs +++ b/managed/CounterStrikeSharp.API/Core/Plugin/PluginContext.cs @@ -204,6 +204,26 @@ public void Load(bool hotReload = false) if (Plugin == null) throw new Exception("Unable to create plugin instance"); + /* Version Priority order: + * ModuleVersion override + * Assembly.GetName().Version + * "" + */ + if (Plugin is BasePlugin basePlugin) + { + // if no override we look for assembly version + if (basePlugin._version == "") + { + Version? assemblyVersion = defaultAssembly.GetName().Version; + + // if its set, we use that, otherwise it remains "" + if (assemblyVersion != null) + { + basePlugin._version = assemblyVersion.ToString(); + } + } + } + State = PluginState.Loading; Plugin.ModulePath = _path; @@ -241,4 +261,4 @@ public void Unload(bool hotReload = false) _logger.LogInformation("Finished unloading plugin {Name}", cachedName); } } -} \ No newline at end of file +}