Uh oh!
There was an error while loading. Please reload this page.
Annotate Microsoft.Extensions.DependencyInjection.Abstractions for nu… - #37488
Conversation
pranavkm
commented
Jun 5, 2020
cc: @buyaa-n, @stephentoub |
…llable reference types Contributes to dotnet#2339
Uh oh!
There was an error while loading. Please reload this page.
| using System; | ||
| using System.Reflection; | ||
| #nullable enable |
There was a problem hiding this comment.
Nit: not a big deal, but we've generally been putting these above the using statements when they're needed
Uh oh!
There was an error while loading. Please reload this page.
| /// <param name="provider">The <see cref="IServiceProvider"/> to retrieve the service object from.</param> | ||
| /// <returns>A service object of type <typeparamref name="T"/>.</returns> | ||
| /// <exception cref="System.InvalidOperationException">There is no service of type <typeparamref name="T"/>.</exception> | ||
| [return: NotNull] |
There was a problem hiding this comment.
Would it be better to constrain T to be non-nullable?
publicstaticTGetRequiredService<T>(thisIServiceProviderprovider)whereT:notnull?
There was a problem hiding this comment.
(Other APIs, like the one below, could use that constraint as well.)
There was a problem hiding this comment.
@davidfowl and I went over some of the other APIs here. We added the notnull constraint to another type, but the rest of these APIs don't qualify for additional constraints.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
| #nullable enable |
There was a problem hiding this comment.
It's a shared source file. So you have to annotate it in case other projects that reference it haven't been updated to nullable.
pranavkm
commented
Jun 16, 2020
@stephentoub does this need to be API reviewed before this is merged? |
stephentoub
commented
Jun 16, 2020
@pranavkm, thanks for checking, but nope. We plan to do an all-up .NET 5 annotations review en mass for all the annotations added in the release. cc: @terrajobst |
…llable reference types
Contributes to #2339