private Instruction AddInstrumentationCode(MethodDefinition method, ILProcessor processor, Instruction instruction, BranchPoint branchPoint) { if (!_result.Documents.TryGetValue(branchPoint.Document, out var document)) { document = new Document { Path = branchPoint.Document }; document.Index = _result.Documents.Count; _result.Documents.Add(document.Path, document); } BranchKey key = new BranchKey(branchPoint.StartLine, (int)branchPoint.Ordinal); if (!document.Branches.ContainsKey(key)) { document.Branches.Add(key, new Branch { Number = branchPoint.StartLine, Class = method.DeclaringType.FullName, Method = method.FullName, Offset = branchPoint.Offset, EndOffset = branchPoint.EndOffset, Path = branchPoint.Path, Ordinal = branchPoint.Ordinal } ); } _result.HitCandidates.Add(new HitCandidate(true, document.Index, branchPoint.StartLine, (int)branchPoint.Ordinal)); return(AddInstrumentationInstructions(method, processor, instruction, _result.HitCandidates.Count - 1)); }
private Instruction AddInstrumentationCode(MethodDefinition method, ILProcessor processor, Instruction instruction, BranchPoint branchPoint) { if (!_result.Documents.TryGetValue(branchPoint.Document, out var document)) { document = new Document { Path = branchPoint.Document }; document.Index = _result.Documents.Count; _result.Documents.Add(document.Path, document); } BranchKey key = new BranchKey(branchPoint.StartLine, (int)branchPoint.Ordinal); if (!document.Branches.ContainsKey(key)) { document.Branches.Add( key, new Branch { Number = branchPoint.StartLine, Class = method.DeclaringType.FullName, Method = method.FullName, Offset = branchPoint.Offset, EndOffset = branchPoint.EndOffset, Path = branchPoint.Path, Ordinal = branchPoint.Ordinal } ); if (method.DeclaringType.CustomAttributes.Any(x => x.AttributeType.FullName == typeof(CompilerGeneratedAttribute).FullName)) { if (_branchesInCompiledGeneratedClass == null) { _branchesInCompiledGeneratedClass = new List <string>(); } if (!_branchesInCompiledGeneratedClass.Contains(method.FullName)) { _branchesInCompiledGeneratedClass.Add(method.FullName); } } } _result.HitCandidates.Add(new HitCandidate(true, document.Index, branchPoint.StartLine, (int)branchPoint.Ordinal)); return(AddInstrumentationInstructions(method, processor, instruction, _result.HitCandidates.Count - 1)); }