Bug 6375 - MonoDevelop deletes all viewcontroller code
Summary: MonoDevelop deletes all viewcontroller code
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: iOS add-in ()
Version: 3.0.x
Hardware: PC Mac OS
: High major
Target Milestone: ---
Assignee: Jeffrey Stedfast
: 6003 8018 ()
Depends on:
Reported: 2012-08-03 04:27 UTC by Ruben Vermeersch
Modified: 2013-02-11 07:07 UTC (History)
5 users (show)

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

Log file (97.69 KB, application/octet-stream)
2012-11-14 12:44 UTC, Ruben Vermeersch

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:

Description Ruben Vermeersch 2012-08-03 04:27:00 UTC
Extremely not-funny bug:

For some reason MonoDevelop decides that the C# files which correspond to the view controller in my storyboard do not exist.

It therefore writes new copies of them and adds them back to the project.

* I get two copies of the same file in my solution panel.
* My code for the view controller is completely nuked.

This started happening while we were refactoring our project. Maybe our project got corrupted? Anyway, this is extremely annoying as it means our work randomly gets wiped out (good thing we use git).

I've attached a listing of files in the project tree, which ones do you need to debug this?

Installation UUID: 46adcb2c-0fef-4128-a852-9a6bc9a39109
	Mono 2.10.9 (tarball)
	GTK 2.24.10
	GTK# (
	Package version: 210090011
Apple Developer Tools:
	 Xcode 4.4 (1484)
	 Build 4F250
Monotouch: 5.2.12
Mono for Android:
Android SDK: /Users/ruben/Library/Developer/Xamarin/android-sdk-mac_x86
Supported Android versions:
	Version: 1.6	ApiLevel: 4
	Version: 2.1	ApiLevel: 7
	Version: 2.2	ApiLevel: 8
	Version: 2.3	ApiLevel: 10
	Version: 3.1	ApiLevel: 12
	Version: 4.0	ApiLevel: 14
	Version: 4.0.3	ApiLevel: 15
Java SDK: /usr/bin

Build information:
	Release ID: 30003005
	Git revision: 3d53e1366933298a3fe0cdc6d0f7d00c9916564c-dirty
	Build date: 2012-07-27 19:06:34+0000
	Xamarin addins: 73ecde7c48d943adb6e33d511d3cf0661d006801
Operating System:
	Mac OS X 10.8.0
	Darwin tsukuba.local 12.0.0 Darwin Kernel Version 12.0.0
	    Sun Jun 24 23:00:16 PDT 2012
	    root:xnu-2050.7.9~1/RELEASE_X86_64 x86_64
Comment 2 Jeffrey Stedfast 2012-10-29 13:37:25 UTC
*** Bug 8018 has been marked as a duplicate of this bug. ***
Comment 3 Jeffrey Stedfast 2012-11-12 16:43:49 UTC
*** Bug 6003 has been marked as a duplicate of this bug. ***
Comment 4 Jeffrey Stedfast 2012-11-12 17:15:54 UTC
I've just committed a partial fix for this, which just prevents files from being added to the project multiple times (which, unfortunately, is just a minor bug in the grand scheme of the issue here).

I'm looking into the logic that scans storyboards for classes that it doesn't know about.

I've got a few questions that will hopefully help me track it down:

1. When MonoDevelop wrongly decides that a class doesn't exist, when it clobbers your existing source file, does the namespace stay the same?

I'm wondering if maybe it has something to do with the namespace...

2. can you get me a copy of an Xcode4Sync-<date>.log file for a session where this happens for you? You can find the log in ~/Library/Logs/MonoDevelop-3.0/Xcode4Sync-<date>.log

It might provide some clues...

Actually, perhaps I can add some more logging logic and provide you with a custom build from git master to hopefully narrow this down.

3. It sounds like for Ruben, this is happening for classes defined in Storyboards and not in xibs? Is this the same with everyone else having this problem? I've been looking at the regular header-file sync-back logic, but perhaps the bug is in the logic that scans Storyboards and decides whether or not to generate a new class. Will begin looking here...
Comment 5 Jeffrey Stedfast 2012-11-13 12:58:56 UTC
Can you guys try out http://files.xamarin.com/~jeff/MonoDevelop-5d3d232b6f294e0e486121f872bd6d58be47b153.dmg and see if that fixes this bug?

I haven't had any luck reproducing the problem so this is a bit like shooting in the dark :-(
Comment 6 Jeffrey Stedfast 2012-11-13 17:50:52 UTC
Another update which fixes some applescript exception handling:

Comment 7 Ruben Vermeersch 2012-11-14 06:24:37 UTC
Hi Jeffrey, I'll have a go at it in a bit. Our hit rate for triggering this is pretty big so it shouldn't be too hard. When I run into it, do you need anything besides the Xcode4Sync-<date>.log file?
Comment 8 Ruben Vermeersch 2012-11-14 08:44:19 UTC
Can't seem to reproduce it with the attached version. Will keep on testing though.
Comment 9 Jeffrey Stedfast 2012-11-14 09:39:26 UTC
Ruben, thanks for testing!

If you are able to reproduce it, the Xcode4Sync will hopefully be all I need.
Comment 10 Jeffrey Stedfast 2012-11-14 11:52:09 UTC

Does your Xcode4Sync log contain any messages like the following?

Generating custom class: ProjectNamespace.ClassName
    File 'ClassName.cs' already exists; ignoring.
Comment 11 Ruben Vermeersch 2012-11-14 12:17:19 UTC
[2012-11-14 14:38:15.9]    Generating custom class: SalesApp.iOS.LeadsViewController
[2012-11-14 14:38:15.9]     File 'SalesApp.iOS/ProductCatalogue/LeadsViewController.cs' already exists; ignoring.

Yup. That is, by the way, the one where MD insisted on eating the code.
Comment 12 Jeffrey Stedfast 2012-11-14 12:22:33 UTC
fudge. I was hoping you wouldn't have any of those... this indicates that the core bug still exists, it's just that my safety-net logic is preventing it from clobbering your existing code.

Could you send me your log file? maybe I can get a better idea of what is leading up to that
Comment 13 Ruben Vermeersch 2012-11-14 12:44:04 UTC
Created attachment 2920 [details]
Log file
Comment 14 jan 2012-11-14 15:31:25 UTC
Hi Jeffrey,

I've installed the MonoDevelop from comment 6, and Xcode is still eating my code. I couldn't find the "already exists" in the log but I'm adding it anyway. I hope it helps. If you need more info, please let me know...
Comment 16 Jeffrey Stedfast 2012-11-14 15:38:03 UTC
Thanks Ruben & Jan. I'll keep digging.
Comment 17 Jeffrey Stedfast 2012-11-14 17:42:34 UTC
Okay, got another potential fix (and more verbose logging):

Comment 18 Jose Medrano 2012-12-11 01:27:02 UTC
Fix down?
Comment 19 Jeffrey Stedfast 2013-01-04 15:13:21 UTC
I periodically delete the temp dmgs that I upload because it starts using a lot of space after a while.

anyway, the fixes I did are probably in the 3.1.1 release that is in Beta right now.
Comment 20 Jeffrey Stedfast 2013-01-25 12:24:18 UTC
Any updates on this? Can either of you reproduce these problems with MonoDevelop 3.1.1?
Comment 21 Ruben Vermeersch 2013-02-11 04:21:23 UTC
Haven't been able to do so recently. You can probably consider this as fixed. Thanks a lot!
Comment 22 Jeffrey Stedfast 2013-02-11 07:07:06 UTC
ok, reopen if you hit it again!