forked from dotnet/codeformatter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
52 lines (45 loc) · 1.67 KB
/
Copy pathProgram.cs
File metadata and controls
52 lines (45 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Microsoft.CodeAnalysis.MSBuild;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace XUnitConverter
{
internal static class Program
{
internal static void Main(string[] args)
{
if (args.Length != 1)
{
Console.WriteLine("xunitconverter <project>");
return;
}
var cts = new CancellationTokenSource();
Console.CancelKeyPress += delegate { cts.Cancel(); };
RunAsync(args[0], cts.Token).Wait();
}
private static async Task RunAsync(string projectPath, CancellationToken cancellationToken)
{
var workspace = MSBuildWorkspace.Create();
workspace.LoadMetadataForReferencedProjects = true;
var project = await workspace.OpenProjectAsync(projectPath, cancellationToken);
var converters = new ConverterBase[]
{
new MSTestToXUnitConverter(),
new TestAssertTrueOrFalseConverter(),
new AssertArgumentOrderConverter(),
};
foreach (var converter in converters)
{
var solution = await converter.ProcessAsync(project, cancellationToken);
project = solution.GetProject(project.Id);
}
workspace.TryApplyChanges(project.Solution);
}
}
}