Skip to content

Allow nullable with IFeatureCollection generic Get/Set #28809

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

Merged

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Dec 22, 2020

Addresses #5680

@JamesNK JamesNK changed the title Enable nullable on generated code Allow nullable with IFeatureCollection generic Get/Set Dec 22, 2020
@@ -33,13 +33,13 @@ public interface IFeatureCollection : IEnumerable<KeyValuePair<Type, object>>
/// </summary>
/// <typeparam name="TFeature">The feature key.</typeparam>
/// <returns>The requested feature, or null if it is not present.</returns>
TFeature Get<TFeature>();
TFeature? Get<TFeature>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we need a GetRequiredFeature to avoid the use of null forgiveness?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. It's not that commonly used API. But it could be added later.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, GetRequiredFeature would be a good idea. There are several features we always assume are present like IHttpRequestFeature.

@JamesNK JamesNK merged commit d4dbba8 into jamesnk/nullable-generatedcode Dec 26, 2020
@JamesNK JamesNK deleted the jamesnk/nullable-featurecollection branch December 26, 2020 20:43
@amcasey amcasey added area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares 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-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares 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.

4 participants