Commit Graph
238 Commits
Author SHA1 Message Date
Marie Píchová 122c9d025d "[QUIC] Adopted msquic generated interop (#68288)" attempt no 2 (#69009)
* Revert "Revert "[QUIC] Adopted msquic generated interop (#68288)" (#68940)"

This reverts commit 4820674a44.

* Exclude S.N.Quic from Mono AOT

* Fix #68954
2022-05-11 16:29:45 +02:00
Viktor Hofer 208e025ab6 Update System.Net solution files (#69112)
* Update System.Net solution files

https://github.com/dotnet/runtime/commit/8823eefe91f6b774961c32800dea977b687d7328 added a dependency onto the source project of System.Net.Security. Because of that, the closure of the System.Net.Quic and System.Net.Http solution files changed. Currently this is manual as we don't have a CI leg that makes sure that solution files are up-to-date.

* Update System.Net.Http.sln
2022-05-10 12:10:15 +02:00
Radek Zikmund b390d0f10a Throw from MsQuicImplementationProvider if not supported. (#68833)
* Throw from MsQuicImplementationProvider if not supported.

* Add tests
2022-05-06 12:07:09 -07:00
Jan Kotas 4820674a44 Revert "[QUIC] Adopted msquic generated interop (#68288)" (#68940)
This reverts commit 992b395a72.
2022-05-05 19:20:52 -07:00
Radek Zikmund 3116f28881 Add test for multiple calls of QuicConnection.CloseAsync (#68893)
* Add test for multiple calls of QuicConnection.CloseAsync

* Add test case for server as well
2022-05-05 17:40:01 +02:00
Marie Píchová 992b395a72 [QUIC] Adopted msquic generated interop (#68288)
* MsQuicApi adjusted

* QuicParamHelper adjusted

* MsQuicConfiguration adjusted

* Added MsQuicException

* MsQuicConnection adjusted

* MsQuicListener adjusted

* MsQuicStream adjusted

* It compiles!

* Some test fixes

* Fixed stream read event handling

* Re-enabled IPv6 tests

* latest greatest

* Update src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicListener.cs

* MsQuic interop enum names

* 3rd Party notice, version check

* SafeHandleType

* Replaced AlpnHelpers with MsQuicBuffers generic QUIC_BUFFER* helper

* Sealed exception class

* Feedback MsQuicBuffers

* NativeMemory use

* Newest msquic interop

* Buffers feedback

* Remove MemoryHandle pooling

* Buffers feedback

* Logging feedback
2022-05-05 12:32:25 +02:00
Elinor Fung bcded447f1 Move CustomTypeMarshaller APIs to System.Runtime.InteropServices.Marshalling (#68842) 2022-05-04 17:11:47 -07:00
Viktor Hofer 24cabc6eb0 Update solution files to include missing deps (#68668) 2022-05-02 20:14:05 +02:00
Tomas Weinfurt 8823eefe91 avoid Reflection in Quic (#68189)
* avoid Reflection in Quic

* add missing file

* update comment

* exclude from ref creation

* feedback from review
2022-05-01 22:38:23 -07:00
Viktor HoferandJeremy Barton ba055bd94e Minimize the build graph by deleting unnecessary references (#68603)
* Minimize the build graph by deleting references

Minimizing projects' dependency graph. There are tons of unnecessary
Reference and ProjectReference items which aren't required anymore as
the referenced projects became full facade assemblies. Removing those
from a leaf's graph makes the graph smaller and therefore the project's
evaluation and build faster.

* Update src/libraries/System.Net.Quic/ref/System.Net.Quic.csproj

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

* Update Versions.props

Co-authored-by: Jeremy Barton <[email protected]>
2022-04-28 15:04:26 +02:00
Radek Zikmund a49958b4b4 Asynchronous opening of QuicStreams (#67859)
* Early draft of Open(Uni|Bidi)rectionalStreamAsync

* Improve exception handling

* Remove non-Async versions

* fixup! Improve exception handling

* Add tests

* fixup! Remove non-Async versions

* handle connection abort

* Minor change

* Fix build

* Code review feedback

* Remove WaitForAvailable* methods

* fixup! Remove WaitForAvailable* methods

* Remove CreateOuboundAsync static method

* Remove StartStatus

* Code review changes

* More code review changes

* Fix build

* Fix data race on locally closing the connection

* Code review feedback

* Remove PInvoke for reporting telemetry

* Minor fixes

* fixup! Minor fixes

* Regenerate ref source

* Fix exception type in test
2022-04-27 12:57:28 +02:00
Radek Zikmund a077f271c3 Handle concurrent reads and concurrent writes on MsQuicStream (#67329)
* Throw on concurrent operations

* Remove redundant test

* Move _state.SendState access under a lock

* Fix data race on ReceiveResettableCompletionSource

* Remove unnecessary override

* Move task completion outside of the lock

* Fix failing tests

* Update comments

* Add missing case

* fixup! Add missing case
2022-04-27 10:46:50 +02:00
Viktor Hofer 09dc0feb6a Fix VS complaining about missing projects in slns (#68488)
* Fix VS complaining about missing projects in slns

Remove inbox (Project-)References in out-of-band projects as these
projects already build on top of the shared framework (targeting pack).

* Update Microsoft.Extensions ref projects

* Update Microsoft.Extensions src projects

* Update graph dependencies of Microsoft.Extensions*

* Update sources that complained about Span usage
2022-04-25 22:06:10 +02:00
Eric Erhardt 18be907176 Change Nullable to default to enable in libraries src and ref projects (#68102)
* Change the default Nullable to enabled for src projects

* Set Nullable=enable as the default for ref projects

* Fixup merge conflicts

* Disable nullable on shim projects and EventLog.Messages

* Set Nullable to blank on EventLog.Messages

This way no CodeAnalysis attributes are emitted into the assembly.
2022-04-25 11:15:37 -05:00
Stephen Toub 46871b8541 Enable new CA1311 (ToLower/Upper culture) and CA1852 (seal internal/private types) rules (#68268)
* Enable new CA1311 (ToLower/Upper culture) and CA1852 (seal internal/private types)

CA1311 flagged a few issues, all addressed by using ToLowerInvariant/ToUpperInvariant.

CA1852 flagged a bunch that previous cleanups around sealing types missed or that are new since.  Sealing types then highlighted places where protected or virtual members were being exposed unnecessarily, so those were fixed, too.  Adding sealed to things also highlighted some discrepancies in the order of "unsafe sealed" keywords, where the vast majority in the repo were "sealed unsafe", so I fixed the few that weren't.

* Address PR feedback and fix more CI failures

* Fix unit test build error
2022-04-21 16:22:53 -04:00
Stephen Toub 215b39abf9 Remove usage of !! from dotnet/runtime (#68178)
* Remove usage of !! from dotnet/runtime

- Use ArgumentNullException.ThrowIfNull instead where possible.  It's only usable for projects that only target .NET 6+, and it can't be used in places like this(...) or base(...).
- In other cases, if the project already has a ThrowHelper, augment it for null as needed and use that.
- For most of the extensions projects, add a ThrowHelper.ThrowIfNull that replicates ArgumentNullException.ThrowIfNull.
- For everything else, just use "throw new".

* Address PR feedback

* Address PR feedback

* Remove false positives from searches

* Address PR feedback
2022-04-21 13:25:52 -04:00
Radek Zikmund 42044c65e9 Fix exception thrown when MsQuicStream write direction is locally aborted or canceled (#67753)
* Fix exception thrown when MsQuicStream write direction is locally aborted

* Remove extra empty lines

* Code review feedback

* Fix failing tests

* Fix MockQuic tests
2022-04-12 19:02:33 +02:00
Radek Zikmund cf12817f20 Small MsQuicStream reafactorings (#67839)
* Merge `NativeCallbackHandler` and `HandleEvent`

* Use constants for `_state.ShutdownDone`

* Don't use Handle... prefix for private helpers

* Send state transition comments
2022-04-11 16:47:06 +02:00
Radek Zikmund dee2bb50f1 Fix exception thrown from MsQuicStream writes when connection is aborted by peer. (#67651)
* Fix exception thrown from MsQuicStream writes when connection is aborted by peer.

* Code review feedback
2022-04-08 16:40:20 +02:00
Radek Zikmund 22870c2e31 Disable System.Net.Quic.Tests.QuicStreamTests.WriteAsync_LocalAbort_Throws (#67638)
Contributes to #67612
2022-04-06 06:35:17 -04:00
Radek Zikmund f6ca720b42 Add CipherSuitesPolicy support for MsQuic (#67239)
* Add CipherSuitesPolicy support for MsQuic

* Add tests

* Code review feedback

* Fix test
2022-04-06 10:08:50 +02:00
Radek Zikmund 07d8b82d54 [QUIC] Call SendResettableCompletionSource.CompleteException in AbortWrite (#67341)
* Call SendResettableCompletionSource.CompleteException in AbortWrite

* Add test

* fixup! Add test

* Use loop to make the test more robust
2022-04-05 15:54:35 +02:00
Marie Píchová ffc5a34196 Fixed msquic method that's become void (#67481) 2022-04-02 17:48:06 +02:00
Marie Píchová d5b1a7f5fe [QUIC] Update to msquic 2 (#67383)
* Update to msquic 2, test and code fixes

* feedback

* Fixed more HTTP/3 bugs

* updated fedora image to contain the newest msquic

* Better test debugging, fixed some timeouts

* feedback

* Return some msquic calls into a lock
2022-04-01 23:26:31 +02:00
Radek ZikmundandNatalia Kondratyeva a847ddfea5 Fix Wrong exception for Open*Stream after connection is closed (#67342)
* Fix Wrong exception for Open*Stream after connection is closed

* Don't handle InvalidState

* Update src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicStream.cs

Co-authored-by: Natalia Kondratyeva <[email protected]>

Co-authored-by: Natalia Kondratyeva <[email protected]>
2022-03-31 21:26:58 +02:00
Radek Zikmund 38fe46837a Use shared SocketAddress code in QUIC (#66794)
* Use shared SocketAddress code in QUIC

* Code review feedback

* Disable broken tests

* Rename file
2022-03-30 12:40:32 +02:00
Radek Zikmund 4bd27a6d3c Do not call into MsQuic inside a lock (#67037)
Fixes #59345
2022-03-29 22:11:09 +02:00
Hugo Woodiwiss 0eccdba3ad Improve QuicImplementationProviders.MsQuic.IsSupported for TLS1.3 On Windows (#66019)
* Scaffold TLS Support Helper

Scaffolds an interoperable TLS support helper.
Needs to be multi-file so that the Microsoft.Win32 dependency can be safely used in `MsQuicTlsSupportHelper.Windows.cs`

* Invert `IsTls1_3Enabled` to `IsTls1_3Disabled`

Disabling TLS1.3 is an explicit action in supported versions of windows, and we should check for the explicit configuration

* Add check for whether TLS1.3 Is DDisabled

* Add reference to Microsoft.Win32.Registry for windows builds

Need access to Registry API to check whether TLS 1.3 has been disabled

* Remove Platform agnostic MsQuicTlsSupportHelper

* Implement IsTls1_3Disabled

- Checks if key exists
- If not returns false
- Gets Value from Key "Enabled"
- If Enabled == 0 returns true
- Any other case returns false

* Revert some spacing and line changes in csproj

* Remove added spaces from .csproj

* Move to conditional compilation for TLS Check

* Move to TARGET_WINDOWS defined constant
Update to check correct registry keys/values

* Simplify IsTls13Disabled implementation

* Remove IsTls13Disabled from Windows version check

* Add TLS13MayBeDisabled flag

* Add `QuicTlsVersionException`
Throw `QuicTlsVersionException` on specific failures of ConfigurationLoadCredential

Throw this exception if status is 0x80090331 (Algorithm Mismatch), and the registry indicated that Tls13 could be disabled

* Fix IDE resource file whitespace changes

* Update net_quic_tls_version_notsupported message

* Change error code comparison to use Interop.SECURITY_STATUS
Make AlgorithmMismatch check TARGET_WINDOWS only

Interop.SECURITY_STATUS contains status values from SChannel, which is the source of this error in the first place.

* Remove QuicTlsVersionException and update usages

* Remove unused using
2022-03-29 09:19:44 -07:00
1a2830be5e [main] Update dependencies from dotnet/roslyn-analyzers (#67189)
* Update dependencies from https://github.com/dotnet/roslyn-analyzers build 20220324.1

Microsoft.CodeAnalysis.NetAnalyzers
 From Version 7.0.0-preview1.22166.1 -> To Version 7.0.0-preview1.22174.1

* React to DisableRuntimeMarshalling attribute analyzer by switching a few extraneous places to source-generated marshalling and removing some unused attributes.

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Jeremy Koritzinsky <[email protected]>
2022-03-28 16:41:45 -06:00
Marek Safar 6a889d2342 Enable CA1822 (Mark members as static) analyzer (#66333) 2022-03-25 12:06:33 +01:00
Radek Zikmund e216e1300b Don't throw PNSE on QuicImplementationProvider.IsSupported (#67036) 2022-03-25 11:37:41 +01:00
Eric Erhardt 7508080ebc Update coding-style to include target-typed new() guideline (#67061)
* Update coding-style to include target-typed new guideline

Similar to `var` usage, `new()` usage is only allowed when the Type can be understood from the same line.

Fix #53369

* Fix coding style violations
2022-03-23 18:54:51 -06:00
Jeremy Koritzinsky a02b49a048 Add the CustomTypeMarshallerAttribute type to make it easier to identify marshaller types (#65591) 2022-03-23 09:06:32 -07:00
Radek Zikmund 00ed84ae9b Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete (#66292)
Fixes #65545
2022-03-08 18:44:17 +01:00
Elinor Fung a0635832f1 Rename DllImportGenerator project to LibraryImportGenerator (#66029) 2022-03-03 22:17:23 -08:00
Tomas Weinfurt 654a574ae7 retire DummyTcpServer from SslStream tests (#65876)
* retire DummyTcpServer from SslStream test

* fix build

* feedback from review
2022-03-03 20:15:52 -08:00
Viktor Hofer 9ebe0efa48 sfx+oob split, shim project refactoring, P2Ps
Split the build of shared framework and out-of-band projects so that
it's possible to just build the shard framework projects, which was
requested by the CLR teams. In the next infrastructure rollout, the
current "libs.ref+libs.src" subsets should be removed. Generate the
targeting pack with an incomplete (without shims) frameworklist as part
of the "libs.sfx" subset.

Build the shim projects after the shared framework and oob projects and
re-generate the targeting pack's frameworklist to include the shims.

Refactor the shims so that they aren't grouped anymore by generated &
manual. Instead group them by "ref" and "src" same as other libraries
in the tree which allows to reference the source project shims and read
from the ReferenceAssembly metadata.

Use ProjectReferences in traversal projects and shim projects instead
of named references that point to binplace directories (see graph below)
This allows to build parts of the product dynamically, i.e. the shim
projects, apicompat.proj, sfx.proj and oob.proj.
2022-02-24 12:32:04 +01:00
Viktor Hofer febaf76743 Fix slngen.proj and update solution files (#65711)
* Fix slngen.proj

The SolutionName property is defined by the SDK and hence the condition was always true. Also the star (*) didn't expand when using the ValurOrDefault msbuild function. Fixing this by using a different name `SolutionNameOverride` and avoiding the ValueOrDefault msbuild function.

* Update solution files

Updating the solution files as those changed because of
microsoft/slngen@cb57e28 and apparently the solution files never were
updated.
2022-02-22 17:18:54 +01:00
WraithandVlad Brezae ddb22ef2ac Remove S.R.CS.Unsafe and Intrinsify Unsafe (#64861)
* private assemblies moved from Internal to System Runtime.CompilerServices

* reformat existing unsafe vm intrinsics

* implement Copy, CopyBlock, CopyBlockUnaligned, InitBlock, InitBlockUnaligned, Unbox, Add, Subtract, SubtractByteOffset

* remove System.Runtime.CompilerServices.Unsafe il project and replace with forward only cs project

* change all ilproj references to csproj

* remove nativeaot Unsafe

* add conditional package reference for S.R.CS.Unsafe on netcoreapp 6.0

* regenerate solutions

* mono interp

* [mono][interp] Implement Copy and Unbox intrinsics

* [mono][jit] Implement Copy and Unbox intrinsics

Co-authored-by: Vlad Brezae <[email protected]>
2022-02-19 21:50:14 -08:00
Jeremy Koritzinsky 6e05d78deb Move Msquic over to Source-generated delegate interop. (#65204)
* Move Msquic over to Source-generated delegate interop.

* More fixes
2022-02-13 08:40:10 -08:00
Viktor Hofer 20e8f905d0 Don't use Targets* helper properties in libs (#64500)
* Don't use Targets* helper properties in libs projs

This change makes it possible to migrate 200+ (ref+src) projects to use
TargetFramework instead of TargetFrameworks which avoids the additional
outer build evaluation and invocation which ultimately makes the overall
build faster.

Targets* properties (i.e. TargetsWindows, TargetsAnyOS, TargetsUnix,
etc.) rely on the TargetFramework property which usually are set
inside a project. The TargetFramework property is only
available before a project specifies it if it's explicitly set in a props
file or if the project is cross-targeting and the outer-build dispatches
into the inner-build. During the dispatch, the TargetFramework property
is passed in as a global property.

Until now that behavior wasn't a problem because every libraries project
cross-targeted (by setting the TargetFrameworks property) even though
many only include a single TargetFramework (i.e. NetCoreAppCurrent).

To allow projects to use the TargetFramework property instead of
TargetFrameworks, the Targets* helper properties can't be calculated
anymore early in a props file as the TargetFramework property isn't set
at that time.

In general, the guidance by the SDK/msbuild team is to not read from the
TargetFramework property before the project sets it
(in a property group). That effectively means that the TargetFramework
property shouldn't be used in props files at all.

Therefore these helper properties can't be used anymore for property
conditions and I'm replacing their usage with TargetPlatformIdentifier
comparisons for both properties and items.
In nearly all cases, the Targets* helper properties can be replaced with
TargetPlatformIdentifier checks on items and in the few cases where
TargetsUnix or TargetsLinux marks multiple tfms as compatible, the exact
tfms must be used instead for the TargetPlatformIdentifier comparison.

Whenever a project needs to condition properties on the platform, I'm
first setting the TargetPlatformIdentifier the same way the SDK sets it
so that the SDK later doesn't need to set it again to avoid the
additional expensive msbuild function call.

* Use TargetFramework singular to avoid outer builds

Use TargetFramework instead of TargetFrameworks property whenever a
projects only targets a single target framework. This avoid unnecessary
outer builds and evaluations and makes the build faster.
2022-02-12 13:07:16 +01:00
Stephen Toub 65008a9df0 Update StyleCopAnalyzers to 1.2.0-beta.406 (#65142)
* Update to StyleCopAnalyzers 1.2.0-beta.406

* Add missing newlines at end of files to satisfy changes to SA1518
2022-02-11 10:03:06 -05:00
Jeremy Koritzinsky ccd67b0c44 Move DllImportGenerator to use DisableRuntimeMarshalling for its blittable classification (#64279) 2022-02-10 11:26:14 -08:00
Tomas Weinfurt ee4640a6a3 stabilize quic tests on server 2022 (#65057) 2022-02-09 11:25:34 -08:00
Stephen Toub 3ae87395f6 Initial roll out of !! (#64720)
* Bump version of C# compiler

This should be reverted when arcade brings in a new enough compiler.

* Fix a few new warnings from updating compiler

* Enable IDE0190 to employ parameter null checking

* Initial roll out of !!

* Fix more compiler warnings from upgrade, plus some test fixes / reverts

* Fix a few more tests

* Disable profiling test
2022-02-08 16:06:59 -05:00
Viktor Hofer 4a19a4940d Use Reference items instead of P2Ps for inbox libs (#64508)
Some libraries still had ProjectReferences to libraries which refs
were added to the targeting pack with the last release. Therefore these
references can just be normal "Reference" items instead of P2Ps.
2022-01-31 21:16:45 +01:00
Adam Sitnik 2074477643 Remove some of the unused resource strings (#64379) 2022-01-27 19:21:12 +01:00
Artem KliatchkineandArtem Kliatchkine f04a242498 Set zero (infinite) options timeout in case of Timeout.InfiniteTimeSpan (#55984) (#63733)
Co-authored-by: Artem Kliatchkine <[email protected]>
2022-01-18 18:18:45 +01:00
Marek Safar 6de7147b92 Enable IDE0059 analyzer: Unnecessary assignment of a value (#63340) 2022-01-12 18:10:45 +01:00
Stephen Toub c92c767df0 Add a few missing Stream overrides (#63579) 2022-01-10 14:36:42 -05:00