aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Extensibility/ICompilerCore.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2017-08-20 14:22:07 -0700
committerRob Mensching <rob@firegiant.com>2017-08-20 14:25:49 -0700
commit3e1c5e3fa80a2498f7d6aac5c0f8ca9e3bd7c66c (patch)
treebbe907a4c5ebf7aa5e3f02141f6e3abd31cb7b5c /src/WixToolset.Extensibility/ICompilerCore.cs
parent6dee3b45cb679786bd49a5db8fde9006d283b3e2 (diff)
downloadwix-3e1c5e3fa80a2498f7d6aac5c0f8ca9e3bd7c66c.tar.gz
wix-3e1c5e3fa80a2498f7d6aac5c0f8ca9e3bd7c66c.tar.bz2
wix-3e1c5e3fa80a2498f7d6aac5c0f8ca9e3bd7c66c.zip
Move to .NET Core 2.0
Diffstat (limited to 'src/WixToolset.Extensibility/ICompilerCore.cs')
-rw-r--r--src/WixToolset.Extensibility/ICompilerCore.cs339
1 files changed, 339 insertions, 0 deletions
diff --git a/src/WixToolset.Extensibility/ICompilerCore.cs b/src/WixToolset.Extensibility/ICompilerCore.cs
new file mode 100644
index 00000000..b2ad6abd
--- /dev/null
+++ b/src/WixToolset.Extensibility/ICompilerCore.cs
@@ -0,0 +1,339 @@
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.Extensibility
4{
5 using System;
6 using System.Collections;
7 using System.Collections.Generic;
8 using System.Xml.Linq;
9 using WixToolset.Data;
10
11 /// <summary>
12 /// Core interface provided by the compiler.
13 /// </summary>
14 public interface ICompilerCore : IMessageHandler
15 {
16 /// <summary>
17 /// Gets whether the compiler core encountered an error while processing.
18 /// </summary>
19 /// <value>Flag if core encountered an error during processing.</value>
20 bool EncounteredError { get; }
21
22 /// <summary>
23 /// Gets the platform which the compiler will use when defaulting 64-bit attributes and elements.
24 /// </summary>
25 /// <value>The platform which the compiler will use when defaulting 64-bit attributes and elements.</value>
26 Platform CurrentPlatform { get; }
27
28 /// <summary>
29 /// Creates a version 3 name-based UUID.
30 /// </summary>
31 /// <param name="namespaceGuid">The namespace UUID.</param>
32 /// <param name="value">The value.</param>
33 /// <returns>The generated GUID for the given namespace and value.</returns>
34 string CreateGuid(Guid namespaceGuid, string value);
35
36 /// <summary>
37 /// Create an identifier by hashing data from the row.
38 /// </summary>
39 /// <param name="prefix">Three letter or less prefix for generated row identifier.</param>
40 /// <param name="args">Information to hash.</param>
41 /// <returns>The new identifier.</returns>
42 Identifier CreateIdentifier(string prefix, params string[] args);
43
44 /// <summary>
45 /// Create an identifier based on passed file name
46 /// </summary>
47 /// <param name="name">File name to generate identifer from</param>
48 /// <returns></returns>
49 Identifier CreateIdentifierFromFilename(string filename);
50
51 /// <summary>
52 /// Convert a bit array into an int value.
53 /// </summary>
54 /// <param name="bits">The bit array to convert.</param>
55 /// <returns>The converted int value.</returns>
56 int CreateIntegerFromBitArray(BitArray bits);
57
58 /// <summary>
59 /// Creates a row in the active section.
60 /// </summary>
61 /// <param name="sourceLineNumbers">Source and line number of current row.</param>
62 /// <param name="tableName">Name of table to create row in.</param>
63 /// <param name="identifier">Optional identifier for the row.</param>
64 /// <returns>New row.</returns>
65 Row CreateRow(SourceLineNumber sourceLineNumbers, string tableName, Identifier identifier = null);
66
67 /// <summary>
68 /// Creates directories using the inline directory syntax.
69 /// </summary>
70 /// <param name="sourceLineNumbers">Source line information.</param>
71 /// <param name="attribute">The attribute to parse.</param>
72 /// <param name="parentId">Optional identifier of parent directory.</param>
73 /// <returns>Identifier of the leaf directory created.</returns>
74 string CreateDirectoryReferenceFromInlineSyntax(SourceLineNumber sourceLineNumbers, XAttribute attribute, string parentId);
75
76 /// <summary>
77 /// Creates a Registry row in the active section.
78 /// </summary>
79 /// <param name="sourceLineNumbers">Source and line number of the current row.</param>
80 /// <param name="root">The registry entry root.</param>
81 /// <param name="key">The registry entry key.</param>
82 /// <param name="name">The registry entry name.</param>
83 /// <param name="value">The registry entry value.</param>
84 /// <param name="componentId">The component which will control installation/uninstallation of the registry entry.</param>
85 /// <param name="escapeLeadingHash">If true, "escape" leading '#' characters so the value is written as a REG_SZ.</param>
86 Identifier CreateRegistryRow(SourceLineNumber sourceLineNumbers, int root, string key, string name, string value, string componentId, bool escapeLeadingHash = false);
87
88 /// <summary>
89 /// Creates a short file/directory name using an identifier and long file/directory name as input.
90 /// </summary>
91 /// <param name="longName">The long file/directory name.</param>
92 /// <param name="keepExtension">The option to keep the extension on generated short names.</param>
93 /// <param name="allowWildcards">true if wildcards are allowed in the filename.</param>
94 /// <param name="args">Any additional information to include in the hash for the generated short name.</param>
95 /// <returns>The generated 8.3-compliant short file/directory name.</returns>
96 string CreateShortName(string longName, bool keepExtension, bool allowWildcards, params string[] args);
97
98 /// <summary>
99 /// Create a WixSimpleReference row in the active section.
100 /// </summary>
101 /// <param name="sourceLineNumbers">Source line information for the row.</param>
102 /// <param name="tableName">The table name of the simple reference.</param>
103 /// <param name="primaryKeys">The primary keys of the simple reference.</param>
104 void CreateSimpleReference(SourceLineNumber sourceLineNumbers, string tableName, params string[] primaryKeys);
105
106 /// <summary>
107 /// Creates WixComplexReference and WixGroup rows in the active section.
108 /// </summary>
109 /// <param name="sourceLineNumbers">Source line information.</param>
110 /// <param name="parentType">The parent type.</param>
111 /// <param name="parentId">The parent id.</param>
112 /// <param name="parentLanguage">The parent language.</param>
113 /// <param name="childType">The child type.</param>
114 /// <param name="childId">The child id.</param>
115 /// <param name="isPrimary">Whether the child is primary.</param>
116 void CreateComplexReference(SourceLineNumber sourceLineNumbers, ComplexReferenceParentType parentType, string parentId, string parentLanguage, ComplexReferenceChildType childType, string childId, bool isPrimary);
117
118 /// <summary>
119 /// Creates a patch resource reference to the list of resoures to be filtered when producing a patch. This method should only be used when processing children of a patch family.
120 /// </summary>
121 /// <param name="sourceLineNumbers">Source and line number of current row.</param>
122 /// <param name="tableName">Name of table to create row in.</param>
123 /// <param name="primaryKeys">Array of keys that make up the primary key of the table.</param>
124 /// <returns>New row.</returns>
125 void CreatePatchFamilyChildReference(SourceLineNumber sourceLineNumbers, string tableName, params string[] primaryKeys);
126
127 /// <summary>
128 /// Checks if the string contains a property (i.e. "foo[Property]bar")
129 /// </summary>
130 /// <param name="possibleProperty">String to evaluate for properties.</param>
131 /// <returns>True if a property is found in the string.</returns>
132 bool ContainsProperty(string possibleProperty);
133
134 /// <summary>
135 /// Add the appropriate rows to make sure that the given table shows up in the resulting output.
136 /// </summary>
137 /// <param name="sourceLineNumbers">Source line numbers.</param>
138 /// <param name="tableName">Name of the table to ensure existance of.</param>
139 void EnsureTable(SourceLineNumber sourceLineNumbers, string tableName);
140
141 /// <summary>
142 /// Get an attribute value and displays an error if the value is empty by default.
143 /// </summary>
144 /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
145 /// <param name="attribute">The attribute containing the value to get.</param>
146 /// <param name="emptyRule">A rule for the contents of the value. If the contents do not follow the rule, an error is thrown.</param>
147 /// <returns>The attribute's value.</returns>
148 string GetAttributeValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, EmptyRule emptyRule = EmptyRule.CanBeWhitespaceOnly);
149
150 /// <summary>
151 /// Gets a Bundle variable value and displays an error for an illegal value.
152 /// </summary>
153 /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
154 /// <param name="attribute">The attribute containing the value to get.</param>
155 /// <returns>The attribute's value.</returns>
156 string GetAttributeBundleVariableValue(SourceLineNumber sourceLineNumbers, XAttribute attribute);
157
158 /// <summary>
159 /// Get a guid attribute value and displays an error for an illegal guid value.
160 /// </summary>
161 /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
162 /// <param name="attribute">The attribute containing the value to get.</param>
163 /// <param name="generatable">Determines whether the guid can be automatically generated.</param>
164 /// <param name="canBeEmpty">If true, no error is raised on empty value. If false, an error is raised.</param>
165 /// <returns>The attribute's guid value or a special value if an error occurred.</returns>
166 string GetAttributeGuidValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool generatable = false, bool canBeEmpty = false);
167
168 /// <summary>
169 /// Get an identifier attribute value and displays an error for an illegal identifier value.
170 /// </summary>
171 /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
172 /// <param name="attribute">The attribute containing the value to get.</param>
173 /// <returns>The attribute's identifier value or a special value if an error occurred.</returns>
174 Identifier GetAttributeIdentifier(SourceLineNumber sourceLineNumbers, XAttribute attribute);
175
176 /// <summary>
177 /// Get an identifier attribute value and displays an error for an illegal identifier value.
178 /// </summary>
179 /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
180 /// <param name="attribute">The attribute containing the value to get.</param>
181 /// <returns>The attribute's identifier value or a special value if an error occurred.</returns>
182 string GetAttributeIdentifierValue(SourceLineNumber sourceLineNumbers, XAttribute attribute);
183
184 /// <summary>
185 /// Get an integer attribute value and displays an error for an illegal integer value.
186 /// </summary>
187 /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
188 /// <param name="attribute">The attribute containing the value to get.</param>
189 /// <param name="minimum">The minimum legal value.</param>
190 /// <param name="maximum">The maximum legal value.</param>
191 /// <returns>The attribute's integer value or a special value if an error occurred during conversion.</returns>
192 int GetAttributeIntegerValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, int minimum, int maximum);
193
194 /// <summary>
195 /// Get a long integral attribute value and displays an error for an illegal long value.
196 /// </summary>
197 /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
198 /// <param name="attribute">The attribute containing the value to get.</param>
199 /// <param name="minimum">The minimum legal value.</param>
200 /// <param name="maximum">The maximum legal value.</param>
201 /// <returns>The attribute's long value or a special value if an error occurred during conversion.</returns>
202 long GetAttributeLongValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, long minimum, long maximum);
203
204 /// <summary>
205 /// Gets a long filename value and displays an error for an illegal long filename value.
206 /// </summary>
207 /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
208 /// <param name="attribute">The attribute containing the value to get.</param>
209 /// <param name="allowWildcards">true if wildcards are allowed in the filename.</param>
210 /// <param name="allowRelative">true if relative paths are allowed in the filename.</param>
211 /// <returns>The attribute's long filename value.</returns>
212 string GetAttributeLongFilename(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool allowWildcards = false, bool allowRelative = false);
213
214 /// <summary>
215 /// Gets a RegistryRoot as a MsiInterop.MsidbRegistryRoot value and displays an error for an illegal value.
216 /// </summary>
217 /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
218 /// <param name="attribute">The attribute containing the value to get.</param>
219 /// <param name="allowHkmu">Whether HKMU is returned as -1 (true), or treated as an error (false).</param>
220 /// <returns>The attribute's RegisitryRootType value.</returns>
221 int GetAttributeMsidbRegistryRootValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool allowHkmu);
222
223 /// <summary>
224 /// Gets a version value or possibly a binder variable and displays an error for an illegal version value.
225 /// </summary>
226 /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
227 /// <param name="attribute">The attribute containing the value to get.</param>
228 /// <returns>The attribute's version value.</returns>
229 string GetAttributeVersionValue(SourceLineNumber sourceLineNumbers, XAttribute attribute);
230
231 /// <summary>
232 /// Gets a yes/no value and displays an error for an illegal yes/no value.
233 /// </summary>
234 /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
235 /// <param name="attribute">The attribute containing the value to get.</param>
236 /// <returns>The attribute's YesNoType value.</returns>
237 YesNoType GetAttributeYesNoValue(SourceLineNumber sourceLineNumbers, XAttribute attribute);
238
239 /// <summary>
240 /// Gets a yes/no/default value and displays an error for an illegal yes/no/default value.
241 /// </summary>
242 /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
243 /// <param name="attribute">The attribute containing the value to get.</param>
244 /// <returns>The attribute's YesNoType value.</returns>
245 YesNoDefaultType GetAttributeYesNoDefaultValue(SourceLineNumber sourceLineNumbers, XAttribute attribute);
246
247 /// <summary>
248 /// Gets node's inner text and ensure's it is safe for use in a condition by trimming any extra whitespace.
249 /// </summary>
250 /// <param name="node">The node to ensure inner text is a condition.</param>
251 /// <returns>The value converted into a safe condition.</returns>
252 string GetConditionInnerText(XElement node);
253
254 /// <summary>
255 /// Get an element's inner text and trims any extra whitespace.
256 /// </summary>
257 /// <param name="element">The element with inner text to be trimmed.</param>
258 /// <returns>The node's inner text trimmed.</returns>
259 string GetTrimmedInnerText(XElement element);
260
261 /// <summary>
262 /// Verifies that a value is a legal identifier.
263 /// </summary>
264 /// <param name="value">The value to verify.</param>
265 /// <returns>true if the value is an identifier; false otherwise.</returns>
266 bool IsValidIdentifier(string value);
267
268 /// <summary>
269 /// Verifies if an identifier is a valid loc identifier.
270 /// </summary>
271 /// <param name="identifier">Identifier to verify.</param>
272 /// <returns>True if the identifier is a valid loc identifier.</returns>
273 bool IsValidLocIdentifier(string identifier);
274
275 /// <summary>
276 /// Verifies if a filename is a valid long filename.
277 /// </summary>
278 /// <param name="filename">Filename to verify.</param>
279 /// <param name="allowWildcards">true if wildcards are allowed in the filename.</param>
280 /// <param name="allowRelative">true if relative paths are allowed in the filename.</param>
281 /// <returns>True if the filename is a valid long filename</returns>
282 bool IsValidLongFilename(string filename, bool allowWildcards = false, bool allowRelative = false);
283
284 /// <summary>
285 /// Verifies if a filename is a valid short filename.
286 /// </summary>
287 /// <param name="filename">Filename to verify.</param>
288 /// <param name="allowWildcards">true if wildcards are allowed in the filename.</param>
289 /// <returns>True if the filename is a valid short filename</returns>
290 bool IsValidShortFilename(string filename, bool allowWildcards = false);
291
292 /// <summary>
293 /// Attempts to use an extension to parse the attribute.
294 /// </summary>
295 /// <param name="element">Element containing attribute to be parsed.</param>
296 /// <param name="attribute">Attribute to be parsed.</param>
297 /// <param name="context">Extra information about the context in which this element is being parsed.</param>
298 void ParseExtensionAttribute(XElement element, XAttribute attribute, IDictionary<string, string> context = null);
299
300 /// <summary>
301 /// Attempts to use an extension to parse the element.
302 /// </summary>
303 /// <param name="parentElement">Element containing element to be parsed.</param>
304 /// <param name="element">Element to be parsed.</param>
305 /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
306 void ParseExtensionElement(XElement parentElement, XElement element, IDictionary<string, string> context = null);
307
308 /// <summary>
309 /// Process all children of the element looking for extensions and erroring on the unexpected.
310 /// </summary>
311 /// <param name="element">Element to parse children.</param>
312 void ParseForExtensionElements(XElement element);
313
314 /// <summary>
315 /// Sets a bit in a bit array based on the index at which an attribute name was found in a string array.
316 /// </summary>
317 /// <param name="attributeNames">Array of attributes that map to bits.</param>
318 /// <param name="attributeName">Name of attribute to check.</param>
319 /// <param name="attributeValue">Value of attribute to check.</param>
320 /// <param name="bits">The bit array in which the bit will be set if found.</param>
321 /// <param name="offset">The offset into the bit array.</param>
322 /// <returns>true if the bit was set; false otherwise.</returns>
323 bool TrySetBitFromName(string[] attributeNames, string attributeName, YesNoType attributeValue, BitArray bits, int offset);
324
325 /// <summary>
326 /// Called when the compiler encounters an unexpected attribute.
327 /// </summary>
328 /// <param name="parentElement">Parent element that found unexpected attribute.</param>
329 /// <param name="attribute">Unexpected attribute.</param>
330 void UnexpectedAttribute(XElement element, XAttribute attribute);
331
332 /// <summary>
333 /// Called when the compiler encounters an unexpected child element.
334 /// </summary>
335 /// <param name="parentElement">Parent element that found unexpected child.</param>
336 /// <param name="childElement">Unexpected child element.</param>
337 void UnexpectedElement(XElement parentElement, XElement childElement);
338 }
339}