Minor fixes in how property lists are serialized to XML, to maintain compatibility with the Apple format:

- NSNumber of "0/real" is serialized as "0.0"
- Data values are not indented
- Newline at the end of the file
- Always use \r as newline
This commit is contained in:
Frederik Carlier
2016-05-24 23:33:34 +02:00
parent 2148034a71
commit 03c95ce192
6 changed files with 111 additions and 5 deletions

View File

@@ -138,6 +138,16 @@ namespace plistcil.test
Assert.IsInstanceOf<double>(weight);
Assert.AreEqual(10d, (double)weight);
}
[Test]
public static void RoundtripTest()
{
var expected = File.ReadAllText(@"test-files\Roundtrip.plist");
var value = XmlPropertyListParser.Parse(new FileInfo(@"test-files\Roundtrip.plist"));
var actual = value.ToXmlPropertyList();
Assert.AreEqual(expected, actual);
}
}
}

View File

@@ -118,6 +118,9 @@
<None Include="test-files\ResourceRules.plist">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="test-files\Roundtrip.plist">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\plist-cil\plist-cil.csproj">

View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>files</key>
<dict>
<key>PkgInfo</key>
<data>
n57qDP4tZfLD1rCS43W0B4LQjzE=
</data>
<key>icon.png</key>
<data>
EUOeOW/HpmiAZeEGzJm8j3hE6vo=
</data>
</dict>
<key>files2</key>
<dict>
<key>PkgInfo</key>
<data>
n57qDP4tZfLD1rCS43W0B4LQjzE=
</data>
<key>icon.png</key>
<data>
EUOeOW/HpmiAZeEGzJm8j3hE6vo=
</data>
</dict>
<key>rules</key>
<dict>
<key>.*</key>
<true/>
<key>Info.plist</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>ResourceRules.plist</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>100</real>
</dict>
</dict>
<key>rules2</key>
<dict>
<key>.*</key>
<true/>
<key>Info.plist</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>ResourceRules.plist</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>100</real>
</dict>
<key>^(Frameworks|SharedFrameworks|Plugins|Plug-ins|XPCServices|Helpers|MacOS)/</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>0.0</real>
</dict>
<key>^[^/]+$</key>
<dict>
<key>top</key>
<true/>
<key>weight</key>
<real>0.0</real>
</dict>
</dict>
</dict>
</plist>