[opt] strip AOT assembly resources. (#54)

main
L0veTomori 2025-04-03 10:48:40 +08:00 committed by GitHub
parent 603b0ccb24
commit 3fe41a8cba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 1 deletions

View File

@ -13,7 +13,14 @@ namespace HybridCLR.Editor.AOT
{
public static byte[] Strip(byte[] assemblyBytes)
{
var mod = ModuleDefMD.Load(assemblyBytes);
var context = ModuleDef.CreateModuleContext();
var readerOption = new ModuleCreationOptions(context)
{
Runtime = CLRRuntimeReaderKind.Mono
};
var mod = ModuleDefMD.Load(assemblyBytes, readerOption);
// remove all resources
mod.Resources.Clear();
foreach (var type in mod.GetTypes())
{
if (type.HasGenericParameters)