Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't throw PNSE on QuicImplementationProvider.IsSupported #67036

Merged
merged 7 commits into from
Mar 25, 2022

Conversation

rzikm
Copy link
Member

@rzikm rzikm commented Mar 23, 2022

This PR adds static QuicConnection.IsSupported member which can be used to check if the platform is capable of QUIC. The implementation is routed to MsQuicApi.IsQuicSupported.

Fixes #65802.

@dotnet-issue-labeler
Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost ghost assigned rzikm Mar 23, 2022
@ghost
Copy link

ghost commented Mar 23, 2022

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

This PR adds static QuicConnection.IsSupported member which can be used to check if the platform is capable of QUIC. The implementation is routed to MsQuicApi.IsQuicSupported.

Fixes #65802.

Author: rzikm
Assignees: -
Labels:

new-api-needs-documentation, area-System.Net.Quic

Milestone: -

Copy link
Member

@ManickaP ManickaP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is not to put IsSupported on connection but to replace generated PNSE on "other" platforms with false returning, already existing property on MsQuicApi.

src/libraries/System.Net.Quic/ref/System.Net.Quic.cs Outdated Show resolved Hide resolved
@ManickaP
Copy link
Member

This comment from the issue has info about how to exclude the auto-generated PNSE: #65802 (comment)

@rzikm rzikm changed the title Add QuicConnection.IsSupported Don't throw PNSE on QuicImplementationProvider.IsSupported Mar 24, 2022
@rzikm
Copy link
Member Author

rzikm commented Mar 24, 2022

Should be better now. I also tested it by manually copying the "unsupported" System.Net.Quic.dll to local testhost bits and MsQuic tests get correctly disabled, while Mock tests throw (since they don't check IsEnabled -> I added that in this PR as well). So I am confident this will work as intended.

@rzikm rzikm requested a review from ManickaP March 24, 2022 16:24
@rzikm
Copy link
Member Author

rzikm commented Mar 25, 2022

CI Failures are unrelated

Copy link
Member

@ManickaP ManickaP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

</PropertyGroup>
<!-- Source files -->
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != ''">
<Compile Include="System\Net\Quic\*.cs" />
<Compile Include="System\Net\Quic\NetEventSource.Quic.cs" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use something like this:

<Compile Include="System\Net\Quic\*.cs" Exclude="QuicImplementationProviders.Unsupported.cs">

Instead of naming out all the files.
Up to you, I don't mind either way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should enumerate all files here to be consistent with other project files. I kept the wildcards in the rest of the file since that part can still change quite often.

{
public abstract partial class QuicImplementationProvider
{
// alternative constructor because currently it is not possible to exlude ctors from
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an issue for this? If so, we should link it here.

{
// alternative constructor because currently it is not possible to exlude ctors from
// PNSE autogeneration
internal QuicImplementationProvider(bool dummy) { }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use _ as a discard. No preference on my side, up to you.

@@ -285,6 +285,7 @@ public async Task Dispose_WithOpenLocalStream_LocalStreamFailsWithQuicOperationA
}
}

[ConditionalClass(typeof(QuicTestBase<MockProviderFactory>), nameof(QuicTestBase<MockProviderFactory>.IsSupported))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand it, we build the S.N.Quic tests only for Linux and Windowsm so they are never run on any of the platforms where we throw PNSE from everything. Thus, the condition was never needed.
But I do agree it doesn't hurt here, and at least it won't break if/when we expand the target OS list.

@ManickaP
Copy link
Member

Also you can look with ILSpy, ildasm, etc. into the content of S.N.Quic.dll for other platforms to check it does have IsSupported returning false instead of throwing.

@rzikm
Copy link
Member Author

rzikm commented Mar 25, 2022

Also you can look with ILSpy, ildasm, etc. into the content of S.N.Quic.dll for other platforms to check it does have IsSupported returning false instead of throwing.

there is a single dll for all unsupported platforms, it looks ok

@rzikm rzikm merged commit e216e13 into dotnet:main Mar 25, 2022
radekdoulik pushed a commit to radekdoulik/runtime that referenced this pull request Mar 30, 2022
@karelz karelz added this to the 7.0.0 milestone Apr 8, 2022
@ghost ghost locked as resolved and limited conversation to collaborators May 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[API Proposal]: QUIC should have an IsSupported API
5 participants