From 3a2c3c799eead15c26f5d65d16e6e01b4a0e8c64 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Mon, 7 Oct 2019 14:20:11 -0700 Subject: Fix Feature parent --- src/WixToolset.Core/Linker.cs | 402 +++++++++++++++++++++--------------------- 1 file changed, 201 insertions(+), 201 deletions(-) (limited to 'src/WixToolset.Core/Linker.cs') diff --git a/src/WixToolset.Core/Linker.cs b/src/WixToolset.Core/Linker.cs index 1f28802b..9526ac95 100644 --- a/src/WixToolset.Core/Linker.cs +++ b/src/WixToolset.Core/Linker.cs @@ -244,12 +244,12 @@ namespace WixToolset.Core break; #endif - case TupleDefinitionType.Class: - if (SectionType.Product == resolvedSection.Type) - { - this.ResolveFeatures(tuple, 2, 11, componentsToFeatures, multipleFeatureComponents); - } - break; + case TupleDefinitionType.Class: + if (SectionType.Product == resolvedSection.Type) + { + this.ResolveFeatures(tuple, 2, 11, componentsToFeatures, multipleFeatureComponents); + } + break; #if MOVE_TO_BACKEND case "CustomAction": @@ -303,12 +303,12 @@ namespace WixToolset.Core } break; #endif - case TupleDefinitionType.Extension: - if (SectionType.Product == resolvedSection.Type) - { - this.ResolveFeatures(tuple, 1, 4, componentsToFeatures, multipleFeatureComponents); - } - break; + case TupleDefinitionType.Extension: + if (SectionType.Product == resolvedSection.Type) + { + this.ResolveFeatures(tuple, 1, 4, componentsToFeatures, multipleFeatureComponents); + } + break; #if MOVE_TO_BACKEND case TupleDefinitionType.ModuleSubstitution: @@ -320,12 +320,12 @@ namespace WixToolset.Core break; #endif - case TupleDefinitionType.Assembly: - if (SectionType.Product == resolvedSection.Type) - { - this.ResolveFeatures(tuple, 0, 1, componentsToFeatures, multipleFeatureComponents); - } - break; + case TupleDefinitionType.Assembly: + if (SectionType.Product == resolvedSection.Type) + { + this.ResolveFeatures(tuple, 0, 1, componentsToFeatures, multipleFeatureComponents); + } + break; #if MOVE_TO_BACKEND case "ProgId": @@ -347,26 +347,26 @@ namespace WixToolset.Core break; #endif - case TupleDefinitionType.PublishComponent: - if (SectionType.Product == resolvedSection.Type) - { - this.ResolveFeatures(tuple, 2, 4, componentsToFeatures, multipleFeatureComponents); - } - break; + case TupleDefinitionType.PublishComponent: + if (SectionType.Product == resolvedSection.Type) + { + this.ResolveFeatures(tuple, 2, 4, componentsToFeatures, multipleFeatureComponents); + } + break; - case TupleDefinitionType.Shortcut: - if (SectionType.Product == resolvedSection.Type) - { - this.ResolveFeatures(tuple, 3, 4, componentsToFeatures, multipleFeatureComponents); - } - break; + case TupleDefinitionType.Shortcut: + if (SectionType.Product == resolvedSection.Type) + { + this.ResolveFeatures(tuple, 3, 4, componentsToFeatures, multipleFeatureComponents); + } + break; - case TupleDefinitionType.TypeLib: - if (SectionType.Product == resolvedSection.Type) - { - this.ResolveFeatures(tuple, 2, 6, componentsToFeatures, multipleFeatureComponents); - } - break; + case TupleDefinitionType.TypeLib: + if (SectionType.Product == resolvedSection.Type) + { + this.ResolveFeatures(tuple, 2, 6, componentsToFeatures, multipleFeatureComponents); + } + break; #if SOLVE_CUSTOM_TABLE case "WixCustomTable": @@ -384,9 +384,9 @@ namespace WixToolset.Core break; #endif - case TupleDefinitionType.WixEnsureTable: - ensureTableRows.Add(tuple); - break; + case TupleDefinitionType.WixEnsureTable: + ensureTableRows.Add(tuple); + break; #if MOVE_TO_BACKEND @@ -409,46 +409,46 @@ namespace WixToolset.Core break; #endif - case TupleDefinitionType.WixMerge: - if (SectionType.Product == resolvedSection.Type) - { - this.ResolveFeatures(tuple, 0, 7, modulesToFeatures, null); - } - break; - - case TupleDefinitionType.WixComplexReference: - copyTuple = false; - break; + case TupleDefinitionType.WixMerge: + if (SectionType.Product == resolvedSection.Type) + { + this.ResolveFeatures(tuple, 0, 7, modulesToFeatures, null); + } + break; - case TupleDefinitionType.WixSimpleReference: - copyTuple = false; - break; + case TupleDefinitionType.WixComplexReference: + copyTuple = false; + break; - case TupleDefinitionType.WixVariable: - // check for colliding values and collect the wix variable rows - { - var row = (WixVariableTuple)tuple; - var id = row.Id.Id; + case TupleDefinitionType.WixSimpleReference: + copyTuple = false; + break; - if (wixVariables.TryGetValue(id, out var collidingRow)) + case TupleDefinitionType.WixVariable: + // check for colliding values and collect the wix variable rows { - if (collidingRow.Overridable && !row.Overridable) + var row = (WixVariableTuple)tuple; + var id = row.Id.Id; + + if (wixVariables.TryGetValue(id, out var collidingRow)) { - wixVariables[id] = row; + if (collidingRow.Overridable && !row.Overridable) + { + wixVariables[id] = row; + } + else if (!row.Overridable || (collidingRow.Overridable && row.Overridable)) + { + this.OnMessage(ErrorMessages.WixVariableCollision(row.SourceLineNumbers, id)); + } } - else if (!row.Overridable || (collidingRow.Overridable && row.Overridable)) + else { - this.OnMessage(ErrorMessages.WixVariableCollision(row.SourceLineNumbers, id)); + wixVariables.Add(id, row); } } - else - { - wixVariables.Add(id, row); - } - } - copyTuple = false; - break; + copyTuple = false; + break; } if (copyTuple) @@ -1152,154 +1152,154 @@ namespace WixToolset.Core ConnectToFeature connection; switch (wixComplexReferenceRow.ParentType) { - case ComplexReferenceParentType.Feature: - switch (wixComplexReferenceRow.ChildType) - { - case ComplexReferenceChildType.Component: - connection = componentsToFeatures[wixComplexReferenceRow.Child]; - if (null == connection) - { - componentsToFeatures.Add(new ConnectToFeature(section, wixComplexReferenceRow.Child, wixComplexReferenceRow.Parent, wixComplexReferenceRow.IsPrimary)); - } - else if (wixComplexReferenceRow.IsPrimary) + case ComplexReferenceParentType.Feature: + switch (wixComplexReferenceRow.ChildType) { - if (connection.IsExplicitPrimaryFeature) - { - this.OnMessage(ErrorMessages.MultiplePrimaryReferences(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.ChildType.ToString(), wixComplexReferenceRow.Child, wixComplexReferenceRow.ParentType.ToString(), wixComplexReferenceRow.Parent, (null != connection.PrimaryFeature ? "Feature" : "Product"), connection.PrimaryFeature ?? resolvedSection.Id)); - continue; - } - else - { - connection.ConnectFeatures.Add(connection.PrimaryFeature); // move the guessed primary feature to the list of connects - connection.PrimaryFeature = wixComplexReferenceRow.Parent; // set the new primary feature - connection.IsExplicitPrimaryFeature = true; // and make sure we remember that we set it so we can fail if we try to set it again - } - } - else - { - connection.ConnectFeatures.Add(wixComplexReferenceRow.Parent); - } + case ComplexReferenceChildType.Component: + connection = componentsToFeatures[wixComplexReferenceRow.Child]; + if (null == connection) + { + componentsToFeatures.Add(new ConnectToFeature(section, wixComplexReferenceRow.Child, wixComplexReferenceRow.Parent, wixComplexReferenceRow.IsPrimary)); + } + else if (wixComplexReferenceRow.IsPrimary) + { + if (connection.IsExplicitPrimaryFeature) + { + this.OnMessage(ErrorMessages.MultiplePrimaryReferences(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.ChildType.ToString(), wixComplexReferenceRow.Child, wixComplexReferenceRow.ParentType.ToString(), wixComplexReferenceRow.Parent, (null != connection.PrimaryFeature ? "Feature" : "Product"), connection.PrimaryFeature ?? resolvedSection.Id)); + continue; + } + else + { + connection.ConnectFeatures.Add(connection.PrimaryFeature); // move the guessed primary feature to the list of connects + connection.PrimaryFeature = wixComplexReferenceRow.Parent; // set the new primary feature + connection.IsExplicitPrimaryFeature = true; // and make sure we remember that we set it so we can fail if we try to set it again + } + } + else + { + connection.ConnectFeatures.Add(wixComplexReferenceRow.Parent); + } - // add a row to the FeatureComponents table - var featureComponent = new FeatureComponentsTuple(); - featureComponent.FeatureRef = wixComplexReferenceRow.Parent; - featureComponent.ComponentRef = wixComplexReferenceRow.Child; + // add a row to the FeatureComponents table + var featureComponent = new FeatureComponentsTuple(); + featureComponent.FeatureRef = wixComplexReferenceRow.Parent; + featureComponent.ComponentRef = wixComplexReferenceRow.Child; - featureComponents.Add(featureComponent); + featureComponents.Add(featureComponent); - // index the component for finding orphaned records - var symbolName = String.Concat("Component:", wixComplexReferenceRow.Child); - referencedComponents.Add(symbolName); + // index the component for finding orphaned records + var symbolName = String.Concat("Component:", wixComplexReferenceRow.Child); + referencedComponents.Add(symbolName); - break; + break; - case ComplexReferenceChildType.Feature: - connection = featuresToFeatures[wixComplexReferenceRow.Child]; - if (null != connection) - { - this.OnMessage(ErrorMessages.MultiplePrimaryReferences(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.ChildType.ToString(), wixComplexReferenceRow.Child, wixComplexReferenceRow.ParentType.ToString(), wixComplexReferenceRow.Parent, (null != connection.PrimaryFeature ? "Feature" : "Product"), (null != connection.PrimaryFeature ? connection.PrimaryFeature : resolvedSection.Id))); - continue; - } + case ComplexReferenceChildType.Feature: + connection = featuresToFeatures[wixComplexReferenceRow.Child]; + if (null != connection) + { + this.OnMessage(ErrorMessages.MultiplePrimaryReferences(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.ChildType.ToString(), wixComplexReferenceRow.Child, wixComplexReferenceRow.ParentType.ToString(), wixComplexReferenceRow.Parent, (null != connection.PrimaryFeature ? "Feature" : "Product"), (null != connection.PrimaryFeature ? connection.PrimaryFeature : resolvedSection.Id))); + continue; + } - featuresToFeatures.Add(new ConnectToFeature(section, wixComplexReferenceRow.Child, wixComplexReferenceRow.Parent, wixComplexReferenceRow.IsPrimary)); - break; + featuresToFeatures.Add(new ConnectToFeature(section, wixComplexReferenceRow.Child, wixComplexReferenceRow.Parent, wixComplexReferenceRow.IsPrimary)); + break; - case ComplexReferenceChildType.Module: - connection = modulesToFeatures[wixComplexReferenceRow.Child]; - if (null == connection) - { - modulesToFeatures.Add(new ConnectToFeature(section, wixComplexReferenceRow.Child, wixComplexReferenceRow.Parent, wixComplexReferenceRow.IsPrimary)); - } - else if (wixComplexReferenceRow.IsPrimary) - { - if (connection.IsExplicitPrimaryFeature) - { - this.OnMessage(ErrorMessages.MultiplePrimaryReferences(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.ChildType.ToString(), wixComplexReferenceRow.Child, wixComplexReferenceRow.ParentType.ToString(), wixComplexReferenceRow.Parent, (null != connection.PrimaryFeature ? "Feature" : "Product"), (null != connection.PrimaryFeature ? connection.PrimaryFeature : resolvedSection.Id))); - continue; - } - else - { - connection.ConnectFeatures.Add(connection.PrimaryFeature); // move the guessed primary feature to the list of connects - connection.PrimaryFeature = wixComplexReferenceRow.Parent; // set the new primary feature - connection.IsExplicitPrimaryFeature = true; // and make sure we remember that we set it so we can fail if we try to set it again - } - } - else - { - connection.ConnectFeatures.Add(wixComplexReferenceRow.Parent); + case ComplexReferenceChildType.Module: + connection = modulesToFeatures[wixComplexReferenceRow.Child]; + if (null == connection) + { + modulesToFeatures.Add(new ConnectToFeature(section, wixComplexReferenceRow.Child, wixComplexReferenceRow.Parent, wixComplexReferenceRow.IsPrimary)); + } + else if (wixComplexReferenceRow.IsPrimary) + { + if (connection.IsExplicitPrimaryFeature) + { + this.OnMessage(ErrorMessages.MultiplePrimaryReferences(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.ChildType.ToString(), wixComplexReferenceRow.Child, wixComplexReferenceRow.ParentType.ToString(), wixComplexReferenceRow.Parent, (null != connection.PrimaryFeature ? "Feature" : "Product"), (null != connection.PrimaryFeature ? connection.PrimaryFeature : resolvedSection.Id))); + continue; + } + else + { + connection.ConnectFeatures.Add(connection.PrimaryFeature); // move the guessed primary feature to the list of connects + connection.PrimaryFeature = wixComplexReferenceRow.Parent; // set the new primary feature + connection.IsExplicitPrimaryFeature = true; // and make sure we remember that we set it so we can fail if we try to set it again + } + } + else + { + connection.ConnectFeatures.Add(wixComplexReferenceRow.Parent); + } + break; + + default: + throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, "Unexpected complex reference child type: {0}", Enum.GetName(typeof(ComplexReferenceChildType), wixComplexReferenceRow.ChildType))); } break; - default: - throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, "Unexpected complex reference child type: {0}", Enum.GetName(typeof(ComplexReferenceChildType), wixComplexReferenceRow.ChildType))); - } - break; - - case ComplexReferenceParentType.Module: - switch (wixComplexReferenceRow.ChildType) - { - case ComplexReferenceChildType.Component: - if (componentsToModules.ContainsKey(wixComplexReferenceRow.Child)) - { - this.OnMessage(ErrorMessages.ComponentReferencedTwice(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.Child)); - continue; - } - else + case ComplexReferenceParentType.Module: + switch (wixComplexReferenceRow.ChildType) { - componentsToModules.Add(wixComplexReferenceRow.Child, wixComplexReferenceRow); // should always be new + case ComplexReferenceChildType.Component: + if (componentsToModules.ContainsKey(wixComplexReferenceRow.Child)) + { + this.OnMessage(ErrorMessages.ComponentReferencedTwice(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.Child)); + continue; + } + else + { + componentsToModules.Add(wixComplexReferenceRow.Child, wixComplexReferenceRow); // should always be new - // add a row to the ModuleComponents table - var moduleComponent = new ModuleComponentsTuple(); - moduleComponent.Component = wixComplexReferenceRow.Child; - moduleComponent.ModuleID = wixComplexReferenceRow.Parent; - moduleComponent.Language = Convert.ToInt32(wixComplexReferenceRow.ParentLanguage); - } + // add a row to the ModuleComponents table + var moduleComponent = new ModuleComponentsTuple(); + moduleComponent.Component = wixComplexReferenceRow.Child; + moduleComponent.ModuleID = wixComplexReferenceRow.Parent; + moduleComponent.Language = Convert.ToInt32(wixComplexReferenceRow.ParentLanguage); + } + + // index the component for finding orphaned records + var componentSymbolName = String.Concat("Component:", wixComplexReferenceRow.Child); + referencedComponents.Add(componentSymbolName); - // index the component for finding orphaned records - var componentSymbolName = String.Concat("Component:", wixComplexReferenceRow.Child); - referencedComponents.Add(componentSymbolName); + break; + default: + throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, "Unexpected complex reference child type: {0}", Enum.GetName(typeof(ComplexReferenceChildType), wixComplexReferenceRow.ChildType))); + } break; - default: - throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, "Unexpected complex reference child type: {0}", Enum.GetName(typeof(ComplexReferenceChildType), wixComplexReferenceRow.ChildType))); - } - break; + case ComplexReferenceParentType.Patch: + switch (wixComplexReferenceRow.ChildType) + { + case ComplexReferenceChildType.PatchFamily: + case ComplexReferenceChildType.PatchFamilyGroup: + break; - case ComplexReferenceParentType.Patch: - switch (wixComplexReferenceRow.ChildType) - { - case ComplexReferenceChildType.PatchFamily: - case ComplexReferenceChildType.PatchFamilyGroup: + default: + throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, "Unexpected complex reference child type: {0}", Enum.GetName(typeof(ComplexReferenceChildType), wixComplexReferenceRow.ChildType))); + } break; - default: - throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, "Unexpected complex reference child type: {0}", Enum.GetName(typeof(ComplexReferenceChildType), wixComplexReferenceRow.ChildType))); - } - break; - - case ComplexReferenceParentType.Product: - switch (wixComplexReferenceRow.ChildType) - { - case ComplexReferenceChildType.Feature: - connection = featuresToFeatures[wixComplexReferenceRow.Child]; - if (null != connection) + case ComplexReferenceParentType.Product: + switch (wixComplexReferenceRow.ChildType) { - this.OnMessage(ErrorMessages.MultiplePrimaryReferences(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.ChildType.ToString(), wixComplexReferenceRow.Child, wixComplexReferenceRow.ParentType.ToString(), wixComplexReferenceRow.Parent, (null != connection.PrimaryFeature ? "Feature" : "Product"), (null != connection.PrimaryFeature ? connection.PrimaryFeature : resolvedSection.Id))); - continue; - } + case ComplexReferenceChildType.Feature: + connection = featuresToFeatures[wixComplexReferenceRow.Child]; + if (null != connection) + { + this.OnMessage(ErrorMessages.MultiplePrimaryReferences(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.ChildType.ToString(), wixComplexReferenceRow.Child, wixComplexReferenceRow.ParentType.ToString(), wixComplexReferenceRow.Parent, (null != connection.PrimaryFeature ? "Feature" : "Product"), (null != connection.PrimaryFeature ? connection.PrimaryFeature : resolvedSection.Id))); + continue; + } + + featuresToFeatures.Add(new ConnectToFeature(section, wixComplexReferenceRow.Child, null, wixComplexReferenceRow.IsPrimary)); + break; - featuresToFeatures.Add(new ConnectToFeature(section, wixComplexReferenceRow.Child, null, wixComplexReferenceRow.IsPrimary)); + default: + throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, "Unexpected complex reference child type: {0}", Enum.GetName(typeof(ComplexReferenceChildType), wixComplexReferenceRow.ChildType))); + } break; default: - throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, "Unexpected complex reference child type: {0}", Enum.GetName(typeof(ComplexReferenceChildType), wixComplexReferenceRow.ChildType))); - } - break; - - default: - // Note: Groups have been processed before getting here so they are not handled by any case above. - throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, "Unexpected complex reference child type: {0}", Enum.GetName(typeof(ComplexReferenceParentType), wixComplexReferenceRow.ParentType))); + // Note: Groups have been processed before getting here so they are not handled by any case above. + throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, "Unexpected complex reference child type: {0}", Enum.GetName(typeof(ComplexReferenceParentType), wixComplexReferenceRow.ParentType))); } } @@ -1614,7 +1614,7 @@ namespace WixToolset.Core groups.FlattenAndRewriteGroups(ComplexReferenceParentType.Package, false); groups.FlattenAndRewriteGroups(ComplexReferenceParentType.Container, false); groups.FlattenAndRewriteGroups(ComplexReferenceParentType.Layout, false); - + // Create Chain packages... groups.UseTypes(new[] { ComplexReferenceParentType.PackageGroup }, new[] { ComplexReferenceChildType.Package, ComplexReferenceChildType.PackageGroup }); groups.FlattenAndRewriteRows(ComplexReferenceChildType.PackageGroup, "WixChain", false); @@ -1631,17 +1631,17 @@ namespace WixToolset.Core { foreach (ConnectToFeature connection in featuresToFeatures) { - var wixSimpleReferenceRow = new WixSimpleReferenceTuple(); - wixSimpleReferenceRow.Table = "Feature"; - wixSimpleReferenceRow.PrimaryKeys = connection.ChildId; + var wixSimpleReferenceRow = new WixSimpleReferenceTuple + { + Table = "Feature", + PrimaryKeys = connection.ChildId + }; - if (!allSymbols.TryGetValue(wixSimpleReferenceRow.SymbolicName, out var symbol)) + if (allSymbols.TryGetValue(wixSimpleReferenceRow.SymbolicName, out var symbol)) { - continue; + var featureTuple = (FeatureTuple)symbol.Row; + featureTuple.ParentFeatureRef = connection.PrimaryFeature; } - - var row = symbol.Row; - row.Set(1, connection.PrimaryFeature); } } -- cgit v1.2.3-55-g6feb