diff --git a/src/VisualStudio/Core/Def/Implementation/TableDataSource/TableEntriesFactory.cs b/src/VisualStudio/Core/Def/Implementation/TableDataSource/TableEntriesFactory.cs index a79e18c33de97eff7f7c4b01fdd84fbdcf96baf1..1a48b8124f81cde943d71f4a43089613e2d019be 100644 --- a/src/VisualStudio/Core/Def/Implementation/TableDataSource/TableEntriesFactory.cs +++ b/src/VisualStudio/Core/Def/Implementation/TableDataSource/TableEntriesFactory.cs @@ -6,6 +6,7 @@ using System.Linq; using Microsoft.VisualStudio.Shell.TableManager; using Microsoft.VisualStudio.Text; +using Roslyn.Utilities; namespace Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource { @@ -185,7 +186,32 @@ public AbstractTableEntriesSnapshot CreateSnapshot(int version, Immutable return _tableSource.CreateSnapshot(_sources.Primary, version, items, trackingPoints); } - return _tableSource.CreateSnapshot(_sources.GetSources().First(), version, items, trackingPoints); + // we can be called back from error list while all sources are removed but before error list know about it yet + // since notification is pending in the queue. + var source = _sources.GetSources().FirstOrDefault(); + if (source == null) + { + return new EmptySnapshot(version); + } + + return _tableSource.CreateSnapshot(source, version, items, trackingPoints); + } + + private class EmptySnapshot : AbstractTableEntriesSnapshot + { + public EmptySnapshot(int version) : + base(version, ImmutableArray>.Empty, ImmutableArray.Empty) + { + } + + protected override bool IsEquivalent(TData item1, TData item2) => false; + public override bool TryNavigateTo(int index, bool previewTab) => false; + + public override bool TryGetValue(int index, string columnName, out object content) + { + content = null; + return false; + } } private class EntriesSourceCollections @@ -195,6 +221,7 @@ private class EntriesSourceCollections public EntriesSourceCollections(AbstractTableEntriesSource primary) { + Contract.ThrowIfNull(primary); _primary = primary; }