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); }
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); }
public static bool NeedsProcessing(ModuleWeavingContext context, MethodDefinition method) => HasLibReference(context, method, out _);