Skip to content
This repository was archived by the owner on Jul 12, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions src/CodeFormatter/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.MSBuild;
Expand Down Expand Up @@ -90,15 +91,31 @@ private static int Main(string[] args)

Console.CancelKeyPress += delegate { cts.Cancel(); };

RunAsync(
projectOrSolutionPath,
ruleTypeBuilder.ToImmutableArray(),
fileNamesBuilder.ToImmutableArray(),
configBuilder.ToImmutableArray(),
copyrightHeader,
ct).Wait(ct);
Console.WriteLine("Completed formatting.");
return 0;
try
{
RunAsync(
projectOrSolutionPath,
ruleTypeBuilder.ToImmutableArray(),
fileNamesBuilder.ToImmutableArray(),
configBuilder.ToImmutableArray(),
copyrightHeader,
ct).Wait(ct);
Console.WriteLine("Completed formatting.");
return 0;
}
catch (AggregateException ex)
{
var typeLoadException = ex.InnerExceptions.FirstOrDefault() as ReflectionTypeLoadException;
if (typeLoadException == null)
throw;

Console.WriteLine("ERROR: Type loading error detected. In order to run this tool you need either Visual Studio 2015 or Microsoft Build Tools 2015 tools installed.");
var messages = typeLoadException.LoaderExceptions.Select(e => e.Message).Distinct();
foreach (var message in messages)
Console.WriteLine("- {0}", message);

return 1;
}
}

private static async Task RunAsync(
Expand Down