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

[Group 2] Enable nullable annotations for Microsoft.Extensions.Configuration.Abstractions #57401

Merged
merged 12 commits into from
Oct 6, 2021

Conversation

maxkoshevoi
Copy link
Contributor

@maxkoshevoi maxkoshevoi commented Aug 14, 2021

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Aug 14, 2021
@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
Copy link

ghost commented Aug 14, 2021

Tagging subscribers to this area: @maryamariyan, @safern
See info in area-owners.md if you want to be subscribed.

Issue Details

Related to #43605, #54012

Author: maxkoshevoi
Assignees: -
Labels:

new-api-needs-documentation, area-Extensions-Configuration, community-contribution

Milestone: -

@maryamariyan
Copy link
Member

Thanks for the PRs @maxkoshevoi, the nullable annotations effort for Microsoft.Extensions.* is targeted for 7.0, and since this week we're focusing on 6.0 bugs, there might be some delays with the reviews.

@maryamariyan maryamariyan added this to the 7.0.0 milestone Aug 16, 2021
@maxkoshevoi
Copy link
Contributor Author

I hoped, at least Configuration.Abstractions can still make it into 6.0.. Got it, thanks.

# Conflicts:
#	src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/ConfigurationExtensions.cs
# Conflicts:
#	src/libraries/Microsoft.Extensions.Configuration.Abstractions/ref/Microsoft.Extensions.Configuration.Abstractions.csproj
#	src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/Microsoft.Extensions.Configuration.Abstractions.csproj
@@ -65,7 +67,7 @@ public static string GetSectionKey(string path)
/// </summary>
/// <param name="path">The path.</param>
/// <returns>The original path minus the last individual segment found in it. Null if the original path corresponds to a top level node.</returns>
public static string GetParentPath(string path)
public static string? GetParentPath(string? path)
Copy link
Member

Choose a reason for hiding this comment

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

honestly I think path should be marked as non-null the doc suggests it should be a path also it's not intuitive what will happen when it's null. I do not feel strongly about this so fine with me if you think we should keep it as is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also don't have a strong opinion. One benefit of making path nullable is that user don't need additional null-check in order to call this method (if their variable may be null).

I didn't find any calls to this method here or in aspnet, so don't know how this method it used.

@@ -21,6 +21,6 @@ public interface IConfigurationSection : IConfiguration
/// <summary>
/// Gets or sets the section value.
/// </summary>
string Value { get; set; }
string? Value { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

if you decide to keep path as nullable arg in other places should this also accept nullable path?

Copy link
Contributor Author

@maxkoshevoi maxkoshevoi Sep 16, 2021

Choose a reason for hiding this comment

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

I don't think so. Path will never be set to null. All sections have a path.

Also all usages don't expect null in Path:

Regarding leaving path parameters as null. I'm not objecting removing ?. My only concern is that it will be harder to call those methods by requiring additional null-check on their side.

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

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

I think these changes look good. Thanks @maxkoshevoi.

@eerhardt eerhardt merged commit 1f555b2 into dotnet:main Oct 6, 2021
@maxkoshevoi maxkoshevoi deleted the mk/43605-Configuration-Abstractions branch October 6, 2021 21:27
@ghost ghost locked as resolved and limited conversation to collaborators Nov 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Extensions-Configuration community-contribution Indicates that the PR has been added by a community member new-api-needs-documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants