@@ -81,7 +81,7 @@ type PdbMethodData =
8181 MethName: string
8282 LocalSignatureToken: int32
8383 Params: PdbLocalVar array
84- RootScope: PdbMethodScope
84+ RootScope: PdbMethodScope option
8585 Range: ( PdbSourceLoc * PdbSourceLoc ) option
8686 SequencePoints: PdbSequencePoint array }
8787
@@ -224,7 +224,7 @@ let generatePortablePdb (embedAllSource:bool) (embedSourceList:string list) (sou
224224let externalRowCounts = getRowCounts info.TableRowCounts
225225let docs =
226226match info.Documentswith
227- | null -> Array.empty< PdbDocumentData >
227+ | null -> Array.empty
228228| _ -> info.Documents
229229
230230let metadata = MetadataBuilder()
@@ -324,23 +324,28 @@ let generatePortablePdb (embedAllSource:bool) (embedSourceList:string list) (sou
324324let docHandle , sequencePointBlob =
325325let sps =
326326match minfo.SequencePointswith
327- | null -> Array.empty< PdbSequencePoint >
327+ | null -> Array.empty
328328| _ ->
329329match minfo.Rangewith
330- | None-> Array.empty< PdbSequencePoint >
330+ | None-> Array.empty
331331| Some(_,_) -> minfo.SequencePoints
332332
333- let getDocumentHandle d =
334- if docs.Length= 0 || d< 0 || d> docs.Lengththen
335- Unchecked.defaultof< DocumentHandle>
336- else
337- match documentIndex.TryGetValue( docs.[ d]. File) with
338- | false , _ -> Unchecked.defaultof< DocumentHandle>
339- | true , h-> h
333+ let builder = new BlobBuilder()
334+ builder.WriteCompressedInteger( minfo.LocalSignatureToken)
340335
341336if sps.Length= 0 then
337+ builder.WriteCompressedInteger( 0 )
338+ builder.WriteCompressedInteger( 0 )
342339 Unchecked.defaultof< DocumentHandle>, Unchecked.defaultof< BlobHandle>
343340else
341+ let getDocumentHandle d =
342+ if docs.Length= 0 || d< 0 || d> docs.Lengththen
343+ Unchecked.defaultof< DocumentHandle>
344+ else
345+ match documentIndex.TryGetValue( docs.[ d]. File) with
346+ | false , _ -> Unchecked.defaultof< DocumentHandle>
347+ | true , h-> h
348+
344349// Return a document that the entire method body is declared within.
345350// If part of the method body is in another document returns nil handle.
346351let tryGetSingleDocumentIndex =
@@ -350,12 +355,8 @@ let generatePortablePdb (embedAllSource:bool) (embedSourceList:string list) (sou
350355 singleDocumentIndex<- - 1
351356 singleDocumentIndex
352357
353- let builder = new BlobBuilder()
354- builder.WriteCompressedInteger( minfo.LocalSignatureToken)
355-
356358// Initial document: When sp's spread over more than one document we put the initial document here.
357359let singleDocumentIndex = tryGetSingleDocumentIndex
358-
359360if singleDocumentIndex= - 1 then
360361 builder.WriteCompressedInteger( MetadataTokens.GetRowNumber( DocumentHandle.op_ Implicit( getDocumentHandle( sps.[ 0 ]. Document))) )
361362
@@ -438,7 +439,10 @@ let generatePortablePdb (embedAllSource:bool) (embedSourceList:string list) (sou
438439for localVariablein s.Localsdo
439440 lastLocalVariableHandle<- metadata.AddLocalVariable( LocalVariableAttributes.None, localVariable.Index, metadata.GetOrAddString( localVariable.Name))
440441)
441- writeMethodScope minfo.RootScope)
442+
443+ match minfo.RootScopewith
444+ | None-> ()
445+ | Some scope-> writeMethodScope scope)
442446
443447let entryPoint =
444448match info.EntryPointwith
@@ -564,7 +568,9 @@ let writePdbInfo showTimes f fpdb info cvChunk =
564568 sco.Children|> Array.iter( writePdbScope( if nestedthen Some scoelse parent))
565569if nestedthen pdbCloseScope! pdbw sco.EndOffset
566570
567- writePdbScope None minfo.RootScope
571+ match minfo.RootScopewith
572+ | None-> ()
573+ | Some rootscope-> writePdbScope None rootscope
568574 pdbCloseMethod! pdbw
569575end )
570576 reportTime showTimes" PDB: Wrote methods"
@@ -674,7 +680,10 @@ let writeMdbInfo fmdb f info =
674680for childin scope.Childrendo
675681 writeScope( child)
676682 wr?CloseScope( scope.EndOffset)
677- writeScope( meth.RootScope)
683+ match meth.RootScopewith
684+ | None-> ()
685+ | Some rootscope-> writeScope( rootscope)
686+
678687
679688// Finished generating debug information for the curretn method
680689 wr?CloseMethod()
@@ -721,5 +730,8 @@ let logDebugInfo (outfile:string) (info:PdbData) =
721730if scope.Locals.Length> 0 then
722731 fprintfn sw" %s Locals:%A " offs[ for pin scope.Locals-> sprintf" %d :%s " p.Index p.Name]
723732for childin scope.Childrendo writeScope( offs+ " " ) child
724- writeScope" " meth.RootScope
733+
734+ match meth.RootScopewith
735+ | None-> ()
736+ | Some rootscope-> writeScope" " rootscope
725737 fprintfn sw" "