Bug 14811

Summary: PackagePart relationship IDs generated by System.IO.Packaging are not valid XML ids
Product: [Mono] Class Libraries Reporter: Otto G <otto.giesenfeld>
Component: WindowsBaseAssignee: Bugzilla <bugzilla>
Severity: normal CC: lexas, mono-bugs+mono, otto.giesenfeld
Priority: ---    
Version: master   
Target Milestone: Untriaged   
Hardware: Macintosh   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:

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:


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).


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.