/// <summary> /// Gets the symbols that were not referenced during processing (usually linking). /// </summary> /// <param name="referencedSymbols">Collection of symbol names in string form.</param> /// <param name="messageHandler">Message handler to display errors while acquiring symbols.</param> /// <returns>Collection of unreferenced symbols.</returns> internal SymbolCollection GetOrphanedSymbols(StringCollection referencedSymbols, IMessageHandler messageHandler) { SymbolCollection unreferencedSymbols = new SymbolCollection(); // Loop through all of the symbols in all of the sections in this collection // looking for names that are not in the provided string collection. foreach (Section section in this.collection) { foreach (Symbol symbol in section.GetSymbols(messageHandler)) { if (!referencedSymbols.Contains(symbol.Name)) { // If the symbol was created by the user, then it will have // a row associated with it. We don't care about generated // (those with out Rows) unreferenced symbols so skip them. if (null != symbol.Row && !unreferencedSymbols.Contains(symbol.Name)) { unreferencedSymbols.Add(symbol); } } } } return(unreferencedSymbols); }
/// <summary> /// Gets the symbols that were not referenced during processing (usually linking). /// </summary> /// <param name="referencedSymbols">Collection of symbol names in string form.</param> /// <param name="messageHandler">Message handler to display errors while acquiring symbols.</param> /// <returns>Collection of unreferenced symbols.</returns> internal SymbolCollection GetOrphanedSymbols(StringCollection referencedSymbols, IMessageHandler messageHandler) { SymbolCollection unreferencedSymbols = new SymbolCollection(); // Loop through all of the symbols in all of the sections in this collection // looking for names that are not in the provided string collection. foreach (Section section in this.collection.Keys) { if (SectionType.Product == section.Type || SectionType.Module == section.Type || SectionType.PatchCreation == section.Type || SectionType.Patch == section.Type) { // Skip all symbols in the entry section; // They may appear to be unreferenced but they // will get into the linked image. continue; } foreach (Symbol symbol in section.GetSymbols(messageHandler)) { if (!referencedSymbols.Contains(symbol.Name)) { // If the symbol was created by the user, then it will have // a row associated with it. We don't care about generated // (those with out Rows) unreferenced symbols so skip them. if (null != symbol.Row && !unreferencedSymbols.Contains(symbol.Name)) { unreferencedSymbols.Add(symbol); } } } } return(unreferencedSymbols); }
/// <summary> /// Finds the entry section and loads the symbols from an array of intermediates. /// </summary> /// <param name="allowIdenticalRows">Flag specifying whether identical rows are allowed or not.</param> /// <param name="messageHandler">Message handler object to route all errors through.</param> /// <param name="entrySection">Located entry section.</param> /// <param name="allSymbols">Collection of symbols loaded.</param> internal void FindEntrySectionAndLoadSymbols( bool allowIdenticalRows, IMessageHandler messageHandler, out Section entrySection, out SymbolCollection allSymbols) { entrySection = null; allSymbols = new SymbolCollection(); foreach (Section section in this.collection) { if (SectionType.Product == section.Type || SectionType.Module == section.Type || SectionType.PatchCreation == section.Type || SectionType.Patch == section.Type) { if (null == entrySection) { entrySection = section; } else { messageHandler.OnMessage(WixErrors.MultipleEntrySections(entrySection.SourceLineNumbers, entrySection.Id, section.Id)); messageHandler.OnMessage(WixErrors.MultipleEntrySections2(section.SourceLineNumbers)); } } foreach (Symbol symbol in section.GetSymbols(messageHandler)) { try { Symbol existingSymbol = allSymbols[symbol.Name]; if (null == existingSymbol) { allSymbols.Add(symbol); } else if (allowIdenticalRows && existingSymbol.Row.IsIdentical(symbol.Row)) { messageHandler.OnMessage(WixWarnings.IdenticalRowWarning(symbol.Row.SourceLineNumbers, existingSymbol.Name)); messageHandler.OnMessage(WixWarnings.IdenticalRowWarning2(existingSymbol.Row.SourceLineNumbers)); } else { allSymbols.AddDuplicate(symbol); } } catch (DuplicateSymbolsException) { // if there is already a duplicate symbol, just // another to the list, don't bother trying to // see if there are any identical symbols allSymbols.AddDuplicate(symbol); } } } }
/// <summary> /// Loads the standard actions' symbols into the entry section. /// </summary> /// <param name="allSymbols">Collection of symbols.</param> /// <param name="entrySection">Entry section.</param> /// <param name="actionTable">Table that contains the standard actions.</param> private void LoadStandardActionSymbols(SymbolCollection allSymbols, Section entrySection, ActionTable actionTable) { foreach (Action action in actionTable) { // if the action's symbol has not already been defined (i.e. overriden by the user), add it now Symbol symbol = action.GetSymbol(entrySection); if (!allSymbols.Contains(symbol.Name)) { allSymbols.Add(symbol); } } }
/// <summary> /// Finds the entry section and loads the symbols from an array of intermediates. /// </summary> /// <param name="allowIdenticalRows">Flag specifying whether identical rows are allowed or not.</param> /// <param name="messageHandler">Message handler object to route all errors through.</param> /// <param name="expectedOutputType">Expected entry output type, based on output file extension provided to the linker.</param> /// <param name="entrySection">Located entry section.</param> /// <param name="allSymbols">Collection of symbols loaded.</param> internal void FindEntrySectionAndLoadSymbols( bool allowIdenticalRows, IMessageHandler messageHandler, OutputType expectedOutputType, out Section entrySection, out SymbolCollection allSymbols) { entrySection = null; allSymbols = new SymbolCollection(); string outputExtension = Output.GetExtension(expectedOutputType); SectionType expectedEntrySectionType; try { expectedEntrySectionType = (SectionType)Enum.Parse(typeof(SectionType), expectedOutputType.ToString()); } catch (ArgumentException) { expectedEntrySectionType = SectionType.Unknown; } foreach (Section section in this.collection.Keys) { if (SectionType.Product == section.Type || SectionType.Module == section.Type || SectionType.PatchCreation == section.Type || SectionType.Patch == section.Type || SectionType.Bundle == section.Type) { if (SectionType.Unknown != expectedEntrySectionType && section.Type != expectedEntrySectionType) { messageHandler.OnMessage(WixWarnings.UnexpectedEntrySection(section.SourceLineNumbers, section.Type.ToString(), expectedEntrySectionType.ToString(), outputExtension)); } if (null == entrySection) { entrySection = section; } else { messageHandler.OnMessage(WixErrors.MultipleEntrySections(entrySection.SourceLineNumbers, entrySection.Id, section.Id)); messageHandler.OnMessage(WixErrors.MultipleEntrySections2(section.SourceLineNumbers)); } } foreach (Symbol symbol in section.GetSymbols(messageHandler)) { try { Symbol existingSymbol = allSymbols[symbol.Name]; if (null == existingSymbol) { allSymbols.Add(symbol); } else if (allowIdenticalRows && existingSymbol.Row.IsIdentical(symbol.Row)) { messageHandler.OnMessage(WixWarnings.IdenticalRowWarning(symbol.Row.SourceLineNumbers, existingSymbol.Name)); messageHandler.OnMessage(WixWarnings.IdenticalRowWarning2(existingSymbol.Row.SourceLineNumbers)); } else { allSymbols.AddDuplicate(symbol); } } catch (DuplicateSymbolsException) { // if there is already a duplicate symbol, just // another to the list, don't bother trying to // see if there are any identical symbols allSymbols.AddDuplicate(symbol); } } } }
/// <summary> /// Gets the symbols that were not referenced during processing (usually linking). /// </summary> /// <param name="referencedSymbols">Collection of symbol names in string form.</param> /// <param name="messageHandler">Message handler to display errors while acquiring symbols.</param> /// <returns>Collection of unreferenced symbols.</returns> internal SymbolCollection GetOrphanedSymbols(StringCollection referencedSymbols, IMessageHandler messageHandler) { SymbolCollection unreferencedSymbols = new SymbolCollection(); // Loop through all of the symbols in all of the sections in this collection // looking for names that are not in the provided string collection. foreach (Section section in this.collection.Keys) { if (SectionType.Product == section.Type || SectionType.Module == section.Type || SectionType.PatchCreation == section.Type || SectionType.Patch == section.Type) { // Skip all symbols in the entry section; // They may appear to be unreferenced but they // will get into the linked image. continue; } foreach (Symbol symbol in section.GetSymbols(messageHandler)) { if (!referencedSymbols.Contains(symbol.Name)) { // If the symbol was created by the user, then it will have // a row associated with it. We don't care about generated // (those with out Rows) unreferenced symbols so skip them. if (null != symbol.Row && !unreferencedSymbols.Contains(symbol.Name)) { unreferencedSymbols.Add(symbol); } } } } return unreferencedSymbols; }
/// <summary> /// Load the standard action symbols. /// </summary> /// <param name="allSymbols">Collection of symbols.</param> private void LoadStandardActionSymbols(SymbolCollection allSymbols) { foreach (WixActionRow actionRow in this.standardActions) { // if the action's symbol has not already been defined (i.e. overriden by the user), add it now if (!allSymbols.Contains(actionRow.Symbol.Name)) { allSymbols.Add(actionRow.Symbol); } } }
/// <summary> /// Finds the entry section and loads the symbols from an array of intermediates. /// </summary> /// <param name="intermediates">Array of intermediates to load symbols for and find entry section.</param> /// <param name="allowIdenticalRows">Flag specifying whether identical rows are allowed or not.</param> /// <param name="messageHandler">Message handler object to route all errors through.</param> /// <param name="entrySection">Located entry section.</param> /// <param name="allSymbols">Collection of symbols loaded.</param> internal static void FindEntrySectionAndLoadSymbols( Intermediate[] intermediates, bool allowIdenticalRows, IMessageHandler messageHandler, out Section entrySection, out SymbolCollection allSymbols) { entrySection = null; allSymbols = new SymbolCollection(); for (int i = 0; i < intermediates.Length; ++i) { foreach (Section section in intermediates[i].Sections) { if (SectionType.Product == section.Type || SectionType.Module == section.Type || SectionType.PatchCreation == section.Type) { if (null == entrySection) { entrySection = section; } else { messageHandler.OnMessage(WixErrors.MultipleEntrySections(SourceLineNumberCollection.FromFileName(entrySection.Intermediate.SourcePath), entrySection.Id, section.Id)); messageHandler.OnMessage(WixErrors.MultipleEntrySections2(SourceLineNumberCollection.FromFileName(section.Intermediate.SourcePath))); } } foreach (Symbol symbol in section.GetSymbols(messageHandler)) { try { Symbol existingSymbol = allSymbols[symbol.Name]; if (null == existingSymbol) { allSymbols.Add(symbol); } else if (allowIdenticalRows && existingSymbol.Row.IsIdentical(symbol.Row)) { messageHandler.OnMessage(WixWarnings.IdenticalRowWarning(symbol.Row.SourceLineNumbers, existingSymbol.Name)); messageHandler.OnMessage(WixWarnings.IdenticalRowWarning2(existingSymbol.Row.SourceLineNumbers)); } else { allSymbols.AddDuplicate(symbol); } } catch (DuplicateSymbolsException) { // if there is already a duplicate symbol, just // another to the list, don't bother trying to // see if there are any identical symbols allSymbols.AddDuplicate(symbol); } } } } }