Update project to .NET 8

This commit is contained in:
Stone_Red
2025-03-03 18:35:18 +01:00
parent 3511fa9b06
commit 3784db3a6e
4 changed files with 8 additions and 14 deletions
+3 -3
View File
@@ -4,14 +4,14 @@ namespace Commander;
public class Command public class Command
{ {
internal readonly List<Command> subCommands = new(); internal readonly List<Command> subCommands = [];
public string[] Identifiers { get; set; } public string[] Identifiers { get; set; }
public Func<string, CommandResult> Method { get; set; } public Func<string, CommandResult> Method { get; set; }
public HelpText HelpText { get; set; } public HelpText HelpText { get; set; }
public Command() public Command()
{ {
Identifiers = Array.Empty<string>(); Identifiers = [];
HelpText = string.Empty; HelpText = string.Empty;
Method = new Func<string, CommandResult>((_) => CommandResult.Success()); Method = new Func<string, CommandResult>((_) => CommandResult.Success());
} }
@@ -80,7 +80,7 @@ public class Command
string[] inputParts = input.Split(' '); string[] inputParts = input.Split(' ');
bool found = false; bool found = false;
commandResults ??= new List<CommandResult>(); commandResults ??= [];
foreach (Command? command in subCommands.Where(command => command.Identifiers.Contains(inputParts[0]))) foreach (Command? command in subCommands.Where(command => command.Identifiers.Contains(inputParts[0])))
{ {
+3 -9
View File
@@ -1,15 +1,9 @@
namespace Commander; namespace Commander;
public class CommandResult public class CommandResult(ResultType type, string message = "")
{ {
public ResultType ResultType { get; } public ResultType ResultType { get; } = type;
public string Message { get; } public string Message { get; } = message;
public CommandResult(ResultType type, string message = "")
{
ResultType = type;
Message = message;
}
public static CommandResult Success(string message = "") public static CommandResult Success(string message = "")
{ {
+1 -1
View File
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild> <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
+1 -1
View File
@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild> <GeneratePackageOnBuild>False</GeneratePackageOnBuild>