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