/// <inheritdoc /> public List <Diagnostic> GetDiagnostics(string fileName = null) { SortAndDeduplicateIfNeeded(); if (fileName != null) { return(m_fileDiagnostics.GetOrAddAtomic(fileName, _ => new List <Diagnostic>())); } List <Diagnostic> allDiagnostics = new List <Diagnostic>(m_nonFileDiagnostics); lock (m_fileDiagnostics) { foreach (var fileDiagnostic in m_fileDiagnostics.Values) { allDiagnostics.AddRange(fileDiagnostic); } } return(DiagnosticUtilities.SortAndDeduplicateDiagnostics(allDiagnostics)); }
private void SortAndDeduplicateIfNeeded() { if (!Volatile.Read(ref m_diagnosticsModified)) { return; } Volatile.Write(ref m_diagnosticsModified, false); m_nonFileDiagnostics = DiagnosticUtilities.SortAndDeduplicateDiagnostics(m_nonFileDiagnostics); Map <List <Diagnostic> > sortedAndDeduplicatedFileDiagnostics = new Map <List <Diagnostic> >(); lock (m_fileDiagnostics) { foreach (var key in m_fileDiagnostics.Keys) { sortedAndDeduplicatedFileDiagnostics[key] = DiagnosticUtilities.SortAndDeduplicateDiagnostics(m_fileDiagnostics[key]); } m_fileDiagnostics = sortedAndDeduplicatedFileDiagnostics; } }