diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2018-12-16 11:57:53 -0600 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2018-12-16 12:03:17 -0600 |
commit | 1b7a9d3734119e658c91ebd9742ab5a3ce94cce4 (patch) | |
tree | 0c4b710cd5665f2b24a4cefcab19626398e3d139 /src/wixext | |
parent | 8464662dfcf3a6e4fafc33440b33236773d96a65 (diff) | |
download | wix-1b7a9d3734119e658c91ebd9742ab5a3ce94cce4.tar.gz wix-1b7a9d3734119e658c91ebd9742ab5a3ce94cce4.tar.bz2 wix-1b7a9d3734119e658c91ebd9742ab5a3ce94cce4.zip |
Integrate into latest v4.
Still needs TupleDefinitions.
Diffstat (limited to 'src/wixext')
-rw-r--r-- | src/wixext/SqlCompiler.cs | 391 | ||||
-rw-r--r-- | src/wixext/SqlDecompiler.cs | 4 | ||||
-rw-r--r-- | src/wixext/SqlErrors.cs | 42 | ||||
-rw-r--r-- | src/wixext/SqlExtensionData.cs | 50 | ||||
-rw-r--r-- | src/wixext/SqlExtensionFactory.cs | 18 | ||||
-rw-r--r-- | src/wixext/SqlWindowsInstallerBackendExtension.cs | 31 | ||||
-rw-r--r-- | src/wixext/WixToolset.Sql.wixext.csproj | 36 | ||||
-rw-r--r-- | src/wixext/WixToolset.Sql.wixext.targets | 11 |
8 files changed, 329 insertions, 254 deletions
diff --git a/src/wixext/SqlCompiler.cs b/src/wixext/SqlCompiler.cs index eecfbba0..c789f3bd 100644 --- a/src/wixext/SqlCompiler.cs +++ b/src/wixext/SqlCompiler.cs | |||
@@ -1,6 +1,6 @@ | |||
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. | 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 | 2 | ||
3 | namespace WixToolset.Extensions | 3 | namespace WixToolset.Sql |
4 | { | 4 | { |
5 | using System; | 5 | using System; |
6 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
@@ -11,7 +11,7 @@ namespace WixToolset.Extensions | |||
11 | /// <summary> | 11 | /// <summary> |
12 | /// The compiler for the WiX Toolset SQL Server Extension. | 12 | /// The compiler for the WiX Toolset SQL Server Extension. |
13 | /// </summary> | 13 | /// </summary> |
14 | public sealed class SqlCompiler : CompilerExtension | 14 | public sealed class SqlCompiler : BaseCompilerExtension |
15 | { | 15 | { |
16 | // sql database attributes definitions (from sca.h) | 16 | // sql database attributes definitions (from sca.h) |
17 | internal const int DbCreateOnInstall = 0x00000001; | 17 | internal const int DbCreateOnInstall = 0x00000001; |
@@ -30,22 +30,17 @@ namespace WixToolset.Extensions | |||
30 | internal const int SqlRollback = 0x00000008; | 30 | internal const int SqlRollback = 0x00000008; |
31 | internal const int SqlExecuteOnReinstall = 0x00000010; | 31 | internal const int SqlExecuteOnReinstall = 0x00000010; |
32 | 32 | ||
33 | /// <summary> | 33 | public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/sql"; |
34 | /// Instantiate a new SqlCompiler. | ||
35 | /// </summary> | ||
36 | public SqlCompiler() | ||
37 | { | ||
38 | this.Namespace = "http://wixtoolset.org/schemas/v4/wxs/sql"; | ||
39 | } | ||
40 | 34 | ||
41 | /// <summary> | 35 | /// <summary> |
42 | /// Processes an element for the Compiler. | 36 | /// Processes an element for the Compiler. |
43 | /// </summary> | 37 | /// </summary> |
44 | /// <param name="sourceLineNumbers">Source line number for the parent element.</param> | 38 | /// <param name="intermediate"></param> |
39 | /// <param name="section"></param> | ||
45 | /// <param name="parentElement">Parent element of element to process.</param> | 40 | /// <param name="parentElement">Parent element of element to process.</param> |
46 | /// <param name="element">Element to process.</param> | 41 | /// <param name="element">Element to process.</param> |
47 | /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param> | 42 | /// <param name="context">Extra information about the context in which this element is being parsed.</param> |
48 | public override void ParseElement(XElement parentElement, XElement element, IDictionary<string, string> context) | 43 | public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context) |
49 | { | 44 | { |
50 | switch (parentElement.Name.LocalName) | 45 | switch (parentElement.Name.LocalName) |
51 | { | 46 | { |
@@ -56,16 +51,16 @@ namespace WixToolset.Extensions | |||
56 | switch (element.Name.LocalName) | 51 | switch (element.Name.LocalName) |
57 | { | 52 | { |
58 | case "SqlDatabase": | 53 | case "SqlDatabase": |
59 | this.ParseSqlDatabaseElement(element, componentId); | 54 | this.ParseSqlDatabaseElement(intermediate, section, element, componentId); |
60 | break; | 55 | break; |
61 | case "SqlScript": | 56 | case "SqlScript": |
62 | this.ParseSqlScriptElement(element, componentId, null); | 57 | this.ParseSqlScriptElement(intermediate, section, element, componentId, null); |
63 | break; | 58 | break; |
64 | case "SqlString": | 59 | case "SqlString": |
65 | this.ParseSqlStringElement(element, componentId, null); | 60 | this.ParseSqlStringElement(intermediate, section, element, componentId, null); |
66 | break; | 61 | break; |
67 | default: | 62 | default: |
68 | this.Core.UnexpectedElement(parentElement, element); | 63 | this.ParseHelper.UnexpectedElement(parentElement, element); |
69 | break; | 64 | break; |
70 | } | 65 | } |
71 | break; | 66 | break; |
@@ -75,15 +70,15 @@ namespace WixToolset.Extensions | |||
75 | switch (element.Name.LocalName) | 70 | switch (element.Name.LocalName) |
76 | { | 71 | { |
77 | case "SqlDatabase": | 72 | case "SqlDatabase": |
78 | this.ParseSqlDatabaseElement(element, null); | 73 | this.ParseSqlDatabaseElement(intermediate, section, element, null); |
79 | break; | 74 | break; |
80 | default: | 75 | default: |
81 | this.Core.UnexpectedElement(parentElement, element); | 76 | this.ParseHelper.UnexpectedElement(parentElement, element); |
82 | break; | 77 | break; |
83 | } | 78 | } |
84 | break; | 79 | break; |
85 | default: | 80 | default: |
86 | this.Core.UnexpectedElement(parentElement, element); | 81 | this.ParseHelper.UnexpectedElement(parentElement, element); |
87 | break; | 82 | break; |
88 | } | 83 | } |
89 | } | 84 | } |
@@ -91,36 +86,38 @@ namespace WixToolset.Extensions | |||
91 | /// <summary> | 86 | /// <summary> |
92 | /// Parses a sql database element | 87 | /// Parses a sql database element |
93 | /// </summary> | 88 | /// </summary> |
94 | /// <param name="node">Element to parse.</param> | 89 | /// <param name="intermediate"></param> |
90 | /// <param name="section"></param> | ||
91 | /// <param name="element">Element to parse.</param> | ||
95 | /// <param name="componentId">Identifier for parent component.</param> | 92 | /// <param name="componentId">Identifier for parent component.</param> |
96 | private void ParseSqlDatabaseElement(XElement node, string componentId) | 93 | private void ParseSqlDatabaseElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId) |
97 | { | 94 | { |
98 | SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); | 95 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); |
99 | string id = null; | 96 | Identifier id = null; |
100 | int attributes = 0; | 97 | int attributes = 0; |
101 | string database = null; | 98 | string database = null; |
102 | string fileSpec = null; | 99 | Identifier fileSpec = null; |
103 | string instance = null; | 100 | string instance = null; |
104 | string logFileSpec = null; | 101 | Identifier logFileSpec = null; |
105 | string server = null; | 102 | string server = null; |
106 | string user = null; | 103 | string user = null; |
107 | 104 | ||
108 | foreach (XAttribute attrib in node.Attributes()) | 105 | foreach (XAttribute attrib in element.Attributes()) |
109 | { | 106 | { |
110 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | 107 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) |
111 | { | 108 | { |
112 | switch (attrib.Name.LocalName) | 109 | switch (attrib.Name.LocalName) |
113 | { | 110 | { |
114 | case "Id": | 111 | case "Id": |
115 | id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); | 112 | id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); |
116 | break; | 113 | break; |
117 | case "ConfirmOverwrite": | 114 | case "ConfirmOverwrite": |
118 | if (null == componentId) | 115 | if (null == componentId) |
119 | { | 116 | { |
120 | this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); | 117 | this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); |
121 | } | 118 | } |
122 | 119 | ||
123 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 120 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
124 | { | 121 | { |
125 | attributes |= DbConfirmOverwrite; | 122 | attributes |= DbConfirmOverwrite; |
126 | } | 123 | } |
@@ -128,10 +125,10 @@ namespace WixToolset.Extensions | |||
128 | case "ContinueOnError": | 125 | case "ContinueOnError": |
129 | if (null == componentId) | 126 | if (null == componentId) |
130 | { | 127 | { |
131 | this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); | 128 | this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); |
132 | } | 129 | } |
133 | 130 | ||
134 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 131 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
135 | { | 132 | { |
136 | attributes |= DbContinueOnError; | 133 | attributes |= DbContinueOnError; |
137 | } | 134 | } |
@@ -139,10 +136,10 @@ namespace WixToolset.Extensions | |||
139 | case "CreateOnInstall": | 136 | case "CreateOnInstall": |
140 | if (null == componentId) | 137 | if (null == componentId) |
141 | { | 138 | { |
142 | this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); | 139 | this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); |
143 | } | 140 | } |
144 | 141 | ||
145 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 142 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
146 | { | 143 | { |
147 | attributes |= DbCreateOnInstall; | 144 | attributes |= DbCreateOnInstall; |
148 | } | 145 | } |
@@ -150,10 +147,10 @@ namespace WixToolset.Extensions | |||
150 | case "CreateOnReinstall": | 147 | case "CreateOnReinstall": |
151 | if (null == componentId) | 148 | if (null == componentId) |
152 | { | 149 | { |
153 | this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); | 150 | this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); |
154 | } | 151 | } |
155 | 152 | ||
156 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 153 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
157 | { | 154 | { |
158 | attributes |= DbCreateOnReinstall; | 155 | attributes |= DbCreateOnReinstall; |
159 | } | 156 | } |
@@ -161,24 +158,24 @@ namespace WixToolset.Extensions | |||
161 | case "CreateOnUninstall": | 158 | case "CreateOnUninstall": |
162 | if (null == componentId) | 159 | if (null == componentId) |
163 | { | 160 | { |
164 | this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); | 161 | this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); |
165 | } | 162 | } |
166 | 163 | ||
167 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 164 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
168 | { | 165 | { |
169 | attributes |= DbCreateOnUninstall; | 166 | attributes |= DbCreateOnUninstall; |
170 | } | 167 | } |
171 | break; | 168 | break; |
172 | case "Database": | 169 | case "Database": |
173 | database = this.Core.GetAttributeValue(sourceLineNumbers, attrib); | 170 | database = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
174 | break; | 171 | break; |
175 | case "DropOnInstall": | 172 | case "DropOnInstall": |
176 | if (null == componentId) | 173 | if (null == componentId) |
177 | { | 174 | { |
178 | this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); | 175 | this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); |
179 | } | 176 | } |
180 | 177 | ||
181 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 178 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
182 | { | 179 | { |
183 | attributes |= DbDropOnInstall; | 180 | attributes |= DbDropOnInstall; |
184 | } | 181 | } |
@@ -186,10 +183,10 @@ namespace WixToolset.Extensions | |||
186 | case "DropOnReinstall": | 183 | case "DropOnReinstall": |
187 | if (null == componentId) | 184 | if (null == componentId) |
188 | { | 185 | { |
189 | this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); | 186 | this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); |
190 | } | 187 | } |
191 | 188 | ||
192 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 189 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
193 | { | 190 | { |
194 | attributes |= DbDropOnReinstall; | 191 | attributes |= DbDropOnReinstall; |
195 | } | 192 | } |
@@ -198,142 +195,141 @@ namespace WixToolset.Extensions | |||
198 | case "DropOnUninstall": | 195 | case "DropOnUninstall": |
199 | if (null == componentId) | 196 | if (null == componentId) |
200 | { | 197 | { |
201 | this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); | 198 | this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); |
202 | } | 199 | } |
203 | 200 | ||
204 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 201 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
205 | { | 202 | { |
206 | attributes |= DbDropOnUninstall; | 203 | attributes |= DbDropOnUninstall; |
207 | } | 204 | } |
208 | break; | 205 | break; |
209 | case "Instance": | 206 | case "Instance": |
210 | instance = this.Core.GetAttributeValue(sourceLineNumbers, attrib); | 207 | instance = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
211 | break; | 208 | break; |
212 | case "Server": | 209 | case "Server": |
213 | server = this.Core.GetAttributeValue(sourceLineNumbers, attrib); | 210 | server = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
214 | break; | 211 | break; |
215 | case "User": | 212 | case "User": |
216 | user = this.Core.GetAttributeValue(sourceLineNumbers, attrib); | 213 | user = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
217 | if (!this.Core.ContainsProperty(user)) | 214 | if (!this.ParseHelper.ContainsProperty(user)) |
218 | { | 215 | { |
219 | user = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); | 216 | user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); |
220 | this.Core.CreateSimpleReference(sourceLineNumbers, "User", user); | 217 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "User", user); |
221 | } | 218 | } |
222 | break; | 219 | break; |
223 | default: | 220 | default: |
224 | this.Core.UnexpectedAttribute(node, attrib); | 221 | this.ParseHelper.UnexpectedAttribute(element, attrib); |
225 | break; | 222 | break; |
226 | } | 223 | } |
227 | } | 224 | } |
228 | else | 225 | else |
229 | { | 226 | { |
230 | this.Core.ParseExtensionAttribute(node, attrib); | 227 | this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); |
231 | } | 228 | } |
232 | } | 229 | } |
233 | 230 | ||
234 | if (null == id) | 231 | if (null == id) |
235 | { | 232 | { |
236 | this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); | 233 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); |
237 | } | 234 | } |
238 | 235 | ||
239 | if (null == database) | 236 | if (null == database) |
240 | { | 237 | { |
241 | this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Database")); | 238 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Database")); |
242 | } | 239 | } |
243 | else if (128 < database.Length) | 240 | else if (128 < database.Length) |
244 | { | 241 | { |
245 | this.Core.OnMessage(WixErrors.IdentifierTooLongError(sourceLineNumbers, node.Name.LocalName, "Database", database, 128)); | 242 | this.Messaging.Write(ErrorMessages.IdentifierTooLongError(sourceLineNumbers, element.Name.LocalName, "Database", database, 128)); |
246 | } | 243 | } |
247 | 244 | ||
248 | if (null == server) | 245 | if (null == server) |
249 | { | 246 | { |
250 | this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Server")); | 247 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Server")); |
251 | } | 248 | } |
252 | 249 | ||
253 | if (0 == attributes && null != componentId) | 250 | if (0 == attributes && null != componentId) |
254 | { | 251 | { |
255 | this.Core.OnMessage(SqlErrors.OneOfAttributesRequiredUnderComponent(sourceLineNumbers, node.Name.LocalName, "CreateOnInstall", "CreateOnUninstall", "DropOnInstall", "DropOnUninstall")); | 252 | this.Messaging.Write(SqlErrors.OneOfAttributesRequiredUnderComponent(sourceLineNumbers, element.Name.LocalName, "CreateOnInstall", "CreateOnUninstall", "DropOnInstall", "DropOnUninstall")); |
256 | } | 253 | } |
257 | 254 | ||
258 | foreach (XElement child in node.Elements()) | 255 | foreach (XElement child in element.Elements()) |
259 | { | 256 | { |
260 | if (this.Namespace == child.Name.Namespace) | 257 | if (this.Namespace == child.Name.Namespace) |
261 | { | 258 | { |
262 | SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); | 259 | SourceLineNumber childSourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(child); |
263 | switch (child.Name.LocalName) | 260 | switch (child.Name.LocalName) |
264 | { | 261 | { |
265 | case "SqlScript": | 262 | case "SqlScript": |
266 | if (null == componentId) | 263 | if (null == componentId) |
267 | { | 264 | { |
268 | this.Core.OnMessage(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); | 265 | this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); |
269 | } | 266 | } |
270 | 267 | ||
271 | this.ParseSqlScriptElement(child, componentId, id); | 268 | this.ParseSqlScriptElement(intermediate, section, child, componentId, id.Id); |
272 | break; | 269 | break; |
273 | case "SqlString": | 270 | case "SqlString": |
274 | if (null == componentId) | 271 | if (null == componentId) |
275 | { | 272 | { |
276 | this.Core.OnMessage(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); | 273 | this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); |
277 | } | 274 | } |
278 | 275 | ||
279 | this.ParseSqlStringElement(child, componentId, id); | 276 | this.ParseSqlStringElement(intermediate, section, child, componentId, id.Id); |
280 | break; | 277 | break; |
281 | case "SqlFileSpec": | 278 | case "SqlFileSpec": |
282 | if (null == componentId) | 279 | if (null == componentId) |
283 | { | 280 | { |
284 | this.Core.OnMessage(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); | 281 | this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); |
285 | } | 282 | } |
286 | else if (null != fileSpec) | 283 | else if (null != fileSpec) |
287 | { | 284 | { |
288 | this.Core.OnMessage(WixErrors.TooManyElements(sourceLineNumbers, node.Name.LocalName, child.Name.LocalName, 1)); | 285 | this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, element.Name.LocalName, child.Name.LocalName, 1)); |
289 | } | 286 | } |
290 | 287 | ||
291 | fileSpec = this.ParseSqlFileSpecElement(child); | 288 | fileSpec = this.ParseSqlFileSpecElement(intermediate, section, child); |
292 | break; | 289 | break; |
293 | case "SqlLogFileSpec": | 290 | case "SqlLogFileSpec": |
294 | if (null == componentId) | 291 | if (null == componentId) |
295 | { | 292 | { |
296 | this.Core.OnMessage(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); | 293 | this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); |
297 | } | 294 | } |
298 | else if (null != logFileSpec) | 295 | else if (null != logFileSpec) |
299 | { | 296 | { |
300 | this.Core.OnMessage(WixErrors.TooManyElements(sourceLineNumbers, node.Name.LocalName, child.Name.LocalName, 1)); | 297 | this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, element.Name.LocalName, child.Name.LocalName, 1)); |
301 | } | 298 | } |
302 | 299 | ||
303 | logFileSpec = this.ParseSqlFileSpecElement(child); | 300 | logFileSpec = this.ParseSqlFileSpecElement(intermediate, section, child); |
304 | break; | 301 | break; |
305 | default: | 302 | default: |
306 | this.Core.UnexpectedElement(node, child); | 303 | this.ParseHelper.UnexpectedElement(element, child); |
307 | break; | 304 | break; |
308 | } | 305 | } |
309 | } | 306 | } |
310 | else | 307 | else |
311 | { | 308 | { |
312 | this.Core.ParseExtensionElement(node, child); | 309 | this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, element, child); |
313 | } | 310 | } |
314 | } | 311 | } |
315 | 312 | ||
316 | if (null != componentId) | 313 | if (null != componentId) |
317 | { | 314 | { |
318 | // Reference InstallSqlData and UninstallSqlData since nothing will happen without it | 315 | // Reference InstallSqlData and UninstallSqlData since nothing will happen without it |
319 | this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "InstallSqlData"); | 316 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "InstallSqlData"); |
320 | this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "UninstallSqlData"); | 317 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "UninstallSqlData"); |
321 | } | 318 | } |
322 | 319 | ||
323 | if (!this.Core.EncounteredError) | 320 | if (!this.Messaging.EncounteredError) |
324 | { | 321 | { |
325 | Row row = this.Core.CreateRow(sourceLineNumbers, "SqlDatabase"); | 322 | var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlDatabase", id); |
326 | row[0] = id; | 323 | row.Set(1, server); |
327 | row[1] = server; | 324 | row.Set(2, instance); |
328 | row[2] = instance; | 325 | row.Set(3, database); |
329 | row[3] = database; | 326 | row.Set(4, componentId); |
330 | row[4] = componentId; | 327 | row.Set(5, user); |
331 | row[5] = user; | 328 | row.Set(6, fileSpec.Id); |
332 | row[6] = fileSpec; | 329 | row.Set(7, logFileSpec.Id); |
333 | row[7] = logFileSpec; | ||
334 | if (0 != attributes) | 330 | if (0 != attributes) |
335 | { | 331 | { |
336 | row[8] = attributes; | 332 | row.Set(8, attributes); |
337 | } | 333 | } |
338 | } | 334 | } |
339 | } | 335 | } |
@@ -341,89 +337,90 @@ namespace WixToolset.Extensions | |||
341 | /// <summary> | 337 | /// <summary> |
342 | /// Parses a sql file specification element. | 338 | /// Parses a sql file specification element. |
343 | /// </summary> | 339 | /// </summary> |
344 | /// <param name="node">Element to parse.</param> | 340 | /// <param name="intermediate"></param> |
341 | /// <param name="section"></param> | ||
342 | /// <param name="element">Element to parse.</param> | ||
345 | /// <returns>Identifier of sql file specification.</returns> | 343 | /// <returns>Identifier of sql file specification.</returns> |
346 | private string ParseSqlFileSpecElement(XElement node) | 344 | private Identifier ParseSqlFileSpecElement(Intermediate intermediate, IntermediateSection section, XElement element) |
347 | { | 345 | { |
348 | SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); | 346 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); |
349 | string id = null; | 347 | Identifier id = null; |
350 | string fileName = null; | 348 | string fileName = null; |
351 | string growthSize = null; | 349 | string growthSize = null; |
352 | string maxSize = null; | 350 | string maxSize = null; |
353 | string name = null; | 351 | string name = null; |
354 | string size = null; | 352 | string size = null; |
355 | 353 | ||
356 | foreach (XAttribute attrib in node.Attributes()) | 354 | foreach (XAttribute attrib in element.Attributes()) |
357 | { | 355 | { |
358 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | 356 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) |
359 | { | 357 | { |
360 | switch (attrib.Name.LocalName) | 358 | switch (attrib.Name.LocalName) |
361 | { | 359 | { |
362 | case "Id": | 360 | case "Id": |
363 | id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); | 361 | id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); |
364 | break; | 362 | break; |
365 | case "Name": | 363 | case "Name": |
366 | name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); | 364 | name = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
367 | break; | 365 | break; |
368 | case "Filename": | 366 | case "Filename": |
369 | fileName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); | 367 | fileName = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
370 | break; | 368 | break; |
371 | case "Size": | 369 | case "Size": |
372 | size = this.Core.GetAttributeValue(sourceLineNumbers, attrib); | 370 | size = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
373 | break; | 371 | break; |
374 | case "MaxSize": | 372 | case "MaxSize": |
375 | maxSize = this.Core.GetAttributeValue(sourceLineNumbers, attrib); | 373 | maxSize = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
376 | break; | 374 | break; |
377 | case "GrowthSize": | 375 | case "GrowthSize": |
378 | growthSize = this.Core.GetAttributeValue(sourceLineNumbers, attrib); | 376 | growthSize = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
379 | break; | 377 | break; |
380 | default: | 378 | default: |
381 | this.Core.UnexpectedAttribute(node, attrib); | 379 | this.ParseHelper.UnexpectedAttribute(element, attrib); |
382 | break; | 380 | break; |
383 | } | 381 | } |
384 | } | 382 | } |
385 | else | 383 | else |
386 | { | 384 | { |
387 | this.Core.ParseExtensionAttribute(node, attrib); | 385 | this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); |
388 | } | 386 | } |
389 | } | 387 | } |
390 | 388 | ||
391 | if (null == id) | 389 | if (null == id) |
392 | { | 390 | { |
393 | this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); | 391 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); |
394 | } | 392 | } |
395 | 393 | ||
396 | if (null == name) | 394 | if (null == name) |
397 | { | 395 | { |
398 | this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name")); | 396 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Name")); |
399 | } | 397 | } |
400 | 398 | ||
401 | if (null == fileName) | 399 | if (null == fileName) |
402 | { | 400 | { |
403 | this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Filename")); | 401 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Filename")); |
404 | } | 402 | } |
405 | 403 | ||
406 | this.Core.ParseForExtensionElements(node); | 404 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); |
407 | 405 | ||
408 | if (!this.Core.EncounteredError) | 406 | if (!this.Messaging.EncounteredError) |
409 | { | 407 | { |
410 | Row row = this.Core.CreateRow(sourceLineNumbers, "SqlFileSpec"); | 408 | var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlFileSpec", id); |
411 | row[0] = id; | 409 | row.Set(1, name); |
412 | row[1] = name; | 410 | row.Set(2, fileName); |
413 | row[2] = fileName; | ||
414 | if (null != size) | 411 | if (null != size) |
415 | { | 412 | { |
416 | row[3] = size; | 413 | row.Set(3, size); |
417 | } | 414 | } |
418 | 415 | ||
419 | if (null != maxSize) | 416 | if (null != maxSize) |
420 | { | 417 | { |
421 | row[4] = maxSize; | 418 | row.Set(4, maxSize); |
422 | } | 419 | } |
423 | 420 | ||
424 | if (null != growthSize) | 421 | if (null != growthSize) |
425 | { | 422 | { |
426 | row[5] = growthSize; | 423 | row.Set(5, growthSize); |
427 | } | 424 | } |
428 | } | 425 | } |
429 | 426 | ||
@@ -433,13 +430,13 @@ namespace WixToolset.Extensions | |||
433 | /// <summary> | 430 | /// <summary> |
434 | /// Parses a sql script element. | 431 | /// Parses a sql script element. |
435 | /// </summary> | 432 | /// </summary> |
436 | /// <param name="node">Element to parse.</param> | 433 | /// <param name="element">Element to parse.</param> |
437 | /// <param name="componentId">Identifier for parent component.</param> | 434 | /// <param name="componentId">Identifier for parent component.</param> |
438 | /// <param name="sqlDb">Optional database to execute script against.</param> | 435 | /// <param name="sqlDb">Optional database to execute script against.</param> |
439 | private void ParseSqlScriptElement(XElement node, string componentId, string sqlDb) | 436 | private void ParseSqlScriptElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string sqlDb) |
440 | { | 437 | { |
441 | SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); | 438 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); |
442 | string id = null; | 439 | Identifier id = null; |
443 | int attributes = 0; | 440 | int attributes = 0; |
444 | bool rollbackAttribute = false; | 441 | bool rollbackAttribute = false; |
445 | bool nonRollbackAttribute = false; | 442 | bool nonRollbackAttribute = false; |
@@ -447,38 +444,38 @@ namespace WixToolset.Extensions | |||
447 | int sequence = CompilerConstants.IntegerNotSet; | 444 | int sequence = CompilerConstants.IntegerNotSet; |
448 | string user = null; | 445 | string user = null; |
449 | 446 | ||
450 | foreach (XAttribute attrib in node.Attributes()) | 447 | foreach (XAttribute attrib in element.Attributes()) |
451 | { | 448 | { |
452 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | 449 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) |
453 | { | 450 | { |
454 | switch (attrib.Name.LocalName) | 451 | switch (attrib.Name.LocalName) |
455 | { | 452 | { |
456 | case "Id": | 453 | case "Id": |
457 | id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); | 454 | id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); |
458 | break; | 455 | break; |
459 | case "BinaryKey": | 456 | case "BinaryKey": |
460 | binary = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); | 457 | binary = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); |
461 | this.Core.CreateSimpleReference(sourceLineNumbers, "Binary", binary); | 458 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "Binary", binary); |
462 | break; | 459 | break; |
463 | case "Sequence": | 460 | case "Sequence": |
464 | sequence = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); | 461 | sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); |
465 | break; | 462 | break; |
466 | case "SqlDb": | 463 | case "SqlDb": |
467 | if (null != sqlDb) | 464 | if (null != sqlDb) |
468 | { | 465 | { |
469 | this.Core.OnMessage(WixErrors.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, node.Parent.Name.LocalName)); | 466 | this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, element.Parent.Name.LocalName)); |
470 | } | 467 | } |
471 | sqlDb = this.Core.GetAttributeValue(sourceLineNumbers, attrib); | 468 | sqlDb = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
472 | this.Core.CreateSimpleReference(sourceLineNumbers, "SqlDatabase", sqlDb); | 469 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "SqlDatabase", sqlDb); |
473 | break; | 470 | break; |
474 | case "User": | 471 | case "User": |
475 | user = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); | 472 | user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); |
476 | this.Core.CreateSimpleReference(sourceLineNumbers, "User", user); | 473 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "User", user); |
477 | break; | 474 | break; |
478 | 475 | ||
479 | // Flag-setting attributes | 476 | // Flag-setting attributes |
480 | case "ContinueOnError": | 477 | case "ContinueOnError": |
481 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 478 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
482 | { | 479 | { |
483 | attributes |= SqlContinueOnError; | 480 | attributes |= SqlContinueOnError; |
484 | } | 481 | } |
@@ -486,11 +483,11 @@ namespace WixToolset.Extensions | |||
486 | case "ExecuteOnInstall": | 483 | case "ExecuteOnInstall": |
487 | if (rollbackAttribute) | 484 | if (rollbackAttribute) |
488 | { | 485 | { |
489 | this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); | 486 | this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); |
490 | } | 487 | } |
491 | nonRollbackAttribute = true; | 488 | nonRollbackAttribute = true; |
492 | 489 | ||
493 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 490 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
494 | { | 491 | { |
495 | attributes |= SqlExecuteOnInstall; | 492 | attributes |= SqlExecuteOnInstall; |
496 | } | 493 | } |
@@ -498,11 +495,11 @@ namespace WixToolset.Extensions | |||
498 | case "ExecuteOnReinstall": | 495 | case "ExecuteOnReinstall": |
499 | if (rollbackAttribute) | 496 | if (rollbackAttribute) |
500 | { | 497 | { |
501 | this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); | 498 | this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); |
502 | } | 499 | } |
503 | nonRollbackAttribute = true; | 500 | nonRollbackAttribute = true; |
504 | 501 | ||
505 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 502 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
506 | { | 503 | { |
507 | attributes |= SqlExecuteOnReinstall; | 504 | attributes |= SqlExecuteOnReinstall; |
508 | } | 505 | } |
@@ -510,11 +507,11 @@ namespace WixToolset.Extensions | |||
510 | case "ExecuteOnUninstall": | 507 | case "ExecuteOnUninstall": |
511 | if (rollbackAttribute) | 508 | if (rollbackAttribute) |
512 | { | 509 | { |
513 | this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); | 510 | this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); |
514 | } | 511 | } |
515 | nonRollbackAttribute = true; | 512 | nonRollbackAttribute = true; |
516 | 513 | ||
517 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 514 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
518 | { | 515 | { |
519 | attributes |= SqlExecuteOnUninstall; | 516 | attributes |= SqlExecuteOnUninstall; |
520 | } | 517 | } |
@@ -522,11 +519,11 @@ namespace WixToolset.Extensions | |||
522 | case "RollbackOnInstall": | 519 | case "RollbackOnInstall": |
523 | if (nonRollbackAttribute) | 520 | if (nonRollbackAttribute) |
524 | { | 521 | { |
525 | this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); | 522 | this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); |
526 | } | 523 | } |
527 | rollbackAttribute = true; | 524 | rollbackAttribute = true; |
528 | 525 | ||
529 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 526 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
530 | { | 527 | { |
531 | attributes |= SqlExecuteOnInstall; | 528 | attributes |= SqlExecuteOnInstall; |
532 | attributes |= SqlRollback; | 529 | attributes |= SqlRollback; |
@@ -535,11 +532,11 @@ namespace WixToolset.Extensions | |||
535 | case "RollbackOnReinstall": | 532 | case "RollbackOnReinstall": |
536 | if (nonRollbackAttribute) | 533 | if (nonRollbackAttribute) |
537 | { | 534 | { |
538 | this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); | 535 | this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); |
539 | } | 536 | } |
540 | rollbackAttribute = true; | 537 | rollbackAttribute = true; |
541 | 538 | ||
542 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 539 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
543 | { | 540 | { |
544 | attributes |= SqlExecuteOnReinstall; | 541 | attributes |= SqlExecuteOnReinstall; |
545 | attributes |= SqlRollback; | 542 | attributes |= SqlRollback; |
@@ -548,65 +545,64 @@ namespace WixToolset.Extensions | |||
548 | case "RollbackOnUninstall": | 545 | case "RollbackOnUninstall": |
549 | if (nonRollbackAttribute) | 546 | if (nonRollbackAttribute) |
550 | { | 547 | { |
551 | this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); | 548 | this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); |
552 | } | 549 | } |
553 | rollbackAttribute = true; | 550 | rollbackAttribute = true; |
554 | 551 | ||
555 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 552 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
556 | { | 553 | { |
557 | attributes |= SqlExecuteOnUninstall; | 554 | attributes |= SqlExecuteOnUninstall; |
558 | attributes |= SqlRollback; | 555 | attributes |= SqlRollback; |
559 | } | 556 | } |
560 | break; | 557 | break; |
561 | default: | 558 | default: |
562 | this.Core.UnexpectedAttribute(node, attrib); | 559 | this.ParseHelper.UnexpectedAttribute(element, attrib); |
563 | break; | 560 | break; |
564 | } | 561 | } |
565 | } | 562 | } |
566 | else | 563 | else |
567 | { | 564 | { |
568 | this.Core.ParseExtensionAttribute(node, attrib); | 565 | this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); |
569 | } | 566 | } |
570 | } | 567 | } |
571 | 568 | ||
572 | if (null == id) | 569 | if (null == id) |
573 | { | 570 | { |
574 | this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); | 571 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); |
575 | } | 572 | } |
576 | 573 | ||
577 | if (null == binary) | 574 | if (null == binary) |
578 | { | 575 | { |
579 | this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "BinaryKey")); | 576 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "BinaryKey")); |
580 | } | 577 | } |
581 | 578 | ||
582 | if (null == sqlDb) | 579 | if (null == sqlDb) |
583 | { | 580 | { |
584 | this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "SqlDb")); | 581 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "SqlDb")); |
585 | } | 582 | } |
586 | 583 | ||
587 | if (0 == attributes) | 584 | if (0 == attributes) |
588 | { | 585 | { |
589 | this.Core.OnMessage(WixErrors.ExpectedAttributes(sourceLineNumbers, node.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall", "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); | 586 | this.Messaging.Write(ErrorMessages.ExpectedAttributes(sourceLineNumbers, element.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall", "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); |
590 | } | 587 | } |
591 | 588 | ||
592 | this.Core.ParseForExtensionElements(node); | 589 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); |
593 | 590 | ||
594 | // Reference InstallSqlData and UninstallSqlData since nothing will happen without it | 591 | // Reference InstallSqlData and UninstallSqlData since nothing will happen without it |
595 | this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "InstallSqlData"); | 592 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "InstallSqlData"); |
596 | this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "UninstallSqlData"); | 593 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "UninstallSqlData"); |
597 | 594 | ||
598 | if (!this.Core.EncounteredError) | 595 | if (!this.Messaging.EncounteredError) |
599 | { | 596 | { |
600 | Row row = this.Core.CreateRow(sourceLineNumbers, "SqlScript"); | 597 | var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlScript", id); |
601 | row[0] = id; | 598 | row.Set(1, sqlDb); |
602 | row[1] = sqlDb; | 599 | row.Set(2, componentId); |
603 | row[2] = componentId; | 600 | row.Set(3, binary); |
604 | row[3] = binary; | 601 | row.Set(4, user); |
605 | row[4] = user; | 602 | row.Set(5, attributes); |
606 | row[5] = attributes; | ||
607 | if (CompilerConstants.IntegerNotSet != sequence) | 603 | if (CompilerConstants.IntegerNotSet != sequence) |
608 | { | 604 | { |
609 | row[6] = sequence; | 605 | row.Set(6, sequence); |
610 | } | 606 | } |
611 | } | 607 | } |
612 | } | 608 | } |
@@ -614,13 +610,13 @@ namespace WixToolset.Extensions | |||
614 | /// <summary> | 610 | /// <summary> |
615 | /// Parses a sql string element. | 611 | /// Parses a sql string element. |
616 | /// </summary> | 612 | /// </summary> |
617 | /// <param name="node">Element to parse.</param> | 613 | /// <param name="element">Element to parse.</param> |
618 | /// <param name="componentId">Identifier for parent component.</param> | 614 | /// <param name="componentId">Identifier for parent component.</param> |
619 | /// <param name="sqlDb">Optional database to execute string against.</param> | 615 | /// <param name="sqlDb">Optional database to execute string against.</param> |
620 | private void ParseSqlStringElement(XElement node, string componentId, string sqlDb) | 616 | private void ParseSqlStringElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string sqlDb) |
621 | { | 617 | { |
622 | SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); | 618 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); |
623 | string id = null; | 619 | Identifier id = null; |
624 | int attributes = 0; | 620 | int attributes = 0; |
625 | bool rollbackAttribute = false; | 621 | bool rollbackAttribute = false; |
626 | bool nonRollbackAttribute = false; | 622 | bool nonRollbackAttribute = false; |
@@ -628,17 +624,17 @@ namespace WixToolset.Extensions | |||
628 | string sql = null; | 624 | string sql = null; |
629 | string user = null; | 625 | string user = null; |
630 | 626 | ||
631 | foreach (XAttribute attrib in node.Attributes()) | 627 | foreach (XAttribute attrib in element.Attributes()) |
632 | { | 628 | { |
633 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | 629 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) |
634 | { | 630 | { |
635 | switch (attrib.Name.LocalName) | 631 | switch (attrib.Name.LocalName) |
636 | { | 632 | { |
637 | case "Id": | 633 | case "Id": |
638 | id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); | 634 | id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); |
639 | break; | 635 | break; |
640 | case "ContinueOnError": | 636 | case "ContinueOnError": |
641 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 637 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
642 | { | 638 | { |
643 | attributes |= SqlContinueOnError; | 639 | attributes |= SqlContinueOnError; |
644 | } | 640 | } |
@@ -646,11 +642,11 @@ namespace WixToolset.Extensions | |||
646 | case "ExecuteOnInstall": | 642 | case "ExecuteOnInstall": |
647 | if (rollbackAttribute) | 643 | if (rollbackAttribute) |
648 | { | 644 | { |
649 | this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); | 645 | this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); |
650 | } | 646 | } |
651 | nonRollbackAttribute = true; | 647 | nonRollbackAttribute = true; |
652 | 648 | ||
653 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 649 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
654 | { | 650 | { |
655 | attributes |= SqlExecuteOnInstall; | 651 | attributes |= SqlExecuteOnInstall; |
656 | } | 652 | } |
@@ -658,11 +654,11 @@ namespace WixToolset.Extensions | |||
658 | case "ExecuteOnReinstall": | 654 | case "ExecuteOnReinstall": |
659 | if (rollbackAttribute) | 655 | if (rollbackAttribute) |
660 | { | 656 | { |
661 | this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); | 657 | this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); |
662 | } | 658 | } |
663 | nonRollbackAttribute = true; | 659 | nonRollbackAttribute = true; |
664 | 660 | ||
665 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 661 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
666 | { | 662 | { |
667 | attributes |= SqlExecuteOnReinstall; | 663 | attributes |= SqlExecuteOnReinstall; |
668 | } | 664 | } |
@@ -670,11 +666,11 @@ namespace WixToolset.Extensions | |||
670 | case "ExecuteOnUninstall": | 666 | case "ExecuteOnUninstall": |
671 | if (rollbackAttribute) | 667 | if (rollbackAttribute) |
672 | { | 668 | { |
673 | this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); | 669 | this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); |
674 | } | 670 | } |
675 | nonRollbackAttribute = true; | 671 | nonRollbackAttribute = true; |
676 | 672 | ||
677 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 673 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
678 | { | 674 | { |
679 | attributes |= SqlExecuteOnUninstall; | 675 | attributes |= SqlExecuteOnUninstall; |
680 | } | 676 | } |
@@ -682,11 +678,11 @@ namespace WixToolset.Extensions | |||
682 | case "RollbackOnInstall": | 678 | case "RollbackOnInstall": |
683 | if (nonRollbackAttribute) | 679 | if (nonRollbackAttribute) |
684 | { | 680 | { |
685 | this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); | 681 | this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); |
686 | } | 682 | } |
687 | rollbackAttribute = true; | 683 | rollbackAttribute = true; |
688 | 684 | ||
689 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 685 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
690 | { | 686 | { |
691 | attributes |= SqlExecuteOnInstall; | 687 | attributes |= SqlExecuteOnInstall; |
692 | attributes |= SqlRollback; | 688 | attributes |= SqlRollback; |
@@ -695,11 +691,11 @@ namespace WixToolset.Extensions | |||
695 | case "RollbackOnReinstall": | 691 | case "RollbackOnReinstall": |
696 | if (nonRollbackAttribute) | 692 | if (nonRollbackAttribute) |
697 | { | 693 | { |
698 | this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); | 694 | this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); |
699 | } | 695 | } |
700 | rollbackAttribute = true; | 696 | rollbackAttribute = true; |
701 | 697 | ||
702 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 698 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
703 | { | 699 | { |
704 | attributes |= SqlExecuteOnReinstall; | 700 | attributes |= SqlExecuteOnReinstall; |
705 | attributes |= SqlRollback; | 701 | attributes |= SqlRollback; |
@@ -708,84 +704,83 @@ namespace WixToolset.Extensions | |||
708 | case "RollbackOnUninstall": | 704 | case "RollbackOnUninstall": |
709 | if (nonRollbackAttribute) | 705 | if (nonRollbackAttribute) |
710 | { | 706 | { |
711 | this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); | 707 | this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); |
712 | } | 708 | } |
713 | rollbackAttribute = true; | 709 | rollbackAttribute = true; |
714 | 710 | ||
715 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 711 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
716 | { | 712 | { |
717 | attributes |= SqlExecuteOnUninstall; | 713 | attributes |= SqlExecuteOnUninstall; |
718 | attributes |= SqlRollback; | 714 | attributes |= SqlRollback; |
719 | } | 715 | } |
720 | break; | 716 | break; |
721 | case "Sequence": | 717 | case "Sequence": |
722 | sequence = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); | 718 | sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); |
723 | break; | 719 | break; |
724 | case "SQL": | 720 | case "SQL": |
725 | sql = this.Core.GetAttributeValue(sourceLineNumbers, attrib); | 721 | sql = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
726 | break; | 722 | break; |
727 | case "SqlDb": | 723 | case "SqlDb": |
728 | if (null != sqlDb) | 724 | if (null != sqlDb) |
729 | { | 725 | { |
730 | this.Core.OnMessage(WixErrors.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, "SqlDb", "SqlDatabase")); | 726 | this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, "SqlDb", "SqlDatabase")); |
731 | } | 727 | } |
732 | 728 | ||
733 | sqlDb = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); | 729 | sqlDb = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); |
734 | this.Core.CreateSimpleReference(sourceLineNumbers, "SqlDatabase", sqlDb); | 730 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "SqlDatabase", sqlDb); |
735 | break; | 731 | break; |
736 | case "User": | 732 | case "User": |
737 | user = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); | 733 | user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); |
738 | this.Core.CreateSimpleReference(sourceLineNumbers, "User", user); | 734 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "User", user); |
739 | break; | 735 | break; |
740 | default: | 736 | default: |
741 | this.Core.UnexpectedAttribute(node, attrib); | 737 | this.ParseHelper.UnexpectedAttribute(element, attrib); |
742 | break; | 738 | break; |
743 | } | 739 | } |
744 | } | 740 | } |
745 | else | 741 | else |
746 | { | 742 | { |
747 | this.Core.ParseExtensionAttribute(node, attrib); | 743 | this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); |
748 | } | 744 | } |
749 | } | 745 | } |
750 | 746 | ||
751 | if (null == id) | 747 | if (null == id) |
752 | { | 748 | { |
753 | this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); | 749 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); |
754 | } | 750 | } |
755 | 751 | ||
756 | if (null == sql) | 752 | if (null == sql) |
757 | { | 753 | { |
758 | this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "SQL")); | 754 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "SQL")); |
759 | } | 755 | } |
760 | 756 | ||
761 | if (null == sqlDb) | 757 | if (null == sqlDb) |
762 | { | 758 | { |
763 | this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "SqlDb")); | 759 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "SqlDb")); |
764 | } | 760 | } |
765 | 761 | ||
766 | if (0 == attributes) | 762 | if (0 == attributes) |
767 | { | 763 | { |
768 | this.Core.OnMessage(WixErrors.ExpectedAttributes(sourceLineNumbers, node.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall", "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); | 764 | this.Messaging.Write(ErrorMessages.ExpectedAttributes(sourceLineNumbers, element.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall", "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); |
769 | } | 765 | } |
770 | 766 | ||
771 | this.Core.ParseForExtensionElements(node); | 767 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); |
772 | 768 | ||
773 | // Reference InstallSqlData and UninstallSqlData since nothing will happen without it | 769 | // Reference InstallSqlData and UninstallSqlData since nothing will happen without it |
774 | this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "InstallSqlData"); | 770 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "InstallSqlData"); |
775 | this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "UninstallSqlData"); | 771 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "UninstallSqlData"); |
776 | 772 | ||
777 | if (!this.Core.EncounteredError) | 773 | if (!this.Messaging.EncounteredError) |
778 | { | 774 | { |
779 | Row row = this.Core.CreateRow(sourceLineNumbers, "SqlString"); | 775 | var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlString", id); |
780 | row[0] = id; | 776 | row.Set(1, sqlDb); |
781 | row[1] = sqlDb; | 777 | row.Set(2, componentId); |
782 | row[2] = componentId; | 778 | row.Set(3, sql); |
783 | row[3] = sql; | 779 | row.Set(4, user); |
784 | row[4] = user; | 780 | row.Set(5, attributes); |
785 | row[5] = attributes; | ||
786 | if (CompilerConstants.IntegerNotSet != sequence) | 781 | if (CompilerConstants.IntegerNotSet != sequence) |
787 | { | 782 | { |
788 | row[6] = sequence; | 783 | row.Set(6, sequence); |
789 | } | 784 | } |
790 | } | 785 | } |
791 | } | 786 | } |
diff --git a/src/wixext/SqlDecompiler.cs b/src/wixext/SqlDecompiler.cs index 64192e84..52436b87 100644 --- a/src/wixext/SqlDecompiler.cs +++ b/src/wixext/SqlDecompiler.cs | |||
@@ -1,7 +1,8 @@ | |||
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. | 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 | 2 | ||
3 | namespace WixToolset.Extensions | 3 | namespace WixToolset.Sql |
4 | { | 4 | { |
5 | #if TODO_CONSIDER_DECOMPILER | ||
5 | using System.Collections; | 6 | using System.Collections; |
6 | using WixToolset.Data; | 7 | using WixToolset.Data; |
7 | using WixToolset.Extensibility; | 8 | using WixToolset.Extensibility; |
@@ -509,4 +510,5 @@ namespace WixToolset.Extensions | |||
509 | } | 510 | } |
510 | } | 511 | } |
511 | } | 512 | } |
513 | #endif | ||
512 | } | 514 | } |
diff --git a/src/wixext/SqlErrors.cs b/src/wixext/SqlErrors.cs index 2043b658..f25728bd 100644 --- a/src/wixext/SqlErrors.cs +++ b/src/wixext/SqlErrors.cs | |||
@@ -1,32 +1,48 @@ | |||
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. | 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 | 2 | ||
3 | namespace WixToolset.Extensions | 3 | namespace WixToolset.Sql |
4 | { | 4 | { |
5 | public sealed class SqlErrors | 5 | using System.Resources; |
6 | using WixToolset.Data; | ||
7 | |||
8 | public static class SqlErrors | ||
6 | { | 9 | { |
7 | 10 | public static Message IllegalAttributeWithoutComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName) | |
8 | private SqlErrors() | ||
9 | { | 11 | { |
12 | return Message(sourceLineNumbers, Ids.IllegalAttributeWithoutComponent, "The {0}/@{1} attribute cannot be specified unless the element has a Component as an ancestor. A {0} that does not have a Component ancestor is not installed.", elementName, attributeName); | ||
10 | } | 13 | } |
11 | 14 | ||
12 | public static MessageEventArgs IllegalAttributeWithoutComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName) | 15 | public static Message IllegalElementWithoutComponent(SourceLineNumber sourceLineNumbers, string elementName) |
13 | { | 16 | { |
14 | return new SqlErrorEventArgs(sourceLineNumbers, 5100, "SqlErrors_IllegalAttributeWithoutComponent_1", elementName, attributeName); | 17 | return Message(sourceLineNumbers, Ids.IllegalElementWithoutComponent, "The {0} element cannot be specified unless the element has a Component as an ancestor. A {0} that does not have a Component ancestor is not installed.", elementName); |
15 | } | 18 | } |
16 | 19 | ||
17 | public static MessageEventArgs IllegalElementWithoutComponent(SourceLineNumber sourceLineNumbers, string elementName) | 20 | public static Message OneOfAttributesRequiredUnderComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName1, string attributeName2, string attributeName3, string attributeName4) |
18 | { | 21 | { |
19 | return new SqlErrorEventArgs(sourceLineNumbers, 5101, "SqlErrors_IllegalElementWithoutComponent_1", elementName); | 22 | return Message(sourceLineNumbers, Ids.OneOfAttributesRequiredUnderComponent, "When nested under a Component, the {0} element must have one of the following attributes specified: {1}, {2}, {3} or {4}.", elementName, attributeName1, attributeName2, attributeName3, attributeName4); |
20 | } | 23 | } |
21 | 24 | ||
22 | public static MessageEventArgs OneOfAttributesRequiredUnderComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName1, string attributeName2, string attributeName3, string attributeName4) | 25 | public static Message DeprecatedBinaryChildElement(SourceLineNumber sourceLineNumbers, string elementName) |
23 | { | 26 | { |
24 | return new SqlErrorEventArgs(sourceLineNumbers, 5102, "SqlErrors_OneOfAttributesRequiredUnderComponent_1", elementName, attributeName1, attributeName2, attributeName3, attributeName4); | 27 | return Message(sourceLineNumbers, Ids.DeprecatedBinaryChildElement, "The {0} element contains a deprecated child Binary element. Please move the Binary element under a Fragment, Module, or Product element and set the {0}/@BinaryKey attribute to the value of the Binary/@Id attribute.", elementName); |
25 | } | 28 | } |
26 | 29 | ||
27 | public static MessageEventArgs DeprecatedBinaryChildElement(SourceLineNumber sourceLineNumbers, string elementName) | 30 | private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) |
31 | { | ||
32 | return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); | ||
33 | } | ||
34 | |||
35 | private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args) | ||
36 | { | ||
37 | return new Message(sourceLineNumber, MessageLevel.Error, (int)id, resourceManager, resourceName, args); | ||
38 | } | ||
39 | |||
40 | public enum Ids | ||
28 | { | 41 | { |
29 | return new SqlErrorEventArgs(sourceLineNumbers, 5103, "SqlErrors_DeprecatedBinaryChildElement_1", elementName); | 42 | IllegalAttributeWithoutComponent = 5100, |
43 | IllegalElementWithoutComponent = 5101, | ||
44 | OneOfAttributesRequiredUnderComponent = 5102, | ||
45 | DeprecatedBinaryChildElement = 5103, | ||
30 | } | 46 | } |
31 | } | 47 | } |
32 | } \ No newline at end of file | 48 | } \ No newline at end of file |
diff --git a/src/wixext/SqlExtensionData.cs b/src/wixext/SqlExtensionData.cs index b43b0341..a1b24b07 100644 --- a/src/wixext/SqlExtensionData.cs +++ b/src/wixext/SqlExtensionData.cs | |||
@@ -1,64 +1,30 @@ | |||
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. | 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 | 2 | ||
3 | namespace WixToolset.Extensions | 3 | namespace WixToolset.Sql |
4 | { | 4 | { |
5 | using System; | ||
6 | using System.Reflection; | ||
7 | using WixToolset.Data; | 5 | using WixToolset.Data; |
8 | using WixToolset.Extensibility; | 6 | using WixToolset.Extensibility; |
9 | 7 | ||
10 | /// <summary> | 8 | /// <summary> |
11 | /// The WiX Toolset SQL Server Extension. | 9 | /// The WiX Toolset SQL Server Extension. |
12 | /// </summary> | 10 | /// </summary> |
13 | public sealed class SqlExtensionData : ExtensionData | 11 | public sealed class SqlExtensionData : BaseExtensionData |
14 | { | 12 | { |
15 | /// <summary> | 13 | /// <summary> |
16 | /// Gets the default culture. | 14 | /// Gets the default culture. |
17 | /// </summary> | 15 | /// </summary> |
18 | /// <value>The default culture.</value> | 16 | /// <value>The default culture.</value> |
19 | public override string DefaultCulture | 17 | public override string DefaultCulture => "en-US"; |
20 | { | ||
21 | get { return "en-us"; } | ||
22 | } | ||
23 | |||
24 | /// <summary> | ||
25 | /// Gets the optional table definitions for this extension. | ||
26 | /// </summary> | ||
27 | /// <value>The optional table definitions for this extension.</value> | ||
28 | public override TableDefinitionCollection TableDefinitions | ||
29 | { | ||
30 | get | ||
31 | { | ||
32 | return SqlExtensionData.GetExtensionTableDefinitions(); | ||
33 | } | ||
34 | } | ||
35 | |||
36 | /// <summary> | ||
37 | /// Gets the library associated with this extension. | ||
38 | /// </summary> | ||
39 | /// <param name="tableDefinitions">The table definitions to use while loading the library.</param> | ||
40 | /// <returns>The loaded library.</returns> | ||
41 | public override Library GetLibrary(TableDefinitionCollection tableDefinitions) | ||
42 | { | ||
43 | return SqlExtensionData.GetExtensionLibrary(tableDefinitions); | ||
44 | } | ||
45 | 18 | ||
46 | /// <summary> | 19 | public override bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) |
47 | /// Internal mechanism to access the extension's table definitions. | ||
48 | /// </summary> | ||
49 | /// <returns>Extension's table definitions.</returns> | ||
50 | internal static TableDefinitionCollection GetExtensionTableDefinitions() | ||
51 | { | 20 | { |
52 | return ExtensionData.LoadTableDefinitionHelper(Assembly.GetExecutingAssembly(), "WixToolset.Extensions.Data.tables.xml"); | 21 | tupleDefinition = null; |
22 | return tupleDefinition != null; | ||
53 | } | 23 | } |
54 | 24 | ||
55 | /// <summary> | 25 | public override Intermediate GetLibrary(ITupleDefinitionCreator tupleDefinitions) |
56 | /// Internal mechanism to access the extension's library. | ||
57 | /// </summary> | ||
58 | /// <returns>Extension's library.</returns> | ||
59 | internal static Library GetExtensionLibrary(TableDefinitionCollection tableDefinitions) | ||
60 | { | 26 | { |
61 | return ExtensionData.LoadLibraryHelper(Assembly.GetExecutingAssembly(), "WixToolset.Extensions.Data.sql.wixlib", tableDefinitions); | 27 | return Intermediate.Load(typeof(SqlExtensionData).Assembly, "WixToolset.Sql.sql.wixlib", tupleDefinitions); |
62 | } | 28 | } |
63 | } | 29 | } |
64 | } | 30 | } |
diff --git a/src/wixext/SqlExtensionFactory.cs b/src/wixext/SqlExtensionFactory.cs new file mode 100644 index 00000000..e7fafed2 --- /dev/null +++ b/src/wixext/SqlExtensionFactory.cs | |||
@@ -0,0 +1,18 @@ | |||
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.Sql | ||
4 | { | ||
5 | using System; | ||
6 | using System.Collections.Generic; | ||
7 | using WixToolset.Extensibility; | ||
8 | |||
9 | public class SqlExtensionFactory : BaseExtensionFactory | ||
10 | { | ||
11 | protected override IEnumerable<Type> ExtensionTypes => new[] | ||
12 | { | ||
13 | typeof(SqlCompiler), | ||
14 | typeof(SqlExtensionData), | ||
15 | typeof(SqlWindowsInstallerBackendBinderExtension), | ||
16 | }; | ||
17 | } | ||
18 | } | ||
diff --git a/src/wixext/SqlWindowsInstallerBackendExtension.cs b/src/wixext/SqlWindowsInstallerBackendExtension.cs new file mode 100644 index 00000000..56bdbb1f --- /dev/null +++ b/src/wixext/SqlWindowsInstallerBackendExtension.cs | |||
@@ -0,0 +1,31 @@ | |||
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.Sql | ||
4 | { | ||
5 | using System.Linq; | ||
6 | using System.Xml; | ||
7 | using WixToolset.Data.WindowsInstaller; | ||
8 | using WixToolset.Extensibility; | ||
9 | |||
10 | public class SqlWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension | ||
11 | { | ||
12 | public SqlWindowsInstallerBackendBinderExtension() | ||
13 | { | ||
14 | |||
15 | } | ||
16 | |||
17 | private static readonly TableDefinition[] Tables = LoadTables(); | ||
18 | |||
19 | protected override TableDefinition[] TableDefinitionsForTuples => Tables; | ||
20 | |||
21 | private static TableDefinition[] LoadTables() | ||
22 | { | ||
23 | using (var resourceStream = typeof(SqlWindowsInstallerBackendBinderExtension).Assembly.GetManifestResourceStream("WixToolset.Sql.tables.xml")) | ||
24 | using (var reader = XmlReader.Create(resourceStream)) | ||
25 | { | ||
26 | var tables = TableDefinitionCollection.Load(reader); | ||
27 | return tables.ToArray(); | ||
28 | } | ||
29 | } | ||
30 | } | ||
31 | } | ||
diff --git a/src/wixext/WixToolset.Sql.wixext.csproj b/src/wixext/WixToolset.Sql.wixext.csproj new file mode 100644 index 00000000..a782ea8f --- /dev/null +++ b/src/wixext/WixToolset.Sql.wixext.csproj | |||
@@ -0,0 +1,36 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <!-- 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. --> | ||
3 | |||
4 | <Project Sdk="Microsoft.NET.Sdk"> | ||
5 | <PropertyGroup> | ||
6 | <TargetFramework>netstandard2.0</TargetFramework> | ||
7 | <RootNamespace>WixToolset.Sql</RootNamespace> | ||
8 | <Description>WiX Toolset Sql Extension</Description> | ||
9 | <Title>WiX Toolset Sql Extension</Title> | ||
10 | <IsTool>true</IsTool> | ||
11 | <ContentTargetFolders>build</ContentTargetFolders> | ||
12 | </PropertyGroup> | ||
13 | |||
14 | <ItemGroup> | ||
15 | <Content Include="$(MSBuildThisFileName).targets" /> | ||
16 | <Content Include="sql.xsd" PackagePath="tools" /> | ||
17 | <EmbeddedResource Include="tables.xml" /> | ||
18 | <EmbeddedResource Include="$(OutputPath)..\sql.wixlib" /> | ||
19 | </ItemGroup> | ||
20 | |||
21 | <ItemGroup> | ||
22 | <ProjectReference Include="$(WixToolsetRootFolder)\Data\src\WixToolset.Data\WixToolset.Data.csproj" Condition=" '$(Configuration)' == 'Debug' And Exists('$(WixToolsetRootFolder)\Data\README.md') " /> | ||
23 | <PackageReference Include="WixToolset.Data" Version="4.0.*" Condition=" '$(Configuration)' == 'Release' Or !Exists('$(WixToolsetRootFolder)\Data\README.md') " PrivateAssets="all" /> | ||
24 | |||
25 | <ProjectReference Include="$(WixToolsetRootFolder)\Extensibility\src\WixToolset.Extensibility\WixToolset.Extensibility.csproj" Condition=" '$(Configuration)' == 'Debug' And Exists('$(WixToolsetRootFolder)\Extensibility\README.md') " /> | ||
26 | <PackageReference Include="WixToolset.Extensibility" Version="4.0.*" Condition=" '$(Configuration)' == 'Release' Or !Exists('$(WixToolsetRootFolder)\Extensibility\README.md') " PrivateAssets="all" /> | ||
27 | </ItemGroup> | ||
28 | |||
29 | <ItemGroup> | ||
30 | <ProjectReference Include="..\wixlib\sql.wixproj" ReferenceOutputAssembly="false" Condition=" '$(NCrunch)'=='' " /> | ||
31 | </ItemGroup> | ||
32 | |||
33 | <ItemGroup> | ||
34 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="all" /> | ||
35 | </ItemGroup> | ||
36 | </Project> | ||
diff --git a/src/wixext/WixToolset.Sql.wixext.targets b/src/wixext/WixToolset.Sql.wixext.targets new file mode 100644 index 00000000..4950e119 --- /dev/null +++ b/src/wixext/WixToolset.Sql.wixext.targets | |||
@@ -0,0 +1,11 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <!-- 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. --> | ||
3 | |||
4 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> | ||
5 | <PropertyGroup> | ||
6 | <WixToolsetSqlWixextPath Condition=" '$(WixToolsetSqlWixextPath)' == '' ">$(MSBuildThisFileDirectory)..\tools\WixToolset.Sql.wixext.dll</WixToolsetSqlWixextPath> | ||
7 | </PropertyGroup> | ||
8 | <ItemGroup> | ||
9 | <WixExtension Include="$(WixToolsetSqlWixextPath)" /> | ||
10 | </ItemGroup> | ||
11 | </Project> | ||