Bug 39591 - Moving folder between projects fails to add files
Summary: Moving folder between projects fails to add files
Status: VERIFIED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Project Management ()
Version: 6.0.0 (C7)
Hardware: PC Mac OS
: High normal
Target Milestone: (C7)
Assignee: Bugzilla
URL:
: 39592 39597 39616 39712 ()
Depends on:
Blocks:
 
Reported: 2016-03-14 16:24 UTC by Mikayla Hutchinson [MSFT]
Modified: 2016-05-11 13:15 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description Mikayla Hutchinson [MSFT] 2016-03-14 16:24:05 UTC
Dragging and dropping a folder from one project to another moves all the files, but does not add them to the destination project.

The following error may explain it.

System.NullReferenceException: Object reference not set to an instance of an object
  at MonoDevelop.Ide.Gui.Document.get_Name () [0x00000] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs:328 
  at MonoDevelop.Xml.Editor.BaseXmlEditorExtension.<HandleProjectChanged>m__1 (MonoDevelop.Projects.ProjectFileEventInfo f) [0x00000] in /Users/mikayla/Mono/monodevelop/main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs:110 
  at System.Linq.Enumerable.Any[TSource] (IEnumerable`1 source, System.Func`2 predicate) [0x00035] in /private/tmp/source-mono-4.4.0/bockbuild-mono-4.4.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/external/referencesource/System.Core/System/Linq/Enumerable.cs:1177 
  at MonoDevelop.Xml.Editor.BaseXmlEditorExtension.HandleProjectChanged (System.Object sender, MonoDevelop.Projects.ProjectFileEventArgs e) [0x00000] in /Users/mikayla/Mono/monodevelop/main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs:110 
  at (wrapper delegate-invoke) <Module>:invoke_void_object_ProjectFileEventArgs (object,MonoDevelop.Projects.ProjectFileEventArgs)
  at MonoDevelop.Ide.RootWorkspace.NotifyFileAddedToProject (System.Object sender, MonoDevelop.Projects.ProjectFileEventArgs e) [0x0000b] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs:1007 
  at MonoDevelop.Projects.Solution.OnFileAddedToProject (MonoDevelop.Projects.ProjectFileEventArgs args) [0x0000b] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Solution.cs:1021 
  at MonoDevelop.Projects.SolutionFolder.OnFileAddedToProject (MonoDevelop.Projects.ProjectFileEventArgs e) [0x00016] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionFolder.cs:933 
  at MonoDevelop.Projects.SolutionFolder.NotifyFileAddedToProject (System.Object sender, MonoDevelop.Projects.ProjectFileEventArgs e) [0x00000] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionFolder.cs:800 
  at MonoDevelop.Projects.Project.DoOnFileAddedToProject (MonoDevelop.Projects.ProjectFileEventArgs e) [0x00012] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs:2853 
  at MonoDevelop.Projects.Project+DefaultMSBuildProjectExtension.OnFileAddedToProject (MonoDevelop.Projects.ProjectFileEventArgs e) [0x00000] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs:3006 
  at MonoDevelop.Projects.ProjectExtension.OnFileAddedToProject (MonoDevelop.Projects.ProjectFileEventArgs e) [0x00000] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs:202 
  at MonoDevelop.Projects.ProjectExtension.OnFileAddedToProject (MonoDevelop.Projects.ProjectFileEventArgs e) [0x00000] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs:202 
  at MonoDevelop.Projects.ProjectExtension.OnFileAddedToProject (MonoDevelop.Projects.ProjectFileEventArgs e) [0x00000] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs:202 
  at MonoDevelop.Projects.Project.OnFileAddedToProject (MonoDevelop.Projects.ProjectFileEventArgs e) [0x00000] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs:2847 
  at MonoDevelop.Projects.SharedAssetsProjects.SharedAssetsProject.OnFileAddedToProject (MonoDevelop.Projects.ProjectFileEventArgs e) <0x12b3aa370 + 0x00047> in <filename unknown>:0 
  at MonoDevelop.Projects.Project.NotifyFileAddedToProject (IEnumerable`1 objs) [0x00061] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs:1968 
  at MonoDevelop.Projects.Project.OnItemsAdded (IEnumerable`1 objs) [0x00064] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs:1906 
  at MonoDevelop.Projects.ProjectItemCollection`1[T].NotifyAdded (IEnumerable`1 items, Boolean comesFromParent) [0x0009a] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectItemCollection.cs:150 
  at MonoDevelop.Projects.ProjectItemCollection`1[T].MonoDevelop.Projects.IItemListHandler.InternalAdd (IEnumerable`1 items, Boolean comesFromParent) [0x00020] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectItemCollection.cs:120 
  at MonoDevelop.Projects.ProjectItemCollection`1[T].NotifyAdded (IEnumerable`1 items, Boolean comesFromParent) [0x00082] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectItemCollection.cs:148 
  at MonoDevelop.Projects.ProjectItemCollection`1[T].OnItemsAdded (IEnumerable`1 items) [0x00013] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectItemCollection.cs:98 
  at MonoDevelop.Projects.ProjectFileCollection.OnItemsAdded (IEnumerable`1 items) [0x00037] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectFileCollection.cs:194 
  at MonoDevelop.Projects.ItemCollection`1[T].Add (MonoDevelop.Projects.T item) [0x00012] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ItemCollection.cs:64 
  at MonoDevelop.Ide.ProjectOperations.TransferFilesInternal (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.Project sourceProject, FilePath sourcePath, MonoDevelop.Projects.Project targetProject, FilePath targetPath, Boolean removeFromSource, Boolean copyOnlyProjectFiles) [0x0068d] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs:1981 
  at MonoDevelop.Ide.ProjectOperations.TransferFiles (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.Project sourceProject, FilePath sourcePath, MonoDevelop.Projects.Project targetProject, FilePath targetPath, Boolean removeFromSource, Boolean copyOnlyProjectFiles) [0x00000] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs:1809 
  at MonoDevelop.Ide.Gui.Pads.ProjectPad.FolderCommandHandler.DropNode (System.Collections.Generic.HashSet`1 projectsToSave, System.Object dataObject, System.Collections.Generic.HashSet`1 groupedFiles, DragOperation operation) [0x006f0] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/FolderNodeBuilder.cs:376 
  at MonoDevelop.Ide.Gui.Pads.ProjectPad.FolderCommandHandler+<OnMultipleNodeDrop>c__async0.MoveNext () [0x00101] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/FolderNodeBuilder.cs:203 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /private/tmp/source-mono-4.4.0/bockbuild-mono-4.4.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (System.Object state) [0x00000] in /private/tmp/source-mono-4.4.0/bockbuild-mono-4.4.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018 
  at MonoDevelop.Ide.DispatchService+GtkSynchronizationContext+<Post>c__AnonStorey0.<>m__0 (System.Object , System.EventArgs ) [0x00000] in /Users/mikayla/Mono/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DispatchService.cs:52 
  at Gtk.Application+InvokeCB.Invoke () <0x11a5f0e50 + 0x00021> in <filename unknown>:0 
  at GLib.Timeout+TimeoutProxy.Handler () <0x11a5efb20 + 0x0004a> in <filename unknown>:0
Comment 1 Lluis Sanchez 2016-03-14 18:33:03 UTC
I can't reproduce. Can you reproduce it all the time? It may be a bogus document. Any idea of which document could that be?
Comment 2 Mikayla Hutchinson [MSFT] 2016-03-14 22:14:07 UTC
IIRC I had several of the csproj files open.
Comment 3 Matt Ward 2016-03-15 17:22:09 UTC
Just reproduced the same exception callstack looking at a different bug. My repro steps are:

1) Create a new Android project with UITest project.
2) Open up the Android manifest file into the editor and close it.
3) Move the Properties folder from the Android project to the UITest project.

Xamarin Studio seems to be in a broken state after opening and closing an Android manifest file. Any action that triggers the project modified event after closing the manifest file will cause the null ref exception accessing the Document.Name to be logged the IDE log.

I will debug XS to see what is going on.
Comment 4 Mikayla Hutchinson [MSFT] 2016-03-15 18:22:28 UTC
*** Bug 39597 has been marked as a duplicate of this bug. ***
Comment 5 Matt Ward 2016-03-15 18:43:27 UTC
Initial investigation - the problem seems to be that the TextEditor is not being destroyed/disposed when the Manifest file is closed if the text editor is not opened by selecting the Source tab. This then causes the xml editor extension to still be attached after the document is disposed and various events are still fired into the xml editor extension.

If you open an ordinary .xml file (not a manifest.xml file) and then close it you see the BaseXmlEditorExtension get disposed properly:

MonoDevelop.Xml.Editor.BaseXmlEditorExtension.Dispose() in monodevelop/main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs:151
MonoDevelop.Xml.Editor.XmlTextEditorExtension.Dispose() in monodevelop/main/src/addins/Xml/Editor/XmlTextEditorExtension.cs:99
MonoDevelop.Ide.Editor.TextEditor.DetachExtensionChain() in monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditor.cs:1136
MonoDevelop.Ide.Editor.TextEditor.Dispose(bool disposing) in monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditor.cs:927
MonoDevelop.Components.Control.OnGtkDestroyed(MonoDevelop.Components.Commands.CommandRouterContainer sender, System.EventArgs args) in monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Control.cs:100
Gtk.Widget.Destroy() in 
MonoDevelop.Ide.Gui.SdiWorkspaceWindow.CloseWindow(bool force, bool animate) in monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs:460
MonoDevelop.Ide.Gui.DefaultWorkbench.CloseClicked(MonoDevelop.Ide.Gui.SdiDragNotebook o, MonoDevelop.Components.DockNotebook.TabEventArgs e) in monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs:1205
MonoDevelop.Components.DockNotebook.DockNotebook.OnCloseTab(MonoDevelop.Components.DockNotebook.DockNotebookTab tab) in monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.DockNotebook/DockNotebook.cs:374
MonoDevelop.Components.DockNotebook.TabStrip.OnButtonReleaseEvent(Gdk.EventButton evnt) in monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.DockNotebook/TabStrip.cs:566


With the manifest open the text editor is created but not displayed and on closing the window the callstack above does not happen. If the text editor is viewed by selecting the Source tab and then the window closed, or if the text editor is viewed, then the manifest editor is switched back to, then the text editor is destroyed/disposed correctly.
Comment 7 Greg Munn 2016-03-15 21:40:09 UTC
I had a similar issue last week working on md-addins. I moved a file from one project to another and the file was removed from the first project but not added to the second project.
Comment 8 Mikayla Hutchinson [MSFT] 2016-03-15 21:48:49 UTC
*** Bug 39616 has been marked as a duplicate of this bug. ***
Comment 9 xamarin-release-manager 2016-03-16 14:09:04 UTC
Fixed in version 6.1.0.294 (master)

Author: Lluis Sanchez
Commit: 1a1cec1bfce03c57c05c11721baefcda4d5fea92 (mono/monodevelop)
Comment 10 xamarin-release-manager 2016-03-16 14:09:54 UTC
Fixed in version 6.0.0.4826 (cycle7)

Author: Lluis Sanchez
Commit: cecf3635180781b27267a3646b70c9da6484e7d9 (mono/monodevelop)
Comment 11 Matt Ward 2016-03-17 09:42:23 UTC
*** Bug 39712 has been marked as a duplicate of this bug. ***
Comment 12 Lluis Sanchez 2016-03-17 14:41:43 UTC
*** Bug 39592 has been marked as a duplicate of this bug. ***
Comment 13 xamarin-release-manager 2016-04-01 14:51:10 UTC
Fixed in version 6.0.0.4918 (cycle7-android-n)

Author: Lluis Sanchez
Commit: cecf3635180781b27267a3646b70c9da6484e7d9 (mono/monodevelop)