FileInfoFactory and DirectoryInfoFactory Wrap implementations don't match the interface for nullability #975
Labels
state: needs discussion
Issues that need further discussion
state: released
Issues that are released
type: bug
Issues that describe misbehaving functionality
Describe the bug
The implementations for
FileInfoFactory.Wrap
andDirectoryInfoFactory.Wrap
require non-null references, while the interfaces are defined as[return: NotNullIfNotNull("fileInfo")] IFileInfoFactory.Wrap(FileInfo? fileInfo)
and likewise forIDirectoryInfoFactory.Wrap
.To Reproduce
Steps to reproduce the behavior:
new FileSystem().FileInfo.Wrap(null);
IFileInfoFactory.Wrap
acceptsFileInfo?
and returnsIFileInfo?
ArgumentNullException
is thrownExpected behavior
I expect to get a
null
IFileInfo?
back if the input isnull
, and no exception thrown.Additional context
Fixing this will help compatibility with System.CommandLine where defining options as
FileInfo?
is a common practice, i.e.:The text was updated successfully, but these errors were encountered: