Commit Graph
733 Commits
Author SHA1 Message Date
Stephen Toub 0817e748b7 Seal internal types in libraries (#50225) 2021-03-25 20:50:33 -04:00
Stephen Toub 48679143aa Seal private classes in libraries (#49969) 2021-03-23 06:14:55 -04:00
Stephen Toub 807747926f Remove a few more unnecessary StringBuilders (#49488) 2021-03-11 20:42:00 -05:00
Jeremy Koritzinsky 4181533899 Use the .noRC2 cert variants in the System.Net tests when on a platform that does not support RC2. (#49461) 2021-03-11 14:02:56 -08:00
Santiago Fernandez Madero 689bac6222 Fix APICompat errors for atttributes on parameters (#49408) 2021-03-11 00:03:10 -08:00
Newell ClarkandAdam Sitnik 62f6c0829d Add Memory Overrides to Streams (#47125)
* 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]>
2021-03-05 16:36:31 +01:00
Dan Moseley c18d7b0aee Name some more threads (#47084)
* name threads

* typo:

* typo

* Truncate

* Name long running TP thread

* Allow resetting thread names

* Fix thread set test

* Remove unnecessary reset of FSW thread name

* prettier names

* consistent syntax

* Fix threadpool test

* Fix code typo

* typo

* adjust names
2021-02-08 20:17:10 +00:00
Stephen Toub 39dd3819b3 Fix ReadWriteTimeout_CancelsResponse test (#47737) 2021-02-02 03:20:56 -08:00
Stephen Toub c9d1fd60d6 Add support for HttpWebRequest.ReadWriteTimeout (#47648)
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.
2021-02-01 11:48:05 -05:00
Stephen Toub 94ffbde615 Fix HttpWebResponse.GetHeaderValueAsString to properly handle empty inputs (#47179) 2021-01-19 22:54:39 -05: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
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
Tomas Weinfurt 21dc074923 increase timeout on WebRequest timeout test (#44612) 2020-11-12 22:01:23 -05:00
Tomas Weinfurt 0f1d011381 log exception if Timeout_SetTenMillisecondsOnLoopback_ThrowsWebException test fails (#44509)
* log exception if Timeout_SetTenMillisecondsOnLoopback_ThrowsWebException test fails

* check exception type before checking time range
2020-11-11 12:21:57 -05: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 001edea339 Delete NetEventSource.Fail (#43579)
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.
2020-10-21 13:33:59 -04:00
Stephen Toub faf91e0a74 Address outstanding issues with System.Net MatchingRefApiCompatBaselines (#43230) 2020-10-09 17:18:36 -04:00
aaecee0646 Remove System.Net.Connections and related features (#41648)
* remove System.Net.Connections and related features

* cleanup csproj changes

* Update src/libraries/pkg/baseline/packageIndex.json

Co-authored-by: Cory Nelson <[email protected]>

* Update src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Tasks.cs

Co-authored-by: Cory Nelson <[email protected]>

Co-authored-by: Geoffrey Kizer <[email protected]>
Co-authored-by: Cory Nelson <[email protected]>
2020-09-01 19:31:14 -07:00
9b79ee6db1 Obsolete WebRequest, ServicePoint and WebClient (#41400)
* Obsolete WebRequest, ServicePoint and WebClient

* Update src/libraries/Common/src/System/Obsoletions.cs

Co-authored-by: Cory Nelson <[email protected]>

* Remove obsoletion from FileWebRequest

* Add refs assemblies obsoletion

* Add missing attribute

* Add missing attribute

* Suppress warning for System.Media.SoundPlayer

* Change message id

Co-authored-by: Jan Jahoda <[email protected]>
Co-authored-by: Cory Nelson <[email protected]>
2020-08-28 19:49:52 +02:00
Maxim Lipnin ff44e33b6d Mark some System.Net.* APIs as unsupported on Browser WASM (#40924) 2020-08-20 11:23:21 +02:00
Marie Píchová ba7c518a49 Renamed EventSources "Microsoft-"->"Private.InternalDiagnostics.". 2020-08-17 13:10:32 +02:00
Maxim Lipnin 6362ec357b Clean up the System.Net.Requests library tests because the respective library is PNSE on browser wasm (#40766) 2020-08-14 01:36:12 -05:00
Geoff KizerandGeoffrey Kizer 701c5d9e4c fix error mapping in HttpWebRequest to handle NetworkException (#40666)
* fix error mapping in HttpWebRequest to handle NetworkException

* add mapping for SocketError.NoData => NetworkError.HostNotFound

Co-authored-by: Geoffrey Kizer <[email protected]>
2020-08-11 20:46:18 -07:00
Matt Kotsenas ead2cd5079 Remove unused locals in System.Net.* (#39575)
* Remove unused locals in System.Net.HttpListener

* Remove unused local in System.Net.Requests

* Remove unused locals and methods in System.Net.Security
2020-08-11 13:54:08 -07:00
Marie Píchová 55140820ac Increased timeouts, fixed indentation. (#40273) 2020-08-04 12:51:04 +02:00
Maxim LipninandAlexander Köplinger 4c0ebbdd34 [wasm] Modify System.Net.Request to throw PNSE on Browser WASM (#40274)
* [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]>
2020-08-04 08:01:22 +00:00
Viktor Hofer 809a06f451 Remove depprojs in favor of PackageReferences (#35606)
- 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)"
2020-07-23 17:20:26 +02:00
5c274f699d Suppress credscan false positives (#38026)
* Suppress initial cred issues

* Another bunch of supresses

* Clean up

* Another bunch of supresses

* Revert to suppression messages

* Clean up

* Apply suggestions from code review

Co-authored-by: Jeremy Barton <[email protected]>

* Revert passwords literals

* Fix suppression justification comment

Co-authored-by: Jan Jahoda <[email protected]>
Co-authored-by: Jeremy Barton <[email protected]>
2020-07-23 11:59:00 +02:00
Jeff Handley 329f0dbfa3 Mark Obsoletions for .NET 5 (#39269)
* 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
2020-07-17 17:09:29 -07:00
Anirudh Agnihotry e94cd90ad1 Adding attribute keyword to all the attributes in the ref (#39255) 2020-07-14 10:03:52 -07:00
Stephen Toub b39c698c62 Delete NetEventSource.Enter/Exit events (#38874)
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).
2020-07-10 09:31:21 -04:00
Eric Erhardt 98eee0587d Trim NetEventSource when EventSource.IsSupported is false (#38828)
* 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.
2020-07-09 14:12:44 -04:00
Anirudh Agnihotry d3f62bd225 remove pragma warning from ref source files (#38907) 2020-07-08 18:33:44 -07:00
Stephen Toub 6072e4d3a7 Update license headers (#38793) 2020-07-08 09:23:11 -04:00
Anirudh Agnihotry 5ce04ccc9a Make browser peer for windows_nt and unix (#37944)
Fixes https://github.com/dotnet/runtime/issues/38559
2020-07-08 12:59:37 +02:00
Mitchell HwangandMitchell Hwang 0e870dfca5 [wasm] Add assembly level skip for System.Net.Requests on Browser (#38674)
Co-authored-by: Mitchell Hwang <[email protected]>
2020-07-02 14:25:08 +02:00
Stephen Toub 049cb40eda Use HttpClient.Send in HttpWebRequest.GetResponse (#38511) 2020-06-29 12:10:43 -04:00
Stephen Toub ed78fadab6 Fix CA1805 for unnecessary initialization of fields (#38410)
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.
2020-06-26 07:52:35 -04:00
9ccfc40ec9 [libraries] Properly skip thread failing WASM tests (#38089)
Co-authored-by: Mitchell Hwang <[email protected]>
Co-authored-by: Alexander Köplinger <[email protected]>
2020-06-20 01:49:29 +02:00
Stephen Toub 5f29a03eca Fix nullable annotation on IEnumerator.Current (#37969)
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.
2020-06-17 17:09:44 -04:00
Alexander Köplinger da10ba8ca7 Use ConditionalFact/Theory for skipping RemoteExecutor on unsupported platforms (#37479)
RemoteExecutor doesn't work on platforms that can't spawn processes like iOS/Android/WebAssembly.
2020-06-09 12:40:44 +02:00
1c048bdfc7 Checking strings against length seem to have better perf (#36443)
* Chckecing strings against length seem to have better perf

* Apply suggestions from code review

Co-authored-by: Miha Zupan <[email protected]>
Co-authored-by: Ben Adams <[email protected]>

* Apply suggestions from code review

Co-authored-by: Ben Adams <[email protected]>

* Update src/libraries/System.Drawing.Common/src/System/Drawing/BitmapSelector.cs

Co-authored-by: Ben Adams <[email protected]>

* Apply suggestions from code review

* Update src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyNameFormatter.cs

* fix build error

* Update SmtpClient.cs

* Update AssemblyNameFormatter.cs

* Update LoggingEventSource.cs

* Fix build error

* Apply suggestions from code review

* Update src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationContent.cs

* Fix build error

* Apply suggestions from code review

Co-authored-by: Miha Zupan <[email protected]>
Co-authored-by: Ben Adams <[email protected]>
2020-05-19 09:39:51 -04:00
Stephen Toub c7a246c000 Delete DebugThreadTracking from networking code (#36549)
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.
2020-05-15 17:47:15 -04:00
Marcus Turewicz 890fab0a64 Use attribute Link syntax for Common files (#35436)
* Change <Link>...</Link> to Link="..."

* Format existing Link="..."
2020-04-25 05:26:50 -07:00
Stephen Toub 75efecb165 Optimize HttpDateParser.TryStringToDate (#34860)
* 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
2020-04-12 08:12:33 -04:00
Matthew R Johnson 78643b9ae7 HttpWebRequest allow returning redirect response (#34560)
* HttpWebRequest allow returning redirect response

Throw WebException for 3xx responses only when `AllowAutoRedirect = true`

Fixes #1074

* Simplify status code check
2020-04-11 08:55:51 -07:00
Maxim Lipnin ab6e225d0c [mono] Remove CoreFX.issues_windows.rsp file (#32592)
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
2020-04-10 12:41:57 +02:00
Viktor Hofer d0dc66bc0b Rename CoreFx.Private.TestUtilities and reference it in slns (#34656)
* Rename CoreFx.Private.TestUtilities to TestUtilities

* Add TestUtilities reference to slns
2020-04-08 01:26:53 +02:00
Stephen Toub 0f4eb8a0d2 Address follow-up feedback on System.Net.Requests annotations (#33691) 2020-03-17 18:54:08 -04:00