@@ -13,38 +13,26 @@ namespace SG.CodeCoverage.Coverage
1313{
1414 public class CoverageResult
1515 {
16+ public VersionInfo Version { get ; private set ; }
17+ public Guid UniqueId { get ; private set ; }
18+ public IReadOnlyCollection < CoverageAssemblyResult > Assemblies { get ; private set ; }
1619
1720 public CoverageResult ( string mapPath , string hitsPath )
1821 {
1922 var map = LoadMapFile ( mapPath ) ;
2023 var ( uniqueId , hits ) = LoadHits ( hitsPath ) ;
21- if ( map . UniqueId != uniqueId )
22- throw new Exception ( $ "Hits file's unique id ({ uniqueId } ) does not match the unique id in the map file ({ map . UniqueId } ).") ;
23-
24- Version = map . Version ;
25- UniqueId = uniqueId ;
26- Assemblies = map . Assemblies . Select ( asm => ToAssemblyCoverage ( asm , hits ) ) . ToList ( ) . AsReadOnly ( ) ;
24+ Init ( map , uniqueId , hits ) ;
2725 }
2826
2927 public CoverageResult ( InstrumentationMap map , string hitsPath )
3028 {
3129 var ( uniqueId , hits ) = LoadHits ( hitsPath ) ;
32- if ( map . UniqueId != uniqueId )
33- throw new Exception ( $ "Hits file's unique id ({ uniqueId } ) does not match the unique id in the map file ({ map . UniqueId } ).") ;
34-
35- Version = map . Version ;
36- UniqueId = uniqueId ;
37- Assemblies = map . Assemblies . Select ( asm => ToAssemblyCoverage ( asm , hits ) ) . ToList ( ) . AsReadOnly ( ) ;
30+ Init ( map , uniqueId , hits ) ;
3831 }
3932
4033 public CoverageResult ( InstrumentationMap map , int [ ] [ ] hits , Guid hitsUniqueId )
4134 {
42- if ( map . UniqueId != hitsUniqueId )
43- throw new Exception ( $ "Hits file's unique id ({ hitsUniqueId } ) does not match the unique id in the map file ({ map . UniqueId } ).") ;
44-
45- Version = map . Version ;
46- UniqueId = hitsUniqueId ;
47- Assemblies = map . Assemblies . Select ( asm => ToAssemblyCoverage ( asm , hits ) ) . ToList ( ) . AsReadOnly ( ) ;
35+ Init ( map , hitsUniqueId , hits ) ;
4836 }
4937
5038 public CoverageResult ( VersionInfo instrumenterVersion , Guid instrumentUniqueId , IReadOnlyCollection < CoverageAssemblyResult > assemblies )
@@ -54,15 +42,20 @@ public CoverageResult(VersionInfo instrumenterVersion, Guid instrumentUniqueId,
5442 Assemblies = assemblies ;
5543 }
5644
57- public VersionInfo Version { get ; }
58- public Guid UniqueId { get ; }
59- public IReadOnlyCollection < CoverageAssemblyResult > Assemblies { get ; }
45+ private void Init ( InstrumentationMap map , Guid uniqueId , int [ ] [ ] hits )
46+ {
47+ if ( map . UniqueId != uniqueId )
48+ throw new Exception ( $ "Hits file's unique id ({ uniqueId } ) does not match the unique id in the map file ({ map . UniqueId } ).") ;
49+
50+ Version = map . Version ;
51+ UniqueId = uniqueId ;
52+ Assemblies = map . Assemblies . Select ( asm => ToAssemblyCoverage ( asm , hits ) ) . ToList ( ) . AsReadOnly ( ) ;
53+ }
6054
6155 private InstrumentationMap LoadMapFile ( string mapFilePath )
6256 {
6357 ValidateFilePath ( mapFilePath ) ;
6458 return InstrumentationMap . Parse ( mapFilePath ) ;
65-
6659 }
6760
6861 private ( Guid uniqueId , int [ ] [ ] hits ) LoadHits ( string hitsFile )
0 commit comments