You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FileInfoFactory and DirectoryInfoFactory Wrap implementations don't match the interface for nullability #975
Describe the bug
The implementations for FileInfoFactory.Wrap and DirectoryInfoFactory.Wrap require non-null references, while the interfaces are defined as [return: NotNullIfNotNull("fileInfo")] IFileInfoFactory.Wrap(FileInfo? fileInfo) and likewise for IDirectoryInfoFactory.Wrap.
To Reproduce
Steps to reproduce the behavior:
new FileSystem().FileInfo.Wrap(null);
The analyzer and compiler accept the syntax since IFileInfoFactory.Wrap accepts FileInfo? and returns IFileInfo?
An ArgumentNullException is thrown
Expected behavior
I expect to get a nullIFileInfo? back if the input is null, 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.:
Activity
vbreuss commentedon Apr 22, 2023
Thanks for creating this issue, @mikeeheler.
I already created a pull request (#976) to fix this bug!
fix: null-handling in Wrap-Method in factories for `IDirectoryInfo` o…
fix: null-handling in Wrap-Method in factories for `IDriveInfo` or `I…
github-actions commentedon Apr 24, 2023
This is addressed in release v19.2.17.