Skip to content

Conversation

@wtgodbe
Copy link
Member

@wtgodbe wtgodbe commented Jul 28, 2021

Fixes #34738. Confirmed in ILSpy that the attribute is present on the 2 enum values.

@ghost ghost added the area-runtime label Jul 28, 2021
@wtgodbe wtgodbe marked this pull request as ready for review July 28, 2021 17:26
@wtgodbe wtgodbe requested a review from JamesNK July 28, 2021 17:26
@Tratcher
Copy link
Member

How does this show up in the sample app, as a warning?

listenOptions.Protocols = HttpProtocols.Http3;

Do we need a suppression there?

@wtgodbe
Copy link
Member Author

wtgodbe commented Jul 28, 2021

How does this show up in the sample app, as a warning?

Unhandled exception. System.NotSupportedException: QUIC is not supported or enabled on this platform. See https://aka.ms/aspnet/kestrel/http3reqs for details.

So I guess we either need to suppress it, or have the sample require preview features as well?

@Tratcher
Copy link
Member

That's a runtime error about your machine not supporting quic. The preview attribute should have given you a compile time warning/error?

@wtgodbe
Copy link
Member Author

wtgodbe commented Jul 28, 2021

Nope, no warnings/errors on building the app

@Tratcher
Copy link
Member

Hmm, then it's not working and we need to figure out why before merging it.

@wtgodbe
Copy link
Member Author

wtgodbe commented Jul 28, 2021

@pgovind @jeffhandley @jkotas this PR adds the RequiresPreviewFeaturesAttribute to the enum values for the Http3 protocol, yet our sample using that protocol gives no warning:

listenOptions.Protocols = HttpProtocols.Http3;
This is surprising, are we doing something wrong?

@jeffhandley
Copy link
Member

The analyzer is currently set to produce Info level diagnostics. We are still refining the implementation ahead of increasing it to Warning/Error. Can you check to see if there was an Info message produced? If you are getting those, then you could proceed in putting your suppression in ahead of us increasing the level.

https://github.com/dotnet/roslyn-analyzers/blob/release/6.0.1xx/src/NetAnalyzers/Core/AnalyzerReleases.Unshipped.md#:~:text=ca2252

@pgovind
Copy link

pgovind commented Jul 28, 2021

Can you check to see if there was an Info message produced? If you are getting those, then you could proceed in putting your suppression in ahead of us increasing the level.

Either this, or you can change the severity of the analyzer from Info to Error and see if VS reports errors. I'm almost certain it will. We have unit tests testing this exact scenario in the analyzer.

@wtgodbe
Copy link
Member Author

wtgodbe commented Jul 28, 2021

Yeah, I do get Using 'Http3' requires opting into preview features. See https://aka.ms/dotnet-warnings/preview-features for more information. Adding a NoWarn suppresses it.

@JamesNK
Copy link
Member

JamesNK commented Jul 28, 2021

That looks like what we want.

https://aka.ms/dotnet-warnings/preview-features links to Bing? I'm guessing this will be fixed before .NET 6 RTMs.

@pgovind @jeffhandley @jkotas Is there a reason why there is no way to add a custom message with this attribute?

@jeffhandley
Copy link
Member

jeffhandley commented Jul 28, 2021

We typically don't set up the aka.ms links until documentation is in place and published, which won't happen until RC1 ships. (aka.ms defaults to bing for undefined links).

I don't recall if the API Design Review discussion included potentially having a custom message. @pgovind / @terrajobst, was there a good reason not to?

@pgovind
Copy link

pgovind commented Jul 28, 2021

Is there a reason there is no way to add a custom message with this attribute?

Interesting. We hadn't considered that because we didn't have a use case for it. @terrajobst should decide if we want to enable it. I'll just point out that adding a message might mean changes in S.P.CoreLib, so we should decide soon if we want it for .NET6 (or we just add it as a new features for .NET 7)

@JamesNK
Copy link
Member

JamesNK commented Jul 28, 2021

For the context of HTTP/3, it would be nice to link to a doc about why the feature is preview, and how to manage using it, but it's not critical.

Its like the ObsoleteAttribute where you want to describe why something is obsolete and how to update your app.

In .NET 7 a constructor overload could be added to the attribute that takes a message. Give a chance to provide more detail to the user.

@JamesNK
Copy link
Member

JamesNK commented Jul 28, 2021

Created issue: dotnet/runtime#56498

Copy link

@terrajobst terrajobst left a comment

Choose a reason for hiding this comment

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

I believe this was briefly discussed a few days ago. Yes, I believe the usage of [RequiresPreviewFeatures] is appropriate here and would communicate our intent (the capability to use Http3 is there, but it's not supported and only provided as a preview).

Copy link

@terrajobst terrajobst left a comment

Choose a reason for hiding this comment

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

Clicked the wrong button because I'm a PM

@terrajobst
Copy link

If we do this, is there a reason why we wouldn't mark this API?

namespace System.Net
{
    public static class HttpVersion
    {
        [RequiresPreviewFeatures]
        public static readonly Version Version30;
    }
}

@dotnet/ncl

@JamesNK
Copy link
Member

JamesNK commented Jul 28, 2021

A client can upgrade to use HTTP/3 without it being configured using that setting.

For example, Version = 2.0 and RequestedVersionOrHigher will upgrade to HTTP/3 without someone seeing the preview warning. That's why a runtime appcontext switch is better for their situation.


<PropertyGroup>
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
<!-- Turn off warnings about using preview features -->
Copy link
Member

Choose a reason for hiding this comment

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

Nit: might be good to add something like "because HTTP/3 is currently in preview state" or something here, so the intent is clear to someone in the future.

Copy link
Member

@adityamandaleeka adityamandaleeka left a comment

Choose a reason for hiding this comment

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

LGTM aside from the minor nit.

@JamesNK JamesNK enabled auto-merge (squash) July 29, 2021 22:15
@JamesNK JamesNK merged commit 5c6d951 into main Jul 30, 2021
@JamesNK JamesNK deleted the wtgodbe/Attr branch July 30, 2021 00:08
@ghost ghost added this to the 6.0-rc1 milestone Jul 30, 2021
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Indicate preview status for HTTP/3 in .NET 6

9 participants