1
0

Updated to C# 12

This commit is contained in:
2024-01-14 13:10:33 +01:00
parent 9cd1344266
commit 27cd54fb30
51 changed files with 637 additions and 379 deletions

View File

@@ -14,7 +14,7 @@ namespace AMWD.Common.Cli
private string[] _args;
private List<Argument> _parsedArguments;
private readonly List<Option> _options = new();
private readonly List<Option> _options = [];
#endregion Private data
@@ -129,7 +129,7 @@ namespace AMWD.Common.Cli
{
args.Add(currentArg.ToString());
}
return args.ToArray();
return [.. args];
}
/// <summary>
@@ -199,7 +199,7 @@ namespace AMWD.Common.Cli
}
// Clear/reset data
_parsedArguments = new();
_parsedArguments = [];
foreach (var option in _options)
{
option.IsSet = false;
@@ -223,7 +223,7 @@ namespace AMWD.Common.Cli
string optName = arg.Substring(arg.StartsWith("--") ? 2 : 1);
// Split option value if separated with : or = instead of whitespace
int separatorIndex = optName.IndexOfAny(new[] { ':', '=' });
int separatorIndex = optName.IndexOfAny([':', '=']);
string optValue = null;
if (separatorIndex != -1)
{
@@ -288,7 +288,7 @@ namespace AMWD.Common.Cli
}
else
{
_parsedArguments.Add(new Argument(null, new[] { arg }));
_parsedArguments.Add(new Argument(null, [arg]));
}
}
@@ -315,7 +315,7 @@ namespace AMWD.Common.Cli
if (_parsedArguments == null)
Parse();
return _parsedArguments.ToArray();
return [.. _parsedArguments];
}
}