alphaleonis / AlphaFS

AlphaFS is a .NET library providing more complete Win32 file system functionality to the .NET platform than the standard System.IO classes.
http://alphafs.alphaleonis.com/
MIT License
563 stars 99 forks source link

System.IO.FileSystemInfo.Refresh() is public; but AlphaFS FileSystemInfo.Refresh() is protected #427

Closed elgonzo closed 6 years ago

elgonzo commented 6 years ago

As the title says, the AlphaFS FileSystemInfo.Refresh() is protected. This is different from System.IO.FileSystemInfo.Refresh(), which is a public method (https://msdn.microsoft.com/en-us/library/system.io.filesysteminfo.refresh(v=vs.110).aspx). This can be a problem, because several public methods return arrays or enumerables of type FileSystemInfo.

As an illustrative example, compiling this line using System.IO is possible without problems:

new System.IO.DirectoryInfo(@"some\directory\path").GetFileSystemInfos()[0].Refresh();

However, with AlphaFS this code breaks and does not compile because of the different accessibility of the Refresh method:

new Alphaleonis.Win32.Filesystem.DirectoryInfo(@"some\directory\path").GetFileSystemInfos()[0].Refresh(); // does not compile!

Unless there are severe reasons to keep FileSystemInfo.Refresh() protected and thus diverging from the public API of System.IO.FileSystemInfo, i would suggest to make this method public and simply remove the re-declaration of the Refresh() method in both DirectoryInfo and FileInfo.

Yomodo commented 6 years ago

Nice catch! Could not find any reason why this is protected.