diff options
author | Rob Mensching <rob@firegiant.com> | 2022-12-06 15:54:17 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2022-12-06 17:29:07 -0800 |
commit | aa591db212c3df5a5c9f501c01fb1fbf2deadb7c (patch) | |
tree | 6e2e1e9ed3cf1b87f1cc3f05eaeb69c69d9bbf6f /src/tools/heat/HeatCommand.cs | |
parent | 07fbc3561fb66dba1502305ba4aff1db905c84e4 (diff) | |
download | wix-aa591db212c3df5a5c9f501c01fb1fbf2deadb7c.tar.gz wix-aa591db212c3df5a5c9f501c01fb1fbf2deadb7c.tar.bz2 wix-aa591db212c3df5a5c9f501c01fb1fbf2deadb7c.zip |
Automated code clean up
Diffstat (limited to 'src/tools/heat/HeatCommand.cs')
-rw-r--r-- | src/tools/heat/HeatCommand.cs | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/tools/heat/HeatCommand.cs b/src/tools/heat/HeatCommand.cs index d0c86401..34198011 100644 --- a/src/tools/heat/HeatCommand.cs +++ b/src/tools/heat/HeatCommand.cs | |||
@@ -68,7 +68,7 @@ namespace WixToolset.Harvesters | |||
68 | } | 68 | } |
69 | else if ('-' == arg[0] || '/' == arg[0]) | 69 | else if ('-' == arg[0] || '/' == arg[0]) |
70 | { | 70 | { |
71 | string parameter = arg.Substring(1); | 71 | var parameter = arg.Substring(1); |
72 | if ("nologo" == parameter) | 72 | if ("nologo" == parameter) |
73 | { | 73 | { |
74 | this.showLogo = false; | 74 | this.showLogo = false; |
@@ -89,7 +89,7 @@ namespace WixToolset.Harvesters | |||
89 | } | 89 | } |
90 | else if (parameter.StartsWith("sw")) | 90 | else if (parameter.StartsWith("sw")) |
91 | { | 91 | { |
92 | string paramArg = parameter.Substring(2); | 92 | var paramArg = parameter.Substring(2); |
93 | try | 93 | try |
94 | { | 94 | { |
95 | if (0 == paramArg.Length) | 95 | if (0 == paramArg.Length) |
@@ -98,7 +98,7 @@ namespace WixToolset.Harvesters | |||
98 | } | 98 | } |
99 | else | 99 | else |
100 | { | 100 | { |
101 | int suppressWarning = Convert.ToInt32(paramArg, CultureInfo.InvariantCulture.NumberFormat); | 101 | var suppressWarning = Convert.ToInt32(paramArg, CultureInfo.InvariantCulture.NumberFormat); |
102 | if (0 >= suppressWarning) | 102 | if (0 >= suppressWarning) |
103 | { | 103 | { |
104 | this.Messaging.Write(ErrorMessages.IllegalSuppressWarningId(paramArg)); | 104 | this.Messaging.Write(ErrorMessages.IllegalSuppressWarningId(paramArg)); |
@@ -123,7 +123,7 @@ namespace WixToolset.Harvesters | |||
123 | } | 123 | } |
124 | else if (parameter.StartsWith("wx")) | 124 | else if (parameter.StartsWith("wx")) |
125 | { | 125 | { |
126 | string paramArg = parameter.Substring(2); | 126 | var paramArg = parameter.Substring(2); |
127 | try | 127 | try |
128 | { | 128 | { |
129 | if (0 == paramArg.Length) | 129 | if (0 == paramArg.Length) |
@@ -132,7 +132,7 @@ namespace WixToolset.Harvesters | |||
132 | } | 132 | } |
133 | else | 133 | else |
134 | { | 134 | { |
135 | int elevateWarning = Convert.ToInt32(paramArg, CultureInfo.InvariantCulture.NumberFormat); | 135 | var elevateWarning = Convert.ToInt32(paramArg, CultureInfo.InvariantCulture.NumberFormat); |
136 | if (0 >= elevateWarning) | 136 | if (0 >= elevateWarning) |
137 | { | 137 | { |
138 | this.Messaging.Write(ErrorMessages.IllegalWarningIdAsError(paramArg)); | 138 | this.Messaging.Write(ErrorMessages.IllegalWarningIdAsError(paramArg)); |
@@ -212,7 +212,7 @@ namespace WixToolset.Harvesters | |||
212 | } | 212 | } |
213 | 213 | ||
214 | // harvest the output | 214 | // harvest the output |
215 | Wix.Wix wix = heatCore.Harvester.Harvest(this.ExtensionArgument); | 215 | var wix = heatCore.Harvester.Harvest(this.ExtensionArgument); |
216 | if (null == wix) | 216 | if (null == wix) |
217 | { | 217 | { |
218 | return this.Messaging.LastErrorNumber; | 218 | return this.Messaging.LastErrorNumber; |
@@ -224,15 +224,15 @@ namespace WixToolset.Harvesters | |||
224 | return this.Messaging.LastErrorNumber; | 224 | return this.Messaging.LastErrorNumber; |
225 | } | 225 | } |
226 | 226 | ||
227 | XmlWriterSettings xmlSettings = new XmlWriterSettings(); | 227 | var xmlSettings = new XmlWriterSettings(); |
228 | xmlSettings.Indent = true; | 228 | xmlSettings.Indent = true; |
229 | xmlSettings.IndentChars = new string(' ', this.Indent); | 229 | xmlSettings.IndentChars = new string(' ', this.Indent); |
230 | xmlSettings.OmitXmlDeclaration = true; | 230 | xmlSettings.OmitXmlDeclaration = true; |
231 | 231 | ||
232 | string wixString; | 232 | string wixString; |
233 | using (StringWriter stringWriter = new StringWriter()) | 233 | using (var stringWriter = new StringWriter()) |
234 | { | 234 | { |
235 | using (XmlWriter xmlWriter = XmlWriter.Create(stringWriter, xmlSettings)) | 235 | using (var xmlWriter = XmlWriter.Create(stringWriter, xmlSettings)) |
236 | { | 236 | { |
237 | wix.OutputXml(xmlWriter); | 237 | wix.OutputXml(xmlWriter); |
238 | } | 238 | } |
@@ -240,7 +240,7 @@ namespace WixToolset.Harvesters | |||
240 | wixString = stringWriter.ToString(); | 240 | wixString = stringWriter.ToString(); |
241 | } | 241 | } |
242 | 242 | ||
243 | string mutatedWixString = heatCore.Mutator.Mutate(wixString); | 243 | var mutatedWixString = heatCore.Mutator.Mutate(wixString); |
244 | if (String.IsNullOrEmpty(mutatedWixString)) | 244 | if (String.IsNullOrEmpty(mutatedWixString)) |
245 | { | 245 | { |
246 | return this.Messaging.LastErrorNumber; | 246 | return this.Messaging.LastErrorNumber; |
@@ -248,17 +248,14 @@ namespace WixToolset.Harvesters | |||
248 | 248 | ||
249 | Directory.CreateDirectory(Path.GetDirectoryName(this.OutputFile)); | 249 | Directory.CreateDirectory(Path.GetDirectoryName(this.OutputFile)); |
250 | 250 | ||
251 | using (StreamWriter streamWriter = new StreamWriter(this.OutputFile, false, System.Text.Encoding.UTF8)) | 251 | using (var streamWriter = new StreamWriter(this.OutputFile, false, System.Text.Encoding.UTF8)) |
252 | { | 252 | { |
253 | xmlSettings.OmitXmlDeclaration = false; | 253 | using (var xmlWriter = XmlWriter.Create(streamWriter, xmlSettings)) |
254 | xmlSettings.Encoding = System.Text.Encoding.UTF8; | ||
255 | using (XmlWriter xmlWriter = XmlWriter.Create(streamWriter, xmlSettings)) | ||
256 | { | 254 | { |
257 | xmlWriter.WriteStartDocument(); | 255 | xmlWriter.WriteStartDocument(); |
258 | xmlWriter.Flush(); | 256 | xmlWriter.Flush(); |
259 | } | 257 | } |
260 | 258 | ||
261 | streamWriter.WriteLine(); | ||
262 | streamWriter.Write(mutatedWixString); | 259 | streamWriter.Write(mutatedWixString); |
263 | } | 260 | } |
264 | } | 261 | } |