TechbloxModdingAPI/CodeGenerator/MakeEverythingPublicInGame.cs

36 lines
1.1 KiB
C#
Raw Normal View History

using System;
using System.IO;
using System.Reflection.Metadata;
using System.Text.RegularExpressions;
using Mono.Cecil;
using ModuleDefinition = Mono.Cecil.ModuleDefinition;
namespace CodeGenerator
{
public class MakeEverythingPublicInGame
{
public void Start()
{
Console.WriteLine("Starting assembly editing...");
var fileRegex =
new Regex(".*(Techblox|Gamecraft|RobocraftX|FullGame|RobocraftECS|DataLoader|RCX|GameState)[^/]*(\\.dll)");
foreach (var file in Directory.EnumerateFiles(@"../../../../../ref/Techblox_Data/Managed"))
{
if (!fileRegex.IsMatch(file)) continue;
Console.WriteLine(file);
ProcessAssembly(file);
}
}
public void ProcessAssembly(string path)
{
var mod = ModuleDefinition.ReadModule(path, new(ReadingMode.Immediate) { ReadWrite = true });
foreach (var typeDefinition in mod.Types)
{
typeDefinition.Attributes |= TypeAttributes.Public;
}
mod.Write();
}
}
}