@@ -175,25 +175,20 @@ private void InstrumentIL(MethodDefinition method)
175175
176176 private Instruction AddInstrumentationCode ( MethodDefinition method , ILProcessor processor , Instruction instruction , SequencePoint sequencePoint )
177177 {
178- int documentIndex = 0 ;
179178 if ( ! _result . Documents . TryGetValue ( sequencePoint . Document . Url , out var document ) )
180179 {
181180 document = new Document { Path = sequencePoint . Document . Url } ;
182- documentIndex = _result . Documents . Count ;
181+ document . Index = _result . Documents . Count ;
183182 _result . Documents . Add ( document . Path , document ) ;
184183 }
185- else
186- {
187- documentIndex = _result . Documents . Keys . ToList ( ) . IndexOf ( document . Path ) ;
188- }
189184
190185 for ( int i = sequencePoint . StartLine ; i <= sequencePoint . EndLine ; i ++ )
191186 {
192187 if ( ! document . Lines . ContainsKey ( i ) )
193188 document . Lines . Add ( i , new Line { Number = i , Class = method . DeclaringType . FullName , Method = method . FullName } ) ;
194189 }
195190
196- string marker = $ "L,{ documentIndex } ,{ sequencePoint . StartLine } ,{ sequencePoint . EndLine } ";
191+ string marker = $ "L,{ document . Index } ,{ sequencePoint . StartLine } ,{ sequencePoint . EndLine } ";
197192
198193 var pathInstr = Instruction . Create ( OpCodes . Ldstr , _result . HitsFilePath ) ;
199194 var markInstr = Instruction . Create ( OpCodes . Ldstr , marker ) ;
@@ -208,17 +203,12 @@ private Instruction AddInstrumentationCode(MethodDefinition method, ILProcessor
208203
209204 private Instruction AddInstrumentationCode ( MethodDefinition method , ILProcessor processor , Instruction instruction , BranchPoint branchPoint )
210205 {
211- int documentIndex = 0 ;
212206 if ( ! _result . Documents . TryGetValue ( branchPoint . Document , out var document ) )
213207 {
214208 document = new Document { Path = branchPoint . Document } ;
215- documentIndex = _result . Documents . Count ;
209+ document . Index = _result . Documents . Count ;
216210 _result . Documents . Add ( document . Path , document ) ;
217211 }
218- else
219- {
220- documentIndex = _result . Documents . Keys . ToList ( ) . IndexOf ( document . Path ) ;
221- }
222212
223213 var key = ( branchPoint . StartLine , ( int ) branchPoint . Ordinal ) ;
224214 if ( ! document . Branches . ContainsKey ( key ) )
@@ -235,7 +225,7 @@ private Instruction AddInstrumentationCode(MethodDefinition method, ILProcessor
235225 }
236226 ) ;
237227
238- string marker = $ "B,{ documentIndex } ,{ branchPoint . StartLine } ,{ branchPoint . Ordinal } ";
228+ string marker = $ "B,{ document . Index } ,{ branchPoint . StartLine } ,{ branchPoint . Ordinal } ";
239229
240230 var pathInstr = Instruction . Create ( OpCodes . Ldstr , _result . HitsFilePath ) ;
241231 var markInstr = Instruction . Create ( OpCodes . Ldstr , marker ) ;
0 commit comments