Skip to content

Commit 3cb6db2

Browse files
authored
bug fix: drop support for < net46 and fix for finding dotnet.exe when DOTNET_ROOT is not set (#526)
1 parent dd5de06 commit 3cb6db2

File tree

15 files changed

+32
-50
lines changed

15 files changed

+32
-50
lines changed

src/CommandLineUtils/Abstractions/ValueParserProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private static readonly MethodInfo s_getParserGeneric
6161
public IValueParser GetParser(Type type)
6262
{
6363
var method = s_getParserGeneric.MakeGenericMethod(type);
64-
return (IValueParser)method.Invoke(this, Util.EmptyArray<object>());
64+
return (IValueParser)method.Invoke(this, Array.Empty<object>());
6565
}
6666

6767
/// <summary>

src/CommandLineUtils/Attributes/CommandAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace McMaster.Extensions.CommandLineUtils
1414
[AttributeUsage(AttributeTargets.Class)]
1515
public sealed class CommandAttribute : Attribute
1616
{
17-
private string[] _names = Util.EmptyArray<string>();
17+
private string[] _names = Array.Empty<string>();
1818

1919
/// <summary>
2020
/// Initializes a new <see cref="CommandAttribute"/>.
@@ -55,7 +55,7 @@ public string? Name
5555
}
5656
else
5757
{
58-
_names = Util.EmptyArray<string>();
58+
_names = Array.Empty<string>();
5959
}
6060
}
6161
}

src/CommandLineUtils/Attributes/VersionOptionFromMemberAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ internal CommandOption Configure(CommandLineApplication app, Type type, Func<obj
6060

6161
shortFormGetter = () =>
6262
{
63-
return (string)methods[0].Invoke(targetInstanceFactory.Invoke(), Util.EmptyArray<object>());
63+
return (string)methods[0].Invoke(targetInstanceFactory.Invoke(), Array.Empty<object>());
6464
};
6565
}
6666

src/CommandLineUtils/CommandLineApplication.Execute.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public static int Execute<TApp>(params string[] args)
129129
public static int Execute<TApp>(IConsole console, params string[] args)
130130
where TApp : class
131131
{
132-
args ??= Util.EmptyArray<string>();
132+
args ??= Array.Empty<string>();
133133
var context = new DefaultCommandLineContext(console, Directory.GetCurrentDirectory(), args);
134134
return Execute<TApp>(context);
135135
}
@@ -168,7 +168,7 @@ public static Task<int> ExecuteAsync<TApp>(string[] args, CancellationToken canc
168168
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
169169
where TApp : class
170170
{
171-
args ??= Util.EmptyArray<string>();
171+
args ??= Array.Empty<string>();
172172
var context = new DefaultCommandLineContext(PhysicalConsole.Singleton, Directory.GetCurrentDirectory(), args);
173173
return ExecuteAsync<TApp>(context, cancellationToken);
174174
}
@@ -189,7 +189,7 @@ public static Task<int> ExecuteAsync<TApp>(string[] args, CancellationToken canc
189189
public static Task<int> ExecuteAsync<TApp>(IConsole console, params string[] args)
190190
where TApp : class
191191
{
192-
args ??= Util.EmptyArray<string>();
192+
args ??= Array.Empty<string>();
193193
var context = new DefaultCommandLineContext(console, Directory.GetCurrentDirectory(), args);
194194
return ExecuteAsync<TApp>(context);
195195
}

src/CommandLineUtils/CommandLineApplication.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ public ParseResult Parse(params string[] args)
748748
{
749749
Reset();
750750

751-
args ??= Util.EmptyArray<string>();
751+
args ??= Array.Empty<string>();
752752

753753
var processor = new CommandLineProcessor(this, args);
754754
var result = processor.Process();

src/CommandLineUtils/Conventions/OptionAttributeConventionBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private protected void AddOption(ConventionContext context, CommandOption option
131131
{
132132
if (!option.HasValue())
133133
{
134-
setter.Invoke(modelAccessor.GetModel(), Util.EmptyArray<bool>());
134+
setter.Invoke(modelAccessor.GetModel(), Array.Empty<bool>());
135135
}
136136

137137
var count = new bool[option.Values.Count];

src/CommandLineUtils/HelpText/DefaultHelpTextGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ private string[] ExtractNamesFromEnum(Type? type)
413413
{
414414
if (type == null)
415415
{
416-
return Util.EmptyArray<string>();
416+
return Array.Empty<string>();
417417
}
418418

419419
if (ReflectionHelper.IsNullableType(type, out var wrappedType))
@@ -431,7 +431,7 @@ private string[] ExtractNamesFromEnum(Type? type)
431431
return Enum.GetNames(type);
432432
}
433433

434-
return Util.EmptyArray<string>();
434+
return Array.Empty<string>();
435435
}
436436
}
437437
}

src/CommandLineUtils/IO/Pager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ public Pager(IConsole console)
4242
throw new ArgumentNullException(nameof(console));
4343
}
4444

45-
#if NET45
45+
#if NET46_OR_GREATER
4646
// if .NET Framework, assume we're on Windows unless it's running on Mono.
4747
_enabled = Type.GetType("Mono.Runtime") != null;
48-
#elif NETSTANDARD2_0 || NETSTANDARD2_1
48+
#elif NETSTANDARD2_0_OR_GREATER
4949
_enabled = !RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !console.IsOutputRedirected;
5050
#else
5151
#error Update target frameworks
@@ -130,7 +130,7 @@ public void Kill()
130130
FileName = "less",
131131
Arguments = ArgumentEscaper.EscapeAndConcatenate(args),
132132
RedirectStandardInput = true,
133-
#if NET45
133+
#if NET46_OR_GREATER
134134
UseShellExecute = false,
135135
#endif
136136
}

src/CommandLineUtils/Internal/Util.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/CommandLineUtils/Internal/ValueParsers/HashSetParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public HashSetParser(Type elementType, IValueParser elementParser, CultureInfo p
2525

2626
public object Parse(string? argName, IReadOnlyList<string?> values)
2727
{
28-
var set = Activator.CreateInstance(_listType, Util.EmptyArray<object>());
28+
var set = Activator.CreateInstance(_listType, Array.Empty<object>());
2929
foreach (var t in values)
3030
{
3131
_addMethod.Invoke(set, new[] { _elementParser.Parse(argName, t, _parserCulture) });

0 commit comments

Comments
 (0)