Skip to content

Commit b3d06d4

Browse files
committed
.
1 parent e554728 commit b3d06d4

6 files changed

Lines changed: 53 additions & 2 deletions

src/DeterministicIoPackaging/DeterministicPackage.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ public static partial class DeterministicPackage
1111
new SheetPatcher(),
1212
new WorkbookPatcher(),
1313
new WorkbookRelationshipPatcher(),
14-
new CorePatcher()
14+
new CorePatcher(),
15+
new SheetRelationshipPatcher()
1516
];
1617

1718
static Archive CreateArchive(Stream target) => new(target, ZipArchiveMode.Create, leaveOpen: true);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class SheetRelationshipPatcher : IPatcher
2+
{
3+
public bool IsMatch(Entry entry) =>
4+
entry.FullName.StartsWith("xl/worksheets/_rels/") &&
5+
entry.FullName.EndsWith(".xml.rels");
6+
7+
public void PatchXml(XDocument xml)
8+
{
9+
var root = xml.Root!;
10+
var relationships = root.Elements()
11+
.OrderBy(_ => _.Attribute("Id")!.Value)
12+
.ToList();
13+
root.ReplaceAll(relationships);
14+
}
15+
}

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project>
33
<PropertyGroup>
44
<NoWarn>CS1591;CS0649;CA1416;NU1608;NU1109</NoWarn>
5-
<Version>0.12.0</Version>
5+
<Version>0.13.0</Version>
66
<LangVersion>preview</LangVersion>
77
<AssemblyVersion>1.0.0</AssemblyVersion>
88
<Description>Modify System.IO.Packaging (https://learn.microsoft.com/en-us/dotnet/api/system.io.packaging) files to ensure they are deterministic. Helpful for testing, build reproducibility, security verification, and ensuring package integrity across different build environments.</Description>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
2+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="https://somesite//invitations/2be3ce9e-5921-4184-b9c0-435f8bb9805b" TargetMode="External" />
3+
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="https://somesite//invitations/24a64e93-7752-4caa-be5d-66b6a0d513e2" TargetMode="External" />
4+
</Relationships>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
2+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="https://somesite//invitations/2be3ce9e-5921-4184-b9c0-435f8bb9805b" TargetMode="External" />
3+
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="https://somesite//invitations/24a64e93-7752-4caa-be5d-66b6a0d513e2" TargetMode="External" />
4+
</Relationships>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[TestFixture]
2+
public class SheetRelationshipPatcherTests
3+
{
4+
[Test]
5+
public Task Patch()
6+
{
7+
var xml =
8+
"""
9+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
10+
<Relationships
11+
xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
12+
<Relationship
13+
Id="rId2"
14+
Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"
15+
Target="https://somesite//invitations/24a64e93-7752-4caa-be5d-66b6a0d513e2"
16+
TargetMode="External" />
17+
<Relationship
18+
Id="rId1"
19+
Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"
20+
Target="https://somesite//invitations/2be3ce9e-5921-4184-b9c0-435f8bb9805b"
21+
TargetMode="External" />
22+
</Relationships>
23+
""";
24+
var document = PatchHelper.Patch<SheetRelationshipPatcher>(xml);
25+
return Verify(document);
26+
}
27+
}

0 commit comments

Comments
 (0)