Uh oh!
There was an error while loading. Please reload this page.
move File.Exists and File.ReadAllBytes to Common - #53168
Conversation
…tion and implementation differences
ghost
commented
May 24, 2021
Tagging subscribers to this area: @carlossanlop Issue DetailsI wanted to start working on and then I realized that we have a copy of runtime/src/libraries/System.Private.CoreLib/src/Internal/IO/File.cs Lines 10 to 16 in d1a0a20 The problem is that it was not kept in sync. The differences:
I moved it to
|
jkotas
commented
May 24, 2021
CoreLib uses these two APIs for specific purpose where we do not need any of this. You can add a comment to CoreLib copy that this is missing instead of increasing the amount of duplicated code. Instead of this, it may be better to fold System.IO.FileSystem into CoreLib (contributes to #2138). @marek-safar asked me about it a while ago. System.IO.FileSystem has a dependency on Linq that would need to be cleaned up before it can be done. |
jkotas
commented
May 24, 2021
We still have the code duplicated in binaries, and more of it than before. |
adamsitnik
commented
May 24, 2021
@jkotas I like the idea of folding |
carlossanlop
commented
May 24, 2021
@jkotas Why move the whole FileSystem namespace to CoreLib? If Linq has dependencies to FileSystem types, can't we instead move only the types that are needed? For example, I'm interested in knowing the reasoning to move the whole namespace. cc @ericstj |
jkotas
commented
May 24, 2021
I think that the file and directory enumeration APIs that exist in System.IO.FileSystem.dll really belong to CoreLib. Note that we have a parallel implementation of file and directory enumeration APIs in CoreCLR PAL (https://github.com/dotnet/runtime/blob/main/src/coreclr/pal/src/file/find.cpp). We are not able to do C# rewrite of the logic that depends on these since the managed file and directory enumeration APIs do not live in CoreLib. Once we move the the managed file and directory enumeration APIs to CoreLib, we will be one stop closer to be able to rewrite a bunch more runtime code in C#.
Use of Linq in System.IO as anti-pattern. We try to avoid use Linq at the lower levels of the stack since it has large performance overhead. I would be good to get rid of Linq in System.IO regardless. |
I wanted to start working on
File.OpenHandlewhich is part of #24847 (comment)and then I realized that we have a copy of
File.ExistsandFile.ReadAllBytesinSystem.Private.CoreLibwhich was promised to keep in sync withSystem.File.IO:runtime/src/libraries/System.Private.CoreLib/src/Internal/IO/File.cs
Lines 10 to 16 in d1a0a20
The problem is that it was not kept in sync. The differences:
TrimEndingDirectorySeparatorforFile.ExistsFile.ReadAllBytes:I moved it to
Commonso we have a single implementation and no code duplication now.