diff options
| author | Rob Mensching <rob@firegiant.com> | 2021-03-23 01:24:54 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2021-03-23 01:30:11 -0700 |
| commit | 734be59ad7edaa1444f713338fcdbc0c4b9c273b (patch) | |
| tree | 1b9c6aa693f861abddee82e944758b16a5552901 /src | |
| parent | 977b748b499e02f7e5226416b1cf5cfcf3842129 (diff) | |
| download | wix-734be59ad7edaa1444f713338fcdbc0c4b9c273b.tar.gz wix-734be59ad7edaa1444f713338fcdbc0c4b9c273b.tar.bz2 wix-734be59ad7edaa1444f713338fcdbc0c4b9c273b.zip | |
Minor code clean up
Diffstat (limited to 'src')
5 files changed, 33 insertions, 88 deletions
diff --git a/src/WixToolset.Core.Burn/Bind/GenerateManifestDataFromIRCommand.cs b/src/WixToolset.Core.Burn/Bind/GenerateManifestDataFromIRCommand.cs index d4a69513..a76f84ec 100644 --- a/src/WixToolset.Core.Burn/Bind/GenerateManifestDataFromIRCommand.cs +++ b/src/WixToolset.Core.Burn/Bind/GenerateManifestDataFromIRCommand.cs | |||
| @@ -16,7 +16,7 @@ namespace WixToolset.Core.Burn.Bind | |||
| 16 | 16 | ||
| 17 | internal class GenerateManifestDataFromIRCommand | 17 | internal class GenerateManifestDataFromIRCommand |
| 18 | { | 18 | { |
| 19 | public GenerateManifestDataFromIRCommand(IMessaging messaging, IntermediateSection section, IEnumerable<IBurnBackendBinderExtension> backendExtensions, IBurnBackendHelper backendHelper, IDictionary<string, IList<IntermediateSymbol>> extensionSearchSymbolsById) | 19 | public GenerateManifestDataFromIRCommand(IMessaging messaging, IntermediateSection section, IEnumerable<IBurnBackendBinderExtension> backendExtensions, IBurnBackendHelper backendHelper, IDictionary<string, IEnumerable<IntermediateSymbol>> extensionSearchSymbolsById) |
| 20 | { | 20 | { |
| 21 | this.Messaging = messaging; | 21 | this.Messaging = messaging; |
| 22 | this.Section = section; | 22 | this.Section = section; |
| @@ -29,7 +29,7 @@ namespace WixToolset.Core.Burn.Bind | |||
| 29 | 29 | ||
| 30 | private IBurnBackendHelper BackendHelper { get; } | 30 | private IBurnBackendHelper BackendHelper { get; } |
| 31 | 31 | ||
| 32 | private IDictionary<string, IList<IntermediateSymbol>> ExtensionSearchSymbolsById { get; } | 32 | private IDictionary<string, IEnumerable<IntermediateSymbol>> ExtensionSearchSymbolsById { get; } |
| 33 | 33 | ||
| 34 | private IMessaging Messaging { get; } | 34 | private IMessaging Messaging { get; } |
| 35 | 35 | ||
diff --git a/src/WixToolset.Core.Burn/Bundles/OrderSearchesCommand.cs b/src/WixToolset.Core.Burn/Bundles/OrderSearchesCommand.cs index dcb4733e..f3afd64e 100644 --- a/src/WixToolset.Core.Burn/Bundles/OrderSearchesCommand.cs +++ b/src/WixToolset.Core.Burn/Bundles/OrderSearchesCommand.cs | |||
| @@ -23,33 +23,28 @@ namespace WixToolset.Core.Burn.Bundles | |||
| 23 | 23 | ||
| 24 | private IntermediateSection Section { get; } | 24 | private IntermediateSection Section { get; } |
| 25 | 25 | ||
| 26 | public IDictionary<string, IList<IntermediateSymbol>> ExtensionSearchSymbolsByExtensionId { get; private set; } | 26 | public IDictionary<string, IEnumerable<IntermediateSymbol>> ExtensionSearchSymbolsByExtensionId { get; private set; } |
| 27 | 27 | ||
| 28 | public IList<ISearchFacade> OrderedSearchFacades { get; private set; } | 28 | public IEnumerable<ISearchFacade> OrderedSearchFacades { get; private set; } |
| 29 | 29 | ||
| 30 | public void Execute() | 30 | public void Execute() |
| 31 | { | 31 | { |
| 32 | this.ExtensionSearchSymbolsByExtensionId = new Dictionary<string, IList<IntermediateSymbol>>(); | 32 | this.ExtensionSearchSymbolsByExtensionId = new Dictionary<string, IEnumerable<IntermediateSymbol>>(); |
| 33 | this.OrderedSearchFacades = new List<ISearchFacade>(); | 33 | this.OrderedSearchFacades = Array.Empty<ISearchFacade>(); |
| 34 | 34 | ||
| 35 | var searchRelationSymbols = this.Section.Symbols.OfType<WixSearchRelationSymbol>().ToList(); | 35 | var searchSymbols = this.Section.Symbols.OfType<WixSearchSymbol>().ToDictionary(t => t.Id.Id); |
| 36 | var searchSymbols = this.Section.Symbols.OfType<WixSearchSymbol>().ToList(); | ||
| 37 | if (searchSymbols.Count == 0) | 36 | if (searchSymbols.Count == 0) |
| 38 | { | 37 | { |
| 39 | // nothing to do! | 38 | // Nothing to do! |
| 40 | return; | 39 | return; |
| 41 | } | 40 | } |
| 42 | 41 | ||
| 43 | var symbolDictionary = searchSymbols.ToDictionary(t => t.Id.Id); | ||
| 44 | |||
| 45 | var constraints = new Constraints(); | 42 | var constraints = new Constraints(); |
| 46 | if (searchRelationSymbols.Count > 0) | 43 | |
| 44 | // Add relational info to our data... | ||
| 45 | foreach (var searchRelationSymbol in this.Section.Symbols.OfType<WixSearchRelationSymbol>()) | ||
| 47 | { | 46 | { |
| 48 | // add relational info to our data... | 47 | constraints.AddConstraint(searchRelationSymbol.Id.Id, searchRelationSymbol.ParentSearchRef); |
| 49 | foreach (var searchRelationSymbol in searchRelationSymbols) | ||
| 50 | { | ||
| 51 | constraints.AddConstraint(searchRelationSymbol.Id.Id, searchRelationSymbol.ParentSearchRef); | ||
| 52 | } | ||
| 53 | } | 48 | } |
| 54 | 49 | ||
| 55 | this.FindCircularReference(constraints); | 50 | this.FindCircularReference(constraints); |
| @@ -67,10 +62,13 @@ namespace WixToolset.Core.Burn.Bundles | |||
| 67 | // lexicographically at each step to ensure a deterministic ordering | 62 | // lexicographically at each step to ensure a deterministic ordering |
| 68 | // based on 'after' dependencies and ID. | 63 | // based on 'after' dependencies and ID. |
| 69 | var sorter = new TopologicalSort(); | 64 | var sorter = new TopologicalSort(); |
| 70 | var sortedIds = sorter.Sort(symbolDictionary.Keys, constraints); | 65 | var sortedIds = sorter.Sort(searchSymbols.Keys, constraints); |
| 71 | 66 | ||
| 72 | // Now, create the search facades with the searches in order... | 67 | // Now, create the search facades with the searches in order... |
| 73 | this.OrderSearches(sortedIds, symbolDictionary); | 68 | (var orderedSearchFacades, var extensionSearchSymbolsByExtensionId) = this.OrderSearches(sortedIds, searchSymbols); |
| 69 | |||
| 70 | this.OrderedSearchFacades = orderedSearchFacades; | ||
| 71 | this.ExtensionSearchSymbolsByExtensionId = extensionSearchSymbolsByExtensionId; | ||
| 74 | } | 72 | } |
| 75 | 73 | ||
| 76 | /// <summary> | 74 | /// <summary> |
| @@ -102,11 +100,11 @@ namespace WixToolset.Core.Burn.Bundles | |||
| 102 | /// <remarks>This is not particularly performant, but it works.</remarks> | 100 | /// <remarks>This is not particularly performant, but it works.</remarks> |
| 103 | private void FindCircularReference(Constraints constraints) | 101 | private void FindCircularReference(Constraints constraints) |
| 104 | { | 102 | { |
| 105 | foreach (string id in constraints.Keys) | 103 | foreach (var id in constraints.Keys) |
| 106 | { | 104 | { |
| 107 | var seenIds = new List<string>(); | 105 | var seenIds = new List<string>(); |
| 108 | string chain = null; | 106 | |
| 109 | if (this.FindCircularReference(constraints, id, id, seenIds, out chain)) | 107 | if (this.FindCircularReference(constraints, id, id, seenIds, out var chain)) |
| 110 | { | 108 | { |
| 111 | // We will show a separate message for every ID that's in | 109 | // We will show a separate message for every ID that's in |
| 112 | // the loop. We could bail after the first one, but then | 110 | // the loop. We could bail after the first one, but then |
| @@ -313,8 +311,11 @@ namespace WixToolset.Core.Burn.Bundles | |||
| 313 | } | 311 | } |
| 314 | } | 312 | } |
| 315 | 313 | ||
| 316 | private void OrderSearches(List<string> sortedIds, Dictionary<string, WixSearchSymbol> searchSymbolDictionary) | 314 | private (IEnumerable<ISearchFacade>, Dictionary<string, IEnumerable<IntermediateSymbol>>) OrderSearches(IEnumerable<string> sortedIds, Dictionary<string, WixSearchSymbol> searchSymbolDictionary) |
| 317 | { | 315 | { |
| 316 | var orderedSearchFacades = new List<ISearchFacade>(); | ||
| 317 | var extensionSearchSymbolsByExtensionId = new Dictionary<string, List<IntermediateSymbol>>(); | ||
| 318 | |||
| 318 | // TODO: Although the WixSearch tables are defined in the Util extension, | 319 | // TODO: Although the WixSearch tables are defined in the Util extension, |
| 319 | // the Bundle Binder has to know all about them. We hope to revisit all | 320 | // the Bundle Binder has to know all about them. We hope to revisit all |
| 320 | // of this in the 4.0 timeframe. | 321 | // of this in the 4.0 timeframe. |
| @@ -334,22 +335,23 @@ namespace WixToolset.Core.Burn.Bundles | |||
| 334 | foreach (var searchId in sortedIds) | 335 | foreach (var searchId in sortedIds) |
| 335 | { | 336 | { |
| 336 | var searchSymbol = searchSymbolDictionary[searchId]; | 337 | var searchSymbol = searchSymbolDictionary[searchId]; |
| 338 | |||
| 337 | if (legacySearchesById.TryGetValue(searchId, out var specificSearchSymbol)) | 339 | if (legacySearchesById.TryGetValue(searchId, out var specificSearchSymbol)) |
| 338 | { | 340 | { |
| 339 | this.OrderedSearchFacades.Add(new LegacySearchFacade(searchSymbol, specificSearchSymbol)); | 341 | orderedSearchFacades.Add(new LegacySearchFacade(searchSymbol, specificSearchSymbol)); |
| 340 | } | 342 | } |
| 341 | else if (setVariablesById.TryGetValue(searchId, out var setVariableSymbol)) | 343 | else if (setVariablesById.TryGetValue(searchId, out var setVariableSymbol)) |
| 342 | { | 344 | { |
| 343 | this.OrderedSearchFacades.Add(new SetVariableSearchFacade(searchSymbol, setVariableSymbol)); | 345 | orderedSearchFacades.Add(new SetVariableSearchFacade(searchSymbol, setVariableSymbol)); |
| 344 | } | 346 | } |
| 345 | else if (extensionSearchesById.TryGetValue(searchId, out var extensionSearchSymbol)) | 347 | else if (extensionSearchesById.TryGetValue(searchId, out var extensionSearchSymbol)) |
| 346 | { | 348 | { |
| 347 | this.OrderedSearchFacades.Add(new ExtensionSearchFacade(searchSymbol)); | 349 | orderedSearchFacades.Add(new ExtensionSearchFacade(searchSymbol)); |
| 348 | 350 | ||
| 349 | if (!this.ExtensionSearchSymbolsByExtensionId.TryGetValue(searchSymbol.BundleExtensionRef, out var extensionSearchSymbols)) | 351 | if (!extensionSearchSymbolsByExtensionId.TryGetValue(searchSymbol.BundleExtensionRef, out var extensionSearchSymbols)) |
| 350 | { | 352 | { |
| 351 | extensionSearchSymbols = new List<IntermediateSymbol>(); | 353 | extensionSearchSymbols = new List<IntermediateSymbol>(); |
| 352 | this.ExtensionSearchSymbolsByExtensionId[searchSymbol.BundleExtensionRef] = extensionSearchSymbols; | 354 | extensionSearchSymbolsByExtensionId[searchSymbol.BundleExtensionRef] = extensionSearchSymbols; |
| 353 | } | 355 | } |
| 354 | extensionSearchSymbols.Add(extensionSearchSymbol); | 356 | extensionSearchSymbols.Add(extensionSearchSymbol); |
| 355 | } | 357 | } |
| @@ -358,6 +360,8 @@ namespace WixToolset.Core.Burn.Bundles | |||
| 358 | this.Messaging.Write(ErrorMessages.MissingBundleSearch(searchSymbol.SourceLineNumbers, searchId)); | 360 | this.Messaging.Write(ErrorMessages.MissingBundleSearch(searchSymbol.SourceLineNumbers, searchId)); |
| 359 | } | 361 | } |
| 360 | } | 362 | } |
| 363 | |||
| 364 | return (orderedSearchFacades, extensionSearchSymbolsByExtensionId.ToDictionary(kvp => kvp.Key, kvp => (IEnumerable<IntermediateSymbol>)kvp.Value)); | ||
| 361 | } | 365 | } |
| 362 | } | 366 | } |
| 363 | } | 367 | } |
diff --git a/src/WixToolset.Core.Burn/Bundles/ProcessPayloadsCommand.cs b/src/WixToolset.Core.Burn/Bundles/ProcessPayloadsCommand.cs index adbb41b1..fa70251a 100644 --- a/src/WixToolset.Core.Burn/Bundles/ProcessPayloadsCommand.cs +++ b/src/WixToolset.Core.Burn/Bundles/ProcessPayloadsCommand.cs | |||
| @@ -15,10 +15,8 @@ namespace WixToolset.Core.Burn.Bundles | |||
| 15 | 15 | ||
| 16 | internal class ProcessPayloadsCommand | 16 | internal class ProcessPayloadsCommand |
| 17 | { | 17 | { |
| 18 | public ProcessPayloadsCommand(IServiceProvider serviceProvider, IBackendHelper backendHelper, IPayloadHarvester payloadHarvester, IEnumerable<WixBundlePayloadSymbol> payloads, PackagingType defaultPackaging, string layoutDirectory) | 18 | public ProcessPayloadsCommand(IBackendHelper backendHelper, IPayloadHarvester payloadHarvester, IEnumerable<WixBundlePayloadSymbol> payloads, PackagingType defaultPackaging, string layoutDirectory) |
| 19 | { | 19 | { |
| 20 | this.Messaging = serviceProvider.GetService<IMessaging>(); | ||
| 21 | |||
| 22 | this.BackendHelper = backendHelper; | 20 | this.BackendHelper = backendHelper; |
| 23 | this.PayloadHarvester = payloadHarvester; | 21 | this.PayloadHarvester = payloadHarvester; |
| 24 | this.Payloads = payloads; | 22 | this.Payloads = payloads; |
| @@ -30,8 +28,6 @@ namespace WixToolset.Core.Burn.Bundles | |||
| 30 | 28 | ||
| 31 | public IEnumerable<ITrackedFile> TrackedFiles { get; private set; } | 29 | public IEnumerable<ITrackedFile> TrackedFiles { get; private set; } |
| 32 | 30 | ||
| 33 | private IMessaging Messaging { get; } | ||
| 34 | |||
| 35 | private IBackendHelper BackendHelper { get; } | 31 | private IBackendHelper BackendHelper { get; } |
| 36 | 32 | ||
| 37 | private IPayloadHarvester PayloadHarvester { get; } | 33 | private IPayloadHarvester PayloadHarvester { get; } |
diff --git a/src/WixToolset.Core/Link/ConnectToFeature.cs b/src/WixToolset.Core/Link/ConnectToFeature.cs index dd95f2db..e9a739a1 100644 --- a/src/WixToolset.Core/Link/ConnectToFeature.cs +++ b/src/WixToolset.Core/Link/ConnectToFeature.cs | |||
| @@ -15,16 +15,6 @@ namespace WixToolset.Core.Link | |||
| 15 | /// </summary> | 15 | /// </summary> |
| 16 | /// <param name="section">Section this connect belongs to.</param> | 16 | /// <param name="section">Section this connect belongs to.</param> |
| 17 | /// <param name="childId">Id of the child.</param> | 17 | /// <param name="childId">Id of the child.</param> |
| 18 | public ConnectToFeature(IntermediateSection section, string childId) : | ||
| 19 | this(section, childId, null, false) | ||
| 20 | { | ||
| 21 | } | ||
| 22 | |||
| 23 | /// <summary> | ||
| 24 | /// Creates a new connect to feature. | ||
| 25 | /// </summary> | ||
| 26 | /// <param name="section">Section this connect belongs to.</param> | ||
| 27 | /// <param name="childId">Id of the child.</param> | ||
| 28 | /// <param name="primaryFeature">Sets the primary feature for the connection.</param> | 18 | /// <param name="primaryFeature">Sets the primary feature for the connection.</param> |
| 29 | /// <param name="explicitPrimaryFeature">Sets if this is explicit primary.</param> | 19 | /// <param name="explicitPrimaryFeature">Sets if this is explicit primary.</param> |
| 30 | public ConnectToFeature(IntermediateSection section, string childId, string primaryFeature, bool explicitPrimaryFeature) | 20 | public ConnectToFeature(IntermediateSection section, string childId, string primaryFeature, bool explicitPrimaryFeature) |
diff --git a/src/WixToolset.Core/Linker.cs b/src/WixToolset.Core/Linker.cs index d5c51f96..a6d43715 100644 --- a/src/WixToolset.Core/Linker.cs +++ b/src/WixToolset.Core/Linker.cs | |||
| @@ -901,51 +901,6 @@ namespace WixToolset.Core | |||
| 901 | } | 901 | } |
| 902 | } | 902 | } |
| 903 | 903 | ||
| 904 | #if DEAD_CODE | ||
| 905 | /// <summary> | ||
| 906 | /// Copies a table's rows to an output table. | ||
| 907 | /// </summary> | ||
| 908 | /// <param name="table">Source table to copy rows from.</param> | ||
| 909 | /// <param name="outputTable">Destination table in output to copy rows into.</param> | ||
| 910 | /// <param name="sectionId">Id of the section that the table lives in.</param> | ||
| 911 | private void CopyTableRowsToOutputTable(Table table, Table outputTable, string sectionId) | ||
| 912 | { | ||
| 913 | int[] localizedColumns = new int[table.Definition.Columns.Count]; | ||
| 914 | int localizedColumnCount = 0; | ||
| 915 | |||
| 916 | // if there are localization strings, figure out which columns can be localized in this table | ||
| 917 | if (null != this.Localizer) | ||
| 918 | { | ||
| 919 | for (int i = 0; i < table.Definition.Columns.Count; i++) | ||
| 920 | { | ||
| 921 | if (table.Definition.Columns[i].IsLocalizable) | ||
| 922 | { | ||
| 923 | localizedColumns[localizedColumnCount++] = i; | ||
| 924 | } | ||
| 925 | } | ||
| 926 | } | ||
| 927 | |||
| 928 | // process each row in the table doing the string resource substitutions | ||
| 929 | // then add the row to the output | ||
| 930 | foreach (Row row in table.Rows) | ||
| 931 | { | ||
| 932 | for (int j = 0; j < localizedColumnCount; j++) | ||
| 933 | { | ||
| 934 | Field field = row.Fields[localizedColumns[j]]; | ||
| 935 | |||
| 936 | if (null != field.Data) | ||
| 937 | { | ||
| 938 | field.Data = this.WixVariableResolver.ResolveVariables(row.SourceLineNumbers, (string)field.Data, true); | ||
| 939 | } | ||
| 940 | } | ||
| 941 | |||
| 942 | row.SectionId = (this.sectionIdOnRows ? sectionId : null); | ||
| 943 | outputTable.Rows.Add(row); | ||
| 944 | } | ||
| 945 | } | ||
| 946 | #endif | ||
| 947 | |||
| 948 | |||
| 949 | /// <summary> | 904 | /// <summary> |
| 950 | /// Resolve features for columns that have null guid placeholders. | 905 | /// Resolve features for columns that have null guid placeholders. |
| 951 | /// </summary> | 906 | /// </summary> |
