@@ -175,19 +175,25 @@ private void InstrumentIL(MethodDefinition method)
175175
176176 private Instruction AddInstrumentationCode ( MethodDefinition method , ILProcessor processor , Instruction instruction , SequencePoint sequencePoint )
177177 {
178+ int documentIndex = 0 ;
178179 if ( ! _result . Documents . TryGetValue ( sequencePoint . Document . Url , out var document ) )
179180 {
180181 document = new Document { Path = sequencePoint . Document . Url } ;
182+ documentIndex = _result . Documents . Count ;
181183 _result . Documents . Add ( document . Path , document ) ;
182184 }
185+ else
186+ {
187+ documentIndex = _result . Documents . Keys . ToList ( ) . IndexOf ( document . Path ) ;
188+ }
183189
184190 for ( int i = sequencePoint . StartLine ; i <= sequencePoint . EndLine ; i ++ )
185191 {
186192 if ( ! document . Lines . ContainsKey ( i ) )
187193 document . Lines . Add ( i , new Line { Number = i , Class = method . DeclaringType . FullName , Method = method . FullName } ) ;
188194 }
189195
190- string marker = $ "L,{ document . Path } ,{ sequencePoint . StartLine } ,{ sequencePoint . EndLine } ";
196+ string marker = $ "L,{ documentIndex } ,{ sequencePoint . StartLine } ,{ sequencePoint . EndLine } ";
191197
192198 var pathInstr = Instruction . Create ( OpCodes . Ldstr , _result . HitsFilePath ) ;
193199 var markInstr = Instruction . Create ( OpCodes . Ldstr , marker ) ;
@@ -202,11 +208,17 @@ private Instruction AddInstrumentationCode(MethodDefinition method, ILProcessor
202208
203209 private Instruction AddInstrumentationCode ( MethodDefinition method , ILProcessor processor , Instruction instruction , BranchPoint branchPoint )
204210 {
211+ int documentIndex = 0 ;
205212 if ( ! _result . Documents . TryGetValue ( branchPoint . Document , out var document ) )
206213 {
207214 document = new Document { Path = branchPoint . Document } ;
215+ documentIndex = _result . Documents . Count ;
208216 _result . Documents . Add ( document . Path , document ) ;
209217 }
218+ else
219+ {
220+ documentIndex = _result . Documents . Keys . ToList ( ) . IndexOf ( document . Path ) ;
221+ }
210222
211223 var key = ( branchPoint . StartLine , ( int ) branchPoint . Ordinal ) ;
212224 if ( ! document . Branches . ContainsKey ( key ) )
@@ -223,7 +235,7 @@ private Instruction AddInstrumentationCode(MethodDefinition method, ILProcessor
223235 }
224236 ) ;
225237
226- string marker = $ "B,{ document . Path } ,{ branchPoint . StartLine } ,{ branchPoint . Ordinal } ";
238+ string marker = $ "B,{ documentIndex } ,{ branchPoint . StartLine } ,{ branchPoint . Ordinal } ";
227239
228240 var pathInstr = Instruction . Create ( OpCodes . Ldstr , _result . HitsFilePath ) ;
229241 var markInstr = Instruction . Create ( OpCodes . Ldstr , marker ) ;
0 commit comments