Bug 17071 - Unexpected end of file in an attribute value
Summary: Unexpected end of file in an attribute value
Status: RESOLVED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: General ()
Version: 1.8.x
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Vinicius Jarina
URL:
Depends on:
Blocks:
 
Reported: 2014-01-06 13:34 UTC by Andy
Modified: 2016-12-22 17:34 UTC (History)
11 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 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 Andy 2014-01-06 13:34:41 UTC
Error while trying to load the project ... 

which resides on the PC hard disk and is managed by VS plugin. When saving the project and opening it with XS, I often get this error. It's usually on the two itunes resource images

Deleting the two attributes fixes it...
Comment 1 Marek Habersack 2014-01-07 09:50:41 UTC
We need more info - what is the error, what is the project file as accepted by XS and what it looks like when saved by VS.
Comment 2 Andy 2014-01-07 10:12:29 UTC
The error pops up in XS as messagebox / alert when loading the project. Which then fails to load.

Project file is a normal project I've been moving between the two VS and XS for a while without problems. I think it started with VS2013, not sure though.

The file is exactly the same on both... I open it and at the point where it says the end of file is found instead of attribute, there is usually the last two attributes. First time was with itunes images, now there are these:

<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default-Portrait.png" />
    <ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default-568h%402x.png" />

Anyway, if I delete those, the project loads... but obviously this isn't a solution since it will repeat the problem with the previous two items...
Comment 3 Andy 2014-01-07 10:13:06 UTC
Sorry, the end of the file was:

<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default-Portrait.png" />
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default-568h%402x.png" />
  </ItemGroup>
</Project>

But removing the two imageasset fixes it
Comment 4 Marek Habersack 2014-01-07 12:12:21 UTC
Thanks for the info, Vinicius can you look at the issue?
Comment 5 Andy 2014-01-12 11:08:32 UTC
Simple test:
open file (local) in notepad on PC. It ends with:

<ItemGroup>
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Contents.json" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon%402x.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-60%402x.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-72.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-72%402x.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-76.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-76%402x.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small%402x.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small-50.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small-50%402x.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small-40.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small-40%402x.png" />
    <ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Contents.json" />
    <ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default.png" />
    <ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default%402x.png" />
    <ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default-Portrait.png" />
    <ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default-568h%402x.png" />
  </ItemGroup>
</Project>


Opening the same file (in pc shared folder) on the Mac with TextEdit, it ends:
 <ItemGroup>
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Contents.json" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon%402x.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-60%402x.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-72.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-72%402x.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-76.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-76%402x.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small%402x.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small-50.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small-50%402x.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small-40.png" />
    <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small-40%402x.png" />
    <ImageAsset Include="Resources\Images.xca


Any idea why ? It might not due to XS, but it makes using XS a huge chore.

Saving the file from Notepad won't change it
Comment 6 Andy 2014-01-12 11:08:44 UTC
(won't change the issue)
Comment 7 Andy 2014-01-12 11:17:51 UTC
Uhm. Created a new file, copied the content and saved it with the same project name (moved the original first).

Now I don't see that problem anymore. However, the file has been automatically saved with ANSI encoding, while the original one in UTF-8.

So I converted it to UTF-8, reloaded it and it still works...

Open in VS, save it, reopen on MAc, it works...

Ideas ?
Comment 8 Vinicius Jarina 2014-01-20 13:13:40 UTC
Andy

So the workflow to repro this is:

* Create a iOS project with XS, enable Assert catalog. 
* Add some images to Icons/LaunchImages
* Close the solution
* Try to open solution with VS 

is that correct?

Thank you.
Comment 9 Andy 2014-01-20 13:38:38 UTC
In the end it's not so easy to repro. The file can't be open correctly in TextEdit too, while on the PC is ok.  

I don't know if assert catalogs are relevant, but give it a try.
Comment 10 Andy 2014-02-03 08:17:27 UTC
I think it's vs2013 or the file system or just the network stack that creates this mess. I'm 99% sure this is not caused by xamarin studio itself. It also happens very rarely but it "sticks" until you create a copy of the corrupted file (which can be read correctly on the PC)

However it is quite annoying when it happens.
Comment 11 Andy 2014-02-03 08:18:10 UTC
It also happens only with proj files. Which seems like a candidate for a vs2013 bug of some sort...
Comment 12 Vinicius Jarina 2014-02-05 07:20:33 UTC
Andy without a procedure to repro the Bug is really hard to find what is wrong is where is the fault. I am moving to NEEDINFO until we have a proper way to repro this behavior ok?
Comment 13 Andy 2014-02-05 07:38:26 UTC
That's mostly what I said, yeah
Comment 14 calvin.fisher 2014-02-28 16:44:10 UTC
Encountered this while doing the following in Xamarin Studio on Mac:

1) Open solution options dialog
2) Make change (to version number), save solution
3) Have save fail because of write error (TFS sets the read-only attribute; XS doesn't edit unless you fix manually)
4) Save again
Comment 16 AMD 2014-03-13 12:19:14 UTC
I have this issue frequently as well. Here are exact steps to reproduce as well as a (very inconvenient) work-around. The short of it is that the error happens when you add a Resource (content or bundled) from VS after having opened the file and worked with it in Xamarin Studio on a Mac. 

Also FWIW the issue is that Windows/Mac/Linux seem to have a different interpretation of a particular hidden character...sadly i don't know what it is. I'm sure one of our guys could write a "clean" script to resolve this. But i don't think you can say you truly support visual studio if you still need to add xib's through Mac but the project can't open on a mac... so i hope you guys would consider this an important issue. We are evaluating Xamarin for a few developers here and so far have encountered many, many issues...

To Reproduce
What you need: Visual Studio 2013 (i woudld guess 2010--not tried--probably has same issue). Mac with Xamarin Studio and XCode up to date.


1. Share a folder on the PC.
2. Create a new iOS blank solution/project using visual studio in the shared folder.
3. Add a folder called Resources if one doesn't exist and a folder called Screens
4. Switch over to Mac (in this case a physical mac on a different PC)
5. Load the solution in Xamarin Studio
6. Confirm the solution works and appears
7. Still on Mac in Xamarin Studio Add a ViewController with the associated xib to the Screens folder
8. Switch back to PC confirm the ViewController and xib are listed in Visual Studio in the Screens folder
9. In visual studio right click on Resources folder->add existing
Choose an image to add. 
10. Build the solution
11. Go over to mac in Xamarin and see that the error indicated above is listed. If you don't see the error close xamarin and open the solution again, or try reload the Project. You will see the solution is fine but the project cannot load and the error message listed above is displayed

HOW TO RESOLVE IF YOU HAVE THIS ERROR:
Xamarin studio will tell you exactly what line the error is on. It will complain about the > character probably because the hidden character being the true culprit. You can delete the entire line and save... but then you don't have your resource listed in Visual Studio!

I (luckily) have Stylus Studio and use that to clean it... I'm assuming any XML editor will be able fix the problem, or maybe even opening the file on the mac in a text-editor? 

How to resolve with Stylus Studio:
Find the CSProj file that you created above and open it in Stylus Studio. Click 
the formatXML button. this will indent your csproj file and i presume remove any offending hidden characters. Save the xml. 

When you go back to the Mac and reload the project the project appears back to normal.
Comment 17 Jeroen Versteege 2014-04-17 07:58:17 UTC
I also experienced this bug and found out an easier way to reproduce and work around it.

1. Create a new solution on a shared folder in Xamarin studio on OSX.
2. Close the solution
3. Open the solution on a Windows machine using Visual Studio 2013
4. Save the, now converted, solution.
5. Open the solution in Xamarin studion, the project now fails to load.

Workaround:

1. Open the solution in Visual studio
2. Right click the project, and click 'unload project'
3. Right click the project file and click 'Edit xxxx.csproj'
4. In the menu bar click [Edit]->[Advanced]->[Tabify selected lines]
5. Save the .csproj file
6. Reload the project in Xamarin studio and it works again.

So it seems Xamarin studio does not like spaces instead of tabs as indentation in csproj files.
Comment 18 Jose Gallardo 2016-12-22 17:34:12 UTC
Marking as resolved fixed.
Please feel free to reopen the issue if you can still reproduce it with current bits.
Thanks!