aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.WindowsInstaller/Bind/ValidateComponentGuidsCommand.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/ValidateComponentGuidsCommand.cs')
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/ValidateComponentGuidsCommand.cs63
1 files changed, 0 insertions, 63 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ValidateComponentGuidsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ValidateComponentGuidsCommand.cs
deleted file mode 100644
index 5cad9247..00000000
--- a/src/WixToolset.Core.WindowsInstaller/Bind/ValidateComponentGuidsCommand.cs
+++ /dev/null
@@ -1,63 +0,0 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.Core.WindowsInstaller.Bind
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Linq;
8 using WixToolset.Data;
9 using WixToolset.Data.Symbols;
10 using WixToolset.Extensibility.Services;
11
12 /// <summary>
13 /// Validate that there are no duplicate GUIDs in the output.
14 /// </summary>
15 /// <remarks>
16 /// Duplicate GUIDs without conditions are an error condition; with conditions, it's a
17 /// warning, as the conditions might be mutually exclusive.
18 /// </remarks>
19 internal class ValidateComponentGuidsCommand
20 {
21 internal ValidateComponentGuidsCommand(IMessaging messaging, IntermediateSection section)
22 {
23 this.Messaging = messaging;
24 this.Section = section;
25 }
26
27 private IMessaging Messaging { get; }
28
29 private IntermediateSection Section { get; }
30
31 public void Execute()
32 {
33 var componentGuidConditions = new Dictionary<string, bool>();
34
35 foreach (var componentSymbol in this.Section.Symbols.OfType<ComponentSymbol>())
36 {
37 // We don't care about unmanaged components and if there's a * GUID remaining,
38 // there's already an error that prevented it from being replaced with a real GUID.
39 if (!String.IsNullOrEmpty(componentSymbol.ComponentId) && "*" != componentSymbol.ComponentId)
40 {
41 var thisComponentHasCondition = !String.IsNullOrEmpty(componentSymbol.Condition);
42 var allComponentsHaveConditions = thisComponentHasCondition;
43
44 if (componentGuidConditions.TryGetValue(componentSymbol.ComponentId, out var alreadyCheckedCondition))
45 {
46 allComponentsHaveConditions = thisComponentHasCondition && alreadyCheckedCondition;
47
48 if (allComponentsHaveConditions)
49 {
50 this.Messaging.Write(WarningMessages.DuplicateComponentGuidsMustHaveMutuallyExclusiveConditions(componentSymbol.SourceLineNumbers, componentSymbol.Id.Id, componentSymbol.ComponentId));
51 }
52 else
53 {
54 this.Messaging.Write(ErrorMessages.DuplicateComponentGuids(componentSymbol.SourceLineNumbers, componentSymbol.Id.Id, componentSymbol.ComponentId));
55 }
56 }
57
58 componentGuidConditions[componentSymbol.ComponentId] = allComponentsHaveConditions;
59 }
60 }
61 }
62 }
63}