PostProcess assembly before Burst kicks in

Hello, I want to post process my assemblies, before Burst compiler kicks in, so to make some of my code Burst compatible.
I’ve subscribed to the CompilationPipeline.compilationFinished += CompilationFinished;,
then I got this handler:

var dlls = CompilationPipeline.GetAssemblies().Select(x => x.outputPath).ToArray();
            if (dlls.Length == 0)
                return;
            
            var root = CompilationPipeline.GetPrecompiledAssemblyPaths(CompilationPipeline.PrecompiledAssemblySources
                .UserAssembly);

            dlls = dlls.Select(x => Path.Combine(Directory.GetCurrentDirectory(), x)).ToArray();
            dlls = dlls.Union(root).ToArray();
            
            foreach (string dll in dlls)
            {
                Debug.Log($"DLL: {dll}");
            }

            Debug.Log("?????");
            HandleAssemblyReload(false, false, dlls, Path.GetDirectoryName(dlls[0]), null, null);
            Debug.Log("!!!!!");

All dlls are printed fine, but Burst compiler error somehow appears in between ??? and !!! Debug.Logs. Here’s the debug log.

** MORE DLL LINES HERE OMITED ***
DLL: C:/Users/.../Library/PackageCache/com.unity.burst@1.8.17/Unity.Burst.CodeGen/Unity.Burst.Cecil.Rocks.dll

?????

C:\Users\...\Assets\UserCode\CsWrappers\EvhWrapper.cs(41,13): Burst error BC1016: The managed function `Meetem.EvhWrapper.get_EventHandle(Meetem.EvhWrapper* this)` is not supported

!!!!!

The error Burst is throwing should be non-existent because my post processing fixing it. But for some reason Burst compiling is executed in-between my post processing code?

How do I guarantee that my IL post processing is executed before Burst, and other question how do I guarantee that my IL post processing is executed after Burst, e.g. how do I control the order of post processing?

UPD: Ok, it seems like Burst compiling is running asynchrnously and doesn’t respect the post processors. E.g. can run while CompilationPipeline.compilationFinished handlers are running.
Don’t know if it’s by-design.

You can hook into Unity’s package ILPP using asmref. I’ve hooked into the Entities package version, but I think there’s one in the collections package you could also hook into. Example: Latios-Framework/ILPostProcessing at master · Dreaming381/Latios-Framework · GitHub

Thank you, while it’s simillar, but there’s also no guarantee that your ILPostProcess will run before default one.

It is guaranteed to run before Burst. If you need it to run before Unity’s other ILPostProcessors, then that is a totally different matter.

Ah, yes, you are right, will check it. Thank you!

Unfortunately this solution doesn’t allow to reference other assemblies, so I can’t include custom Mono.Cecil (Burst assembly is using custom Mono.Cecil contrary to Entities package) or other managed dlls and user code :frowning: