Skip to content

Commit 3d65f70

Browse files
Allow slnx inputs to command line
1 parent b18def1 commit 3d65f70

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

CodeConv/CodeConvProgram.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Please backup / commit your files to source control before use.
3030
public partial class CodeConvProgram
3131
{
3232
public const string CoreOptionDefinition = "--core-only";
33+
private static readonly string[] ValidSolutionExtensions = { ".sln", ".slnx" };
3334

3435
/// <remarks>Calls <see cref="OnExecuteAsync(CommandLineApplication)"/> by reflection</remarks>
3536
public static async Task<int> Main(string[] args) => await CommandLineApplication.ExecuteAsync<CodeConvProgram>(args);
@@ -105,8 +106,10 @@ private async Task ConvertAsync(IProgress<ConversionProgress> progress, Cancella
105106

106107
IProgress<string> strProgress = new Progress<string>(p => progress.Report(new ConversionProgress(p)));
107108

108-
if (!string.Equals(Path.GetExtension(finalSolutionPath), ".sln", StringComparison.OrdinalIgnoreCase)) {
109-
throw new ValidationException("Solution path must end in `.sln`");
109+
var extension = Path.GetExtension(finalSolutionPath);
110+
if (!ValidSolutionExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase)) {
111+
var extensionsStr = string.Join(" or ", ValidSolutionExtensions.Select(e => $"`{e}`"));
112+
throw new ValidationException($"Solution path must end in {extensionsStr}");
110113
}
111114

112115
string? directoryName = string.IsNullOrWhiteSpace(OutputDirectory) ? Path.GetDirectoryName(finalSolutionPath) : OutputDirectory;

0 commit comments

Comments
 (0)