Bug 46983 - Designer with same layout file in two different layout folders overwrites the wrong file
Summary: Designer with same layout file in two different layout folders overwrites the...
Status: CONFIRMED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Android Designer ()
Version: 4.5.0 (15.2)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-11-15 10:46 UTC by Yoni
Modified: 2017-07-10 16:02 UTC (History)
6 users (show)

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


Attachments
Screen capture of the described problem (2.85 MB, application/x-shockwave-flash)
2016-11-15 10:46 UTC, Yoni
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 for Bug 46983 on Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.
Related Links:
Status:
CONFIRMED

Description Yoni 2016-11-15 10:46:08 UTC
Created attachment 18467 [details]
Screen capture of the described problem

So I captured the whole thing in a screen capture which I attached to this issue. I have an activity_login.axml file in both Resources/layout as well as in Resources/layout-sw480dp. When the designer is opened for the default layout it shows both versions. If I then navigate to the sw480dp version and open the source it will correctly show the source of the sw480dp version, however if I save the file (because it says it has changes, this is due to the fact the default layout version is not indented properly and the designer does the indenting) it overwrites the default layout version with the content of the sw480dp version.

So the steps as can be seen in the screen cast:

1. make sure the default layout does not have proper indentation (don't know if this is necessary, could be a manually edit to the default layout will trigger the same bug, I have not tested that)
2. open default layout in designer
3. switch to Source (or make sure a change is made to the default layout)
4. switch back to Designer.
5. switch to Source of the sw480dp version
6. double click the default layout version in solution explorer
7. confirm in the dialog that you want to close the open version
8. confirm that you want to save the changes made to the default layout

The default layout is now overwritten with the sw480dp versions content.

Because I don't want that I do an undo pending changes in TFS for this file, after that I try to reopen the activity_login.axml the designer is stuck on loading (This may be related to https://bugzilla.xamarin.com/show_bug.cgi?id=37201). I have to kill the java.exe that is started under visual studio and then the designer responds again. This may be a separate issue but I though I just let you know here, because I can only reproduce the issue by following the steps to my first issue.

Thanks,
Yoni
Comment 1 Jon Douglas [MSFT] 2017-07-10 16:02:36 UTC
I am CONFIRMING this behavior based on your video and reproduction steps in https://bugzilla.xamarin.com/show_bug.cgi?id=46983#c0

I had noticed that when opening the "layout-sw840dp" the file that is still active is the "layout" one instead of "layout-sw840dp" thus the changes made even when the Visual Studio Solution Explorer shows "layout-sw840dp" are actually being made for the "layout" one instead.

So really the designer needs to better track the files it is opening and closing. It seems that the only way to ensure you are making changes in a different qualifier is to ensure that no other named files are open. For example:

If I open layout/Main.axml and then I want to make changes in layout-sw840dp/Main.axml, if I switch over by double clicking the file, it will still have layout/Main.axml in the editor.

However if I close completely out of any same name XML file, it will open up the correct corresponding path to the file and the changes will save correctly.

This also happens vice versa, but the idea is the same.

Ideally the designer should just open the file regardless and indicate that it is a different file by opening up a different editor tab for the file. Playing around with this for even a couple minutes, you start to question what is actually being saved or not. The reality is that whatever the editor has open and hovering over the file gives the path which is ultimately saved.

Thus I am CONFIRMING this behavior as it is quite confusing. Thank you Yoni for the report!