public void WriteDefinitionLocations(MultiDictionary <DebugSourceDocument, DefinitionWithLocation> file2definitions) { var writer5 = this.symWriter as ISymUnmanagedWriter5; if ((object)writer5 != null) { // NOTE: ISymUnmanagedWriter5 reports HRESULT = 0x806D000E in case we open and close // the map without writing any resords with MapTokenToSourceSpan(...) bool open = false; foreach (var doc in file2definitions.Keys) { ISymUnmanagedDocumentWriter docWriter = GetDocumentWriter(doc); foreach (var definition in file2definitions[doc]) { if (!open) { try { writer5.OpenMapTokensToSourceSpans(); } catch (Exception ex) { throw new PdbWritingException(ex); } open = true; } uint token = peWriter.GetTokenForDefinition(definition.Definition); Debug.Assert(token != 0); try { writer5.MapTokenToSourceSpan(token, docWriter, definition.StartLine + 1, definition.StartColumn + 1, definition.EndLine + 1, definition.EndColumn + 1); } catch (Exception ex) { throw new PdbWritingException(ex); } } } if (open) { try { writer5.CloseMapTokensToSourceSpans(); } catch (Exception ex) { throw new PdbWritingException(ex); } } } }
public void WriteDefinitionLocations(PeWriter peWriter, MultiDictionary<Cci.DebugSourceDocument, Cci.DefinitionWithLocation> file2definitions) { ISymUnmanagedWriter5 writer5 = this.symWriter as ISymUnmanagedWriter5; if ((object)writer5 != null) { // NOTE: ISymUnmanagedWriter5 reports HRESULT = 0x806D000E in case we open and close // the map without writing any resords with MapTokenToSourceSpan(...) bool open = false; foreach (var doc in file2definitions.Keys) { ISymUnmanagedDocumentWriter docWriter = GetDocumentWriter(doc); foreach (var definition in file2definitions[doc]) { if (!open) { try { writer5.OpenMapTokensToSourceSpans(); } catch (Exception ex) { throw new PdbWritingException(ex); } open = true; } uint token = peWriter.GetTokenForDefinition(definition.Definition); Debug.Assert(token != 0); try { writer5.MapTokenToSourceSpan(token, docWriter, definition.StartLine + 1, definition.StartColumn + 1, definition.EndLine + 1, definition.EndColumn + 1); } catch (Exception ex) { throw new PdbWritingException(ex); } } } if (open) { try { writer5.CloseMapTokensToSourceSpans(); } catch (Exception ex) { throw new PdbWritingException(ex); } } } }