@joebigelow / wix-1 / commits / 2c73e671

Fix test CanDecompileNestedDirSearchUnderRegSearch.

Sean Hall committed Nov 25, 2019 at 17:24 UTC 2c73e671599f4d05bb98b38dbc79750a1cf04b45
3 files changed +46 -24
src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs
+44 -22
@@ -2292,6 +2292,14 @@ namespace WixToolset.Core.WindowsInstaller
2292 usedDrLocator = true;
2293 }
2294 }
2295 + else if ("RegLocator" == parentLocatorRow.TableDefinition.Name)
2296 + {
2297 + var parentSearchElement = (Wix.IParentElement)this.core.GetIndexedElement(parentLocatorRow);
2298 +
2299 + parentSearchElement.AddChild(searchElement);
2300 + usedSearchElements[searchElement] = null;
2301 + usedDrLocator = true;
2302 + }
2303 }
2304
2305 // keep track of unused DrLocator rows
@@ -2362,7 +2370,8 @@ namespace WixToolset.Core.WindowsInstaller
2370 }
2371 else
2372 {
2365 - if ("DrLocator" == locatorRow.TableDefinition.Name)
2373 + if ("DrLocator" == locatorRow.TableDefinition.Name ||
2374 + "RegLocator" == locatorRow.TableDefinition.Name)
2375 {
2376 unusedSearchElements.Add(searchElement);
2377 }
@@ -2385,32 +2394,45 @@ namespace WixToolset.Core.WindowsInstaller
2394 {
2395 var used = false;
2396
2388 - foreach (Wix.ISchemaElement schemaElement in unusedSearchElement.Children)
2397 + Wix.DirectorySearch leafDirectorySearch = null;
2398 + var parentElement = unusedSearchElement;
2399 + var updatedLeaf = true;
2400 + while (updatedLeaf)
2401 {
2390 - var directorySearch = schemaElement as Wix.DirectorySearch;
2391 - if (null != directorySearch)
2402 + updatedLeaf = false;
2403 + foreach (var schemaElement in parentElement.Children)
2404 {
2393 - var appSearchProperties = (StringCollection)appSearches[directorySearch.Id];
2394 -
2395 - var unusedSearchSchemaElement = unusedSearchElement as Wix.ISchemaElement;
2396 - if (null != appSearchProperties)
2405 + if (schemaElement is Wix.DirectorySearch directorySearch)
2406 {
2398 - var property = this.EnsureProperty(appSearchProperties[0]);
2399 -
2400 - property.AddChild(unusedSearchSchemaElement);
2401 - used = true;
2407 + parentElement = leafDirectorySearch = directorySearch;
2408 + updatedLeaf = true;
2409 break;
2410 }
2404 - else if (ccpSearches.Contains(directorySearch.Id))
2405 - {
2406 - complianceCheck.AddChild(unusedSearchSchemaElement);
2407 - used = true;
2408 - break;
2409 - }
2410 - else
2411 - {
2412 - // TODO: warn
2413 - }
2411 + }
2412 + }
2413 +
2414 + if (leafDirectorySearch != null)
2415 + {
2416 + var appSearchProperties = (StringCollection)appSearches[leafDirectorySearch.Id];
2417 +
2418 + var unusedSearchSchemaElement = unusedSearchElement as Wix.ISchemaElement;
2419 + if (null != appSearchProperties)
2420 + {
2421 + var property = this.EnsureProperty(appSearchProperties[0]);
2422 +
2423 + property.AddChild(unusedSearchSchemaElement);
2424 + used = true;
2425 + break;
2426 + }
2427 + else if (ccpSearches.Contains(leafDirectorySearch.Id))
2428 + {
2429 + complianceCheck.AddChild(unusedSearchSchemaElement);
2430 + used = true;
2431 + break;
2432 + }
2433 + else
2434 + {
2435 + // TODO: warn
2436 }
2437 }
2438
src/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs
+1 -1
@@ -66,7 +66,7 @@ namespace WixToolsetTest.CoreIntegration
66 }
67 }
68
69 - [Fact(Skip = "Test demonstrates failure")]
69 + [Fact]
70 public void CanDecompileNestedDirSearchUnderRegSearch()
71 {
72 var folder = TestData.Get(@"TestData\AppSearch");
src/test/WixToolsetTest.CoreIntegration/TestData/AppSearch/DecompiledNestedDirSearchUnderRegSearch.wxs
+1 -1
@@ -18,7 +18,7 @@
18 <Media Id="1" />
19 <Property Id="ALLUSERS" Value="1" />
20 <Property Id="SAMPLEDIRFOUND">
21 - <RegistrySearch Id="SubRegSearch" Root="HKLM" Key="SampleReg" Type="raw">
21 + <RegistrySearch Id="SubRegSearch" Root="HKLM" Key="SampleReg" Type="raw" Win64="no">
22 <DirectorySearch Id="SampleDirSearch" Path="SampleDir">
23 <DirectorySearch Id="SubDirSearch" Path="Subdir" />
24 </DirectorySearch>