diff --git a/src/System.CommandLine.Hosting/System.CommandLine.Hosting.csproj b/src/System.CommandLine.Hosting/System.CommandLine.Hosting.csproj
index 9433f93a0c..acab3a977e 100644
--- a/src/System.CommandLine.Hosting/System.CommandLine.Hosting.csproj
+++ b/src/System.CommandLine.Hosting/System.CommandLine.Hosting.csproj
@@ -2,7 +2,7 @@
true
- netstandard2.0;netstandard2.1
+ netstandard2.0;netstandard2.1;net7.0
This package provides support for using System.CommandLine with Microsoft.Extensions.Hosting.
diff --git a/src/System.CommandLine.NamingConventionBinder/CommandHandler.cs b/src/System.CommandLine.NamingConventionBinder/CommandHandler.cs
index a0fa5a5d5e..dbcf4daed9 100644
--- a/src/System.CommandLine.NamingConventionBinder/CommandHandler.cs
+++ b/src/System.CommandLine.NamingConventionBinder/CommandHandler.cs
@@ -605,7 +605,7 @@ public static ICommandHandler Create> action) =>
HandlerDescriptor.FromDelegate(action).GetCommandHandler();
- internal static async Task GetExitCodeAsync(object returnValue, InvocationContext context)
+ internal static async Task GetExitCodeAsync(object? returnValue, InvocationContext context)
{
switch (returnValue)
{
diff --git a/src/System.CommandLine.NamingConventionBinder/MethodInfoHandlerDescriptor.cs b/src/System.CommandLine.NamingConventionBinder/MethodInfoHandlerDescriptor.cs
index c94b951149..6f4e09e744 100644
--- a/src/System.CommandLine.NamingConventionBinder/MethodInfoHandlerDescriptor.cs
+++ b/src/System.CommandLine.NamingConventionBinder/MethodInfoHandlerDescriptor.cs
@@ -38,7 +38,7 @@ public override ICommandHandler GetCommandHandler()
}
}
- public override ModelDescriptor Parent => ModelDescriptor.FromType(_handlerMethodInfo.ReflectedType);
+ public override ModelDescriptor Parent => ModelDescriptor.FromType(_handlerMethodInfo.ReflectedType!);
private protected override IEnumerable InitializeParameterDescriptors() =>
_handlerMethodInfo.GetParameters()
diff --git a/src/System.CommandLine.NamingConventionBinder/ModelBinder.cs b/src/System.CommandLine.NamingConventionBinder/ModelBinder.cs
index 08c52d510b..9eb6facc07 100644
--- a/src/System.CommandLine.NamingConventionBinder/ModelBinder.cs
+++ b/src/System.CommandLine.NamingConventionBinder/ModelBinder.cs
@@ -141,7 +141,7 @@ private bool ShortCutTheBinding()
private (bool success, object? newInstance, bool anyNonDefaults) InstanceFromSpecificConstructor(
BindingContext bindingContext, ConstructorDescriptor constructor, IReadOnlyList? boundValues, ref bool nonDefaultsUsed)
{
- var values = boundValues.Select(x => x.Value).ToArray();
+ var values = boundValues?.Select(x => x.Value).ToArray() ?? Array.Empty