The default value of a nullable "Array", "IEnumerable<T>", "IList<T>" or "ICollection<T>" should be "null"
I noticed that the default value of CliOption<IList<string>?> always ends up being an empty list. This seems counterintuitive to me, as I explicitly defined the list to be nullable. The same applies for the types mentioned in the title.
Would it be possible to add some additional checks if the type is nullable here? https://github.com/dotnet/command-line-api/blob/6daed85086c41a1cd72a97f298f9cfe2beafa3f4/src/System.CommandLine/Argument%7BT%7D.cs#L168
No, it would not be possible to add the checks. typeof(T) is the same for nullable IList<string>? as for non-nullable IList<string>. The nullability of C# reference types is encoded as attributes, not as separate Type objects. If the code in CliOption<T> had a MemberInfo instance representing a field or property whose type is CliOption<IList<string>?>, then it would be possible to figure out the nullability at run time; but it doesn't have that.
So the default value cannot directly depend on the nullability of the type argument. However, it could be possible to set up a source generator that checks the nullability at compile time and tells CliOption<T> about it in some other way.