Commit Graph
835 Commits
Author SHA1 Message Date
Adam SitnikandStephen Toub ba4eae0b96 Reduce allocations for CreateDirectory (#61777)
* introduce an overload that accepts ROS<char> instead of a string

* remove dead code

* avoid string allocations

* remove List<int> allocation

* Apply suggestions from code review

Co-authored-by: Stephen Toub <[email protected]>
2021-11-19 13:02:26 +01:00
Viktor Hofer 0964be0ae9 Update slngen and solution files (#60871)
Update slngen tooling to latest stable version and solution files since
a lot changed since the last time they were updated:
- NET7 (removal of older TFMs)
- Source Generators
2021-10-26 21:23:54 +02:00
Elinor Fung 39048dd5de Undo solution and config changes from DllImportGenerator (#60481)
* Remove dotnet-experimental feed from NuGet.config
* Revert changes to solution files and restore configs
2021-10-15 11:06:12 -07:00
Jeremy Koritzinsky d924fbc7e9 Merge branch 'main' of github.com:dotnet/runtime into merge-main 2021-09-24 09:26:18 -07:00
Jeremy Koritzinsky 27034bc84b Run slngen to regenerate the solution files. 2021-09-22 17:02:14 -07:00
Tom Deseyn cd90de0683 Remove mostly unused SafeFileHandleHelper.Unix class (#59254) 2021-09-17 17:46:12 +02:00
Jeremy Koritzinsky 81293bfc1e Merge branch 'main' of https://github.com/dotnet/runtime into merge-main 2021-09-14 16:29:42 -07:00
Jeremy Koritzinsky 5b8ce63f73 Update DllImportGenerator to the latest version (#59117) 2021-09-14 16:15:21 -07:00
Viktor Hofer 67354a2fb4 Upgrade to net7.0 and remove target frameworks (#58011)
* Remove EOL tfms and upgrade to net7.0

* Make linker tests net7 aware

Make installer tests run on net7.0

Don't attempt to use live apphost

Fix payloads

Regenerate test files

Fix package testing
2021-09-08 22:04:23 +02:00
Viktor Hofer 36b6247cc7 Update solution files for correct ordering of elements (#58655)
With the newest udpate of slngen, the order of elements (configuration, folders, etc.) is in sync with how Visual Studio arranges them.
Also the order is now deterministic.

Based on that, updating all solution files to have the correct ordering of elements. This change also unblocks adding CI protection for
making sure that solution files are up-to-date in regards to their dependencies as slngen is now generating the files deterministically.
2021-09-04 00:16:15 +02:00
Dan Moseley e617017564 More xml docs (#57039)
* Update Handle docs

* Some easy xmldoc updates

* typo

* typo

* another

* Build breaks with M.IO.R.csproj

* updates
2021-08-12 17:49:53 -06:00
Emmanuel AndréandStephen Toub e4b4666e20 Use IValueTaskSource in PipeStream on Windows (#52695)
* Use IValueTaskSource in PipeStream on Windows

* Revise implementation of IValueTaskSources

Better match implementation in RandomAccess

Co-authored-by: Stephen Toub <[email protected]>
2021-08-11 20:59:40 -04:00
Jeremy Koritzinsky 108fcdb61c Merge branch 'main' of github.com:dotnet/runtime into feature/use-dllimport-generator 2021-07-29 10:44:59 -07:00
Viktor Hofer a6b9a63f35 Update libraries solution and NuGet.config files (#56430)
* Update slngen and invocation

* Update NuGet.config files

* Update solution files with slngen
2021-07-28 18:44:17 +02:00
Emmanuel AndréandStephen Toub c5edf0e095 Fix WaitForConnectionAsync when NamedPipeServerStream is disposed (#52825)
* Fix WaitForConnectionAsync when NamedPipeServerStream is disposed

* Align Unix implementation on broken pipe IO exception as on Windows

* Add missing methods to test against ObjectDisposedException

* Apply suggestions from code review

Co-authored-by: Stephen Toub <[email protected]>

* Rebase and fix suggestions

* Cancel Accept on dispose

* Improve test

* Apply suggestions from code review

Co-authored-by: Stephen Toub <[email protected]>
2021-07-18 13:30:16 -04:00
Stephen Toub dfd618dc64 Use interpolated strings in more places 2021-07-13 10:11:51 -04:00
Elinor Fung 6271751fca Merge remote-tracking branch 'upstream/main' into HEAD 2021-06-11 10:04:20 -07:00
Steve MacLean d66e9361f5 Apple Silicon reenable 49568 (#52202) 2021-06-09 20:27:31 -04:00
Elinor Fung 061e414d57 Use GeneratedDllImport in System.Net.Http (#53885) 2021-06-08 15:40:34 -07:00
Tom Deseyn d3ed5a9ede Socket: delete unix local endpoint filename on Close (#52103)
Fixes #45537
2021-05-31 18:07:31 +02:00
Geoff KizerandGeoffrey Kizer b5c91e4c29 add AcceptAsync cancellation overloads (#53340)
* add AcceptAsync cancellation overloads

* pass cancellationToken to AcceptAsync in Unix NamedPipe impl

* add TcpListener overloads too

* enable pipe cancellation test on Unix

Co-authored-by: Geoffrey Kizer <[email protected]>
2021-05-29 12:10:10 -07:00
Eric StJohn c0a1734094 Remove the use of IsPartialFacadeAssembly in refererences (#52793)
* Remove the use of IsPartialFacadeAssembly in refererences

This flag requires assembly-re-writing to replace type-defs in reference
assemblies with type forwards, when the same type exists in references.

We've pretty much exclusively used this on .NETFramework, since it's
not friendly to source build (CCI isn't part of source build).
.NETFramework isn't going to be changing so it doesn't save us much
to generate these typeforwards in the build.

We also used these to make sure the netstandard surface area was
compatible with .NETFramework facades (we'd use the pre-rewritten
reference assemblies for contract), but this need goes away now that we
have package validation based APICompat that compares netstandard refs
to net4x facades.

* Fix some projects I missed after changing naming convention

* Fixup another project

* Fix build of System.System.Threading.AccessControl

* Adding a section to ref-source docs on .NETFramework facades

* Address feedback
2021-05-19 08:22:04 +02:00
Viktor Hofer 089717bdfb Stop harvesting S.IO.Pipes.AccessControl (#52294)
* Stop harvesting S.IO.Pipes.AccessControl

The removed configurations (netstandard1.3, netcoreapp2.1, net46) aren't
built anymore. Instead the already built matching binaries from the
latest available packages are redistributed when packaging these
libraries.

Dropping these assets as the minimum supported set of platforms are ones
that support netstandard2.0 and are still in-support. As an example,
also dropping the netcoreapp2.1 asset which isn't supported anymore and
upgrading it to netcoreapp3.1.. For .NET Framework, there's still a
net461 configuration present to avoid binding redirect issues.

The ugly part of this change is that System.IO.Pipes.AccessControl
depends on an internal API of System.IO.Pipes for all .NETCoreApp
configurations. Because of that, for configurations that don't apply
to the current band (netcoreapp3.1, net5.0), the runtime packs need
to be downloaded so that runtime assembly can be referenced. Ideally
we will come up with a better solution to not require runtime packs
to be fetched as that adds 60MB of download size to the repo and breaks
source build.

Contributes to #47530

* Use non shipping refs for Pipes typeforwards
2021-05-11 17:40:30 +02:00
Kareem ZedanandJan Kotas b08a97afb8 Task/use get last p invoke error (#52212)
* replacing GetLastWin32Error with GetLastPInvokeError in remaining assemblies

* replace GetLastWin32Error with GetLastPInvokeError in assemblies outside system.private.corelib

* Apply suggestions from code review

Co-authored-by: Jan Kotas <[email protected]>
2021-05-09 12:42:21 -07:00
Jeff HandleyandJeremy Barton ebd695fee1 Mark RNGCryptoServiceProvider as Obsolete (#52373)
* Mark RNGCryptoServiceProvider as Obsolete

* Use the static methods on RandomNumberGenerator instead of Create()

* Use RandomNumberGenerator.GetBytes() instead of RandomNumberGenerator.Create().GetBytes()

* Revert "Use RandomNumberGenerator.GetBytes() instead of RandomNumberGenerator.Create().GetBytes()"

This reverts commit 447f8485a08f831f34d00597a30800ac36f034ef.

* Update src/libraries/System.IO.Pipes/tests/NamedPipeTests/NamedPipeTest.CurrentUserOnly.Windows.cs

Co-authored-by: Jeremy Barton <[email protected]>
2021-05-07 18:33:52 -07:00
Alexander Köplinger bc9f00c226 Cleanup PlatformSpecific/SkipOnMono attributes that skip a platform (#50907)
We have a bunch of test assemblies that don't make sense on some platforms, e.g. Browser.
Right now we're skipping them via `[SkipOnMono("reason", TestPlatforms.Browser)]` but there's nothing that inherently ties this to Mono other than the current implementation.

The more generic `SkipOnPlatform` attribute can be used instead.
We can also use it in places where we do `[PlatformSpecific(~TestPlatforms....)]` to avoid the double inversion.
2021-04-09 13:20:18 +02:00
kronicandkronic 62170c1147 remove repetitions ';' (#50236)
Co-authored-by: kronic <[email protected]>
2021-03-25 20:59:08 -04:00
Stephen Toub 0817e748b7 Seal internal types in libraries (#50225) 2021-03-25 20:50:33 -04:00
Steve Pfister bc5b227c9f Remove openssl dependency from android (#49282) 2021-03-23 00:17:12 -04:00
Steve MacLean e867be6cab Enable macOS-arm64 libraries tests on runtime-staging rolling builds (#49445)
* Disable failing Apple Silicon Libraries tests

-  Use tests.proj to disable catastrophically failing libraries tests
-  Add ActiveIssues where XUnit didn't crash

* Enable CoreCLR lib tests for Apple Silicon in Runtime-Staging
2021-03-18 14:03:08 -04:00
Tom Deseyn 2606d828b8 AnonymousPipeStreams.Linux, Process.Unix Streams: perform async I/O by using Socket implementation (#44647)
* experiment: use read/write for socket operations instead of recvmsg/sendmsg

* AnonymousPipeStreams: perform async I/O by using Socket implementation

* PipeStream.Unix: use sync/async functions on Socket

* Refactor Socket creation

* Cleanup

* Fix broken comment

* Allow passing pipe fd to Socket/SafeSocketHandle public ctor

* macOS: Handle EPIPE on registration

* Refactor IsPipe to IsSocket

* Move registration error handling in to single method

* Process: use AnonymousPipeClientStream for redirected streams.

* Remove unneeded BufferedStream

* PR feedback

* PipeStream.Unix: enable cancelation tests

* Add back Ctor_SafeHandle_Invalid_ThrowsException test

* SysRead/SysWrite: Assert not used for socket-type handle
2021-03-16 22:03:36 -04:00
Geoff KizerandGeoffrey Kizer 027c093de1 Improve zero-byte read handling in SslStream to reduce memory usage (#49123)
* add ZeroByteRead_PerformsZeroByteReadOnUnderlyingStreamWhenDataNeeded to stream conformance tests

* remove dead code

* change SslStream zero byte read implementation to issue zero-byte read on underlying stream when appropriate

* ensure buffer is always freed when not needed, and assert this

* create StreamConformanceTests assembly and reference from appropriate test projects

Co-authored-by: Geoffrey Kizer <[email protected]>
2021-03-07 13:02:28 -08:00
Stephen Toub a9c5eadd95 Remove superfluous #nullable enables (#48033)
And enable nullable annotations in test projects
2021-02-10 14:04:48 -05:00
Jeremy Koritzinsky 3cbdf4c57e Update SafeHandle types to have public parameterless constructors and add InitHandle API (#47189)
* Update public SafeHandle types to have public parameterless constructors.

Remove now-unneeded ILLink trim files.

Make public abstract SafeHandle constructors protected.

Remove comment on SafeWaitHandle

* Make SafeHandle constructors public for internal types.

Make internal abstract SafeHandle default constructors protected. Make non-abstract internal SafeHandles sealed when possible.

More internal SafeHandle types.

* Add new Marshal.InitHandle API.

Fix SetHandle accessibility

Fix test.

Use Marshal.InitHandle.

* PR feedback.

* Remove trailing whitespace.
2021-01-20 22:01:09 +00:00
d448461805 Implement and use MultiArrayBuffer (#44980)
* add MultiArrayBuffer and use in StreamBuffer and Http2Stream

* rework EnsureAvailableSpace and add tests for it

* make dispose handling more robust, plus minor tweaks

* add AssertExtensions.SequenceEqual for providing more useful information about sequence differences, and use in StreamConformanceTests

* tweaks

* replace _blockCount with _allocatedEnd

* use uint instead of int internally to assure bitop optimizations

* fix _allocatedEnd calculation

* address PR feedback

* more PR feedback and some minor fixes/improvements

* small test improvements

* Apply suggestions from code review

Co-authored-by: Günther Foidl <[email protected]>

* address review feedback

Co-authored-by: Geoffrey Kizer <[email protected]>
Co-authored-by: Günther Foidl <[email protected]>
2021-01-06 11:06:15 -08:00
Anirudh Agnihotry fd5609d44c Remove targets* platform condition from project references (#46377)
* remove targets* platform condition from project references

* Remove extra condition

* remove redundant condition
2021-01-04 14:26:32 -08:00
xtqqczze 8d6e098d64 Remove nonsensical comments about fixed statement (#46013) 2020-12-13 17:46:25 -08:00
Anirudh AgnihotryandViktor Hofer 659c5fbc7f disable restore in vs for projects targeting platform specific old frameworks (#44932)
* disable vs restore in vs for projects targeting platform specific older frameworks

* Add infra to auto-update solution files for restore

* Add NuGet.config files for solutions affected by restore issue

Co-authored-by: Viktor Hofer <[email protected]>
2020-12-02 23:18:52 +01:00
Stephen Toub 93cbc0974a Remove ForceAsync from CryptoStream (#45150) 2020-11-24 20:25:27 -05:00
Stephen Toub ef2a187879 Remove some overhead from Process.Start (#44691)
- Avoid StringBuilder marshaling
- Let CreateProcess{WithLogonW} determine the current working directory
- Avoid creating SafeHandles for GetCurrentProcess()
- Avoid forcing ProcessStartInfo.ArgumentList into existence just to check if it contains anything
- Prefer using ProcessStartInfo.Arguments in Start(string, IEnumerable<string>) if there's only one string in the enumerable
- Use ValueStringBuilder instead of StringBuilder to build up arguments, so as to use stack space / pooled char[]s and avoid actually needing to produce strings.
- Avoid unnecessary SafeHandle for PROCESS_INFORMATION.hThread
2020-11-17 17:48:19 -05:00
Viktor Hofer ed295782bf Add workflow to update solution files with SlnGen and update them initially (#44703)
* Add slngen infra

* Update all solution files
2020-11-17 18:23:30 +01:00
Anirudh Agnihotry b37f10a504 Changing Windows_NT -> Windows for enabling TargetPlatformMoniker feature of the sdk for platform specific tfms. (#43651)
* eng change

* coreclr change

* libraries change

* tests change

* installer & mono change

* py files changed

* .md change

* .yml change

* remove redundant targetos property

* Windows_NT -> windows after ninja change

* fixing runtime build failure
2020-11-02 14:25:58 -08:00
Stephen Toub a112379a67 Add Stream argument validation helpers and use throughout dotnet/runtime (#43968)
* Add Stream argument validation helpers and use throughout dotnet/runtime

* Delete unnecessary code in Stream

Stream.Null was using BlockingBegin/EndRead/Write, but the operations are nops (they don't even do argument validation), so the functionality was unnecessary complication.  We can just use TaskToApm instead, with already completed tasks, and then also delete the SynchronousAsyncResult that was used by these operations.

Also, the Begin/EndRead/Write methods were checking CanRead/Write and throwing if they return false, but this is a private sealed type with CanRead/Write hardcoded to return true! Delete.

Finally added consistency across Stream.Null to checking for cancellation.

* Clean up some style on Stream

Also consolidate a few resources and use a few existing ThrowHelpers where appropriate.

* Fix a few issues, and remove duplicative tests missed in conformance tests rollout

* Address PR feedback
2020-10-30 05:50:49 -04:00
Stephen Toub 0acbafe061 Add initial set of conformance tests for Stream (#43834)
* Fix invalid assert in StreamBuffer

This can be hit by calling code and thus shouldn't be an assert.  As an assert it prevents testing.

* Add ConnectedStreams.CreateUnidirectional

* Add initial set of Stream conformance tests

These primarily focus on "connected streams", ones that can be arranged to communicate with each other in a producer/consumer pattern or as a bidirectional communication mechanism, e.g. NetworkStream, PipeStream, SslStream wrapped around a NetworkStream, FileStream created around pipes, etc.  Later we can add more tests focused on standalone streams, e.g. FileStream created for an on-disk file, MemoryStream, etc.

* Add ConnectedStreams tests

These are currently helpers used by many other tests.  At some point they could become public API as well.

* Fix NetworkStream argument names

Technically a breaking change, but the current divergence from the base Stream class is a bug, and bringing them into sync means argument exceptions that emerge from the derived type make sense when used via the base type, as well as then being able to use shared validation logic across all streams (subsequent to these changes).

* Add stream conformance tests for NetworkStream

* Add stream conformance tests for QuicStream

* Fix several CryptoStream behaviors

1. Flushing a stream that wraps another stream for writing should always flush that underlying stream, even if no additional data was written as part of the flush.
2. Argument validation should validate buffers are not null rather than null ref'ing on a null buffer.
3. Checks for the CryptoStream mode should come after argument validation.

* Add stream conformance tests for CryptoStream

* Fix FileStream argument names

Technically a breaking change, but the current divergence from the base Stream class is a bug, and bringing them into sync means argument exceptions that emerge from the derived type make sense when used via the base type, as well as then being able to use shared validation logic across all streams (subsequent to these changes).

* Fix BufferedStream argument names

Technically a breaking change, but the current divergence from the base Stream class is a bug, and bringing them into sync means argument exceptions that emerge from the derived type make sense when used via the base type, as well as then being able to use shared validation logic across all streams (subsequent to these changes).

* Add stream conformance tests for FileStream

Specifically when used in a connected fashion, wrapped around an anonymous or named pipe.

* Add stream conformance tests for BufferedStream

Specifically when used in a connected fashion, wrapped around some other connected stream.

* Add stream conformance tests for SslStream and NegotiateStream

* Fix PipeStream.Flush to not fail on readable streams

Consumers may expect Stream.Flush to be a nop if the stream is readable only, but PipeStream.Flush is throwing in that case.  Stop doing that.

* Add stream conformance tests for PipeStream

* Fix several BrotliStream behaviors

1. When passed a null buffer, it's throwing an exception with the argument name "array", even though the parameter's name is "buffer".
2. Even if there's no data written as part of the Flush{Async} call on a writeable stream, it should be calling flush on the wrapped stream.

* Fix several DeflateStream (and friends) issues

1. DeflateStream.Flush{Async} when writing needs to always flush the underlying stream, even if there's no data written as part of the flush call itself.
2. Several byte[] array arguments should be byte[] buffer. Technically a breaking change, but the current divergence from the base Stream class is a bug, and bringing them into sync means argument exceptions that emerge from the derived type make sense when used via the base type, as well as then being able to use shared validation logic across all streams (subsequent to these changes).
3. DeflateStream.EndRead/Write needs to do additional state validation.
4. Not a bug, but simplify ReadAsync to match the sync Read implementation flow.

* Add stream conformance tests for Deflate/ZLib/GZip/BrotliStream

* Fix PipeReader/WriterStream argument validation

* Add stream conformance tests for PipeReader/WriterStream

* Remove erroneous asserts from Stream.ReadWriteTask

* Address PR feedback

* Fix a few tests in CI
2020-10-28 09:36:23 -04:00
Stephen Toub cf276ce537 Change Task.FromResult to use same task cache as async methods (#43894)
* Change Task.FromResult to use same task cache as async methods

Task.FromResult today always creates a new task.  This leads developers that are aware of this to then create their own caches for common values, typically 0, true, and false, to avoid task allocations for those common values.  But we already have such values cached internally, used for async method return values.  We can just use the same cache for Task.FromResult.

* Address PR feedback
2020-10-28 06:50:00 -04:00
Stephen Toub e8339af091 Remove some unnecessary unsafe usage (#43430) 2020-10-16 22:24:20 -04:00
Santiago Fernandez Madero b04361aacf Disable NamedPipeTests CurrentUserOnly on server core (#43381) 2020-10-14 12:43:15 -07:00
Stephen Toub e4034f8d85 Fix several BeginXx nullable annotations (#42442)
AsyncCallback and object state parameters in APM BeginXx methods should always be nullable.  Several in annotated libraries were annotated incorrectly.
2020-09-19 06:51:20 -04:00
Mitchell HwangandMitchell Hwang bef2ca3b04 Mark System.IO.Pipes Unsupported at assembly level (#41976)
Co-authored-by: Mitchell Hwang <[email protected]>
2020-09-09 09:36:02 -04:00
Anirudh Agnihotry 94ec04c946 Cleaning up unused TargetsBrowser conditions (#41062)
* minor cleanup

* remove unused string
2020-08-19 19:35:23 -07:00