Skip to content

Commit 49cdae2

Browse files
committed
feat: priority order for plugin version
1 parent ba3e2d0 commit 49cdae2

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

managed/CounterStrikeSharp.API/Core/Plugin/PluginContext.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,26 @@ public void Load(bool hotReload = false)
204204

205205
if (Plugin == null) throw new Exception("Unable to create plugin instance");
206206

207+
/* Version Priority order:
208+
* ModuleVersion override
209+
* Assembly.GetName().Version
210+
* "<unknown>"
211+
*/
212+
if (Plugin is BasePlugin basePlugin)
213+
{
214+
// if no override we look for assembly version
215+
if (basePlugin._version == "<unknown>")
216+
{
217+
Version? assemblyVersion = defaultAssembly.GetName().Version;
218+
219+
// if its set, we use that, otherwise it remains "<unknown>"
220+
if (assemblyVersion != null)
221+
{
222+
basePlugin._version = assemblyVersion.ToString();
223+
}
224+
}
225+
}
226+
207227
State = PluginState.Loading;
208228

209229
Plugin.ModulePath = _path;
@@ -241,4 +261,4 @@ public void Unload(bool hotReload = false)
241261
_logger.LogInformation("Finished unloading plugin {Name}", cachedName);
242262
}
243263
}
244-
}
264+
}

0 commit comments

Comments
 (0)