Skip to content
This repository was archived by the owner on Jul 12, 2022. It is now read-only.

Commit 3234b6b

Browse files
committed
Hooked up the command line arguments
1 parent 351ef13 commit 3234b6b

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

src/XUnitConverter/Program.cs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
using System;
1+
using Microsoft.CodeAnalysis.MSBuild;
2+
using System;
23
using System.Collections.Generic;
34
using System.Linq;
45
using System.Text;
6+
using System.Threading;
57
using System.Threading.Tasks;
68

79
namespace XUnitConverter
@@ -10,7 +12,38 @@ internal static class Program
1012
{
1113
internal static void Main(string[] args)
1214
{
15+
if (args.Length != 1)
16+
{
17+
Console.WriteLine("xunitconverter <project>");
18+
return;
19+
}
1320

21+
var cts = new CancellationTokenSource();
22+
Console.CancelKeyPress += delegate { cts.Cancel(); };
23+
RunAsync(args[0], cts.Token).Wait();
24+
}
25+
26+
private static async Task RunAsync(string projectPath, CancellationToken cancellationToken)
27+
{
28+
var workspace = MSBuildWorkspace.Create();
29+
workspace.LoadMetadataForReferencedProjects = true;
30+
31+
var project = await workspace.OpenProjectAsync(projectPath, cancellationToken);
32+
var solution = project.Solution;
33+
var xunitConverter = new XUnitConverter();
34+
foreach (var id in project.DocumentIds)
35+
{
36+
var document = solution.GetDocument(id);
37+
var syntaxNode = await document.GetSyntaxRootAsync(cancellationToken);
38+
if (syntaxNode == null)
39+
{
40+
continue;
41+
}
42+
43+
solution = await xunitConverter.ProcessAsync(document, syntaxNode, cancellationToken);
44+
}
45+
46+
workspace.TryApplyChanges(solution);
1447
}
1548
}
1649
}

src/XUnitConverter/XUnitConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
using System.Runtime.Serialization;
1616
using System.IO;
1717

18-
namespace Microsoft.DotNet.CodeFormatting.Rules
18+
namespace XUnitConverter
1919
{
2020
internal sealed class XUnitConverter
2121
{

0 commit comments

Comments
 (0)