Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.

Fixes VSTS Bug 958221: System.ArgumentNullException exception in #8340

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void SetDefaultInsertionPosition (ChainedExtension insertBefore)

public IEnumerable<ChainedExtension> GetAllExtensions ()
{
return extensions;
return extensions ?? Enumerable.Empty<ChainedExtension> ();
}

public IDisposable BatchModify () => batchModifier = new BatchModifier (this);
Expand Down
11 changes: 11 additions & 0 deletions main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,31 @@ void OnContentChanged ()

public T GetContent<T> (bool forActiveView) where T : class
{
if (IsDisposed)
return null;
return (T)GetContent (forActiveView, typeof (T));
}

public T GetContent<T> () where T : class
{
if (IsDisposed)
return null;
return GetContent<T> (false);
}

public IEnumerable<T> GetContents<T> (bool forActiveView) where T : class
{
if (IsDisposed)
return Enumerable.Empty<T> ();
if (forActiveView)
return view.GetActiveControllerHierarchy ().Select (controller => controller.GetContents<T> ()).SelectMany (c => c);
return GetControllersForContentCheck ().Select (controller => controller.GetContents<T> ()).SelectMany (c => c);
}

public IEnumerable<T> GetContents<T> () where T : class
{
if (IsDisposed)
return Enumerable.Empty<T> ();
return GetContents<T> (false);
}

Expand Down Expand Up @@ -637,8 +645,11 @@ void Window_CloseRequested (object sender, EventArgs e)
Close ().Ignore ();
}

public bool IsDisposed { get; private set; }

void Dispose ()
{
IsDisposed = true;
DocumentRegistry.Remove (this);
callbackRegistration?.Dispose ();
var workspace = Runtime.PeekService<RootWorkspace> ();
Expand Down