コード例 #1
0
        public void WriteDefinitionLocations(MultiDictionary <DebugSourceDocument, DefinitionWithLocation> file2definitions)
        {
            var writer5 = _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 kvp in file2definitions)
                {
                    ISymUnmanagedDocumentWriter docWriter = GetDocumentWriter(kvp.Key);
                    foreach (var definition in kvp.Value)
                    {
                        if (!open)
                        {
                            try
                            {
                                writer5.OpenMapTokensToSourceSpans();
                            }
                            catch (Exception ex)
                            {
                                throw new PdbWritingException(ex);
                            }

                            open = true;
                        }

                        uint token = _metadataWriter.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);
                    }
                }
            }
        }