diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 2f98df6b..8391fe20 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -42,7 +42,7 @@ jobs:
with:
dotnet-version: |
6.0.x
- 7.0.x
+ 8.0.x
- name: Run build script
id: build_script
run: ./build.ps1 -ci
diff --git a/Directory.Build.props b/Directory.Build.props
index c471bc63..22ffa8c3 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -28,7 +28,6 @@
$(WarningsNotAsErrors);1591
- 9.0
true
enable
$(MSBuildThisFileDirectory)src\StrongName.snk
@@ -41,7 +40,7 @@
- 4.1.1
+ 5.0.0
beta
true
$(GITHUB_RUN_NUMBER)
@@ -53,11 +52,6 @@
$(PackageVersion)+$(RepositoryCommit)
-
-
-
-
-
diff --git a/docs/samples/attributes/Attributes.csproj b/docs/samples/attributes/Attributes.csproj
index 2bb53ac1..29ecb192 100644
--- a/docs/samples/attributes/Attributes.csproj
+++ b/docs/samples/attributes/Attributes.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/docs/samples/custom-attribute/CustomAttribute.csproj b/docs/samples/custom-attribute/CustomAttribute.csproj
index 2bb53ac1..29ecb192 100644
--- a/docs/samples/custom-attribute/CustomAttribute.csproj
+++ b/docs/samples/custom-attribute/CustomAttribute.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/docs/samples/custom-conventions/CustomConvention.csproj b/docs/samples/custom-conventions/CustomConvention.csproj
index 2bb53ac1..29ecb192 100644
--- a/docs/samples/custom-conventions/CustomConvention.csproj
+++ b/docs/samples/custom-conventions/CustomConvention.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/docs/samples/dependency-injection/custom/CustomServices.csproj b/docs/samples/dependency-injection/custom/CustomServices.csproj
index 8c569f7c..ab539c35 100644
--- a/docs/samples/dependency-injection/custom/CustomServices.csproj
+++ b/docs/samples/dependency-injection/custom/CustomServices.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/docs/samples/dependency-injection/generic-host/GenericHostDI.csproj b/docs/samples/dependency-injection/generic-host/GenericHostDI.csproj
index d5814b02..c4ed30fb 100644
--- a/docs/samples/dependency-injection/generic-host/GenericHostDI.csproj
+++ b/docs/samples/dependency-injection/generic-host/GenericHostDI.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/docs/samples/dependency-injection/standard/StandardServices.csproj b/docs/samples/dependency-injection/standard/StandardServices.csproj
index 2bb53ac1..29ecb192 100644
--- a/docs/samples/dependency-injection/standard/StandardServices.csproj
+++ b/docs/samples/dependency-injection/standard/StandardServices.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/docs/samples/generic-host/AttributeApi/AttributeApi.csproj b/docs/samples/generic-host/AttributeApi/AttributeApi.csproj
index 413300dc..25158855 100644
--- a/docs/samples/generic-host/AttributeApi/AttributeApi.csproj
+++ b/docs/samples/generic-host/AttributeApi/AttributeApi.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/docs/samples/generic-host/BuilderApi/BuilderApi.csproj b/docs/samples/generic-host/BuilderApi/BuilderApi.csproj
index 413300dc..25158855 100644
--- a/docs/samples/generic-host/BuilderApi/BuilderApi.csproj
+++ b/docs/samples/generic-host/BuilderApi/BuilderApi.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/docs/samples/helloworld-async-attributes/AsyncAttributes.csproj b/docs/samples/helloworld-async-attributes/AsyncAttributes.csproj
index 2bb53ac1..29ecb192 100644
--- a/docs/samples/helloworld-async-attributes/AsyncAttributes.csproj
+++ b/docs/samples/helloworld-async-attributes/AsyncAttributes.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/docs/samples/interactive-prompts/Prompt.csproj b/docs/samples/interactive-prompts/Prompt.csproj
index 2bb53ac1..29ecb192 100644
--- a/docs/samples/interactive-prompts/Prompt.csproj
+++ b/docs/samples/interactive-prompts/Prompt.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/docs/samples/pager/Pager.csproj b/docs/samples/pager/Pager.csproj
index 2bb53ac1..29ecb192 100644
--- a/docs/samples/pager/Pager.csproj
+++ b/docs/samples/pager/Pager.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/docs/samples/passthru-args/attributes/AttributesPassThru.csproj b/docs/samples/passthru-args/attributes/AttributesPassThru.csproj
index 2bb53ac1..29ecb192 100644
--- a/docs/samples/passthru-args/attributes/AttributesPassThru.csproj
+++ b/docs/samples/passthru-args/attributes/AttributesPassThru.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/docs/samples/passthru-args/builder-api/BuilderApiPassThru.csproj b/docs/samples/passthru-args/builder-api/BuilderApiPassThru.csproj
index 2bb53ac1..29ecb192 100644
--- a/docs/samples/passthru-args/builder-api/BuilderApiPassThru.csproj
+++ b/docs/samples/passthru-args/builder-api/BuilderApiPassThru.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/docs/samples/response-file-parsing/attributes/RspAttributes.csproj b/docs/samples/response-file-parsing/attributes/RspAttributes.csproj
index 2bb53ac1..29ecb192 100644
--- a/docs/samples/response-file-parsing/attributes/RspAttributes.csproj
+++ b/docs/samples/response-file-parsing/attributes/RspAttributes.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/docs/samples/response-file-parsing/builder-api/RspBuilderApi.csproj b/docs/samples/response-file-parsing/builder-api/RspBuilderApi.csproj
index 2bb53ac1..29ecb192 100644
--- a/docs/samples/response-file-parsing/builder-api/RspBuilderApi.csproj
+++ b/docs/samples/response-file-parsing/builder-api/RspBuilderApi.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/docs/samples/subcommands/builder-api/BuilderApiSubcommands.csproj b/docs/samples/subcommands/builder-api/BuilderApiSubcommands.csproj
index 2bb53ac1..29ecb192 100644
--- a/docs/samples/subcommands/builder-api/BuilderApiSubcommands.csproj
+++ b/docs/samples/subcommands/builder-api/BuilderApiSubcommands.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/docs/samples/subcommands/inheritance/InheritanceSubcommands.csproj b/docs/samples/subcommands/inheritance/InheritanceSubcommands.csproj
index 2bb53ac1..29ecb192 100644
--- a/docs/samples/subcommands/inheritance/InheritanceSubcommands.csproj
+++ b/docs/samples/subcommands/inheritance/InheritanceSubcommands.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/docs/samples/subcommands/nested-types/NestedTypeSubcommands.csproj b/docs/samples/subcommands/nested-types/NestedTypeSubcommands.csproj
index 2bb53ac1..29ecb192 100644
--- a/docs/samples/subcommands/nested-types/NestedTypeSubcommands.csproj
+++ b/docs/samples/subcommands/nested-types/NestedTypeSubcommands.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/docs/samples/validation/attributes/Program.cs b/docs/samples/validation/attributes/Program.cs
index e90535ff..1eba78eb 100644
--- a/docs/samples/validation/attributes/Program.cs
+++ b/docs/samples/validation/attributes/Program.cs
@@ -5,6 +5,9 @@
using System.ComponentModel.DataAnnotations;
using System.Linq;
using McMaster.Extensions.CommandLineUtils;
+// This is required since .NET 8 introduced a new type System.ComponentModel.DataAnnotations.AllowedValuesAttribute
+// which conflicts with the attribute in this library (added long before .NET 8.)
+using AllowedValues = McMaster.Extensions.CommandLineUtils.AllowedValuesAttribute;
[MaxSizeOptionRequiresAttachmentValidation()]
class AttributeProgram
diff --git a/docs/samples/validation/attributes/ValidationAttributes.csproj b/docs/samples/validation/attributes/ValidationAttributes.csproj
index 2bb53ac1..29ecb192 100644
--- a/docs/samples/validation/attributes/ValidationAttributes.csproj
+++ b/docs/samples/validation/attributes/ValidationAttributes.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/docs/samples/validation/builder-api/ValidationBuilderApi.csproj b/docs/samples/validation/builder-api/ValidationBuilderApi.csproj
index 2bb53ac1..29ecb192 100644
--- a/docs/samples/validation/builder-api/ValidationBuilderApi.csproj
+++ b/docs/samples/validation/builder-api/ValidationBuilderApi.csproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net8.0
diff --git a/src/CommandLineUtils/Abstractions/CommandLineContext.cs b/src/CommandLineUtils/Abstractions/CommandLineContext.cs
index ecdb6107..20845572 100644
--- a/src/CommandLineUtils/Abstractions/CommandLineContext.cs
+++ b/src/CommandLineUtils/Abstractions/CommandLineContext.cs
@@ -11,7 +11,7 @@ namespace McMaster.Extensions.CommandLineUtils.Abstractions
///
public abstract class CommandLineContext
{
- private string[] _args = new string[0];
+ private string[] _args = Array.Empty();
private string _workDir = Directory.GetCurrentDirectory();
private IConsole _console = PhysicalConsole.Singleton;
diff --git a/src/CommandLineUtils/Abstractions/ValueParserProvider.cs b/src/CommandLineUtils/Abstractions/ValueParserProvider.cs
index 07ff412a..d7b694df 100644
--- a/src/CommandLineUtils/Abstractions/ValueParserProvider.cs
+++ b/src/CommandLineUtils/Abstractions/ValueParserProvider.cs
@@ -61,7 +61,11 @@ private static readonly MethodInfo s_getParserGeneric
public IValueParser GetParser(Type type)
{
var method = s_getParserGeneric.MakeGenericMethod(type);
+#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
+#pragma warning disable CS8603 // Possible null reference return.
return (IValueParser)method.Invoke(this, Array.Empty