Created
March 19, 2020 18:53
-
-
Save mrvoorhe/4711e93688968f4a8a13dda2344c4727 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using Mono.Cecil; | |
using Mono.Linker; | |
using Mono.Linker.Steps; | |
using Unity.Cecil.Awesome; | |
namespace Unity.Linker.Steps.Resolution | |
{ | |
public class ResolveFromMonoBehaviours : BaseResolveStep, IStep | |
{ | |
private readonly AssemblyDefinition _assembly; | |
protected UnityLinkContext _context; | |
protected ResolveFromMonoBehaviours() | |
{ | |
} | |
public ResolveFromMonoBehaviours(AssemblyDefinition assembly) | |
{ | |
_assembly = assembly; | |
} | |
public UnityTracer Tracer => _context.Tracer; | |
public override void Process(LinkContext context) | |
{ | |
_context = (UnityLinkContext)context; | |
foreach (var typeDefinition in _assembly.MainModule.AllDefinedTypes().Where(t => MonoBehaviorUtilities.IsMonoBehaviourOrScriptableObject(_context, t))) | |
{ | |
ProcessType(typeDefinition); | |
} | |
} | |
protected void ProcessType(TypeDefinition typeDefinition) | |
{ | |
using (Tracer.PushScoped(typeDefinition)) | |
{ | |
// Mark all types derived from MonoBehaviour | |
_context.Annotations.Mark(typeDefinition, new DependencyInfo(<What goes here?>); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment