* System.IO.Compression.DeflateStream.CopyToStream
-Implemented memory-based WriteAsync in DeflateStream.CopyToStream class.
This required implementing a memory-based overload of System.IO.Inflater.SetInput(). Previously, Inflater used a GCHandle to pin the array that was passed into SetInput. I converted it to use a MemoryHandle, and changed the array-based overload of SetInput to delegate to the new Memory-based overload.
* Implement suggested changes
* Memorify RequestStream
- Memory overrides for System.Net.RequestStream
- Memory overrides for System.Net.NetworkStreamWrapper
* Spanified ChunkedMemoryStream
WriteAsync is implemented in terms of Write, so I went ahead and implemented Write(ReadOnlySpan<byte>).
For some reason, AsSpan() isn't available in this file.
* Apply suggested changes
* Apply suggestions from code review
Co-authored-by: Adam Sitnik <[email protected]>
Uses the recently added support for SocketsHttpHandler.ConnectCallback to be used for synchronous operations to add support for HttpWebRequest.ReadWriteTimeout. That value is now used to set the Read/WriteTimeout on the underlying socket, with it then affecting all synchronous reads and writes on that connection. The ReadWriteTimeout is added to the cache key for whether the cached HttpClient instance can be used, as is whether the request is sync or async because that influences how connections are created from the HttpClient instance.
* 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]>
* 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
At some point some Debug.Asserts/Fails were replaced by this NetEventSource.Fail helper, which both Debug.Fails and fires an EventSource event. But asserts in our code base are intended for things that should never happen, and we needn't be emitting events for them (if we did want to emit events for them, we'd need to tackle the other ~20,000 Debug.Assert/Fails in the codebase.
I've deleted NetEventSource.Fail, and fixed up the call sites. Some were simply replaced by Debug.Assert/Fail. Some were deleted entirely, when from code inspection it looked like they could actually be hit, but were guarded by a check for the event source being enabled and thus were unlikely to have been triggered in our previous testing. Etc.
* Remove unused locals in System.Net.HttpListener
* Remove unused local in System.Net.Requests
* Remove unused locals and methods in System.Net.Security
* [wasm] Modify System.Net.Request to throw PNSE on Browser WASM
* [wasm] Re-enable System.ComponentModel.EventBasedAsync.Tests.BackgroundWorkerTests.TestFinalization test
* Make the CS0809 build warning depend on if PNSE assembly is going to be generated
* Update src/libraries/System.Net.Requests/src/System.Net.Requests.csproj
Co-authored-by: Alexander Köplinger <[email protected]>
* Remove redundant condition
Co-authored-by: Alexander Köplinger <[email protected]>
- Remove depprojs which currently binplace external references into the RefPath folders in favor of PackageReference and PackageDownload items.
- Build all configurations by default when building an individual project (either on the CLI or inside VS) same as with the official SDK. This enables .NETFramework Test Explorer support.
- Centrally define libraries that compose the shared framework instead of in each Directory.Build.props file to be able to build the targeting pack first and consume it in the OOB libraries.
- Use ProjectReferences to reference OOB projects. Compile against the reference assembly but use the implementation assembly app-local during runtime.
- Remove OOBs from the testhost and remove the testhost folder for .NETFramework as it isn't required anymore.
- Only binplace for $(NetCoreAppCurrent) to compose a) the targeting pack, b) the runtime pack, c) the testhost, d) a full closure for the shims.
- Use Targeting Packs for OOB projects (with their implicit assembly references) but still explicitly define granular references for .NETCoreApp configurations (DisableImplicitAssemblyReferences switch). Use the implicit targeting pack references in some Microsoft.Extensions.* cases.
- Remove placeholder configurations as they aren't needed anymore with explicit P2Ps vs Targeting Pack references.
- Remove implicit assembly references (ie for .NETFramework, mscorlib)
- Remove AssemblySearchPath hacks that were introduced with b7c4cb7 as the targeting pack is now used by default.
- Reduce unnecessary .NETFramework configurations that were added to run tests in favor of the already existing ref&src configurations.
- Stop hardcoding the paths for wasm assemblies and use the returned TargetPath of the ProjectReferences.
- Addressed formatting (ItemGroups, References at the bottom of the project file, ordering of references, use LibrariesProjectRoot instead of a relative path, unnecessary AssemblyName and RootNamespace properties which are identical to the project name, ordering of tfms)
- Revert "fix clean (#33758)"
* Mark new obsoletions for .NET 5; update existing obsoletions
* Exclude DirectoryServicesPermission/DirectoryServicesPermissionAttribute from obsoletions for now
* No need to restore SYSLIB0003 at end of Forwards files
* Use a common Obsoletions.cs file for all SYSLIB obsoletions
* Resurrect CER code behind #ifdef in EventSource
* Mark GlobalAssemblyCache overrides as Obsolete
* Suppress Thread.Abort() error in ImageAnimator.Unix.cs
* Unconditionally mark RoAssembly.GlobalAssemblyCache as obsolete
* Rename MSLIB0001 to SYSLIB0001 in ref assembly
* Suppress obsoletion warnings in tests
* Adopt a uniform #ifdef for NET50_OBSOLETIONS
* Fix BinaryFormatter obsoletion message after the rebase
* Use SYSTEM_PRIVATE_CORELIB constant instead of NETCOREAPP
* Remove the code comment on the ifdef
* Apply feedback related to CER obsoletions
* Apply feedback related to CAS
* Update ref assembly to reflect SecurityManager obsoletion
* Fix regression in System.IO.Pipes.NamedPipeServerStream.Windows.RunAsClient
They're super verbose, very inconsistent, costly, and not helpful (they appear to be trying to provide tracing of the full flow of calls, but they fail to do even that).
* Trim NetEventSource when EventSource.IsSupported is false
Follow up to #38129. NetEventSource code was still left in even when EventSource.IsSupported is false, since all the usages of NetEventSource are keying off its own static property: NetEventSource.IsEnabled.
Remove NetEventSource.IsEnabled so the linker can trim NetEventSource code when EventSource.IsSupported is false.
* Remove HttpTelemetry.IsEnabled static property so the linker can trim EventSource code when EventSource.IsSupported is false.
* Fix fake NetEventSource to match what is in the product.
This has three primary benefits:
1. In some cases, in particular for static fields where other static fields have non-default initialization, the C# compiler can't elide the default initialization, resulting in more IL.
2. It highlights places where the field is otherwise unused and can be deleted, but where the presence of the initialization was silencing the C# compiler's warnings about the unused field.
3. It increases consistency and decreases maintenance / code size / etc.
For the non-generic IEnumerator, we don't have any idea whether the type contains nulls or not. If we're forced to annotate it, `?` is correct, because it says "it's possible this is null" and we can't prove it's not. But that ends up leading to lots of spurious warnings, in particular when enumerating over supplied collections that won't ever contain null, e.g. enumerating a CookieCollection. Since the non-generic IEnumerator is effectively legacy, our best path forward while maintaining correctness and avoiding causing unnecessary warnings is to simply not annotate `IEnumerator.Current` at all, leaving it "oblivious"; in that way, we don't make any claims about its state, and leave it up to tooling how to best convey that.
The System.Net.* libs in dotnet/runtime inherited this from .NET Framework. To my knowledge it's not once helped flag any issues in dotnet/runtime, it's only built into debug builds, it's become very inconsistent as the code base has evolved, and it's just cluttering stuff up. So, goodbye.
* Optimize HttpDateParser.TryStringToDate
When HttpResponseMessage headers are enumerated, even though SocketsHttpHandler adds headers with TryAddWithoutValidation, the enumeration ends up validating them (that's something to be discussed and follow-up on separately). As part of that, it validates the Date header that's required of most responses. It does so using DateTimeOffset.TryParseExact, but using a long list of allowed formats as well as options that knock TryParseExact's processing off the fast path. Since most responses are going to contain a date using RFC1123 format (aka "r"), we just try that first, in a way that will generally result in hitting the optimized "r" code path which is much faster.
* Address PR feedback
Changes:
- enabled `runtime (Libraries Test Run release mono Windows_NT x64 Debug)` CI lane (Windows Nano Server CI leg is disabled);
- enabled the tests that pass;
- marked failing test assemblies/classes/methods with `ActiveIssue` attribute using respective GH issues;
- removed CoreFX.issues_windows.rsp file and related mono rsp arguments.
Fixes#1980