@@ -46,6 +46,19 @@ public void TestInstrument()
46
46
instrumenterTest . Directory . Delete ( true ) ;
47
47
}
48
48
49
+ [ Fact ]
50
+ public void TestInstrumentCoreLib ( )
51
+ {
52
+ var instrumenterTest = CreateInstrumentor ( fakeCoreLibModule : true ) ;
53
+
54
+ var result = instrumenterTest . Instrumenter . Instrument ( ) ;
55
+
56
+ Assert . Equal ( Path . GetFileNameWithoutExtension ( instrumenterTest . Module ) , result . Module ) ;
57
+ Assert . Equal ( instrumenterTest . Module , result . ModulePath ) ;
58
+
59
+ instrumenterTest . Directory . Delete ( true ) ;
60
+ }
61
+
49
62
[ Theory ]
50
63
[ InlineData ( typeof ( ClassExcludedByCodeAnalysisCodeCoverageAttr ) ) ]
51
64
[ InlineData ( typeof ( ClassExcludedByCoverletCodeCoverageAttr ) ) ]
@@ -63,18 +76,30 @@ public void TestInstrument_ClassesWithExcludeAttributeAreExcluded(Type excludedT
63
76
instrumenterTest . Directory . Delete ( true ) ;
64
77
}
65
78
66
- private InstrumenterTest CreateInstrumentor ( )
79
+ private InstrumenterTest CreateInstrumentor ( bool fakeCoreLibModule = false )
67
80
{
68
81
string module = GetType ( ) . Assembly . Location ;
69
82
string pdb = Path . Combine ( Path . GetDirectoryName ( module ) , Path . GetFileNameWithoutExtension ( module ) + ".pdb" ) ;
70
83
string identifier = Guid . NewGuid ( ) . ToString ( ) ;
71
84
72
85
DirectoryInfo directory = Directory . CreateDirectory ( Path . Combine ( Path . GetTempPath ( ) , identifier ) ) ;
73
86
74
- File . Copy ( module , Path . Combine ( directory . FullName , Path . GetFileName ( module ) ) , true ) ;
75
- File . Copy ( pdb , Path . Combine ( directory . FullName , Path . GetFileName ( pdb ) ) , true ) ;
87
+ string destModule , destPdb ;
88
+ if ( fakeCoreLibModule )
89
+ {
90
+ destModule = "System.Private.CoreLib.dll" ;
91
+ destPdb = "System.Private.CoreLib.pdb" ;
92
+ }
93
+ else
94
+ {
95
+ destModule = Path . GetFileName ( module ) ;
96
+ destPdb = Path . GetFileName ( pdb ) ;
97
+ }
98
+
99
+ File . Copy ( module , Path . Combine ( directory . FullName , destModule ) , true ) ;
100
+ File . Copy ( pdb , Path . Combine ( directory . FullName , destPdb ) , true ) ;
76
101
77
- module = Path . Combine ( directory . FullName , Path . GetFileName ( module ) ) ;
102
+ module = Path . Combine ( directory . FullName , destModule ) ;
78
103
Instrumenter instrumenter = new Instrumenter ( module , identifier , Array . Empty < string > ( ) , Array . Empty < string > ( ) , Array . Empty < string > ( ) ) ;
79
104
return new InstrumenterTest
80
105
{
0 commit comments