-
Notifications
You must be signed in to change notification settings - Fork 1k
Fixes VSTS Bug 958221: System.ArgumentNullException exception in #8340
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If GetAllExtensions can never be null then I guess this code can be changed:
monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentController.cs
Line 675 in d167b82
var allExtensions = (extensionChain.GetAllExtensions () ?? Array.Empty<DocumentControllerExtension>()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extensions
can only be null if the extension chain has been disposed, which happens when the document controller is disposed. If we are trying to access a disposed object, the bug is somewhere else.
I'm wondering if MonoDevelopDocumentTrackingService is keeping a reference to a disposed document. |
@slluis there's some other traces, not just MonoDevelopDocumentTrackingService:
|
@Therzok yes, there may be more than one problem. This is not right though: Lines 77 to 78 in 50fbe0a
In any case, caching the active document here is a potential problem. It may happen that |
Maybe |
Looks like the code was changed compared to the initial caching commit. This commit changed it to be assigned after |
e576e6c
to
f09b97b
Compare
/fixed the activeDocument assignment - that was wrong. Y there are different scenarios where that can happen. |
How about that ? Just giving cutting the GetContent pipe on disposed Documents ? |
@mkrueger tests are failing now |
My question still stands. Why is GetContent() being called on a disposed document? |
Honestly, I think this is a fallout from asynchronizing all the document code. Given we can have a situation where: var doc = await GetDocument();
await SomethingElse(); // User closes the document in the meantime
...
// This is now disposed
DoSomething (doc); and the user closes the document in the meantime, it can |
@Therzok we have an event that is raised when a document is closed, so that case can be avoided. I don't agree this is a problem of asynchronizing code. |
Okay, I think I understand now what's going on, at least for the roslyn stack.
|
We also should probably remove the |
f5ad5ba
to
1c40857
Compare
No idea what you mean with remove active document from the list. Just because the IDE document is closed it's not affecting it's contents. Interesting would just be closing a document with changes and discard the changes on close. |
@mkrueger We need to modify this test and ensure it passes: monodevelop/main/tests/MonoDevelop.Core.Tests/MonoDevelop.Projects/ExtensionChainTests.cs Line 137 in 6f21173
|
Can we split this PR? The roslyn active doc fix is good to merge. Stalling this too long is not really a good idea... |
In general I don't think that this change is harmful. Even if there is a deeper problem it makes the code more solid. |
System.Linq.Enumerable.OfType[DocumentControllerExtension]() https://devdiv.visualstudio.com/DevDiv/_workitems/edit/958221
1c40857
to
3f7a550
Compare
I still think Lluis is right, in that it hides a problem, not fixes it. |
System.Linq.Enumerable.OfTypeDocumentControllerExtension
https://devdiv.visualstudio.com/DevDiv/_workitems/edit/958221