Bug 5188 - Designer does not handle moved or linked files well
Summary: Designer does not handle moved or linked files well
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Designer ()
Version: 4.2.x
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Lluis Sanchez
URL:
Depends on:
Blocks:
 
Reported: 2012-05-19 15:24 UTC by Alex Corrado [MSFT]
Modified: 2012-05-31 12:52 UTC (History)
0 users

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


Attachments
Test case (31.86 KB, application/zip)
2012-05-19 15:24 UTC, Alex Corrado [MSFT]
Details


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:
RESOLVED FIXED

Description Alex Corrado [MSFT] 2012-05-19 15:24:22 UTC
Created attachment 1924 [details]
Test case

Here is what I did:

1. Created a new solution with 2 MfA application projects.

2. Deleted the Main.axml in the second project and added the Main.axml from the first as a linked file under Resources/layout.

At this point, the layout could be opened in the designer when double clicked from the first project, but double clicking the link in the second project opened it in the source editor.

3. Removed (but not delete) the Main.axml in both projects. Then, in the second project, right click on the Resources/layout folder -> Add Files -> select the Main.axml file still in the directory of the first project -> choose to Move the file.

At this point, trying to open the layout yields the following exception dialog:

System.InvalidOperationException: out of sync
  at System.Collections.Generic.Dictionary`2+Enumerator[Xamarin.AndroidDesigner.Resources.ResourceQualifier,Xamarin.AndroidDesigner.Resources.QualifierValue].VerifyState () [0x00033] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:958 
  at System.Collections.Generic.Dictionary`2+Enumerator[Xamarin.AndroidDesigner.Resources.ResourceQualifier,Xamarin.AndroidDesigner.Resources.QualifierValue].MoveNext () [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:880 
  at System.Collections.Generic.Dictionary`2+ValueCollection+Enumerator[Xamarin.AndroidDesigner.Resources.ResourceQualifier,Xamarin.AndroidDesigner.Resources.QualifierValue].MoveNext () [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:1190 
  at System.Linq.Enumerable+<CreateWhereIterator>c__Iterator35`1[Xamarin.AndroidDesigner.Resources.QualifierValue].MoveNext () [0x00089] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.Core/System.Linq/Enumerable.cs:3009 
  at System.Linq.Enumerable+<CreateConcatIterator>c__Iterator18`1[Xamarin.AndroidDesigner.Resources.QualifierValue].MoveNext () [0x00077] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.Core/System.Linq/Enumerable.cs:593 
  at System.Collections.Generic.List`1[Xamarin.AndroidDesigner.Resources.QualifierValue].AddEnumerable (IEnumerable`1 enumerable) [0x0001a] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/corlib/System.Collections.Generic/List.cs:126 
  at System.Collections.Generic.List`1[Xamarin.AndroidDesigner.Resources.QualifierValue]..ctor (IEnumerable`1 collection) [0x0002f] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/corlib/System.Collections.Generic/List.cs:63 
  at System.Linq.Enumerable.ToArray[QualifierValue] (IEnumerable`1 source) [0x00029] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.Core/System.Linq/Enumerable.cs:2801 
  at Xamarin.AndroidDesigner.DesignerSession.FindAdjustedBestMatchingResourceFileInternal (Xamarin.AndroidDesigner.Resources.ResourceQualifier qualifierToAdjust, System.Collections.Generic.List`1 list, IEnumerable`1 qualifiersToMatch) [0x0009b] in /Users/builder/data/lanes/monodevelop-mac-3.0.1/6642975f/source/md-addins/MonoDevelop.MonoDroid/Xamarin.AndroidDesigner/Xamarin.AndroidDesigner/DesignerSession.cs:1219 
  at Xamarin.AndroidDesigner.DesignerSession.FindBestMatchingResourceFile (IEnumerable`1 files, IEnumerable`1 qualifiersToMatch) [0x0004c] in /Users/builder/data/lanes/monodevelop-mac-3.0.1/6642975f/source/md-addins/MonoDevelop.MonoDroid/Xamarin.AndroidDesigner/Xamarin.AndroidDesigner/DesignerSession.cs:1207 
  at Xamarin.AndroidDesigner.DesignerSession.FindBestMatchingLayoutFile () [0x00000] in /Users/builder/data/lanes/monodevelop-mac-3.0.1/6642975f/source/md-addins/MonoDevelop.MonoDroid/Xamarin.AndroidDesigner/Xamarin.AndroidDesigner/DesignerSession.cs:1083 
  at Xamarin.AndroidDesigner.DesignerSession.InitSession () [0x000fd] in /Users/builder/data/lanes/monodevelop-mac-3.0.1/6642975f/source/md-addins/MonoDevelop.MonoDroid/Xamarin.AndroidDesigner/Xamarin.AndroidDesigner/DesignerSession.cs:1047 
  at Xamarin.AndroidDesigner.DesignerSession.DoRefresh (Boolean asyncRefresh) [0x00014] in /Users/builder/data/lanes/monodevelop-mac-3.0.1/6642975f/source/md-addins/MonoDevelop.MonoDroid/Xamarin.AndroidDesigner/Xamarin.AndroidDesigner/DesignerSession.cs:904 
  at Xamarin.AndroidDesigner.DesignerSession.<Refresh>m__27 (System.Object ) [0x00000] in /Users/builder/data/lanes/monodevelop-mac-3.0.1/6642975f/source/md-addins/MonoDevelop.MonoDroid/Xamarin.AndroidDesigner/Xamarin.AndroidDesigner/DesignerSession.cs:894

4. Add the Main.axml back to the Resources/layout folder of the first project as a link (as it was moved to the second project in step 3). Restart MD. Now, double clicking the linked layout in the first project opens the source editor, and double click the layout in the second project opens the designer but with this error:

"The layout could not be loaded. Layout resource could not be found."

Attached is a test case in which you can observe the state described in (4). Removing the linked Main.axml from Project1 will allow the layout in Project2 to be opened in the designer.
Comment 1 Lluis Sanchez 2012-05-20 04:35:16 UTC
Linked layout files are never going to work. The designer requires the layout file to physically exist in the resources folder, which is not the case when you use a link. In any case, I'll add more control code to avoid the exception and give a more meaningful message.
Comment 2 Lluis Sanchez 2012-05-31 12:52:19 UTC
The exception is now fixed, although you can only open the designer in the project where the file physically exists.