void MarkType(TypeMirror t) { MarkAssembly(t.Assembly); if (loadedTypes.Contains(t.FullName)) { return; } Log("adding matched type {0}", t.FullName); loadedTypes.Add(t.FullName); var meths = t.GetMethods(); // make a record for all methods defined by this type foreach (var m in meths) { CodeRecord rec; if (!records.TryGetValue(m.FullName, out rec)) { Log("adding matched method {0}", m.FullName); rec = new CodeRecord() { ClassName = m.DeclaringType.CSharpName, Assembly = m.DeclaringType.Assembly.GetName().FullName, Name = m.Name, FullMethodName = m.FullName, SourceFile = m.SourceFile, }; rec.AddLines(m.LineNumbers.ToArray()); if (!bps.ContainsKey(m.FullName)) { bps [m.FullName] = new List <BreakPoint> (); // add a break on each line Log("adding {0} breakpoints", m.Locations.Count); foreach (var l in m.Locations) { var bp = VirtualMachine.CreateBreakpointRequest(l); var b = new BreakPoint() { Location = l, Record = rec, Request = bp }; bps [m.FullName].Add(b); rbps [bp] = b; bp.Enabled = true; } } records.Add(m.FullName, rec); DataStore.RegisterMethod(rec); } } }
public List <CodeRecord> Load() { var rv = new List <CodeRecord>(); // load code points using (var tx = con.BeginTransaction()) using (var cmd = new SqliteCommand(con)){ cmd.Transaction = tx; cmd.CommandText = @"SELECT assembly, sourcefile, classname, name FROM methods"; using (var sth = cmd.ExecuteReader()) { while (sth.HasRows && sth.Read()) { var rec = new CodeRecord(); rec.Assembly = Convert.ToString(sth["assembly"]); rec.SourceFile = Convert.ToString(sth["sourcefile"]); rec.ClassName = Convert.ToString(sth["classname"]); rec.Name = Convert.ToString(sth["name"]); // get call count var calls = new SqliteCommand(con); calls.CommandText = "SELECT hits FROM calls WHERE assembly = :ASSEMBLY AND classname = :CLASSNAME AND name = :NAME"; calls.Parameters.Add(new SqliteParameter(":ASSEMBLY", rec.Assembly)); calls.Parameters.Add(new SqliteParameter(":CLASSNAME", rec.ClassName)); calls.Parameters.Add(new SqliteParameter(":NAME", rec.Name)); var ccount = Convert.ToInt32(calls.ExecuteScalar()); rec.CallCount = ccount; // get lines var lines = new SqliteCommand(con); lines.CommandText = "SELECT line, hits FROM lines WHERE assembly = :ASSEMBLY AND classname = :CLASSNAME AND name = :NAME"; lines.Parameters.Add(new SqliteParameter(":ASSEMBLY", rec.Assembly)); lines.Parameters.Add(new SqliteParameter(":CLASSNAME", rec.ClassName)); lines.Parameters.Add(new SqliteParameter(":NAME", rec.Name)); using (var lsth = lines.ExecuteReader()){ while (lsth.HasRows && lsth.Read()) { var l = Convert.ToInt32(lsth["line"]); var hc = Convert.ToInt32(lsth["hits"]); rec.AddLines(l); rec.SetHits(l, hc); } } rv.Add(rec); } } tx.Commit(); } return(rv); }
public List<CodeRecord> Load() { var rv = new List<CodeRecord>(); // load code points using ( var tx = con.BeginTransaction() ) using ( var cmd = new SqliteCommand( con ) ){ cmd.Transaction = tx; cmd.CommandText = @"SELECT fullname, assembly, sourcefile, classname, name FROM methods"; using ( var sth = cmd.ExecuteReader() ) { while ( sth.HasRows && sth.Read() ){ var rec = new CodeRecord(); rec.FullMethodName = Convert.ToString( sth["fullname"] ); rec.Assembly = Convert.ToString( sth["assembly"] ); rec.SourceFile = Convert.ToString( sth["sourcefile"] ); rec.ClassName = Convert.ToString( sth["classname"] ); rec.Name = Convert.ToString( sth["name"] ); // get call count var calls = new SqliteCommand( con ); calls.CommandText = "SELECT hits FROM calls WHERE assembly = :ASSEMBLY AND fullname = :FULLNAME"; calls.Parameters.Add( new SqliteParameter( ":ASSEMBLY", rec.Assembly ) ); calls.Parameters.Add( new SqliteParameter( ":FULLNAME", rec.FullMethodName ) ); var ccount = Convert.ToInt32( calls.ExecuteScalar() ); rec.CallCount = ccount; // get lines var lines = new SqliteCommand( con ); lines.CommandText = "SELECT line, hits FROM lines WHERE assembly = :ASSEMBLY AND fullname = :FULLNAME"; lines.Parameters.Add( new SqliteParameter( ":ASSEMBLY", rec.Assembly ) ); lines.Parameters.Add( new SqliteParameter( ":FULLNAME", rec.FullMethodName ) ); using ( var lsth = lines.ExecuteReader() ){ while ( lsth.HasRows && lsth.Read() ) { var l = Convert.ToInt32( lsth["line"] ); var hc = Convert.ToInt32( lsth["hits"] ); rec.AddLines(l); rec.SetHits( l, hc ); } } rv.Add(rec); } } tx.Commit(); } return rv; }
public void ParseGCovFile(string filepath) { CodeRecord record = new CodeRecord(); Dictionary <string, string> fileDetails = new Dictionary <string, string> (); var lines = File.ReadAllLines(filepath); foreach (var line in lines) { var parts = line.Split(new char[] { ':' }, 3); // counts, line-num, details if (parts.Length == 3) { var line_num = parts [1].Trim(); var linenum = ParseInt(line_num); if (linenum == 0) { // key:value var details = parts [2].Split(new char[] { ':' }, 2); fileDetails [details [0]] = details [1]; } else { // coverage and line data var hitcount = parts[0].Trim(); if (!hitcount.Equals("-")) { // is an executable line if (hitcount.Contains("#")) { record.AddLines(new int[] { linenum }); } else { var hits = ParseInt(hitcount); if (hits > 0 && linenum > 0) { record.AddLines(new int[] { linenum }); record.SetHits(linenum, hits); } } } } } } if (fileDetails.ContainsKey("Source")) { record.SourceFile = fileDetails ["Source"]; if (!Path.IsPathRooted(record.SourceFile)) { // relative path, make it absolute according to the notes file path record.SourceFile = Path.Combine(BuildRoot, record.SourceFile); } // make a relative path for the "assembly/class name" var relpath = GetRelativePath(BuildRoot, record.SourceFile); record.Assembly = record.SourceFile; record.Name = Path.GetFileName(record.SourceFile); record.ClassName = Path.GetDirectoryName(relpath); record.FullMethodName = relpath; // add to the data Records.Add(record); } }
void MarkType( TypeMirror t ) { MarkAssembly( t.Assembly ); if ( loadedTypes.Contains( t.FullName ) ) return; Log("adding matched type {0}",t.FullName); loadedTypes.Add( t.FullName ); var meths = t.GetMethods (); // make a record for all methods defined by this type foreach (var m in meths) { CodeRecord rec; if (!records.TryGetValue (m.FullName, out rec)) { Log("adding matched method {0}",m.FullName); rec = new CodeRecord () { ClassName = m.DeclaringType.CSharpName, Assembly = m.DeclaringType.Assembly.GetName().FullName, Name = m.Name, FullMethodName = m.FullName, SourceFile = m.SourceFile, }; rec.AddLines( m.LineNumbers.ToArray() ); if (!bps.ContainsKey (m.FullName)) { bps [m.FullName] = new List<BreakPoint> (); // add a break on each line Log("adding {0} breakpoints", m.Locations.Count); foreach (var l in m.Locations) { var bp = VirtualMachine.CreateBreakpointRequest (l); var b = new BreakPoint () { Location = l, Record = rec, Request = bp }; bps [m.FullName].Add (b); rbps [bp] = b; bp.Enabled = true; } } records.Add (m.FullName, rec); DataStore.RegisterMethod (rec); } } }