* Support trimmed paths in FileInfo
Some paths are not creatable in Windows without special syntax. Notably paths with trailing spaces and periods. As GetFullPath() (and GetFullPathName()) trim these we would lose the correct file name as we passed the path around. With the enumeration changes we now populate FileInfo correctly- this change allows the other methods to work when wrapped around such a path.
* Tweak comments.
Remove NotSupported and SecurityException from Exists as these are no longer thrown.
Add a test fix I hadn't staged correctly.
Commit migrated from https://github.com/dotnet/corefx/commit/41a2120b233cc02c175f812e4e19e3f058396cb0
ReadAllTextAsync is convenience method that allocates a lot anyway, so the saving from StringBuilderCache is unlikely to show up. And this method is unlikely to be used for small strings where StringBuilderCache helps anyway.
Commit migrated from https://github.com/dotnet/corefx/commit/80918915b4df50047e763a3a6ee36aa20809e6da
This commit does several things:
- Exposes the new `ValueTask` extensibility model being added in coreclr. The ValueTask-related files will separately be mirrored over to corefx to enable the netstandard build of System.Threading.Tasks.Extensions.
- Adapts all `Stream`-derived types to return `ValueTask` instead of `Task` from `WriteAsync`.
- Changes the new `WebSocket` `SendAsync` method to return `ValueTask` instead of `Task`, and updates the `ManagedWebSocket` implementation accordingly. Most `SendAsync`s on `ManagedWebSocket` should now return a `ValueTask` that's either completed synchronously (no allocation) or using a pooled object. It now uses the underlying transport's new `WriteAsync` overload that returns `ValueTask`.
- Switches more uses of `ReadAsync` and `WriteAsync` over to the new overloads, including in Process, DeflateStream, BrotliStream, File, HttpClient, SslStream, WebClient, BufferedStream, CryptoStream,
- Removed some unnecessary array clearing from various routines using ArrayPool (after the clearing was added we changed our minds and decided clearing was only necessary in very specific circumstances)
- Implements a custom `IValueTaskSource` in Socket, such that async receives and sends become allocation-free (ammortized). `NetworkStream` then inherits this functionality, such that its new `ReadAsync` and `WriteAsync` are also allocation-free (in the unbounded channel implementations; we can subsequently add it in for bounded).
- Implements a custom `IValueTaskSource` in System.Threading.Channels, such that reading and writing are ammortized allocation-free up to one concurrent reader and writer.
- A few random things I noticed as I was going through, e.g. missing ConfigureAwait, some incorrect synchronization in tests, etc.
- Adds a ton of new tests, mainly in System.Threading.Tasks.Extensions, System.Threading.Channels, and System.Net.Sockets.
Commit migrated from https://github.com/dotnet/corefx/commit/6d1671b2cfcf130b7bc6c059bb0508073426532a
* Make final API review changes to file enumeration
Tweak stack array initialization to just zero the first element in matcher algorithm.
cc: @danmosemsft @terrajobst
* Don't null out the native name to track conversion
Commit migrated from https://github.com/dotnet/corefx/commit/62878f34d65f8bac6f7ebd91083fb9a02866de98
* Rename string-slicing extension methods
As part of
https://github.com/dotnet/corefx/issues/26894
the api folks have approved renaming AsROSpan and AsROMemory
on string instances to AsSpan and AsMemory (as the "readonly"
is obvious given the read-only nature of the input.)
This puts the renaming in effect. Basically a big search-replace
commit.
* Fix OpenSSL build break
* I see this is going to be a treadmill
Commit migrated from https://github.com/dotnet/corefx/commit/3538128fa1fb2b77a81026934d61cd370a0fd7f5
* Handle errors getting state in Unix
Throwing errors while examining extended state while enumerating isn't consistent with Windows behavior. Windows never throws past getting directory entry data as all state is already available.
Ensure entry attribute state is consistent with initial construction.
* Win 7 CI machines are also setting NotContentIndexed.
Commit migrated from https://github.com/dotnet/corefx/commit/597f44c5056badfb47f45731480454d698849800
* Fix enumerating the root directory.
Shouldn't trim the trailing separator when at the root. On Windows that makes
the path drive relative- which breaks most of the logic.
Add a test to catch this case.
* Add the Unix part of the fix.
Commit migrated from https://github.com/dotnet/corefx/commit/5b4ce203c563a20053f32f9901ea6b7dc67c8e37
NtCreateFile allows passing in a base handle which makes opening child directories much faster. This cuts anywhere from 3-10% of the time off of a GetFiles() call.
It is significantly faster as it avoids normalization and path parsing overhead.
Commit migrated from https://github.com/dotnet/corefx/commit/a28a2cdda67c024126f690bbe1331174a194f9ce
* Clear initlocals in a bunch of assemblies
Sets
```XML
<ILLinkClearInitLocals>true</ILLinkClearInitLocals>
```
for the assemblies:
- System.IO.FileSystem
- System.IO.Pipes
- System.Memory
- System.Net.Http
- System.Net.Http.WinHttpHandler
- System.Net.NameResolution
- System.Net.NetworkInformation
- System.Net.Primitives
- System.Net.Requests
- System.Net.Security
- System.Net.Sockets
- System.Net.WebSockets
- System.Net.WebSockets.Client
- System.Net.WebSockets.WebSocketsProtocol
- System.Private.Uri
- System.Runtime
- System.Runtime.Extensions
Eventually we'd ideally set the flag for the whole repo; these are just the ones I audited thus far. In a few cases I had to make code changes to adapt, where the code was expecting stackallocs to be cleared. I also looked at a few other projects (System.Collections, System.Runtime.Numerics) where there were more significant dependencies on clearing and I decided to leave those for later.
* Disable ILLinkClearInitLocals running on Unix until it works there
Commit migrated from https://github.com/dotnet/corefx/commit/f0a032e4a1c8a848574a5db3e69e8a6fa0aae91e
* Reduce Unix enumeration allocations
This change factors out the FileStatus access into a helper struct and adds overloads
for the stat imports that allow passing a span.
The next steps:
- Handle errors manually
- Skip using safehandle
- Look for further opportunities around UTF-8/16 conversion
* Address feedback
Shuffle code around a bit in FileInfo for clarity. Also shift directory determination
to FileSystemEntry to avoid allocation on links.
Commit migrated from https://github.com/dotnet/corefx/commit/c64171e379090b372fe232ec3f27a57ae838406c
* Fix accessing trimmed paths
Paths with trailing spaces or periods are normally trimmed by Windows. They can, however, be created using `\\?\` or be exposed via mapping of remote file systems. This change fixes the ability to work with returned *Info classes on files of this type.
This change also cleans up the Info classes:
- removes non-relevant comments
- removes "display" paths (limited trust holdover)
Also remove dead PathPair class.
* Fix helper for .NET Standard
Commit migrated from https://github.com/dotnet/corefx/commit/e2cd5a8fc468b63255f91f4f28bccddb3bb31e8f