Exemple #1
0
 public MethodWeaver(ModuleWeavingContext context, MethodDefinition method)
 {
     _context        = context;
     _method         = method;
     _il             = new WeaverILProcessor(_method);
     _labels         = new LabelMapper(_il);
     _sequencePoints = new SequencePointMapper(_method, context.Config);
     _consumer       = new ArgumentConsumer(_il);
 }
Exemple #2
0
        private static bool HasLibReference(ModuleWeavingContext context, MethodDefinition method, out Instruction?refInstruction)
        {
            refInstruction = null;

            if (method.IsInlineILTypeUsage(context))
            {
                return(true);
            }

            if (!method.HasBody)
            {
                return(false);
            }

            if (method.Body.Variables.Any(i => i.VariableType.IsInlineILTypeUsage(context)))
            {
                return(true);
            }

            foreach (var instruction in method.Body.Instructions)
            {
                refInstruction = instruction;

                switch (instruction.Operand)
                {
                case MethodReference methodRef when methodRef.IsInlineILTypeUsage(context):
                case TypeReference typeRef when typeRef.IsInlineILTypeUsage(context):
                case FieldReference fieldRef when fieldRef.IsInlineILTypeUsage(context):
                case CallSite callSite when callSite.IsInlineILTypeUsage(context):
                    return(true);
                }
            }

            refInstruction = null;
            return(false);
        }
Exemple #3
0
 public static bool NeedsProcessing(ModuleWeavingContext context, MethodDefinition method)
 => HasLibReference(context, method, out _);