This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 14811 - PackagePart relationship IDs generated by System.IO.Packaging are not valid XML ids
: PackagePart relationship IDs generated by System.IO.Packaging are not valid X...
Status: RESOLVED FIXED
Product: Class Libraries
Classification: Mono
Component: WindowsBase
: Trunk
: Macintosh Mac OS
: --- normal
: ---
Assigned To: Bugzilla
:
:
:
:
  Show dependency treegraph
 
Reported: 2013-09-17 12:27 EDT by Otto G
Modified: 2014-04-04 12:13 EDT (History)
3 users (show)

See Also:
Tags:
Test Case URL:
External Submit: ---


Attachments

Description Otto G 2013-09-17 12:27:18 EDT
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 EDT
The change was added a while ago and survived
(https://github.com/mono/mono/commit/5a25913631f17071d121875289875c554448db26#diff-9e27cca2c25aa0bcfe85711539d07cea),
closing.

Note You need to log in before you can comment on or make changes to this bug.