Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

MirageNet/BetterCecil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BetterCecil

Better Cecil is a collection of helper methods for using Mono.Cecil.

Better Cecil is created to be used in unity so comes with classes to be used with unity's ILPostProcessing

Requires and Install

  • Mono.cecil

Add "com.unity.nuget.mono-cecil": "1.10.2", to your manifest.json and unity will important the dependencies.

Install

Import all files into project

How to use

public class MyILPostProcessor : ILPostProcessor
{
    public override ILPostProcessor GetInstance() => this;

    public override ILPostProcessResult Process(ICompiledAssembly compiledAssembly)
    {
        // call WillProcess because unity doesn't check it before calling Process
        if (!WillProcess(compiledAssembly))
            return null;

        // Use inherited class WeaverBase to return ILPostProcessResult
        var weaver = new MyWeaver();
        return weaver.Process(compiledAssembly);
    }

    public override bool WillProcess(ICompiledAssembly compiledAssembly) 
    { 
        // here to only process some assemblies
        return true;
    }
}

public class MyWeaver : WeaverBase
{
    protected override Result Process(AssemblyDefinition assembly) 
    {
        // put your server code here 

        // Example:
        // check all types in assembly
        ModuleDefinition module = assembly.MainModule;
        foreach (TypeDefinition type in module.Types)
        {
            // do stuff with types here
        }
    }
}

MIT License

Some of the extension methods in here are originally from Mirage and Mirror

The original ReflectionImporter and AssemblyResolver code is from com.unity.netcode.gameobjects

About

No description, website, or topics provided.

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages