
All checks were successful
Build / Compute Version (push) Successful in 4s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 2m47s
Build / Build Nuget package (CringePlugins) (push) Successful in 5m31s
Build / Build Nuget package (NuGet) (push) Successful in 6m2s
Build / Build Nuget package (SharedCringe) (push) Successful in 7m25s
Build / Build Launcher (push) Successful in 9m11s
21 lines
780 B
C#
21 lines
780 B
C#
using System.Reflection;
|
|
using dnlib.DotNet;
|
|
|
|
namespace CringePlugins.Loader;
|
|
|
|
public record PluginMetadata(string Name, Version Version)
|
|
{
|
|
public static PluginMetadata ReadFromEntrypoint(string entrypointPath)
|
|
{
|
|
var module = ModuleDefMD.Load(entrypointPath);
|
|
|
|
var titleAttribute = module.CustomAttributes.Find(typeof(AssemblyTitleAttribute).FullName);
|
|
var versionAttribute = module.CustomAttributes.Find(typeof(AssemblyVersionAttribute).FullName);
|
|
|
|
var name = titleAttribute?.ConstructorArguments[0].Value as string ?? module.FullName;
|
|
if (!Version.TryParse(versionAttribute?.ConstructorArguments[0].Value as string ?? "0.0.0.0", out var version))
|
|
version = new();
|
|
|
|
return new(name, version);
|
|
}
|
|
} |