aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2020-06-08 16:19:45 -0700
committerRob Mensching <rob@firegiant.com>2020-06-08 16:40:24 -0700
commit71e3338346841dcd31f18dd715cfa106b2a6e548 (patch)
tree7a9afce97fa84747bbd6602a5e8f8a422c9b236b /src
parent8c76578ce852a04f7ebeb8631f67913daa3ab307 (diff)
downloadwix-71e3338346841dcd31f18dd715cfa106b2a6e548.tar.gz
wix-71e3338346841dcd31f18dd715cfa106b2a6e548.tar.bz2
wix-71e3338346841dcd31f18dd715cfa106b2a6e548.zip
Make convert code async
Diffstat (limited to 'src')
-rw-r--r--src/WixToolset.Converters/ConvertCommand.cs16
-rw-r--r--src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs2
2 files changed, 11 insertions, 7 deletions
diff --git a/src/WixToolset.Converters/ConvertCommand.cs b/src/WixToolset.Converters/ConvertCommand.cs
index a684bc95..139b5813 100644
--- a/src/WixToolset.Converters/ConvertCommand.cs
+++ b/src/WixToolset.Converters/ConvertCommand.cs
@@ -5,6 +5,8 @@ namespace WixToolset.Converters
5 using System; 5 using System;
6 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using System.IO; 7 using System.IO;
8 using System.Threading;
9 using System.Threading.Tasks;
8 using System.Xml; 10 using System.Xml;
9 using WixToolset.Extensibility.Data; 11 using WixToolset.Extensibility.Data;
10 using WixToolset.Extensibility.Services; 12 using WixToolset.Extensibility.Services;
@@ -110,12 +112,12 @@ namespace WixToolset.Converters
110 } 112 }
111 } 113 }
112 114
113 public int Execute() 115 public Task<int> ExecuteAsync(CancellationToken cancellationToken)
114 { 116 {
115 if (this.ShowHelp) 117 if (this.ShowHelp)
116 { 118 {
117 DisplayHelp(); 119 DisplayHelp();
118 return 1; 120 return Task.FromResult(1);
119 } 121 }
120 122
121 // parse the settings if any were specified 123 // parse the settings if any were specified
@@ -133,7 +135,7 @@ namespace WixToolset.Converters
133 135
134 var converter = new Wix3Converter(this.Messaging, this.IndentationAmount, this.ErrorsAsWarnings, this.IgnoreErrors); 136 var converter = new Wix3Converter(this.Messaging, this.IndentationAmount, this.ErrorsAsWarnings, this.IgnoreErrors);
135 137
136 var errors = this.InspectSubDirectories(converter, Path.GetFullPath(".")); 138 var errors = this.InspectSubDirectories(converter, Path.GetFullPath("."), cancellationToken);
137 139
138 foreach (var searchPattern in this.SearchPatterns) 140 foreach (var searchPattern in this.SearchPatterns)
139 { 141 {
@@ -144,7 +146,7 @@ namespace WixToolset.Converters
144 } 146 }
145 } 147 }
146 148
147 return errors != 0 ? 2 : 0; 149 return Task.FromResult(errors != 0 ? 2 : 0);
148 } 150 }
149 151
150 private static void DisplayHelp() 152 private static void DisplayHelp()
@@ -202,7 +204,7 @@ namespace WixToolset.Converters
202 /// </summary> 204 /// </summary>
203 /// <param name="directory">The directory whose sub-directories will be inspected.</param> 205 /// <param name="directory">The directory whose sub-directories will be inspected.</param>
204 /// <returns>The number of errors that were found.</returns> 206 /// <returns>The number of errors that were found.</returns>
205 private int InspectSubDirectories(Wix3Converter converter, string directory) 207 private int InspectSubDirectories(Wix3Converter converter, string directory, CancellationToken cancellationToken)
206 { 208 {
207 var errors = 0; 209 var errors = 0;
208 210
@@ -210,6 +212,8 @@ namespace WixToolset.Converters
210 { 212 {
211 foreach (var sourceFilePath in GetFiles(directory, searchPattern)) 213 foreach (var sourceFilePath in GetFiles(directory, searchPattern))
212 { 214 {
215 cancellationToken.ThrowIfCancellationRequested();
216
213 var file = new FileInfo(sourceFilePath); 217 var file = new FileInfo(sourceFilePath);
214 218
215 if (!this.ExemptFiles.Contains(file.Name.ToUpperInvariant())) 219 if (!this.ExemptFiles.Contains(file.Name.ToUpperInvariant()))
@@ -224,7 +228,7 @@ namespace WixToolset.Converters
224 { 228 {
225 foreach (var childDirectoryPath in Directory.GetDirectories(directory)) 229 foreach (var childDirectoryPath in Directory.GetDirectories(directory))
226 { 230 {
227 errors += this.InspectSubDirectories(converter, childDirectoryPath); 231 errors += this.InspectSubDirectories(converter, childDirectoryPath, cancellationToken);
228 } 232 }
229 } 233 }
230 234
diff --git a/src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs b/src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs
index 6138fd2b..860c195f 100644
--- a/src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs
+++ b/src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs
@@ -158,7 +158,7 @@ namespace WixToolsetTest.Converters
158 targetFile 158 targetFile
159 }, serviceProvider, out var messages); 159 }, serviceProvider, out var messages);
160 160
161 return new WixRunnerResult { ExitCode = exitCode, Messages = messages.ToArray() }; 161 return new WixRunnerResult { ExitCode = exitCode.Result, Messages = messages.ToArray() };
162 } 162 }
163 163
164 private static void EnsureFixed(string targetFile) 164 private static void EnsureFixed(string targetFile)