@@ -175,19 +175,25 @@ private void InstrumentIL(MethodDefinition method)
175
175
176
176
private Instruction AddInstrumentationCode ( MethodDefinition method , ILProcessor processor , Instruction instruction , SequencePoint sequencePoint )
177
177
{
178
+ int documentIndex = 0 ;
178
179
if ( ! _result . Documents . TryGetValue ( sequencePoint . Document . Url , out var document ) )
179
180
{
180
181
document = new Document { Path = sequencePoint . Document . Url } ;
182
+ documentIndex = _result . Documents . Count ;
181
183
_result . Documents . Add ( document . Path , document ) ;
182
184
}
185
+ else
186
+ {
187
+ documentIndex = _result . Documents . Keys . ToList ( ) . IndexOf ( document . Path ) ;
188
+ }
183
189
184
190
for ( int i = sequencePoint . StartLine ; i <= sequencePoint . EndLine ; i ++ )
185
191
{
186
192
if ( ! document . Lines . ContainsKey ( i ) )
187
193
document . Lines . Add ( i , new Line { Number = i , Class = method . DeclaringType . FullName , Method = method . FullName } ) ;
188
194
}
189
195
190
- string marker = $ "L,{ document . Path } ,{ sequencePoint . StartLine } ,{ sequencePoint . EndLine } ";
196
+ string marker = $ "L,{ documentIndex } ,{ sequencePoint . StartLine } ,{ sequencePoint . EndLine } ";
191
197
192
198
var pathInstr = Instruction . Create ( OpCodes . Ldstr , _result . HitsFilePath ) ;
193
199
var markInstr = Instruction . Create ( OpCodes . Ldstr , marker ) ;
@@ -202,11 +208,17 @@ private Instruction AddInstrumentationCode(MethodDefinition method, ILProcessor
202
208
203
209
private Instruction AddInstrumentationCode ( MethodDefinition method , ILProcessor processor , Instruction instruction , BranchPoint branchPoint )
204
210
{
211
+ int documentIndex = 0 ;
205
212
if ( ! _result . Documents . TryGetValue ( branchPoint . Document , out var document ) )
206
213
{
207
214
document = new Document { Path = branchPoint . Document } ;
215
+ documentIndex = _result . Documents . Count ;
208
216
_result . Documents . Add ( document . Path , document ) ;
209
217
}
218
+ else
219
+ {
220
+ documentIndex = _result . Documents . Keys . ToList ( ) . IndexOf ( document . Path ) ;
221
+ }
210
222
211
223
var key = ( branchPoint . StartLine , ( int ) branchPoint . Ordinal ) ;
212
224
if ( ! document . Branches . ContainsKey ( key ) )
@@ -223,7 +235,7 @@ private Instruction AddInstrumentationCode(MethodDefinition method, ILProcessor
223
235
}
224
236
) ;
225
237
226
- string marker = $ "B,{ document . Path } ,{ branchPoint . StartLine } ,{ branchPoint . Ordinal } ";
238
+ string marker = $ "B,{ documentIndex } ,{ branchPoint . StartLine } ,{ branchPoint . Ordinal } ";
227
239
228
240
var pathInstr = Instruction . Create ( OpCodes . Ldstr , _result . HitsFilePath ) ;
229
241
var markInstr = Instruction . Create ( OpCodes . Ldstr , marker ) ;
0 commit comments