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