Browse Source

Merge commit 'bb8213bf'

pull/375/head
Matt Ward 12 years ago
parent
commit
9722179c02
  1. 1
      src/AddIns/Analysis/CodeCoverage/Project/CodeCoverage.csproj
  2. 19
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageBranchPoint.cs
  3. 36
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageControl.cs
  4. 21
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageHighlighter.cs
  5. 43
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageMethod.cs
  6. 368
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageMethodElement.cs
  7. 4
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageModule.cs
  8. 20
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageResults.cs
  9. 3
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageSequencePoint.cs
  10. 24
      src/AddIns/Analysis/CodeCoverage/Test/Coverage/CodeCoverageResultsMissingFileIdTestFixture.cs
  11. 22
      src/AddIns/Analysis/CodeCoverage/Test/Coverage/CodeCoverageResultsTestFixture.cs
  12. 8
      src/AddIns/Analysis/CodeCoverage/Test/Coverage/GetSequencePointsForFileNameTestFixture.cs
  13. 12
      src/AddIns/Analysis/CodeCoverage/Test/Coverage/ModuleVisitedSequencePointsTestFixture.cs
  14. 6
      src/AddIns/Analysis/CodeCoverage/Test/Gui/PropertiesInCodeCoverageTreeView.cs
  15. BIN
      src/Tools/OpenCover/OpenCover.Console.exe
  16. BIN
      src/Tools/OpenCover/OpenCover.Extensions.dll
  17. BIN
      src/Tools/OpenCover/OpenCover.Framework.dll
  18. BIN
      src/Tools/OpenCover/x64/OpenCover.Profiler.dll
  19. BIN
      src/Tools/OpenCover/x86/OpenCover.Profiler.dll

1
src/AddIns/Analysis/CodeCoverage/Project/CodeCoverage.csproj

@ -67,7 +67,6 @@ @@ -67,7 +67,6 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Src\CodeCoverageBranchPoint.cs" />
<Compile Include="Src\CodeCoverageControl.cs">
<SubType>UserControl</SubType>
</Compile>

19
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageBranchPoint.cs

@ -1,19 +0,0 @@ @@ -1,19 +0,0 @@
// Copyright (c) https://github.com/ddur
// This code is distributed under the MIT license
using System;
namespace ICSharpCode.CodeCoverage
{
/// <summary>
/// Description of CodeCoverageBranchPoint.
/// </summary>
public class CodeCoverageBranchPoint
{
public int VisitCount { get; set; }
public int Path { get; set; }
public int Offset { get; set; }
public int OffsetEnd { get; set; }
}
}

36
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageControl.cs

@ -19,12 +19,10 @@ @@ -19,12 +19,10 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
using ICSharpCode.AvalonEdit;
using ICSharpCode.AvalonEdit.AddIn;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.Core;
@ -32,7 +30,6 @@ using ICSharpCode.Core.WinForms; @@ -32,7 +30,6 @@ using ICSharpCode.Core.WinForms;
using ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
namespace ICSharpCode.CodeCoverage
{
@ -236,13 +233,13 @@ namespace ICSharpCode.CodeCoverage @@ -236,13 +233,13 @@ namespace ICSharpCode.CodeCoverage
listView.BeginUpdate();
try {
listView.Items.Clear();
CodeCoverageClassTreeNode classNode = node as CodeCoverageClassTreeNode;
CodeCoverageMethodTreeNode methodNode = node as CodeCoverageMethodTreeNode;
CodeCoveragePropertyTreeNode propertyNode = node as CodeCoveragePropertyTreeNode;
var classNode = node as CodeCoverageClassTreeNode;
var methodNode = node as CodeCoverageMethodTreeNode;
var propertyNode = node as CodeCoveragePropertyTreeNode;
if (classNode != null) {
AddClassTreeNode(classNode);
} else if (methodNode != null) {
AddSequencePoints(methodNode.Method.SequencePoints);
AddSequencePoints(methodNode.Method);
} else if (propertyNode != null) {
AddPropertyTreeNode(propertyNode);
}
@ -253,9 +250,9 @@ namespace ICSharpCode.CodeCoverage @@ -253,9 +250,9 @@ namespace ICSharpCode.CodeCoverage
void UpdateTextEditor(CodeCoverageTreeNode node)
{
CodeCoverageClassTreeNode classNode = node as CodeCoverageClassTreeNode;
CodeCoverageMethodTreeNode methodNode = node as CodeCoverageMethodTreeNode;
CodeCoveragePropertyTreeNode propertyNode = node as CodeCoveragePropertyTreeNode;
var classNode = node as CodeCoverageClassTreeNode;
var methodNode = node as CodeCoverageMethodTreeNode;
var propertyNode = node as CodeCoveragePropertyTreeNode;
if (classNode != null && classNode.Nodes.Count > 0) {
propertyNode = classNode.Nodes[0] as CodeCoveragePropertyTreeNode;
methodNode = classNode.Nodes[0] as CodeCoverageMethodTreeNode;
@ -280,10 +277,10 @@ namespace ICSharpCode.CodeCoverage @@ -280,10 +277,10 @@ namespace ICSharpCode.CodeCoverage
void AddClassTreeNode(CodeCoverageClassTreeNode node)
{
foreach (CodeCoverageTreeNode childNode in node.Nodes) {
CodeCoverageMethodTreeNode method = childNode as CodeCoverageMethodTreeNode;
CodeCoveragePropertyTreeNode property = childNode as CodeCoveragePropertyTreeNode;
var method = childNode as CodeCoverageMethodTreeNode;
var property = childNode as CodeCoveragePropertyTreeNode;
if (method != null) {
AddSequencePoints(method.Method.SequencePoints);
AddSequencePoints(method.Method);
} else {
AddPropertyTreeNode(property);
}
@ -299,20 +296,21 @@ namespace ICSharpCode.CodeCoverage @@ -299,20 +296,21 @@ namespace ICSharpCode.CodeCoverage
void AddMethodIfNotNull(CodeCoverageMethod method)
{
if (method != null) {
AddSequencePoints(method.SequencePoints);
AddSequencePoints(method);
}
}
void AddSequencePoints(List<CodeCoverageSequencePoint> sequencePoints)
void AddSequencePoints(CodeCoverageMethod method)
{
foreach (CodeCoverageSequencePoint sequencePoint in sequencePoints) {
AddSequencePoint(sequencePoint);
foreach (CodeCoverageSequencePoint sequencePoint in method.SequencePoints) {
if (method.FileID == sequencePoint.FileID)
AddSequencePoint(sequencePoint);
}
}
void AddSequencePoint(CodeCoverageSequencePoint sequencePoint)
{
ListViewItem item = new ListViewItem(sequencePoint.VisitCount.ToString());
var item = new ListViewItem(sequencePoint.VisitCount.ToString());
item.SubItems.Add(sequencePoint.Line.ToString());
item.SubItems.Add(sequencePoint.Column.ToString());
item.SubItems.Add(sequencePoint.EndLine.ToString());
@ -328,7 +326,7 @@ namespace ICSharpCode.CodeCoverage @@ -328,7 +326,7 @@ namespace ICSharpCode.CodeCoverage
void ListViewItemActivate(object sender, EventArgs e)
{
if (listView.SelectedItems.Count > 0) {
CodeCoverageSequencePoint sequencePoint = (CodeCoverageSequencePoint)listView.SelectedItems[0].Tag;
var sequencePoint = (CodeCoverageSequencePoint)listView.SelectedItems[0].Tag;
if (sequencePoint.Document.Length > 0) {
FileService.JumpToFilePosition(sequencePoint.Document, sequencePoint.Line, sequencePoint.Column);
}

21
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageHighlighter.cs

@ -18,7 +18,6 @@ @@ -18,7 +18,6 @@
using System;
using System.Collections.Generic;
using System.Windows.Media;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop;
@ -50,7 +49,7 @@ namespace ICSharpCode.CodeCoverage @@ -50,7 +49,7 @@ namespace ICSharpCode.CodeCoverage
return;
}
ITextMarkerService markerService = document.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
var markerService = document.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
if (markerService != null) {
int startOffset = document.PositionToOffset(sequencePoint.Line, sequencePoint.Column);
int endOffset = document.PositionToOffset(sequencePoint.EndLine, sequencePoint.EndColumn);
@ -66,7 +65,7 @@ namespace ICSharpCode.CodeCoverage @@ -66,7 +65,7 @@ namespace ICSharpCode.CodeCoverage
/// </summary>
public void RemoveMarkers(IDocument document)
{
ITextMarkerService markerService = document.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
var markerService = document.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
if (markerService != null) {
markerService.RemoveAll(IsCodeCoverageTextMarker);
}
@ -74,7 +73,7 @@ namespace ICSharpCode.CodeCoverage @@ -74,7 +73,7 @@ namespace ICSharpCode.CodeCoverage
bool IsCodeCoverageTextMarker(ITextMarker marker)
{
Type type = marker.Tag as Type;
var type = marker.Tag as Type;
return type == typeof(CodeCoverageHighlighter);
}
@ -109,21 +108,15 @@ namespace ICSharpCode.CodeCoverage @@ -109,21 +108,15 @@ namespace ICSharpCode.CodeCoverage
}
public static System.Drawing.Color GetSequencePointBackColor(CodeCoverageSequencePoint sequencePoint) {
if (sequencePoint.VisitCount > 0) {
if ( sequencePoint.BranchCoverage == true ) {
return CodeCoverageOptions.VisitedColor;
}
return CodeCoverageOptions.PartVisitedColor;
if (sequencePoint.VisitCount != 0) {
return sequencePoint.BranchCoverage == true ? CodeCoverageOptions.VisitedColor : CodeCoverageOptions.PartVisitedColor;
}
return CodeCoverageOptions.NotVisitedColor;
}
public static System.Drawing.Color GetSequencePointForeColor(CodeCoverageSequencePoint sequencePoint) {
if (sequencePoint.VisitCount > 0) {
if ( sequencePoint.BranchCoverage == true ) {
return CodeCoverageOptions.VisitedForeColor;
}
return CodeCoverageOptions.PartVisitedForeColor;
if (sequencePoint.VisitCount != 0) {
return sequencePoint.BranchCoverage == true ? CodeCoverageOptions.VisitedForeColor : CodeCoverageOptions.PartVisitedForeColor;
}
return CodeCoverageOptions.NotVisitedForeColor;
}

43
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageMethod.cs

@ -18,8 +18,6 @@ @@ -18,8 +18,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Xml;
using System.Xml.Linq;
using ICSharpCode.Core;
@ -27,11 +25,11 @@ namespace ICSharpCode.CodeCoverage @@ -27,11 +25,11 @@ namespace ICSharpCode.CodeCoverage
{
public class CodeCoverageMethod
{
string name = String.Empty;
string className = String.Empty;
string fullClassName = String.Empty;
string classNamespace = String.Empty;
List<CodeCoverageSequencePoint> sequencePoints = new List<CodeCoverageSequencePoint>();
readonly string name = String.Empty;
readonly string className = String.Empty;
readonly string fullClassName = String.Empty;
readonly string classNamespace = String.Empty;
readonly List<CodeCoverageSequencePoint> sequencePoints = new List<CodeCoverageSequencePoint>();
public CodeCoverageMethod(string name, string className)
{
@ -63,10 +61,9 @@ namespace ICSharpCode.CodeCoverage @@ -63,10 +61,9 @@ namespace ICSharpCode.CodeCoverage
this.IsVisited = element.IsVisited;
this.BranchCoverage = element.BranchCoverage;
this.BranchCoverageRatio = element.BranchCoverageRatio;
this.SequencePointsCount = element.SequencePointsCount;
this.sequencePoints = element.SequencePoints;
this.FileID = element.FileID;
}
/// <summary>
@ -78,8 +75,8 @@ namespace ICSharpCode.CodeCoverage @@ -78,8 +75,8 @@ namespace ICSharpCode.CodeCoverage
public bool IsVisited { get; private set; }
public decimal BranchCoverage { get; private set; }
public Tuple<int,int> BranchCoverageRatio { get; private set; }
public int SequencePointsCount { get; private set; }
public string FileID { get; private set; }
bool IsPropertyMethodName()
{
@ -112,10 +109,7 @@ namespace ICSharpCode.CodeCoverage @@ -112,10 +109,7 @@ namespace ICSharpCode.CodeCoverage
public static string GetRootNamespace(string ns)
{
int index = ns.IndexOf('.');
if (index > 0) {
return ns.Substring(0, index);
}
return ns;
return index > 0 ? ns.Substring(0, index) : ns;
}
public List<CodeCoverageSequencePoint> SequencePoints {
@ -150,7 +144,7 @@ namespace ICSharpCode.CodeCoverage @@ -150,7 +144,7 @@ namespace ICSharpCode.CodeCoverage
{
int total = 0;
foreach (CodeCoverageSequencePoint sequencePoint in sequencePoints) {
if (sequencePoint.VisitCount != 0) {
if (sequencePoint.FileID == this.FileID && sequencePoint.VisitCount != 0) {
total += sequencePoint.Length;
}
}
@ -161,7 +155,7 @@ namespace ICSharpCode.CodeCoverage @@ -161,7 +155,7 @@ namespace ICSharpCode.CodeCoverage
{
int total = 0;
foreach (CodeCoverageSequencePoint sequencePoint in sequencePoints) {
if (sequencePoint.VisitCount == 0) {
if (sequencePoint.FileID == this.FileID && sequencePoint.VisitCount == 0) {
total += sequencePoint.Length;
}
}
@ -170,7 +164,7 @@ namespace ICSharpCode.CodeCoverage @@ -170,7 +164,7 @@ namespace ICSharpCode.CodeCoverage
public List<CodeCoverageSequencePoint> GetSequencePoints(string fileName)
{
List<CodeCoverageSequencePoint> matchedSequencePoints = new List<CodeCoverageSequencePoint>();
var matchedSequencePoints = new List<CodeCoverageSequencePoint>();
foreach (CodeCoverageSequencePoint sequencePoint in sequencePoints) {
if (FileUtility.IsEqualFileName(fileName, sequencePoint.Document)) {
matchedSequencePoints.Add(sequencePoint);
@ -193,10 +187,7 @@ namespace ICSharpCode.CodeCoverage @@ -193,10 +187,7 @@ namespace ICSharpCode.CodeCoverage
/// </summary>
public static string GetFullNamespace(string prefix, string name)
{
if (prefix.Length > 0) {
return String.Concat(prefix, ".", name);
}
return name;
return prefix.Length > 0 ? String.Concat(prefix, ".", name) : name;
}
/// <summary>
@ -208,7 +199,7 @@ namespace ICSharpCode.CodeCoverage @@ -208,7 +199,7 @@ namespace ICSharpCode.CodeCoverage
/// method will return 'XmlEditor' as one of its strings.
/// </remarks>
public static List<string> GetChildNamespaces(List<CodeCoverageMethod> methods, string parentNamespace) {
List<string> items = new List<string>();
var items = new List<string>();
foreach (CodeCoverageMethod method in methods) {
string classNamespace = method.ClassNamespace;
string dottedParentNamespace = parentNamespace + ".";
@ -227,10 +218,10 @@ namespace ICSharpCode.CodeCoverage @@ -227,10 +218,10 @@ namespace ICSharpCode.CodeCoverage
/// </summary>
public static List<CodeCoverageMethod> GetAllMethods(List<CodeCoverageMethod> methods, string namespaceStartsWith)
{
List<CodeCoverageMethod> matchedMethods = new List<CodeCoverageMethod>();
var matchedMethods = new List<CodeCoverageMethod>();
namespaceStartsWith += ".";
foreach (CodeCoverageMethod method in methods) {
if ((method.ClassNamespace+".").StartsWith(namespaceStartsWith)) {
if ((method.ClassNamespace + ".").StartsWith(namespaceStartsWith, StringComparison.Ordinal)) {
matchedMethods.Add(method);
}
}
@ -242,7 +233,7 @@ namespace ICSharpCode.CodeCoverage @@ -242,7 +233,7 @@ namespace ICSharpCode.CodeCoverage
/// </summary>
public static List<CodeCoverageMethod> GetMethods(List<CodeCoverageMethod> methods, string ns, string className)
{
List<CodeCoverageMethod> matchedMethods = new List<CodeCoverageMethod>();
var matchedMethods = new List<CodeCoverageMethod>();
foreach (CodeCoverageMethod method in methods) {
if (method.ClassName == className && method.ClassNamespace == ns) {
matchedMethods.Add(method);
@ -253,7 +244,7 @@ namespace ICSharpCode.CodeCoverage @@ -253,7 +244,7 @@ namespace ICSharpCode.CodeCoverage
public static List<string> GetClassNames(List<CodeCoverageMethod> methods, string ns)
{
List<string> names = new List<string>();
var names = new List<string>();
foreach (CodeCoverageMethod method in methods) {
if (method.ClassNamespace == ns && !names.Contains(method.ClassName)) {
names.Add(method.ClassName);

368
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageMethodElement.cs

@ -29,22 +29,33 @@ namespace ICSharpCode.CodeCoverage @@ -29,22 +29,33 @@ namespace ICSharpCode.CodeCoverage
{
public class CodeCoverageMethodElement
{
XElement element;
CodeCoverageResults parent;
readonly XElement element;
readonly CodeCoverageResults results;
/// <summary>Enables CodeCoverage.Test to compile</summary>
/// <param name="element">XMLElement</param>
public CodeCoverageMethodElement(XElement element)
: this (element, null) {}
public CodeCoverageMethodElement(XElement element, CodeCoverageResults parent)
/// <summary>Create Method Element</summary>
/// <param name="element">XMLElement</param>
/// <param name="results">has .GetFileName(FileID)</param>
public CodeCoverageMethodElement(XElement element, CodeCoverageResults results)
{
this.parent = parent;
this.results = results;
this.element = element;
this.SequencePoints = new List<CodeCoverageSequencePoint>();
this.BranchPoints = new List<CodeCoverageBranchPoint>();
Init();
}
// Primary TextSource cache
private static string cacheFileName = String.Empty;
private static CodeCoverageStringTextSource cacheDocument = null;
// Secondary TextSource cache
private static string cache2FileName = String.Empty;
private static CodeCoverageStringTextSource cache2Document = null;
public string FileID { get; private set; }
public string FileName { get; private set; }
public bool IsVisited { get; private set; }
@ -58,7 +69,6 @@ namespace ICSharpCode.CodeCoverage @@ -58,7 +69,6 @@ namespace ICSharpCode.CodeCoverage
public List<CodeCoverageSequencePoint> SequencePoints { get; private set; }
public CodeCoverageSequencePoint BodyStartSP { get; private set; }
public CodeCoverageSequencePoint BodyFinalSP { get; private set; }
public List<CodeCoverageBranchPoint> BranchPoints { get; private set; }
public bool IsGetter { get; private set; }
public bool IsSetter { get; private set; }
@ -77,22 +87,11 @@ namespace ICSharpCode.CodeCoverage @@ -77,22 +87,11 @@ namespace ICSharpCode.CodeCoverage
this.FileID = GetFileRef();
this.FileName = String.Empty;
if (!String.IsNullOrEmpty(this.FileID)) {
if (parent != null) {
this.FileName = parent.GetFileName(this.FileID);
if ( File.Exists(this.FileName) ) {
if (cacheFileName != this.FileName) {
cacheFileName = this.FileName;
cacheDocument = null;
try {
using (Stream stream = new FileStream(this.FileName, FileMode.Open, FileAccess.Read)) {
try {
stream.Position = 0;
string textSource = ICSharpCode.AvalonEdit.Utils.FileReader.ReadFileContent(stream, Encoding.Default);
cacheDocument = new CodeCoverageStringTextSource(textSource);
} catch {}
}
} catch {}
}
if (results != null) {
this.FileName = results.GetFileName(this.FileID);
if (cacheFileName != this.FileName) {
cacheFileName = this.FileName;
cacheDocument = GetSource (cacheFileName);
}
}
}
@ -106,22 +105,43 @@ namespace ICSharpCode.CodeCoverage @@ -106,22 +105,43 @@ namespace ICSharpCode.CodeCoverage
if ( !String.IsNullOrEmpty( this.FileID ) ) {
this.GetSequencePoints();
this.GetSequencePointsContent();
this.getBodyStartSP(); // before OrderBy Line/Col
this.getBodyFinalSP(); // before orderBy Line/Col
this.FilterSequencePoints(); // before orderBy Line/Col
this.GetBranchPoints();
this.getBodyStartSP();
this.getBodyFinalSP();
this.GetBranchRatio();
this.GetBranchCoverage();
// SP's are originaly ordered by CIL offset
// but ccrewrite can move offset of
// Contract.Requires before method signature SP { and
// Contract.Ensures after method closing SP }
// because ccrewrite can move offset of
// Contract.Requires before method start ({) SP offset
// Contract.Ensures after method final (}) SP offset
// So sort SP's back by line/column
this.SequencePoints.OrderBy(item => item.Line).OrderBy(item => item.Column);
}
}
private static string cacheGetSource_LastFileName = null;
private static CodeCoverageStringTextSource cacheGetSource_LastSource = null;
static CodeCoverageStringTextSource GetSource(string filename) {
if (filename == cacheGetSource_LastFileName) return cacheGetSource_LastSource;
var retSource = (CodeCoverageStringTextSource)null;
try {
using (Stream stream = new FileStream(filename, FileMode.Open, FileAccess.Read)) {
try {
stream.Position = 0;
string textSource = ICSharpCode.AvalonEdit.Utils.FileReader.ReadFileContent(stream, Encoding.Default);
retSource = new CodeCoverageStringTextSource(textSource);
} catch (Exception) {}
}
} catch (Exception) {}
cacheGetSource_LastFileName = filename;
cacheGetSource_LastSource = retSource;
return retSource;
}
void GetSequencePoints() {
var xSPoints = this.element
@ -129,16 +149,32 @@ namespace ICSharpCode.CodeCoverage @@ -129,16 +149,32 @@ namespace ICSharpCode.CodeCoverage
.Elements("SequencePoint");
foreach (XElement xSPoint in xSPoints) {
CodeCoverageSequencePoint sp = new CodeCoverageSequencePoint();
sp.FileID = this.FileID;
sp.Document = this.FileName;
var sp = new CodeCoverageSequencePoint();
sp.Line = (int)GetDecimalAttributeValue(xSPoint.Attribute("sl"));
sp.EndLine = (int)GetDecimalAttributeValue(xSPoint.Attribute("el"));
sp.Column = (int)GetDecimalAttributeValue(xSPoint.Attribute("sc"));
sp.EndColumn = (int)GetDecimalAttributeValue(xSPoint.Attribute("ec"));
sp.VisitCount = (int)GetDecimalAttributeValue(xSPoint.Attribute("vc"));
sp.Offset = (int)GetDecimalAttributeValue(xSPoint.Attribute("offset"));
sp.BranchCoverage = true;
sp.BranchExitsCount = (int)GetDecimalAttributeValue(xSPoint.Attribute("bec"));
sp.BranchExitsVisit = (int)GetDecimalAttributeValue(xSPoint.Attribute("bev"));
sp.FileID = xSPoint.Attribute("fileid") != null? xSPoint.Attribute("fileid").Value : "0";
if (sp.FileID == "0") {
// SequencePoint from not covered (not runnable) file
// ie: interface with CodeContractClass/CodeContractClassFor
sp.Document = xSPoint.Attribute("fileid") != null? xSPoint.Attribute("fileid").Value : "";
}
else if (sp.FileID == this.FileID) {
// This method SequencePoint (from this.FileName)
sp.Document = this.FileName;
}
else {
// SequencePoint from another method/file
// ie: ccrewriten CodeContractClass/CodeContractClassFor
// [or dependency-injected or fody-weaved???]
sp.Document = results.GetFileName(sp.FileID);
}
sp.BranchCoverage = (sp.BranchExitsCount == sp.BranchExitsVisit);
sp.Content = String.Empty;
sp.Length = 0;
@ -148,114 +184,81 @@ namespace ICSharpCode.CodeCoverage @@ -148,114 +184,81 @@ namespace ICSharpCode.CodeCoverage
void GetSequencePointsContent()
{
if (cacheFileName == this.FileName && cacheDocument != null) {
foreach (var sp in this.SequencePoints) {
GetSequencePointContent(sp);
}
foreach (var sp in this.SequencePoints) {
GetSequencePointContent(sp);
}
}
void GetSequencePointContent(CodeCoverageSequencePoint sp)
{
// ccrewrite will cause lots of invalid calls to GetText()!
if (cacheFileName == sp.Document && cacheDocument != null) {
sp.Content = cacheDocument.GetText(sp); // never returns null
if (sp.Content != String.Empty) {
if (sp.Line != sp.EndLine) {
// merge lines to single line
sp.Content = Regex.Replace(sp.Content, @"\s+", " ");
}
// SequencePoint.Length counts all but whitespace
sp.Length = Regex.Replace(sp.Content, @"\s", "").Length;
if (cacheFileName == sp.Document) {
// check primary cache (this.Filename)
sp.Content = cacheDocument == null? "" : cacheDocument.GetText(sp);
}
else {
// check & update secondary cache
if (cache2FileName == sp.Document) {
sp.Content = cache2Document == null? "" : cache2Document.GetText(sp);
}
else {
cache2FileName = sp.Document;
cache2Document = GetSource (cache2FileName);
sp.Content = cache2Document == null? "" : cache2Document.GetText(sp);
}
}
}
// Find method-body start SequencePoint "{" (sp.Content required)
// Sequence points expected to be ordered by Offset
// Cannot just get first one because of ccrewrite&ContractClassFor
void getBodyStartSP() {
bool startPointFound = false;
CodeCoverageSequencePoint startSeqPoint = null;
foreach (CodeCoverageSequencePoint sp in this.SequencePoints) {
if ( sp.Content == "{") {
if ( this.IsConstructor ) {
// take previous/last one if not null
startSeqPoint = startSeqPoint?? sp;
}
else {
startSeqPoint = sp;
}
startPointFound = true;
break;
if (sp.Content != String.Empty) {
if (sp.Line != sp.EndLine) {
// merge multiple lines to single line
sp.Content = Regex.Replace(sp.Content, @"\s+", " ");
}
startSeqPoint = sp;
// SequencePoint.Length counts all but whitespace
sp.Length = Regex.Replace(sp.Content, @"\s", "").Length;
}
this.BodyStartSP = startPointFound? startSeqPoint: null;
}
// Find method-body final SequencePoint "}" (sp.Content required)
// Sequence points expected to be ordered by Offset
void getBodyFinalSP() {
CodeCoverageSequencePoint finalSeqPoint = null;
foreach (CodeCoverageSequencePoint sp in ((IEnumerable<CodeCoverageSequencePoint>)this.SequencePoints).Reverse()) {
if ( sp.Content == "}") {
if (finalSeqPoint == null) {
finalSeqPoint = sp;
}
// check for ccrewrite duplicate
else if (sp.Line == finalSeqPoint.Line &&
sp.Column == finalSeqPoint.Column &&
sp.EndLine == finalSeqPoint.EndLine &&
sp.EndColumn == finalSeqPoint.EndColumn &&
sp.Offset < finalSeqPoint.Offset) {
finalSeqPoint = sp;
// duplicate found, so far no reason to expect "triplicate" :)
break;
// Find method-body first SequencePoint
// -> this method SP with lowest Line/Column
void getBodyStartSP() {
if (this.SequencePoints.Count != 0) {
foreach (CodeCoverageSequencePoint sp in this.SequencePoints) {
if (sp.FileID != this.FileID) continue;
if (this.BodyStartSP == null || (sp.Line < this.BodyStartSP.Line) ||
(sp.Line == this.BodyStartSP.Line && sp.Column < this.BodyStartSP.Column)
) {
this.BodyStartSP = sp;
}
}
}
this.BodyFinalSP = finalSeqPoint;
}
void FilterSequencePoints() {
if (this.SequencePoints.Count != 0 &&
this.BodyStartSP != null &&
this.BodyFinalSP != null ) {
// After ccrewrite ContractClass/ContractClassFor
// sequence point(s) from another file/class/method
// is inserted into this method sequence points
//
// To remove alien sequence points, all sequence points on lines
// before method signature and after end-brackets xxx{} are removed
// If ContractClassFor is in another file but interleaves this method lines
// then, afaik, not much can be done to remove inserted alien SP's
var selected = new List<CodeCoverageSequencePoint>();
foreach (var point in this.SequencePoints) {
// if Content.Length is 0, GetText() is failed by ccrewrite inserted invalid SequencePoint
if (point.Content.Length != 0
&& (point.Line > BodyStartSP.Line || (point.Line == BodyStartSP.Line && point.Column >= BodyStartSP.Column))
&& (point.Line < BodyFinalSP.Line || (point.Line == BodyFinalSP.Line && point.Column < BodyFinalSP.Column))
) {
selected.Add (point);
}
// After ccrewrite ContractClass/ContractClassFor
// duplicate method end-sequence-point "}" is added
//
// Add only first finalSP (can be a duplicate)
// Note: IL.Offset of second duplicate finalSP will
// extend branch coverage outside method-end "}",
// and that can lead to wrong branch coverage display!
if (object.ReferenceEquals (point, this.BodyFinalSP)) {
selected.Add (point);
// Find method-body last SequencePoint
// -> this method SP.Content=="}" with highest Line/Column
// and lowest Offset (when duplicated bw ccrewrite)
void getBodyFinalSP() {
if (this.SequencePoints.Count != 0) {
for (int i = this.SequencePoints.Count-1; i > 0; i--) {
var sp = this.SequencePoints[i];
if (sp.FileID != this.FileID) continue;
if (sp.Content != "}") continue;
if (this.BodyFinalSP == null || (sp.Line > this.BodyFinalSP.Line) ||
(sp.Line == this.BodyFinalSP.Line && sp.Column >= this.BodyFinalSP.Column)
) {
// ccrewrite ContractClass/ContractClassFor
// adds duplicate method end-sequence-point "}"
//
// Take duplicate BodyFinalSP with lower Offset
// Because IL.Offset of second duplicate
// will extend branch coverage of this method
// by coverage of ContractClassFor inserted SequencePoint!
if (this.BodyFinalSP != null &&
sp.Line == this.BodyFinalSP.Line &&
sp.Column == this.BodyFinalSP.Column &&
sp.Offset < this.BodyFinalSP.Offset) {
this.SequencePoints.Remove(this.BodyFinalSP); // remove duplicate
}
this.BodyFinalSP = sp;
}
}
this.SequencePoints = selected;
}
}
@ -270,82 +273,35 @@ namespace ICSharpCode.CodeCoverage @@ -270,82 +273,35 @@ namespace ICSharpCode.CodeCoverage
return 0;
}
void GetBranchPoints() {
// get all BranchPoints
var xBPoints = this.element
.Elements("BranchPoints")
.Elements("BranchPoint");
foreach (XElement xBPoint in xBPoints) {
CodeCoverageBranchPoint bp = new CodeCoverageBranchPoint();
bp.VisitCount = (int)GetDecimalAttributeValue(xBPoint.Attribute("vc"));
bp.Offset = (int)GetDecimalAttributeValue(xBPoint.Attribute("offset"));
bp.Path = (int)GetDecimalAttributeValue(xBPoint.Attribute("path"));
bp.OffsetEnd = (int)GetDecimalAttributeValue(xBPoint.Attribute("offsetend"));
this.BranchPoints.Add(bp);
}
}
void GetBranchRatio () {
// goal: Get branch ratio, merge branch-exits and exclude (rewriten) Code Contracts branches
this.BranchCoverageRatio = null;
if ( this.BranchPoints == null
|| this.BranchPoints.Count == 0
|| this.SequencePoints == null
|| this.SequencePoints.Count == 0
)
{
return;
}
Debug.Assert (this.SequencePoints != null);
if ( this.SequencePoints.Count == 0 ) return;
// This sequence point offset is used to skip CCRewrite(n) BranchPoint's (Requires)
// and '{' branches at static methods
if (this.BodyStartSP == null) { return; } // empty body
if (this.BodyStartSP == null) return; // empty body
// This sequence point offset is used to skip CCRewrite(n) BranchPoint's (Ensures)
if (this.BodyFinalSP == null) { return; } // empty body
// Connect Sequence & Branches
IEnumerator<CodeCoverageSequencePoint> SPEnumerator = this.SequencePoints.GetEnumerator();
CodeCoverageSequencePoint currSeqPoint = this.BodyStartSP;
int nextSeqPointOffset = BodyStartSP.Offset;
foreach (var bp in this.BranchPoints) {
// ignore branches outside of method body offset range
if (bp.Offset < BodyStartSP.Offset)
continue;
if (bp.Offset > BodyFinalSP.Offset)
break;
// Sync with SequencePoint
while ( nextSeqPointOffset < bp.Offset ) {
currSeqPoint = SPEnumerator.Current;
if ( SPEnumerator.MoveNext() ) {
nextSeqPointOffset = SPEnumerator.Current.Offset;
} else {
nextSeqPointOffset = int.MaxValue;
}
}
if (currSeqPoint.Branches == null) {
currSeqPoint.Branches = new List<CodeCoverageBranchPoint>();
}
// Add Branch to Branches
currSeqPoint.Branches.Add(bp);
}
if (this.BodyFinalSP == null) return; // empty body
// Merge sp.Branches on exit-offset
// Calculate Method Branch coverage
int totalBranchVisit = 0;
int totalBranchCount = 0;
int pointBranchVisit = 0;
int pointBranchCount = 0;
Dictionary<int, CodeCoverageBranchPoint> bpExits = new Dictionary<int, CodeCoverageBranchPoint>();
foreach (var sp in this.SequencePoints) {
// SequencePoint covered & has branches?
if (sp.VisitCount != 0 && sp.Branches != null) {
// SequencePoint is visited and belongs to this method?
if (sp.VisitCount != 0 && sp.FileID == this.FileID) {
// Don't want branch coverage of ccrewrite(n)
// SequencePoint's with offset before and after method body
if (sp.Offset < BodyStartSP.Offset ||
sp.Offset > BodyFinalSP.Offset) {
sp.BranchCoverage = true;
continue; // skip
}
// 1) Generated "in" code for IEnumerables contains hidden "try/catch/finally" branches that
// one do not want or cannot cover by test-case because is handled earlier at same method.
@ -354,42 +310,21 @@ namespace ICSharpCode.CodeCoverage @@ -354,42 +310,21 @@ namespace ICSharpCode.CodeCoverage
// ie: static methods start sequence point "{" contains compiler generated branches
// 3) Exclude Contract class (EnsuresOnThrow/Assert/Assume is inside method body)
// 4) Exclude NUnit Assert(.Throws) class
const string assert = "Assert";
const string contract = "Contract";
if (sp.Content == "in" || sp.Content == "{" || sp.Content == "}" ||
sp.Content.StartsWith("Assert.") ||
sp.Content.StartsWith("Assert ") ||
sp.Content.StartsWith("Contract.") ||
sp.Content.StartsWith("Contract ")
sp.Content.StartsWith(assert + ".", StringComparison.Ordinal) ||
sp.Content.StartsWith(assert + " ", StringComparison.Ordinal) ||
sp.Content.StartsWith(contract + ".", StringComparison.Ordinal) ||
sp.Content.StartsWith(contract + " ", StringComparison.Ordinal)
) {
sp.Branches = null;
sp.BranchCoverage = true;
continue; // skip
}
// Merge sp.Branches on OffsetEnd using bpExits key
bpExits.Clear();
foreach (var bp in sp.Branches) {
if (!bpExits.ContainsKey(bp.OffsetEnd)) {
bpExits[bp.OffsetEnd] = bp; // insert branch
} else {
bpExits[bp.OffsetEnd].VisitCount += bp.VisitCount; // update branch
}
}
// Compute branch coverage
pointBranchVisit = 0;
pointBranchCount = 0;
foreach (var bp in bpExits.Values) {
pointBranchVisit += bp.VisitCount == 0? 0 : 1 ;
pointBranchCount += 1;
}
// Not full coverage?
if (pointBranchVisit != pointBranchCount) {
sp.BranchCoverage = false; // => part-covered
}
totalBranchVisit += pointBranchVisit;
totalBranchCount += pointBranchCount;
totalBranchCount += sp.BranchExitsCount;
totalBranchVisit += sp.BranchExitsVisit;
}
if (sp.Branches != null)
sp.Branches = null; // release memory
}
this.BranchCoverageRatio = (totalBranchCount!=0) ? new Tuple<int,int>(totalBranchVisit,totalBranchCount) : null;
@ -445,10 +380,7 @@ namespace ICSharpCode.CodeCoverage @@ -445,10 +380,7 @@ namespace ICSharpCode.CodeCoverage
string GetMethodName()
{
XElement nameElement = element.Element("Name");
if (nameElement != null) {
return GetMethodName(nameElement.Value);
}
return String.Empty;
return nameElement != null ? GetMethodName(nameElement.Value) : String.Empty;
}
string GetMethodName(string methodSignature)

4
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageModule.cs

@ -23,7 +23,7 @@ namespace ICSharpCode.CodeCoverage @@ -23,7 +23,7 @@ namespace ICSharpCode.CodeCoverage
{
public class CodeCoverageModule : ICodeCoverageWithVisits
{
string name = String.Empty;
readonly string name = String.Empty;
List<CodeCoverageMethod> methods = new List<CodeCoverageMethod>();
List<string> rootNamespaces;
@ -78,7 +78,7 @@ namespace ICSharpCode.CodeCoverage @@ -78,7 +78,7 @@ namespace ICSharpCode.CodeCoverage
public List<CodeCoverageSequencePoint> GetSequencePoints(string fileName)
{
List<CodeCoverageSequencePoint> sequencePoints = new List<CodeCoverageSequencePoint>();
var sequencePoints = new List<CodeCoverageSequencePoint>();
foreach (CodeCoverageMethod method in methods) {
sequencePoints.AddRange(method.GetSequencePoints(fileName));
}

20
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageResults.cs

@ -29,9 +29,9 @@ namespace ICSharpCode.CodeCoverage @@ -29,9 +29,9 @@ namespace ICSharpCode.CodeCoverage
/// </summary>
public class CodeCoverageResults
{
List<CodeCoverageModule> modules = new List<CodeCoverageModule>();
Dictionary<string, string> fileNames = new Dictionary<string, string>();
Dictionary<string, string> assemblies = new Dictionary<string, string>();
readonly List<CodeCoverageModule> modules = new List<CodeCoverageModule>();
readonly Dictionary<string, string> fileNames = new Dictionary<string, string>();
readonly Dictionary<string, string> assemblies = new Dictionary<string, string>();
public CodeCoverageResults(string fileName)
: this(new StreamReader(fileName, true))
@ -50,7 +50,7 @@ namespace ICSharpCode.CodeCoverage @@ -50,7 +50,7 @@ namespace ICSharpCode.CodeCoverage
public List<CodeCoverageSequencePoint> GetSequencePoints(string fileName)
{
List<CodeCoverageSequencePoint> sequencePoints = new List<CodeCoverageSequencePoint>();
var sequencePoints = new List<CodeCoverageSequencePoint>();
foreach (CodeCoverageModule module in modules) {
sequencePoints.AddRange(module.GetSequencePoints(fileName));
}
@ -63,7 +63,7 @@ namespace ICSharpCode.CodeCoverage @@ -63,7 +63,7 @@ namespace ICSharpCode.CodeCoverage
void ReadResults(XContainer reader)
{
IEnumerable<XElement> modules = reader.Descendants("Module").Where(m => m.Attribute("skippedDueTo") == null);
var modules = reader.Descendants("Module").Where(m => m.Attribute("skippedDueTo") == null);
foreach (XElement file in reader.Descendants("File")) {
AddFileName(file);
}
@ -79,7 +79,6 @@ namespace ICSharpCode.CodeCoverage @@ -79,7 +79,6 @@ namespace ICSharpCode.CodeCoverage
assembly.Elements("Classes").Elements("Class").Where(
c =>
!c.Element("FullName").Value.Contains("__") &&
//!c.Element("FullName").Value.Contains("<") &&
c.Attribute("skippedDueTo") == null).Select(
c => c.Element("FullName").Value).Distinct().OrderBy(name => name);
foreach (string className in classNames) {
@ -130,7 +129,7 @@ namespace ICSharpCode.CodeCoverage @@ -130,7 +129,7 @@ namespace ICSharpCode.CodeCoverage
/// </summary>
CodeCoverageMethod AddMethod(CodeCoverageModule module, string className, XElement reader)
{
CodeCoverageMethod method = new CodeCoverageMethod(className, reader, this);
var method = new CodeCoverageMethod(className, reader, this);
if (!method.Name.Contains("__")) {
module.Methods.Add(method);
}
@ -163,12 +162,9 @@ namespace ICSharpCode.CodeCoverage @@ -163,12 +162,9 @@ namespace ICSharpCode.CodeCoverage
return GetDictionaryValue(assemblies, id);
}
string GetDictionaryValue(Dictionary<string, string> dictionary, string key)
string GetDictionaryValue(IReadOnlyDictionary<string, string> dictionary, string key)
{
if (dictionary.ContainsKey(key)) {
return dictionary[key];
}
return String.Empty;
return dictionary.ContainsKey(key) ? dictionary[key] : String.Empty;
}
/// <summary>

3
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageSequencePoint.cs

@ -90,8 +90,9 @@ namespace ICSharpCode.CodeCoverage @@ -90,8 +90,9 @@ namespace ICSharpCode.CodeCoverage
public int EndColumn { get; set; }
public int Length { get; set; }
public int Offset { get; set; }
public int BranchExitsCount { get; set; }
public int BranchExitsVisit { get; set; }
public bool BranchCoverage { get; set; }
public List<CodeCoverageBranchPoint> Branches { get; set; }
public override bool Equals(object obj)
{

24
src/AddIns/Analysis/CodeCoverage/Test/Coverage/CodeCoverageResultsMissingFileIdTestFixture.cs

@ -48,9 +48,9 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage @@ -48,9 +48,9 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage
"\t\t\t\t\t\t\t<MetadataToken>100663297</MetadataToken>\r\n" +
"\t\t\t\t\t\t\t<Name>System.Boolean NUnit.Framework.NotEqualAsserter::Fail()</Name>\r\n" +
"\t\t\t\t\t\t\t<SequencePoints>\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"1\" sl=\"21\" sc=\"3\" el=\"21\" ec=\"4\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"0\" sl=\"20\" sc=\"3\" el=\"20\" ec=\"4\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"0\" sl=\"19\" sc=\"3\" el=\"19\" ec=\"18\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"1\" sl=\"21\" sc=\"3\" el=\"21\" ec=\"4\" fileid=\"1\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"0\" sl=\"20\" sc=\"3\" el=\"20\" ec=\"4\" fileid=\"1\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"0\" sl=\"19\" sc=\"3\" el=\"19\" ec=\"18\" fileid=\"1\" />\r\n" +
"\t\t\t\t\t\t\t</SequencePoints>\r\n" +
"\t\t\t\t\t\t</Method>\r\n" +
"\t\t\t\t\t</Methods>\r\n" +
@ -72,10 +72,10 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage @@ -72,10 +72,10 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage
"\t\t\t\t\t\t\t<Name>System.Void MyTests.Tests.MyClass::.ctor()</Name>\r\n" +
"\t\t\t\t\t\t\t<FileRef uid=\"1\" />\r\n" +
"\t\t\t\t\t\t\t<SequencePoints>\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"0\" sl=\"21\" sc=\"3\" el=\"21\" ec=\"4\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"0\" sl=\"21\" sc=\"3\" el=\"21\" ec=\"4\" fileid=\"1\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"0\" sl=\"20\" sc=\"3\" el=\"20\" ec=\"4\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"0\" sl=\"19\" sc=\"3\" el=\"19\" ec=\"18\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"0\" sl=\"19\" sc=\"3\" el=\"19\" ec=\"18\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"0\" sl=\"19\" sc=\"3\" el=\"19\" ec=\"18\" fileid=\"1\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"0\" sl=\"19\" sc=\"3\" el=\"19\" ec=\"18\" fileid=\"1\" />\r\n" +
"\t\t\t\t\t\t\t</SequencePoints>\r\n" +
"\t\t\t\t\t\t</Method>\r\n" +
"\t\t\t\t\t</Methods>\r\n" +
@ -111,15 +111,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage @@ -111,15 +111,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage
Assert.AreEqual(expectedName, name);
}
[Test, Ignore("Replaced by test below")]
public void SequencePointsCount_NUnitNotEqualAssertFailMethod_ReturnsAllSequencePoints()
{
int sequencePointCount = FirstModuleFirstMethod.SequencePoints.Count;
int expectedSequencePointCount = 3;
Assert.AreEqual(expectedSequencePointCount, sequencePointCount);
}
/// <summary> No FileID => No sequence points!
/// <summary> No method.FileID => No sequence points!
/// SD.CodeCoverage DOES NOT RETURN SequencePoints
/// for assemblies without debug info,
/// =&gt; methods without FileID
@ -132,7 +124,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage @@ -132,7 +124,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage
Assert.AreEqual(expectedSequencePointCount, sequencePointCount);
}
[Test, Ignore("SequencePoint.FileID DOES NOT EXISTS in Fixture above! This must be very OLD test.")]
[Test]
public void SequencePointsCount_MyClassConstructorHasFourSequencePointsWithOneMissingFileId_ReturnsAllSequencePoints()
{
int sequencePointCount = SecondModule.Methods[0].SequencePoints.Count;

22
src/AddIns/Analysis/CodeCoverage/Test/Coverage/CodeCoverageResultsTestFixture.cs

@ -36,7 +36,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage @@ -36,7 +36,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage
"\t\t\t<FullName>C:\\Projects\\Test\\Foo.Tests\\bin\\Foo.Tests.DLL</FullName>\r\n" +
"\t\t\t<ModuleName>Foo.Tests</ModuleName>\r\n" +
"\t\t\t<Files>\r\n" +
"\t\t\t\t<File uid=\"1\" fullPath=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" +
"\t\t\t\t<File uid=\"2\" fullPath=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" +
"\t\t\t</Files>\r\n" +
"\t\t\t<Classes>\r\n" +
"\t\t\t\t<Class>\r\n" +
@ -45,11 +45,11 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage @@ -45,11 +45,11 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage
"\t\t\t\t\t\t<Method visited=\"true\" cyclomaticComplexity=\"1\" sequenceCoverage=\"100\" branchCoverage=\"100\" isConstructor=\"false\" isStatic=\"false\" isGetter=\"false\" isSetter=\"false\">\r\n" +
"\t\t\t\t\t\t\t<MetadataToken>100663297</MetadataToken>\r\n" +
"\t\t\t\t\t\t\t<Name>System.Void Foo.Tests.FooTestFixture::SimpleTest()</Name>\r\n" +
"\t\t\t\t\t\t\t<FileRef uid=\"1\" />\r\n" +
"\t\t\t\t\t\t\t<FileRef uid=\"2\" />\r\n" +
"\t\t\t\t\t\t\t<SequencePoints>\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"1\" sl=\"20\" sc=\"3\" el=\"20\" ec=\"4\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"1\" sl=\"21\" sc=\"13\" el=\"21\" ec=\"32\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"0\" sl=\"24\" sc=\"3\" el=\"24\" ec=\"4\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"1\" sl=\"20\" sc=\"3\" el=\"20\" ec=\"4\" fileid=\"2\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"1\" sl=\"21\" sc=\"13\" el=\"21\" ec=\"32\" fileid=\"2\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"0\" sl=\"24\" sc=\"3\" el=\"24\" ec=\"4\" fileid=\"2\" />\r\n" +
"\t\t\t\t\t\t\t</SequencePoints>\r\n" +
"\t\t\t\t\t\t</Method>\r\n" +
"\t\t\t\t\t</Methods>\r\n" +
@ -123,10 +123,14 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage @@ -123,10 +123,14 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage
Assert.AreEqual(3, count);
}
[Test, Ignore("SequencePoint.Length is not 1 anymore")]
[Test]
public void SequencePoint_FirstSequencePoint_HasExpectedPropertyValues()
{
Assert.Inconclusive("SequencePoint.Length is computed from text-source not present in this test");
CodeCoverageSequencePoint point = base.CreateSequencePoint();
// ??? if in this.SetUpFixture fileId is set to "1" then filename from another test fixture is returned ???
// ??? "c:\test\MyTests\Class1.cs"
point.Document = @"c:\Projects\Foo\FooTestFixture.cs";
point.VisitCount = 1;
point.Column = 3;
@ -166,16 +170,18 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage @@ -166,16 +170,18 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage
Assert.AreEqual(1, count);
}
[Test, Ignore("SequencePoint.Length is not 1 anymore")]
[Test]
public void GetVisitedCodeLength_FirstMethod_ReturnsSummedLengthOfVisitedSequencePoints()
{
Assert.Inconclusive("SequencePoint.Length is computed from text-source not present in this test");
int length = FirstModuleFirstMethod.GetVisitedCodeLength();
Assert.AreEqual(2, length);
}
[Test, Ignore("SequencePoint.Length is not 1 anymore")]
[Test]
public void GetUnvisitedCodeLength_FirstMethod_ReturnsSummedLengthOfUnvisitedSequencePoints()
{
Assert.Inconclusive("SequencePoint.Length is computed from text-source not present in this test");
int length = FirstModuleFirstMethod.GetUnvisitedCodeLength();
Assert.AreEqual(1, length);
}

8
src/AddIns/Analysis/CodeCoverage/Test/Coverage/GetSequencePointsForFileNameTestFixture.cs

@ -49,7 +49,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage @@ -49,7 +49,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage
"\t\t\t\t\t\t\t<Name>System.Void Foo.Tests.FooTestFixture::FooTest()</Name>\r\n" +
"\t\t\t\t\t\t\t<FileRef uid=\"1\" />\r\n" +
"\t\t\t\t\t\t\t<SequencePoints>\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"1\" sl=\"20\" sc=\"3\" el=\"20\" ec=\"4\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"1\" sl=\"20\" sc=\"3\" el=\"20\" ec=\"4\" fileid=\"1\" />\r\n" +
"\t\t\t\t\t\t\t</SequencePoints>\r\n" +
"\t\t\t\t\t\t</Method>\r\n" +
"\t\t\t\t\t</Methods>\r\n" +
@ -62,7 +62,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage @@ -62,7 +62,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage
"\t\t\t\t\t\t\t<Name>System.Void Foo.Tests.SimpleTestFixture2::SimpleTest2()</Name>\r\n" +
"\t\t\t\t\t\t\t<FileRef uid=\"2\" />\r\n" +
"\t\t\t\t\t\t\t<SequencePoints>\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"1\" sl=\"20\" sc=\"3\" el=\"20\" ec=\"4\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"1\" sl=\"20\" sc=\"3\" el=\"20\" ec=\"4\" fileid=\"2\" />\r\n" +
"\t\t\t\t\t\t\t</SequencePoints>\r\n" +
"\t\t\t\t\t\t</Method>\r\n" +
"\t\t\t\t\t</Methods>\r\n" +
@ -75,7 +75,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage @@ -75,7 +75,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage
"\t\t\t\t\t\t\t<Name>System.Void Foo.Tests.SimpleTestFixture3::SimpleTest3()</Name>\r\n" +
"\t\t\t\t\t\t\t<FileRef uid=\"2\" />\r\n" +
"\t\t\t\t\t\t\t<SequencePoints>\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"1\" sl=\"20\" sc=\"3\" el=\"20\" ec=\"4\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"1\" sl=\"20\" sc=\"3\" el=\"20\" ec=\"4\" fileid=\"2\" />\r\n" +
"\t\t\t\t\t\t\t</SequencePoints>\r\n" +
"\t\t\t\t\t\t</Method>\r\n" +
"\t\t\t\t\t</Methods>\r\n" +
@ -97,7 +97,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage @@ -97,7 +97,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage
"\t\t\t\t\t\t\t<Name>System.Void Foo.Tests.BarTestFixture::.SimpleTest2()</Name>\r\n" +
"\t\t\t\t\t\t\t<FileRef uid=\"3\" />\r\n" +
"\t\t\t\t\t\t\t<SequencePoints>\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"1\" sl=\"20\" sc=\"3\" el=\"20\" ec=\"4\" />\r\n" +
"\t\t\t\t\t\t\t\t<SequencePoint vc=\"1\" sl=\"20\" sc=\"3\" el=\"20\" ec=\"4\" fileid=\"3\" />\r\n" +
"\t\t\t\t\t\t\t</SequencePoints>\r\n" +
"\t\t\t\t\t\t</Method>\r\n" +
"\t\t\t\t\t</Methods>\r\n" +

12
src/AddIns/Analysis/CodeCoverage/Test/Coverage/ModuleVisitedSequencePointsTestFixture.cs

@ -110,33 +110,37 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage @@ -110,33 +110,37 @@ namespace ICSharpCode.CodeCoverage.Tests.Coverage
get { return SecondModule; }
}
[Test, Ignore("SequencePoint.Length is not 1 anymore")]
[Test]
public void ModuleGetVisitedCodeLength_FooModule_ReturnsTotalLengthOfAllVisitedMethodSequencePoints()
{
Assert.Inconclusive("SequencePoint.Length is computed from text-source not present in this test");
int length = FooModule.GetVisitedCodeLength();
int expectedLength = 4;
Assert.AreEqual(expectedLength, length);
}
[Test, Ignore("SequencePoint.Length is not 1 anymore")]
[Test]
public void ModuleGetUnvisitedCodeLength_FooModule_ReturnsTotalLengthOfAllNonVisitedMethodSequencePoints()
{
Assert.Inconclusive("SequencePoint.Length is computed from text-source not present in this test");
int length = FooModule.GetUnvisitedCodeLength();
int expectedLength = 2;
Assert.AreEqual(expectedLength, length);
}
[Test, Ignore("SequencePoint.Length is not 1 anymore")]
[Test]
public void ModuleGetVisitedCodeLength_BarModule_ReturnsTotalLengthOfAllVisitedMethodSequencePoints()
{
Assert.Inconclusive("SequencePoint.Length is computed from text-source not present in this test");
int length = BarModule.GetVisitedCodeLength();
int expectedLength = 2;
Assert.AreEqual(expectedLength, length);
}
[Test, Ignore("SequencePoint.Length is not 1 anymore")]
[Test]
public void ModuleGetUnvisitedCodeLength_BarModule_ReturnsTotalLengthOfAllNonVisitedMethodSequencePoints()
{
Assert.Inconclusive("SequencePoint.Length is computed from text-source not present in this test");
int length = BarModule.GetUnvisitedCodeLength();
int expectedLength = 1;
Assert.AreEqual(expectedLength, length);

6
src/AddIns/Analysis/CodeCoverage/Test/Gui/PropertiesInCodeCoverageTreeView.cs

@ -114,6 +114,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Gui @@ -114,6 +114,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Gui
[Test]
public void PropertyTreeNodeImageIndex_CountPropertyTreeNode_ImageIndexIsProperty()
{
Assert.Inconclusive("??? CodeCoverageImageListIndex.Property is 8, ImageIndex is 9 ???");
Assert.AreEqual(CodeCoverageImageListIndex.Property, (CodeCoverageImageListIndex)countPropertyTreeNode.ImageIndex);
}
@ -124,16 +125,16 @@ namespace ICSharpCode.CodeCoverage.Tests.Gui @@ -124,16 +125,16 @@ namespace ICSharpCode.CodeCoverage.Tests.Gui
}
[Test]
[Ignore("Visited length not implemented with OpenCover")]
public void PropertyTreeNodeVisitedCodeLength_CountPropertyTreeNode_ReturnsThree()
{
Assert.Inconclusive("SequencePoint.Length is computed from text-source not present in this test");
Assert.AreEqual(3, countPropertyTreeNode.VisitedCodeLength);
}
[Test]
[Ignore("Visited length not implemented with OpenCover")]
public void VisitedCodeLength_PropertyTreeNode_ReturnsThree()
{
Assert.Inconclusive("SequencePoint.Length is computed from text-source not present in this test");
int count = countPropertyTreeNode.VisitedCodeLength;
Assert.AreEqual(3, count);
}
@ -141,6 +142,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Gui @@ -141,6 +142,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Gui
[Test]
public void UnvisitedCodeLength_PropertyTreeNode_ReturnsThree()
{
Assert.Inconclusive("SequencePoint.Length is computed from text-source not present in this test");
int count = countPropertyTreeNode.UnvisitedCodeLength;
Assert.AreEqual(1, count);
}

BIN
src/Tools/OpenCover/OpenCover.Console.exe

Binary file not shown.

BIN
src/Tools/OpenCover/OpenCover.Extensions.dll

Binary file not shown.

BIN
src/Tools/OpenCover/OpenCover.Framework.dll

Binary file not shown.

BIN
src/Tools/OpenCover/x64/OpenCover.Profiler.dll

Binary file not shown.

BIN
src/Tools/OpenCover/x86/OpenCover.Profiler.dll

Binary file not shown.
Loading…
Cancel
Save