@@ -36,16 +36,16 @@ public static Report Parse(string coverage) {
36
36
if ( string . IsNullOrWhiteSpace ( line ) ) continue ;
37
37
38
38
var parts = line . Trim ( ) . Split ( ':' ) ;
39
- if ( parts . Length < 2 && parts [ 0 ] != Token . EndOfRecord ) throw new FormatException ( $ "Invalid token format at line { offset } .") ;
39
+ if ( parts . Length < 2 && parts [ 0 ] != Tokens . EndOfRecord ) throw new FormatException ( $ "Invalid token format at line { offset } .") ;
40
40
41
41
var data = string . Join ( ':' , parts [ 1 ..] ) . Split ( ',' ) ;
42
42
var token = parts [ 0 ] ;
43
43
switch ( token ) {
44
- case Token . TestName : if ( string . IsNullOrWhiteSpace ( report . TestName ) ) report . TestName = data [ 0 ] ; break ;
45
- case Token . SourceFile : sourceFile = new ( data [ 0 ] ) { Branches = new ( ) , Functions = new ( ) , Lines = new ( ) } ; break ;
46
- case Token . EndOfRecord : report . SourceFiles . Add ( sourceFile ) ; break ;
44
+ case Tokens . TestName : if ( string . IsNullOrWhiteSpace ( report . TestName ) ) report . TestName = data [ 0 ] ; break ;
45
+ case Tokens . SourceFile : sourceFile = new ( data [ 0 ] ) { Branches = new ( ) , Functions = new ( ) , Lines = new ( ) } ; break ;
46
+ case Tokens . EndOfRecord : report . SourceFiles . Add ( sourceFile ) ; break ;
47
47
48
- case Token . BranchData :
48
+ case Tokens . BranchData :
49
49
if ( data . Length < 4 ) throw new FormatException ( $ "Invalid branch data at line #{ offset } .") ;
50
50
sourceFile . Branches ? . Data . Add ( new ( ) {
51
51
BlockNumber = int . Parse ( data [ 1 ] ) ,
@@ -55,7 +55,7 @@ public static Report Parse(string coverage) {
55
55
} ) ;
56
56
break ;
57
57
58
- case Token . FunctionData :
58
+ case Tokens . FunctionData :
59
59
if ( data . Length < 2 ) throw new FormatException ( $ "Invalid function data at line #{ offset } .") ;
60
60
if ( sourceFile . Functions is not null ) {
61
61
var items = sourceFile . Functions . Data ;
@@ -66,12 +66,12 @@ public static Report Parse(string coverage) {
66
66
}
67
67
break ;
68
68
69
- case Token . FunctionName :
69
+ case Tokens . FunctionName :
70
70
if ( data . Length < 2 ) throw new FormatException ( $ "Invalid function name at line #{ offset } .") ;
71
71
sourceFile . Functions ? . Data . Add ( new ( ) { FunctionName = data [ 1 ] , LineNumber = int . Parse ( data [ 0 ] ) } ) ;
72
72
break ;
73
73
74
- case Token . LineData :
74
+ case Tokens . LineData :
75
75
if ( data . Length < 2 ) throw new FormatException ( $ "Invalid line data at line #{ offset } .") ;
76
76
sourceFile . Lines ? . Data . Add ( new ( ) {
77
77
Checksum = data . Length >= 3 ? data [ 2 ] : string . Empty ,
@@ -80,12 +80,12 @@ public static Report Parse(string coverage) {
80
80
} ) ;
81
81
break ;
82
82
83
- case Token . BranchesFound when sourceFile . Branches is not null : sourceFile . Branches . Found = int . Parse ( data [ 0 ] ) ; break ;
84
- case Token . BranchesHit when sourceFile . Branches is not null : sourceFile . Branches . Hit = int . Parse ( data [ 0 ] ) ; break ;
85
- case Token . FunctionsFound when sourceFile . Functions is not null : sourceFile . Functions . Found = int . Parse ( data [ 0 ] ) ; break ;
86
- case Token . FunctionsHit when sourceFile . Functions is not null : sourceFile . Functions . Hit = int . Parse ( data [ 0 ] ) ; break ;
87
- case Token . LinesFound when sourceFile . Lines is not null : sourceFile . Lines . Found = int . Parse ( data [ 0 ] ) ; break ;
88
- case Token . LinesHit when sourceFile . Lines is not null : sourceFile . Lines . Hit = int . Parse ( data [ 0 ] ) ; break ;
83
+ case Tokens . BranchesFound when sourceFile . Branches is not null : sourceFile . Branches . Found = int . Parse ( data [ 0 ] ) ; break ;
84
+ case Tokens . BranchesHit when sourceFile . Branches is not null : sourceFile . Branches . Hit = int . Parse ( data [ 0 ] ) ; break ;
85
+ case Tokens . FunctionsFound when sourceFile . Functions is not null : sourceFile . Functions . Found = int . Parse ( data [ 0 ] ) ; break ;
86
+ case Tokens . FunctionsHit when sourceFile . Functions is not null : sourceFile . Functions . Hit = int . Parse ( data [ 0 ] ) ; break ;
87
+ case Tokens . LinesFound when sourceFile . Lines is not null : sourceFile . Lines . Found = int . Parse ( data [ 0 ] ) ; break ;
88
+ case Tokens . LinesHit when sourceFile . Lines is not null : sourceFile . Lines . Hit = int . Parse ( data [ 0 ] ) ; break ;
89
89
default : throw new FormatException ( $ "Unknown token at line { offset } .") ;
90
90
}
91
91
}
@@ -115,7 +115,7 @@ public static bool TryParse(string coverage, [NotNullWhen(true)] out Report? rep
115
115
/// </summary>
116
116
/// <returns>The string representation of this object.</returns>
117
117
public override string ToString ( ) => string . Join ( '\n ' , [
118
- .. string . IsNullOrWhiteSpace ( TestName ) ? Array . Empty < string > ( ) : [ $ "{ Token . TestName } :{ TestName } "] ,
118
+ .. string . IsNullOrWhiteSpace ( TestName ) ? Array . Empty < string > ( ) : [ $ "{ Tokens . TestName } :{ TestName } "] ,
119
119
.. SourceFiles . Select ( item => item . ToString ( ) )
120
120
] ) ;
121
121
}
0 commit comments