-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Add QuicConnection.IsQuicSupported for runtime feature detection #31689
Add QuicConnection.IsQuicSupported for runtime feature detection #31689
Conversation
no merge: found an issue; correction incoming. |
|
// TODO: check using MsQuicOpen return value; but there doesn't seem to be a consistent error code for this yet. | ||
OperatingSystem ver = Environment.OSVersion; | ||
|
||
if (ver.Platform != PlatformID.Win32NT || ver.Version >= new Version(10, 0, 19041, 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should be checking this version of Windows here; technically, this OS version is for schannel support of TLS 1.3. There are other TLS implementation which would work on a lower windows version (I haven't tried but there are options for msquic).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to get rid of that version check all together. It is not something that MsQuicOpen
currently checks, and will instead result in callbacks failing with unspecified platform-specific TLS errors.
The TODO is left to find a better way. It is unclear what exactly msquic requires from kernel to be successful. The recommendation I've got so far is that "latest is better". This version check will at least avoid loading MsQuic on versions of Windows we haven't tested it against.
My primary goal is to avoid needing to comment out source code to avoid breaking CI; that's fragile and we will have an embarrassing merge at some point.
{ | ||
try | ||
{ | ||
new MsQuicApi().Dispose(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of newing up a MsQuicApi, can you just create a new property (ex: IsLoaded) that would be set in the private constructor and check Api.IsLoaded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
… update tests to use it. Add QuicNotSupportedException.
ae8173a
to
f1c8a67
Compare
uint status = Interop.MsQuic.MsQuicOpen(version: 1, out registration); | ||
if (!MsQuicStatusHelper.SuccessfulStatusCode(status)) | ||
{ | ||
throw new QuicNotSupportedException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, if we can avoid this exception that would be nice. Just use NotSupportedException.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pending some feedback and making it really clear that we should remove the OS check 😄
@@ -27,6 +27,7 @@ public sealed partial class QuicConnection : System.IDisposable | |||
public System.Net.Security.SslApplicationProtocol NegotiatedApplicationProtocol => throw null; | |||
public ValueTask CloseAsync(long errorCode, System.Threading.CancellationToken cancellationToken = default) => throw null; | |||
public void Dispose() => throw null; | |||
public static bool IsQuicSupported => throw null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're still operating in a "none of this has been reviewed yet and we won't ship these APIs until we do and revise them accordingly" mode, right? Is there a must-do issue tracking that to make sure it doesn't slip through the cracks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're still operating in a "none of this has been reviewed yet and we won't ship these APIs until we do and revise them accordingly" mode, right?
Yes.
Is there a must-do issue tracking that to make sure it doesn't slip through the cracks?
It's been in active discussion during QUIC syncs; I'm aiming for us to have that ironed out in the next couple weeks. #31709
@@ -57,8 +117,10 @@ | |||
<resheader name="writer"> | |||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||
</resheader> | |||
|
|||
<data name="net_quic_notsupported" xml:space="preserve"> | |||
<value>QUIC is not supported on this platform. See http://aka.ms/dotnetquic</value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link redirects to https://github.com/dotnet/runtime
Is this intentional or is the redirect not setup right now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentional; Around release we'll have a docs page or blog post outlining how to play with HTTP/3 -- it'll get updated at that time.
Note regarding the This PR is modifying a ref *.cs file. When adding/modifying a public API, 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. |
Add
QuicConnection.IsQuicSupported
for runtime feature detection, update tests to use it, and add aQuicNotSupportedException
.