| 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 | |
| 3 | namespace WixToolset.VisualStudio |
| 4 | { |
| 5 | #if TODO_CONSIDER_DECOMPILER |
| 6 | using System; |
| 7 | using System.Collections; |
| 8 | using System.Diagnostics; |
| 9 | using System.Globalization; |
| 10 | using WixToolset.Data; |
| 11 | using WixToolset.Extensibility; |
| 12 | using VS = WixToolset.Extensions.Serialize.VS; |
| 13 | using Wix = WixToolset.Data.Serialize; |
| 14 | |
| 15 | /// <summary> |
| 16 | /// The decompiler for the WiX Toolset Visual Studio Extension. |
| 17 | /// </summary> |
| 18 | public sealed class VSDecompiler : DecompilerExtension |
| 19 | { |
| 20 | /// <summary> |
| 21 | /// Creates a decompiler for VS Extension. |
| 22 | /// </summary> |
| 23 | public VSDecompiler() |
| 24 | { |
| 25 | this.TableDefinitions = VSExtensionData.GetExtensionTableDefinitions(); |
| 26 | } |
| 27 | |
| 28 | /// <summary> |
| 29 | /// Get the extensions library to be removed. |
| 30 | /// </summary> |
| 31 | /// <param name="tableDefinitions">Table definitions for library.</param> |
| 32 | /// <returns>Library to remove from decompiled output.</returns> |
| 33 | public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions) |
| 34 | { |
| 35 | return VSExtensionData.GetExtensionLibrary(tableDefinitions); |
| 36 | } |
| 37 | |
| 38 | /// <summary> |
| 39 | /// Decompiles an extension table. |
| 40 | /// </summary> |
| 41 | /// <param name="table">The table to decompile.</param> |
| 42 | public override void DecompileTable(Table table) |
| 43 | { |
| 44 | switch (table.Name) |
| 45 | { |
| 46 | case "HelpFile": |
| 47 | this.DecompileHelpFileTable(table); |
| 48 | break; |
| 49 | case "HelpFileToNamespace": |
| 50 | this.DecompileHelpFileToNamespaceTable(table); |
| 51 | break; |
| 52 | case "HelpFilter": |
| 53 | this.DecompileHelpFilterTable(table); |
| 54 | break; |
| 55 | case "HelpFilterToNamespace": |
| 56 | this.DecompileHelpFilterToNamespaceTable(table); |
| 57 | break; |
| 58 | case "HelpNamespace": |
| 59 | this.DecompileHelpNamespaceTable(table); |
| 60 | break; |
| 61 | case "HelpPlugin": |
| 62 | this.DecompileHelpPluginTable(table); |
| 63 | break; |
| 64 | default: |
| 65 | base.DecompileTable(table); |
| 66 | break; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | /// <summary> |
| 71 | /// Decompile the HelpFile table. |
| 72 | /// </summary> |
| 73 | /// <param name="table">The table to decompile.</param> |
| 74 | private void DecompileHelpFileTable(Table table) |
| 75 | { |
| 76 | foreach (Row row in table.Rows) |
| 77 | { |
| 78 | VS.HelpFile helpFile = new VS.HelpFile(); |
| 79 | |
| 80 | helpFile.Id = (string)row[0]; |
| 81 | |
| 82 | helpFile.Name = (string)row[1]; |
| 83 | |
| 84 | if (null != row[2]) |
| 85 | { |
| 86 | helpFile.Language = (int)row[2]; |
| 87 | } |
| 88 | |
| 89 | if (null != row[4]) |
| 90 | { |
| 91 | helpFile.Index = (string)row[4]; |
| 92 | } |
| 93 | |
| 94 | if (null != row[5]) |
| 95 | { |
| 96 | helpFile.Search = (string)row[5]; |
| 97 | } |
| 98 | |
| 99 | if (null != row[6]) |
| 100 | { |
| 101 | helpFile.AttributeIndex = (string)row[6]; |
| 102 | } |
| 103 | |
| 104 | if (null != row[7]) |
| 105 | { |
| 106 | helpFile.SampleLocation = (string)row[7]; |
| 107 | } |
| 108 | |
| 109 | if (this.Core.RootElement is Wix.Module) |
| 110 | { |
| 111 | helpFile.SuppressCustomActions = VS.YesNoType.yes; |
| 112 | } |
| 113 | |
| 114 | Wix.File file = (Wix.File)this.Core.GetIndexedElement("File", (string)row[3]); |
| 115 | if (null != file) |
| 116 | { |
| 117 | file.AddChild(helpFile); |
| 118 | } |
| 119 | else |
| 120 | { |
| 121 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "File_HxS", (string)row[3], "File")); |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | /// <summary> |
| 127 | /// Decompile the HelpFileToNamespace table. |
| 128 | /// </summary> |
| 129 | /// <param name="table">The table to decompile.</param> |
| 130 | private void DecompileHelpFileToNamespaceTable(Table table) |
| 131 | { |
| 132 | foreach (Row row in table.Rows) |
| 133 | { |
| 134 | VS.HelpFileRef helpFileRef = new VS.HelpFileRef(); |
| 135 | |
| 136 | helpFileRef.Id = (string)row[0]; |
| 137 | |
| 138 | VS.HelpCollection helpCollection = (VS.HelpCollection)this.Core.GetIndexedElement("HelpNamespace", (string)row[1]); |
| 139 | if (null != helpCollection) |
| 140 | { |
| 141 | helpCollection.AddChild(helpFileRef); |
| 142 | } |
| 143 | else |
| 144 | { |
| 145 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "HelpNamespace_", (string)row[1], "HelpNamespace")); |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | /// <summary> |
| 151 | /// Decompile the HelpFilter table. |
| 152 | /// </summary> |
| 153 | /// <param name="table">The table to decompile.</param> |
| 154 | private void DecompileHelpFilterTable(Table table) |
| 155 | { |
| 156 | foreach (Row row in table.Rows) |
| 157 | { |
| 158 | VS.HelpFilter helpFilter = new VS.HelpFilter(); |
| 159 | |
| 160 | helpFilter.Id = (string)row[0]; |
| 161 | |
| 162 | helpFilter.Name = (string)row[1]; |
| 163 | |
| 164 | if (null != row[2]) |
| 165 | { |
| 166 | helpFilter.FilterDefinition = (string)row[2]; |
| 167 | } |
| 168 | |
| 169 | if (this.Core.RootElement is Wix.Module) |
| 170 | { |
| 171 | helpFilter.SuppressCustomActions = VS.YesNoType.yes; |
| 172 | } |
| 173 | |
| 174 | this.Core.RootElement.AddChild(helpFilter); |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | /// <summary> |
| 179 | /// Decompile the HelpFilterToNamespace table. |
| 180 | /// </summary> |
| 181 | /// <param name="table">The table to decompile.</param> |
| 182 | private void DecompileHelpFilterToNamespaceTable(Table table) |
| 183 | { |
| 184 | foreach (Row row in table.Rows) |
| 185 | { |
| 186 | VS.HelpFilterRef helpFilterRef = new VS.HelpFilterRef(); |
| 187 | |
| 188 | helpFilterRef.Id = (string)row[0]; |
| 189 | |
| 190 | VS.HelpCollection helpCollection = (VS.HelpCollection)this.Core.GetIndexedElement("HelpNamespace", (string)row[1]); |
| 191 | if (null != helpCollection) |
| 192 | { |
| 193 | helpCollection.AddChild(helpFilterRef); |
| 194 | } |
| 195 | else |
| 196 | { |
| 197 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "HelpNamespace_", (string)row[1], "HelpNamespace")); |
| 198 | } |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | /// <summary> |
| 203 | /// Decompile the HelpNamespace table. |
| 204 | /// </summary> |
| 205 | /// <param name="table">The table to decompile.</param> |
| 206 | private void DecompileHelpNamespaceTable(Table table) |
| 207 | { |
| 208 | foreach (Row row in table.Rows) |
| 209 | { |
| 210 | VS.HelpCollection helpCollection = new VS.HelpCollection(); |
| 211 | |
| 212 | helpCollection.Id = (string)row[0]; |
| 213 | |
| 214 | helpCollection.Name = (string)row[1]; |
| 215 | |
| 216 | if (null != row[3]) |
| 217 | { |
| 218 | helpCollection.Description = (string)row[3]; |
| 219 | } |
| 220 | |
| 221 | if (this.Core.RootElement is Wix.Module) |
| 222 | { |
| 223 | helpCollection.SuppressCustomActions = VS.YesNoType.yes; |
| 224 | } |
| 225 | |
| 226 | Wix.File file = (Wix.File)this.Core.GetIndexedElement("File", (string)row[2]); |
| 227 | if (null != file) |
| 228 | { |
| 229 | file.AddChild(helpCollection); |
| 230 | } |
| 231 | else if (0 != String.Compare(helpCollection.Id, "MS_VSIPCC_v80", StringComparison.Ordinal) && |
| 232 | 0 != String.Compare(helpCollection.Id, "MS.VSIPCC.v90", StringComparison.Ordinal)) |
| 233 | { |
| 234 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "File_Collection", (string)row[2], "File")); |
| 235 | } |
| 236 | this.Core.IndexElement(row, helpCollection); |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | /// <summary> |
| 241 | /// Decompile the HelpPlugin table. |
| 242 | /// </summary> |
| 243 | /// <param name="table">The table to decompile.</param> |
| 244 | private void DecompileHelpPluginTable(Table table) |
| 245 | { |
| 246 | foreach (Row row in table.Rows) |
| 247 | { |
| 248 | VS.PlugCollectionInto plugCollectionInto = new VS.PlugCollectionInto(); |
| 249 | |
| 250 | plugCollectionInto.TargetCollection = (string)row[1]; |
| 251 | |
| 252 | if (null != row[2]) |
| 253 | { |
| 254 | plugCollectionInto.TableOfContents = (string)row[2]; |
| 255 | } |
| 256 | |
| 257 | if (null != row[3]) |
| 258 | { |
| 259 | plugCollectionInto.Attributes = (string)row[3]; |
| 260 | } |
| 261 | |
| 262 | if (null != row[4]) |
| 263 | { |
| 264 | plugCollectionInto.TargetTableOfContents = (string)row[4]; |
| 265 | } |
| 266 | |
| 267 | if (this.Core.RootElement is Wix.Module) |
| 268 | { |
| 269 | plugCollectionInto.SuppressExternalNamespaces = VS.YesNoType.yes; |
| 270 | } |
| 271 | |
| 272 | //we cannot do this work because we cannot get the FeatureComponent table |
| 273 | //plugCollectionInto.TargetFeature = DecompileHelpComponents(); |
| 274 | |
| 275 | VS.HelpCollection helpCollection = (VS.HelpCollection)this.Core.GetIndexedElement("HelpNamespace", (string)row[0]); |
| 276 | if (null != helpCollection) |
| 277 | { |
| 278 | helpCollection.AddChild(plugCollectionInto); |
| 279 | } |
| 280 | else |
| 281 | { |
| 282 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "HelpNamespace_", (string)row[0], "HelpNamespace")); |
| 283 | } |
| 284 | } |
| 285 | } |
| 286 | //private string DecompileHelpComponents() |
| 287 | //{ |
| 288 | // throw new NotImplementedException(); |
| 289 | // //Find both known compontents from FeatureComponents table and build feature list |
| 290 | |
| 291 | // //remove components from FeatureComponents |
| 292 | |
| 293 | // //return a space delimited list of features that mapped to our help components |
| 294 | // return String.Empty; |
| 295 | //} |
| 296 | } |
| 297 | #endif |
| 298 | } |