diff options
Diffstat (limited to 'src/test/WixToolsetTest.WixCop/WixCopRunner.cs')
-rw-r--r-- | src/test/WixToolsetTest.WixCop/WixCopRunner.cs | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/src/test/WixToolsetTest.WixCop/WixCopRunner.cs b/src/test/WixToolsetTest.WixCop/WixCopRunner.cs deleted file mode 100644 index d2a0abbe..00000000 --- a/src/test/WixToolsetTest.WixCop/WixCopRunner.cs +++ /dev/null | |||
@@ -1,68 +0,0 @@ | |||
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 WixToolsetTest.WixCop | ||
4 | { | ||
5 | using System; | ||
6 | using System.Collections.Generic; | ||
7 | using WixToolset.Core; | ||
8 | using WixToolset.Core.TestPackage; | ||
9 | using WixToolset.Extensibility; | ||
10 | using WixToolset.Extensibility.Services; | ||
11 | using WixToolset.Tools.WixCop; | ||
12 | using WixToolset.Tools.WixCop.CommandLine; | ||
13 | using WixToolset.Tools.WixCop.Interfaces; | ||
14 | |||
15 | public class WixCopRunner | ||
16 | { | ||
17 | public bool FixErrors { get; set; } | ||
18 | |||
19 | public List<string> SearchPatterns { get; } = new List<string>(); | ||
20 | |||
21 | public string SettingFile1 { get; set; } | ||
22 | |||
23 | public WixCopRunnerResult Execute() | ||
24 | { | ||
25 | var argList = new List<string>(); | ||
26 | |||
27 | if (this.FixErrors) | ||
28 | { | ||
29 | argList.Add("-f"); | ||
30 | } | ||
31 | |||
32 | if (!String.IsNullOrEmpty(this.SettingFile1)) | ||
33 | { | ||
34 | argList.Add($"-set1{this.SettingFile1}"); | ||
35 | } | ||
36 | |||
37 | foreach (var searchPattern in this.SearchPatterns) | ||
38 | { | ||
39 | argList.Add(searchPattern); | ||
40 | } | ||
41 | |||
42 | return WixCopRunner.Execute(argList.ToArray()); | ||
43 | } | ||
44 | |||
45 | public static WixCopRunnerResult Execute(string[] args) | ||
46 | { | ||
47 | var listener = new TestMessageListener(); | ||
48 | |||
49 | var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider(); | ||
50 | serviceProvider.AddService<IMessageListener>((x, y) => listener); | ||
51 | serviceProvider.AddService<IWixCopCommandLineParser>((x, y) => new WixCopCommandLineParser(x)); | ||
52 | |||
53 | var exitCode = Execute(serviceProvider, args); | ||
54 | |||
55 | return new WixCopRunnerResult | ||
56 | { | ||
57 | ExitCode = exitCode, | ||
58 | Messages = listener.Messages.ToArray() | ||
59 | }; | ||
60 | } | ||
61 | |||
62 | public static int Execute(IWixToolsetServiceProvider serviceProvider, string[] args) | ||
63 | { | ||
64 | var wixcop = new Program(); | ||
65 | return wixcop.Run(serviceProvider, args); | ||
66 | } | ||
67 | } | ||
68 | } | ||