Bug 14811 - PackagePart relationship IDs generated by System.IO.Packaging are not valid XML ids
Summary: PackagePart relationship IDs generated by System.IO.Packaging are not valid X...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: WindowsBase ()
Version: master
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-09-17 12:27 UTC by Otto G
Modified: 2014-04-04 12:13 UTC (History)
3 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 GitHub or 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 Otto G 2013-09-17 12:27:18 UTC
I compiled the trunk version of EPPlus, a library for working with Excel (xlsx) files (Office Open XML format) with Xamarin Studio 4.0.12 for Mac OS:

http://epplus.codeplex.com/SourceControl/changeset/1c0510c8d300

After patching some hard-coded backslashes and paths in Sample_Main.cs, the sample console application could execute the first few tests. Excel could not read the generated files, though. The identical compiled code emitted from Xamarin Studio but run under a Windows virtual machine with .NET generated readable files.

I found that the problem was related to PackagePart ids. After unzipping the first sample xlsx file, hand-editing workbook.xml and workbook.xml.rels to replace IDs with ones similar to those generated by .NET, and zipping the xlsx file again, Excel could read it without errors or warnings.

After studying the similar bug 1462 (https://bugzilla.xamarin.com/show_bug.cgi?id=1462) I have realized that the issue is that PackagePart generates invalid XML ids. The ids do not need to have the same structure as those generated by .NET, but they do need to start with an XML NameStartChar. (Not that I have tested anything other than a few of the letters a-z with Excel.)

The method NextId() used to be exactly duplicated in Package.cs and PackagePart.cs, but in Package.cs, it has been patched (bug 1462) to prefix the id with two letters (Re).

https://github.com/mono/mono/blob/master/mcs/class/WindowsBase/System.IO.Packaging/Package.cs
https://github.com/mono/mono/blob/master/mcs/class/WindowsBase/System.IO.Packaging/PackagePart.cs

The same patch should be applied to NextId(), or the code should be refactored to use a common ID generator.

I am unfortunately not familiar with the procedure to upload an actual patch to the version control system, but my hope is that someone with more experience might volunteer to do that.

Basically, line 240 of PackagePart.cs needs to be changed to match line 347 of Package.cs. A search in GitHub for "relationshipId.ToString" yields no other files that are in obvious need of being patched in a similar way.
Comment 1 Alexis Christoforides 2014-04-04 12:13:13 UTC
The change was added a while ago and survived (https://github.com/mono/mono/commit/5a25913631f17071d121875289875c554448db26#diff-9e27cca2c25aa0bcfe85711539d07cea), closing.