diff options
author | fyodorkor <fyodorkor@gmail.com> | 2023-04-13 22:37:02 +0300 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2023-06-03 01:24:39 -0700 |
commit | 9b78fdffb9c651d5f03cffdde8b0ae6c77598d63 (patch) | |
tree | 645ab2c9685c9138ca5d503606c47cbbc0405c04 | |
parent | 5520259549e1ca3380c8e03d5660e399ed12c48e (diff) | |
download | wix-9b78fdffb9c651d5f03cffdde8b0ae6c77598d63.tar.gz wix-9b78fdffb9c651d5f03cffdde8b0ae6c77598d63.tar.bz2 wix-9b78fdffb9c651d5f03cffdde8b0ae6c77598d63.zip |
Fix XmlConfig decompile to produce schema element, Add unitest for XmlDecomile
-rw-r--r-- | src/ext/Util/test/WixToolsetTest.Util/UtilExtensionFixture.cs | 23 | ||||
-rw-r--r-- | src/ext/Util/wixext/UtilDecompiler.cs | 20 |
2 files changed, 34 insertions, 9 deletions
diff --git a/src/ext/Util/test/WixToolsetTest.Util/UtilExtensionFixture.cs b/src/ext/Util/test/WixToolsetTest.Util/UtilExtensionFixture.cs index e04252da..7cc3a6d4 100644 --- a/src/ext/Util/test/WixToolsetTest.Util/UtilExtensionFixture.cs +++ b/src/ext/Util/test/WixToolsetTest.Util/UtilExtensionFixture.cs | |||
@@ -302,6 +302,29 @@ namespace WixToolsetTest.Util | |||
302 | } | 302 | } |
303 | 303 | ||
304 | [Fact] | 304 | [Fact] |
305 | public void CanRoundtripXmlConfig() | ||
306 | { | ||
307 | var folder = TestData.Get(@"TestData", "XmlConfig"); | ||
308 | var build = new Builder(folder, typeof(UtilExtensionFactory), new[] { folder }); | ||
309 | var output = Path.Combine(folder, "XmlConfigdecompile.xml"); | ||
310 | |||
311 | build.BuildAndDecompileAndBuild(Build, Decompile, output); | ||
312 | |||
313 | var doc = XDocument.Load(output); | ||
314 | var utilElementNames = doc.Descendants().Where(e => e.Name.Namespace == "http://wixtoolset.org/schemas/v4/wxs/util") | ||
315 | .Select(e => e.Name.LocalName) | ||
316 | .ToArray(); | ||
317 | |||
318 | WixAssert.CompareLineByLine(new[] | ||
319 | { | ||
320 | "XmlConfig", | ||
321 | "XmlConfig", | ||
322 | "XmlConfig", | ||
323 | "XmlConfig" | ||
324 | }, utilElementNames); | ||
325 | } | ||
326 | |||
327 | [Fact] | ||
305 | public void CanBuildModuleWithXmlConfig() | 328 | public void CanBuildModuleWithXmlConfig() |
306 | { | 329 | { |
307 | var folder = TestData.Get(@"TestData", "XmlConfigModule"); | 330 | var folder = TestData.Get(@"TestData", "XmlConfigModule"); |
diff --git a/src/ext/Util/wixext/UtilDecompiler.cs b/src/ext/Util/wixext/UtilDecompiler.cs index 0a78201e..52b64889 100644 --- a/src/ext/Util/wixext/UtilDecompiler.cs +++ b/src/ext/Util/wixext/UtilDecompiler.cs | |||
@@ -673,7 +673,7 @@ namespace WixToolset.Util | |||
673 | { | 673 | { |
674 | foreach (var row in table.Rows) | 674 | foreach (var row in table.Rows) |
675 | { | 675 | { |
676 | var flags = row.FieldAsNullableInteger(6) ?? 0; | 676 | var flags = row.FieldAsNullableInteger(7) ?? 0; |
677 | string node = null; | 677 | string node = null; |
678 | string action = null; | 678 | string action = null; |
679 | string on = null; | 679 | string on = null; |
@@ -712,14 +712,16 @@ namespace WixToolset.Util | |||
712 | var xmlConfig = new XElement(UtilConstants.XmlConfigName, | 712 | var xmlConfig = new XElement(UtilConstants.XmlConfigName, |
713 | new XAttribute("Id", row.FieldAsString(0)), | 713 | new XAttribute("Id", row.FieldAsString(0)), |
714 | new XAttribute("File", row.FieldAsString(1)), | 714 | new XAttribute("File", row.FieldAsString(1)), |
715 | new XAttribute("ElementPath", row.FieldAsString(2)), | 715 | AttributeIfNotNull("ElementId", row, 2), |
716 | AttributeIfNotNull("VerifyPath", row, 3), | 716 | AttributeIfNotNull("ElementPath", row, 3), |
717 | AttributeIfNotNull("Name", row, 4), | 717 | AttributeIfNotNull("VerifyPath", row, 4), |
718 | AttributeIfNotNull("Name", row, 5), | ||
719 | AttributeIfNotNull("Value", row, 6), | ||
718 | AttributeIfNotNull("Node", node), | 720 | AttributeIfNotNull("Node", node), |
719 | AttributeIfNotNull("Action", action), | 721 | AttributeIfNotNull("Action", action), |
720 | AttributeIfNotNull("On", on), | 722 | AttributeIfNotNull("On", on), |
721 | AttributeIfTrue("PreserveModifiedDate", 0x00001000 == (flags & 0x00001000)), | 723 | AttributeIfTrue("PreserveModifiedDate", 0x00001000 == (flags & 0x00001000)), |
722 | NumericAttributeIfNotNull("Sequence", row, 8) | 724 | NumericAttributeIfNotNull("Sequence", row, 9) |
723 | ); | 725 | ); |
724 | 726 | ||
725 | this.DecompilerHelper.IndexElement(row, xmlConfig); | 727 | this.DecompilerHelper.IndexElement(row, xmlConfig); |
@@ -967,16 +969,16 @@ namespace WixToolset.Util | |||
967 | /// <param name="tables">Collection of all tables.</param> | 969 | /// <param name="tables">Collection of all tables.</param> |
968 | private void FinalizeXmlConfigTable(TableIndexedCollection tables) | 970 | private void FinalizeXmlConfigTable(TableIndexedCollection tables) |
969 | { | 971 | { |
970 | if (tables.TryGetTable("XmlConfig", out var xmlConfigTable)) | 972 | if (tables.TryGetTable("Wix4XmlConfig", out var xmlConfigTable)) |
971 | { | 973 | { |
972 | foreach (var row in xmlConfigTable.Rows) | 974 | foreach (var row in xmlConfigTable.Rows) |
973 | { | 975 | { |
974 | var xmlConfig = this.DecompilerHelper.GetIndexedElement(row); | 976 | var xmlConfig = this.DecompilerHelper.GetIndexedElement(row); |
975 | 977 | ||
976 | if (null == row[6] || 0 == (int)row[6]) | 978 | if (null != row[2]) |
977 | { | 979 | { |
978 | var id = row.FieldAsString(2); | 980 | var id = row.FieldAsString(2); |
979 | if (this.DecompilerHelper.TryGetIndexedElement("XmlConfig", id, out var parentXmlConfig)) | 981 | if (this.DecompilerHelper.TryGetIndexedElement("Wix4XmlConfig", id, out var parentXmlConfig)) |
980 | { | 982 | { |
981 | parentXmlConfig.Add(xmlConfig); | 983 | parentXmlConfig.Add(xmlConfig); |
982 | } | 984 | } |
@@ -987,7 +989,7 @@ namespace WixToolset.Util | |||
987 | } | 989 | } |
988 | else | 990 | else |
989 | { | 991 | { |
990 | var componentId = row.FieldAsString(7); | 992 | var componentId = row.FieldAsString(8); |
991 | if (this.DecompilerHelper.TryGetIndexedElement("Component", componentId, out var component)) | 993 | if (this.DecompilerHelper.TryGetIndexedElement("Component", componentId, out var component)) |
992 | { | 994 | { |
993 | component.Add(xmlConfig); | 995 | component.Add(xmlConfig); |