internal void AddSequencePoint(Mono.Cecil.Cil.SequencePoint point) { if (SequencePoints.All(s => s.GetIdentifier() != SequencePoint.GetIdentifier(point))) { SequencePoints.Add(new SequencePoint(point)); } }
internal void MergeFrom(SourceFile sourceFile) { foreach (var sequencePoint in sourceFile.SequencePoints) { if (SequencePoints.All(s => s.GetIdentifier() != sequencePoint.GetIdentifier())) { SequencePoints.Add(sequencePoint); } else { SequencePoints.First(s => s.GetIdentifier() == sequencePoint.GetIdentifier()).MergeFrom( sequencePoint); } } }
public TextRun this[int ilOffset] { get { // todo. support 0xfeefee semantics here // see http://blogs.msdn.com/jmstall/archive/2005/06/19/FeeFee_SequencePoints.aspx for (var i = 0; i < SequencePoints.Count(); ++i) { var from = SequencePoints[i].ILOffset; var to = i == SequencePoints.Count() - 1 ? int.MaxValue : SequencePoints[i + 1].ILOffset; if (from <= ilOffset && ilOffset < to) { return(SequencePoints[i].TextRun); } } return(null); } }
internal void AddResult(Mono.Cecil.Cil.SequencePoint sequencePoint, MutantMetaData mutantMetaData, bool mutantKilled) { string identifier = SequencePoint.GetIdentifier(sequencePoint); _readerWriterLock.EnterUpgradeableReadLock(); try { if (SequencePoints.All(s => s.GetIdentifier() != identifier)) { _readerWriterLock.EnterWriteLock(); SequencePoints.Add(new SequencePoint(sequencePoint)); _readerWriterLock.ExitWriteLock(); } } finally { _readerWriterLock.ExitUpgradeableReadLock(); } var sourceSequencePoint = SequencePoints.First(s => s.GetIdentifier() == identifier); sourceSequencePoint.AddResult(mutantMetaData, mutantKilled); }
public override string ToString() { return($@"{CoveragePercent}%: {MethodName} --- {string.Join("\r\n", SequencePoints.Select(s => s.ToString()).AsEnumerable())}"); }
public IEnumerable <byte> Encode() { var allSbs = new List <List <byte> >(); var curSb = new List <byte>(); allSbs.Add(curSb); Action <byte> addByte = b => { curSb.Add(b); if (curSb.Count >= int.MaxValue / 2) { var newSb = new List <byte>(); allSbs.Add(newSb); curSb = newSb; } }; Action <IEnumerable <byte> > addByteRange = e => { foreach (var b in e) { addByte(b); } }; var methodNameBytes = Encoding.UTF8.GetBytes(MethodName); var len = methodNameBytes.Length; if (len > ushort.MaxValue) { throw new Exception("Yeah, that shouldn't be possible"); } addByte((byte)((len >> 8) & 0xFF)); addByte((byte)((len >> 0) & 0xFF)); addByteRange(methodNameBytes); var maxOrdinal = SequencePoints.Max(s => s.Ordinal); if (maxOrdinal > ushort.MaxValue) { throw new Exception("That's a giant method, wtf"); } addByte((byte)((maxOrdinal >> 8) & 0xFF)); addByte((byte)((maxOrdinal >> 0) & 0xFF)); if (SequencePoints.Any(s => s.Visited)) { var bitMask = new System.Collections.BitArray(maxOrdinal + 1); foreach (var seq in SequencePoints) { if (seq.Visited) { bitMask.Set(seq.Ordinal, true); } } var bitArrayByteCount = ((maxOrdinal + 1) / 8) + ((maxOrdinal + 1) % 8); var bitArrayBytes = new byte[bitArrayByteCount]; bitMask.CopyTo(bitArrayBytes, 0); addByteRange(bitArrayBytes); } foreach (var set in allSbs) { foreach (var b in set) { yield return(b); } } }