private Triple GetGenericTriple(Instruction instruction, MethodDefinition parentMethod, ObjectType toObjectType, string constructorInstructionKey = null) { var fromInstruction = instruction.Previous; var fromObjectType = InstructionKeyService.GetFromObjectType(fromInstruction); var fromInstanceOwnerKey = InstructionKeyService.GetFromInstanceOwnerKey(fromInstruction, fromObjectType, parentMethod); string toInstanceOwnerKey = string.Empty; if (constructorInstructionKey != null) { toInstanceOwnerKey = null; } else { toInstanceOwnerKey = InstructionKeyService.GetToInstanceOwnerKey(instruction, toObjectType, parentMethod); } var triple = BuildTriple(instruction, toInstanceOwnerKey, fromInstruction, fromInstanceOwnerKey, parentMethod); if (constructorInstructionKey != null) { triple.SetsObjectInitializerMember = true; triple.ConstructorInstructionKey = constructorInstructionKey; } return(triple); }
private List <Triple> TraverseTree(MethodDefinition parentMethod, InstructionTreeNode parentNode, string instanceOwnerKey, bool isObjectInitializerMember, string constructorInstructionKey = null) { var triples = new List <Triple>(); var toArgumentCounter = parentNode.ChildInstructions.Count; foreach (var argumentInstruction in parentNode.ChildInstructions) { var fromObjectType = InstructionKeyService.GetFromObjectType(argumentInstruction.Instruction); var fromInstanceOwnerKey = InstructionKeyService.GetFromInstanceOwnerKey(argumentInstruction.Instruction, fromObjectType, parentMethod); var triple = BuildTriple(parentNode.Instruction, instanceOwnerKey, argumentInstruction.Instruction, fromInstanceOwnerKey, parentMethod, toArgumentCounter); if (triple == null) { continue; } if (isObjectInitializerMember) { triple.SetsObjectInitializerMember = true; triple.ConstructorInstructionKey = constructorInstructionKey; } triples.Add(triple); toArgumentCounter--; if (argumentInstruction.ChildInstructions.Any()) { var subTriples = TraverseTree(parentMethod, argumentInstruction, triple.From.InstanceOwnerKey, false); triples.AddRange(subTriples); } } return(triples); }