diff options
author | Bevan Weiss <bevan.weiss@gmail.com> | 2025-01-18 23:01:30 +1100 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2025-03-03 06:35:56 -0800 |
commit | 61d789db5de8613c51df1e7db94f459aadbd3ca8 (patch) | |
tree | be35d8cddab1d70df621949afd5ef84456602a37 /src | |
parent | 3b9efe831c6a408cd71a7bea6fa95f65c141911b (diff) | |
download | wix-61d789db5de8613c51df1e7db94f459aadbd3ca8.tar.gz wix-61d789db5de8613c51df1e7db94f459aadbd3ca8.tar.bz2 wix-61d789db5de8613c51df1e7db94f459aadbd3ca8.zip |
Add a basic unit test for the round msmq decompiler round trip.
Needed fix up for Group decompiler to work correctly, adding to Index,
and fixing where the Group name column is located.
Signed-off-by: Bevan Weiss <bevan.weiss@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/ext/Msmq/test/WixToolsetTest.Msmq/MsmqExtensionFixture.cs | 32 | ||||
-rw-r--r-- | src/ext/Msmq/wixext/MsmqDecompiler.cs | 38 | ||||
-rw-r--r-- | src/ext/Msmq/wixext/MsmqExtensionFactory.cs | 1 | ||||
-rw-r--r-- | src/ext/Msmq/wixext/MsmqTableDefinitions.cs | 4 | ||||
-rw-r--r-- | src/ext/Util/wixext/UtilDecompiler.cs | 6 |
5 files changed, 59 insertions, 22 deletions
diff --git a/src/ext/Msmq/test/WixToolsetTest.Msmq/MsmqExtensionFixture.cs b/src/ext/Msmq/test/WixToolsetTest.Msmq/MsmqExtensionFixture.cs index 424d3d5b..c89d138a 100644 --- a/src/ext/Msmq/test/WixToolsetTest.Msmq/MsmqExtensionFixture.cs +++ b/src/ext/Msmq/test/WixToolsetTest.Msmq/MsmqExtensionFixture.cs | |||
@@ -2,7 +2,10 @@ | |||
2 | 2 | ||
3 | namespace WixToolsetTest.Msmq | 3 | namespace WixToolsetTest.Msmq |
4 | { | 4 | { |
5 | using System.Data; | ||
6 | using System.IO; | ||
5 | using System.Linq; | 7 | using System.Linq; |
8 | using System.Xml.Linq; | ||
6 | using WixInternal.TestSupport; | 9 | using WixInternal.TestSupport; |
7 | using WixInternal.Core.TestPackage; | 10 | using WixInternal.Core.TestPackage; |
8 | using WixToolset.Msmq; | 11 | using WixToolset.Msmq; |
@@ -34,6 +37,29 @@ namespace WixToolsetTest.Msmq | |||
34 | }, results); | 37 | }, results); |
35 | } | 38 | } |
36 | 39 | ||
40 | [Fact] | ||
41 | public void CanRoundtripMessageQueue() | ||
42 | { | ||
43 | var folder = TestData.Get(@"TestData\UsingMessageQueue"); | ||
44 | var build = new Builder(folder, new[] { typeof(MsmqExtensionFactory), typeof(UtilExtensionFactory) }, new[] { folder }); | ||
45 | var output = Path.Combine(folder, "MessageQueueDecompile.xml"); | ||
46 | |||
47 | build.BuildAndDecompileAndBuild(Build, Decompile, output); | ||
48 | |||
49 | var doc = XDocument.Load(output); | ||
50 | var actual = doc.Descendants() | ||
51 | .Where(e => e.Name.Namespace == "http://wixtoolset.org/schemas/v4/wxs/msmq") | ||
52 | .Select(fe => new { Name = fe.Name.LocalName, Id = fe.Attributes().Where(a => a.Name == "Id").Select(a => a.Value).FirstOrDefault() }) | ||
53 | .ToArray(); | ||
54 | |||
55 | WixAssert.CompareLineByLine(new[] | ||
56 | { | ||
57 | "MessageQueue:TestMQ", | ||
58 | "MessageQueuePermission:TestMQ_TestUser", | ||
59 | "MessageQueuePermission:TestMQ_TestGroup", | ||
60 | }, actual.Select(a => $"{a.Name}:{a.Id}").ToArray()); | ||
61 | } | ||
62 | |||
37 | private static void Build(string[] args) | 63 | private static void Build(string[] args) |
38 | { | 64 | { |
39 | args = args.Concat(new[] { "-arch", "arm64" }).ToArray(); | 65 | args = args.Concat(new[] { "-arch", "arm64" }).ToArray(); |
@@ -41,5 +67,11 @@ namespace WixToolsetTest.Msmq | |||
41 | var result = WixRunner.Execute(args); | 67 | var result = WixRunner.Execute(args); |
42 | result.AssertSuccess(); | 68 | result.AssertSuccess(); |
43 | } | 69 | } |
70 | |||
71 | private static void Decompile(string[] args) | ||
72 | { | ||
73 | var result = WixRunner.Execute(args); | ||
74 | result.AssertSuccess(); | ||
75 | } | ||
44 | } | 76 | } |
45 | } | 77 | } |
diff --git a/src/ext/Msmq/wixext/MsmqDecompiler.cs b/src/ext/Msmq/wixext/MsmqDecompiler.cs index 53734e88..44bd8aba 100644 --- a/src/ext/Msmq/wixext/MsmqDecompiler.cs +++ b/src/ext/Msmq/wixext/MsmqDecompiler.cs | |||
@@ -144,17 +144,17 @@ namespace WixToolset.Msmq | |||
144 | 144 | ||
145 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueueAttributes.Authenticate)) | 145 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueueAttributes.Authenticate)) |
146 | { | 146 | { |
147 | messageQueue.Add(new XAttribute("Authenticate", YesNoType.Yes)); | 147 | messageQueue.Add(new XAttribute("Authenticate", "yes")); |
148 | } | 148 | } |
149 | 149 | ||
150 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueueAttributes.Journal)) | 150 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueueAttributes.Journal)) |
151 | { | 151 | { |
152 | messageQueue.Add(new XAttribute("Journal", YesNoType.Yes)); | 152 | messageQueue.Add(new XAttribute("Journal", "yes")); |
153 | } | 153 | } |
154 | 154 | ||
155 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueueAttributes.Transactional)) | 155 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueueAttributes.Transactional)) |
156 | { | 156 | { |
157 | messageQueue.Add(new XAttribute("Transactional", YesNoType.Yes)); | 157 | messageQueue.Add(new XAttribute("Transactional", "yes")); |
158 | } | 158 | } |
159 | 159 | ||
160 | this.DecompilerHelper.IndexElement(row, messageQueue); | 160 | this.DecompilerHelper.IndexElement(row, messageQueue); |
@@ -337,82 +337,82 @@ namespace WixToolset.Msmq | |||
337 | 337 | ||
338 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.DeleteMessage)) | 338 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.DeleteMessage)) |
339 | { | 339 | { |
340 | element.Add("DeleteMessage", YesNoType.Yes); | 340 | element.Add(new XAttribute("DeleteMessage", "yes")); |
341 | } | 341 | } |
342 | 342 | ||
343 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.PeekMessage)) | 343 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.PeekMessage)) |
344 | { | 344 | { |
345 | element.Add("PeekMessage", YesNoType.Yes); | 345 | element.Add(new XAttribute("PeekMessage", "yes")); |
346 | } | 346 | } |
347 | 347 | ||
348 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.WriteMessage)) | 348 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.WriteMessage)) |
349 | { | 349 | { |
350 | element.Add("WriteMessage", YesNoType.Yes); | 350 | element.Add(new XAttribute("WriteMessage", "yes")); |
351 | } | 351 | } |
352 | 352 | ||
353 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.DeleteJournalMessage)) | 353 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.DeleteJournalMessage)) |
354 | { | 354 | { |
355 | element.Add("DeleteJournalMessage", YesNoType.Yes); | 355 | element.Add(new XAttribute("DeleteJournalMessage", "yes")); |
356 | } | 356 | } |
357 | 357 | ||
358 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.SetQueueProperties)) | 358 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.SetQueueProperties)) |
359 | { | 359 | { |
360 | element.Add("SetQueueProperties", YesNoType.Yes); | 360 | element.Add(new XAttribute("SetQueueProperties", "yes")); |
361 | } | 361 | } |
362 | 362 | ||
363 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.GetQueueProperties)) | 363 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.GetQueueProperties)) |
364 | { | 364 | { |
365 | element.Add("GetQueueProperties", YesNoType.Yes); | 365 | element.Add(new XAttribute("GetQueueProperties", "yes")); |
366 | } | 366 | } |
367 | 367 | ||
368 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.DeleteQueue)) | 368 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.DeleteQueue)) |
369 | { | 369 | { |
370 | element.Add("DeleteQueue", YesNoType.Yes); | 370 | element.Add(new XAttribute("DeleteQueue", "yes")); |
371 | } | 371 | } |
372 | 372 | ||
373 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.GetQueuePermissions)) | 373 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.GetQueuePermissions)) |
374 | { | 374 | { |
375 | element.Add("GetQueuePermissions", YesNoType.Yes); | 375 | element.Add(new XAttribute("GetQueuePermissions", "yes")); |
376 | } | 376 | } |
377 | 377 | ||
378 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.ChangeQueuePermissions)) | 378 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.ChangeQueuePermissions)) |
379 | { | 379 | { |
380 | element.Add("ChangeQueuePermissions", YesNoType.Yes); | 380 | element.Add(new XAttribute("ChangeQueuePermissions", "yes")); |
381 | } | 381 | } |
382 | 382 | ||
383 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.TakeQueueOwnership)) | 383 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.TakeQueueOwnership)) |
384 | { | 384 | { |
385 | element.Add("TakeQueueOwnership", YesNoType.Yes); | 385 | element.Add(new XAttribute("TakeQueueOwnership", "yes")); |
386 | } | 386 | } |
387 | 387 | ||
388 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.ReceiveMessage)) | 388 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.ReceiveMessage)) |
389 | { | 389 | { |
390 | element.Add("ReceiveMessage", YesNoType.Yes); | 390 | element.Add(new XAttribute("ReceiveMessage", "yes")); |
391 | } | 391 | } |
392 | 392 | ||
393 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.ReceiveJournalMessage)) | 393 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.ReceiveJournalMessage)) |
394 | { | 394 | { |
395 | element.Add("ReceiveJournalMessage", YesNoType.Yes); | 395 | element.Add(new XAttribute("ReceiveJournalMessage", "yes")); |
396 | } | 396 | } |
397 | 397 | ||
398 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.QueueGenericRead)) | 398 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.QueueGenericRead)) |
399 | { | 399 | { |
400 | element.Add("QueueGenericRead", YesNoType.Yes); | 400 | element.Add(new XAttribute("QueueGenericRead", "yes")); |
401 | } | 401 | } |
402 | 402 | ||
403 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.QueueGenericWrite)) | 403 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.QueueGenericWrite)) |
404 | { | 404 | { |
405 | element.Add("QueueGenericWrite", YesNoType.Yes); | 405 | element.Add(new XAttribute("QueueGenericWrite", "yes")); |
406 | } | 406 | } |
407 | 407 | ||
408 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.QueueGenericExecute)) | 408 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.QueueGenericExecute)) |
409 | { | 409 | { |
410 | element.Add("QueueGenericExecute", YesNoType.Yes); | 410 | element.Add(new XAttribute("QueueGenericExecute", "yes")); |
411 | } | 411 | } |
412 | 412 | ||
413 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.QueueGenericAll)) | 413 | if (0 != (attributes & (int)MsmqCompiler.MqiMessageQueuePermission.QueueGenericAll)) |
414 | { | 414 | { |
415 | element.Add("QueueGenericAll", YesNoType.Yes); | 415 | element.Add(new XAttribute("QueueGenericAll", "yes")); |
416 | } | 416 | } |
417 | } | 417 | } |
418 | } | 418 | } |
diff --git a/src/ext/Msmq/wixext/MsmqExtensionFactory.cs b/src/ext/Msmq/wixext/MsmqExtensionFactory.cs index de9f786d..6bb3fb64 100644 --- a/src/ext/Msmq/wixext/MsmqExtensionFactory.cs +++ b/src/ext/Msmq/wixext/MsmqExtensionFactory.cs | |||
@@ -11,6 +11,7 @@ namespace WixToolset.Msmq | |||
11 | protected override IReadOnlyCollection<Type> ExtensionTypes => new[] | 11 | protected override IReadOnlyCollection<Type> ExtensionTypes => new[] |
12 | { | 12 | { |
13 | typeof(MsmqCompiler), | 13 | typeof(MsmqCompiler), |
14 | typeof(MsmqDecompiler), | ||
14 | typeof(MsmqExtensionData), | 15 | typeof(MsmqExtensionData), |
15 | typeof(MsmqWindowsInstallerBackendBinderExtension), | 16 | typeof(MsmqWindowsInstallerBackendBinderExtension), |
16 | }; | 17 | }; |
diff --git a/src/ext/Msmq/wixext/MsmqTableDefinitions.cs b/src/ext/Msmq/wixext/MsmqTableDefinitions.cs index 610e9409..0046c7ec 100644 --- a/src/ext/Msmq/wixext/MsmqTableDefinitions.cs +++ b/src/ext/Msmq/wixext/MsmqTableDefinitions.cs | |||
@@ -34,7 +34,7 @@ namespace WixToolset.Msmq | |||
34 | new ColumnDefinition("MessageQueueUserPermission", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, modularizeType: ColumnModularizeType.Column), | 34 | new ColumnDefinition("MessageQueueUserPermission", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, modularizeType: ColumnModularizeType.Column), |
35 | new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, modularizeType: ColumnModularizeType.Column), | 35 | new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, modularizeType: ColumnModularizeType.Column), |
36 | new ColumnDefinition("MessageQueue_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Wix4MessageQueue", keyColumn: 1, modularizeType: ColumnModularizeType.Column), | 36 | new ColumnDefinition("MessageQueue_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Wix4MessageQueue", keyColumn: 1, modularizeType: ColumnModularizeType.Column), |
37 | new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, modularizeType: ColumnModularizeType.Column), | 37 | new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Wix4User", keyColumn: 1, modularizeType: ColumnModularizeType.Column), |
38 | new ColumnDefinition("Permissions", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Unknown), | 38 | new ColumnDefinition("Permissions", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Unknown), |
39 | }, | 39 | }, |
40 | symbolIdIsPrimaryKey: true | 40 | symbolIdIsPrimaryKey: true |
@@ -48,7 +48,7 @@ namespace WixToolset.Msmq | |||
48 | new ColumnDefinition("MessageQueueGroupPermission", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, modularizeType: ColumnModularizeType.Column), | 48 | new ColumnDefinition("MessageQueueGroupPermission", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, modularizeType: ColumnModularizeType.Column), |
49 | new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, modularizeType: ColumnModularizeType.Column), | 49 | new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, modularizeType: ColumnModularizeType.Column), |
50 | new ColumnDefinition("MessageQueue_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Wix4MessageQueue", keyColumn: 1, modularizeType: ColumnModularizeType.Column), | 50 | new ColumnDefinition("MessageQueue_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Wix4MessageQueue", keyColumn: 1, modularizeType: ColumnModularizeType.Column), |
51 | new ColumnDefinition("Group_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, modularizeType: ColumnModularizeType.Column), | 51 | new ColumnDefinition("Group_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Wix4Group", keyColumn: 1, modularizeType: ColumnModularizeType.Column), |
52 | new ColumnDefinition("Permissions", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Unknown), | 52 | new ColumnDefinition("Permissions", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Unknown), |
53 | }, | 53 | }, |
54 | symbolIdIsPrimaryKey: true | 54 | symbolIdIsPrimaryKey: true |
diff --git a/src/ext/Util/wixext/UtilDecompiler.cs b/src/ext/Util/wixext/UtilDecompiler.cs index 1f3079d8..55323e15 100644 --- a/src/ext/Util/wixext/UtilDecompiler.cs +++ b/src/ext/Util/wixext/UtilDecompiler.cs | |||
@@ -435,11 +435,15 @@ namespace WixToolset.Util | |||
435 | { | 435 | { |
436 | foreach (var row in table.Rows) | 436 | foreach (var row in table.Rows) |
437 | { | 437 | { |
438 | this.DecompilerHelper.AddElementToRoot(UtilConstants.GroupName, | 438 | var group = new XElement(UtilConstants.GroupName, |
439 | new XAttribute("Id", row.FieldAsString(0)), | 439 | new XAttribute("Id", row.FieldAsString(0)), |
440 | new XAttribute("Name", row.FieldAsString(2)), | 440 | new XAttribute("Name", row.FieldAsString(2)), |
441 | AttributeIfNotNull("Domain", row, 3) | 441 | AttributeIfNotNull("Domain", row, 3) |
442 | ); | 442 | ); |
443 | |||
444 | this.DecompilerHelper.AddElementToRoot(group); | ||
445 | |||
446 | this.DecompilerHelper.IndexElement(row, group); | ||
443 | } | 447 | } |
444 | } | 448 | } |
445 | /// <summary> | 449 | /// <summary> |