1818
1919using System ;
2020using System . Collections . Generic ;
21- using System . Reflection ;
22- using System . Xml ;
2321using System . Xml . Linq ;
2422using ICSharpCode . Core ;
2523
2624namespace ICSharpCode . CodeCoverage
2725{
2826 public class CodeCoverageMethod
2927 {
30- string name = String . Empty ;
31- string className = String . Empty ;
32- string fullClassName = String . Empty ;
33- string classNamespace = String . Empty ;
34- List < CodeCoverageSequencePoint > sequencePoints = new List < CodeCoverageSequencePoint > ( ) ;
28+ readonly string name = String . Empty ;
29+ readonly string className = String . Empty ;
30+ readonly string fullClassName = String . Empty ;
31+ readonly string classNamespace = String . Empty ;
32+ readonly List < CodeCoverageSequencePoint > sequencePoints = new List < CodeCoverageSequencePoint > ( ) ;
3533
3634 public CodeCoverageMethod ( string name , string className )
3735 {
@@ -63,10 +61,9 @@ public CodeCoverageMethod(string className, CodeCoverageMethodElement element)
6361
6462 this . IsVisited = element . IsVisited ;
6563 this . BranchCoverage = element . BranchCoverage ;
66- this . BranchCoverageRatio = element . BranchCoverageRatio ;
6764 this . SequencePointsCount = element . SequencePointsCount ;
6865 this . sequencePoints = element . SequencePoints ;
69-
66+ this . FileID = element . FileID ;
7067 }
7168
7269 /// <summary>
@@ -78,8 +75,8 @@ public CodeCoverageMethod(string className, CodeCoverageMethodElement element)
7875
7976 public bool IsVisited { get ; private set ; }
8077 public decimal BranchCoverage { get ; private set ; }
81- public Tuple < int , int > BranchCoverageRatio { get ; private set ; }
8278 public int SequencePointsCount { get ; private set ; }
79+ public string FileID { get ; private set ; }
8380
8481 bool IsPropertyMethodName ( )
8582 {
@@ -112,10 +109,7 @@ public string RootNamespace {
112109 public static string GetRootNamespace ( string ns )
113110 {
114111 int index = ns . IndexOf ( '.' ) ;
115- if ( index > 0 ) {
116- return ns . Substring ( 0 , index ) ;
117- }
118- return ns ;
112+ return index > 0 ? ns . Substring ( 0 , index ) : ns ;
119113 }
120114
121115 public List < CodeCoverageSequencePoint > SequencePoints {
@@ -150,7 +144,7 @@ public int GetVisitedCodeLength()
150144 {
151145 int total = 0 ;
152146 foreach ( CodeCoverageSequencePoint sequencePoint in sequencePoints ) {
153- if ( sequencePoint . VisitCount != 0 ) {
147+ if ( sequencePoint . FileID == this . FileID && sequencePoint . VisitCount != 0 ) {
154148 total += sequencePoint . Length ;
155149 }
156150 }
@@ -161,7 +155,7 @@ public int GetUnvisitedCodeLength()
161155 {
162156 int total = 0 ;
163157 foreach ( CodeCoverageSequencePoint sequencePoint in sequencePoints ) {
164- if ( sequencePoint . VisitCount == 0 ) {
158+ if ( sequencePoint . FileID == this . FileID && sequencePoint . VisitCount == 0 ) {
165159 total += sequencePoint . Length ;
166160 }
167161 }
@@ -170,7 +164,7 @@ public int GetUnvisitedCodeLength()
170164
171165 public List < CodeCoverageSequencePoint > GetSequencePoints ( string fileName )
172166 {
173- List < CodeCoverageSequencePoint > matchedSequencePoints = new List < CodeCoverageSequencePoint > ( ) ;
167+ var matchedSequencePoints = new List < CodeCoverageSequencePoint > ( ) ;
174168 foreach ( CodeCoverageSequencePoint sequencePoint in sequencePoints ) {
175169 if ( FileUtility . IsEqualFileName ( fileName , sequencePoint . Document ) ) {
176170 matchedSequencePoints . Add ( sequencePoint ) ;
@@ -193,10 +187,7 @@ public static string GetChildNamespace(string fullNamespace, string parentNamesp
193187 /// </summary>
194188 public static string GetFullNamespace ( string prefix , string name )
195189 {
196- if ( prefix . Length > 0 ) {
197- return String . Concat ( prefix , "." , name ) ;
198- }
199- return name ;
190+ return prefix . Length > 0 ? String . Concat ( prefix , "." , name ) : name ;
200191 }
201192
202193 /// <summary>
@@ -208,7 +199,7 @@ public static string GetFullNamespace(string prefix, string name)
208199 /// method will return 'XmlEditor' as one of its strings.
209200 /// </remarks>
210201 public static List < string > GetChildNamespaces ( List < CodeCoverageMethod > methods , string parentNamespace ) {
211- List < string > items = new List < string > ( ) ;
202+ var items = new List < string > ( ) ;
212203 foreach ( CodeCoverageMethod method in methods ) {
213204 string classNamespace = method . ClassNamespace ;
214205 string dottedParentNamespace = parentNamespace + "." ;
@@ -227,10 +218,10 @@ public static List<string> GetChildNamespaces(List<CodeCoverageMethod> methods,
227218 /// </summary>
228219 public static List < CodeCoverageMethod > GetAllMethods ( List < CodeCoverageMethod > methods , string namespaceStartsWith )
229220 {
230- List < CodeCoverageMethod > matchedMethods = new List < CodeCoverageMethod > ( ) ;
221+ var matchedMethods = new List < CodeCoverageMethod > ( ) ;
231222 namespaceStartsWith += "." ;
232223 foreach ( CodeCoverageMethod method in methods ) {
233- if ( ( method . ClassNamespace + "." ) . StartsWith ( namespaceStartsWith ) ) {
224+ if ( ( method . ClassNamespace + "." ) . StartsWith ( namespaceStartsWith , StringComparison . Ordinal ) ) {
234225 matchedMethods . Add ( method ) ;
235226 }
236227 }
@@ -242,7 +233,7 @@ public static List<CodeCoverageMethod> GetAllMethods(List<CodeCoverageMethod> me
242233 /// </summary>
243234 public static List < CodeCoverageMethod > GetMethods ( List < CodeCoverageMethod > methods , string ns , string className )
244235 {
245- List < CodeCoverageMethod > matchedMethods = new List < CodeCoverageMethod > ( ) ;
236+ var matchedMethods = new List < CodeCoverageMethod > ( ) ;
246237 foreach ( CodeCoverageMethod method in methods ) {
247238 if ( method . ClassName == className && method . ClassNamespace == ns ) {
248239 matchedMethods . Add ( method ) ;
@@ -253,7 +244,7 @@ public static List<CodeCoverageMethod> GetMethods(List<CodeCoverageMethod> metho
253244
254245 public static List < string > GetClassNames ( List < CodeCoverageMethod > methods , string ns )
255246 {
256- List < string > names = new List < string > ( ) ;
247+ var names = new List < string > ( ) ;
257248 foreach ( CodeCoverageMethod method in methods ) {
258249 if ( method . ClassNamespace == ns && ! names . Contains ( method . ClassName ) ) {
259250 names . Add ( method . ClassName ) ;
0 commit comments