-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Group 3] Enable nullable annotations for Microsoft.Extensions.Configuration
#57414
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
Merged
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
ad2ea3d
Annotate src
maxkoshevoi 04bc30b
Annotate ref
maxkoshevoi 65f47b2
Add net6 to Configuration.Abstractions
maxkoshevoi 44d0ac0
Fix tests
maxkoshevoi 1226d7e
Merge branch 'main' into mk/43605-Configuration
maxkoshevoi 07cc6a8
Merge branch 'main' into mk/43605-Configuration
maxkoshevoi 802a753
Merge branch 'main' into mk/43605-Configuration
maxkoshevoi 051b15b
Merge branch 'main' into mk/43605-Configuration
maxkoshevoi 5a7a6d3
DisableImplicitAssemblyReferences
maxkoshevoi 9bde07c
Merge branch 'main' into mk/43605-Configuration
maxkoshevoi 4945112
TryGet can return null
maxkoshevoi 330dc3a
Merge branch 'main' into mk/43605-Configuration
maxkoshevoi f320ed0
new()
maxkoshevoi 7cbd323
Merge remote-tracking branch 'upstream/main' into mk/43605-Configuration
eerhardt b9a0a93
Fix merge error
eerhardt e5228aa
InvalidOperationException
maxkoshevoi 1c583ec
Source.Stream DisallowNull
maxkoshevoi a45a821
Revert unnecessary changes
maxkoshevoi d33438a
More message into resources
maxkoshevoi 2ca692a
Configuration DisallowNull
maxkoshevoi 4813528
MaybeNullWhen(false)
maxkoshevoi 581c024
Revert "MaybeNullWhen(false)"
maxkoshevoi ff9af93
Remove MaybeNullWhen
maxkoshevoi 3790ba6
NotNullWhen
maxkoshevoi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
...ibraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,15 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <TargetFrameworks>netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks> | ||
| <TargetFrameworks>$(NetCoreAppCurrent);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks> | ||
| <Nullable>enable</Nullable> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Compile Include="Microsoft.Extensions.Configuration.cs" /> | ||
| <ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Configuration.Abstractions\ref\Microsoft.Extensions.Configuration.Abstractions.csproj" /> | ||
| <ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Primitives\ref\Microsoft.Extensions.Primitives.csproj" /> | ||
| </ItemGroup> | ||
| <ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'"> | ||
| <ProjectReference Include="$(LibrariesProjectRoot)System.Collections\ref\System.Collections.csproj" /> | ||
| <ProjectReference Include="$(LibrariesProjectRoot)System.Runtime\ref\System.Runtime.csproj" /> | ||
| </ItemGroup> | ||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,29 +21,29 @@ public abstract class ConfigurationProvider : IConfigurationProvider | |
| /// </summary> | ||
| protected ConfigurationProvider() | ||
| { | ||
| Data = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); | ||
| Data = new Dictionary<string, string?>(StringComparer.OrdinalIgnoreCase); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// The configuration key value pairs for this provider. | ||
| /// </summary> | ||
| protected IDictionary<string, string> Data { get; set; } | ||
| protected IDictionary<string, string?> Data { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Attempts to find a value with the given key, returns true if one is found, false otherwise. | ||
| /// </summary> | ||
| /// <param name="key">The key to lookup.</param> | ||
| /// <param name="value">The value found at key if one is found.</param> | ||
| /// <returns>True if key has a value, false otherwise.</returns> | ||
| public virtual bool TryGet(string key, out string value) | ||
| public virtual bool TryGet(string key, out string? value) | ||
| => Data.TryGetValue(key, out value); | ||
|
|
||
| /// <summary> | ||
| /// Sets a value for a given key. | ||
| /// </summary> | ||
| /// <param name="key">The configuration key to set.</param> | ||
| /// <param name="value">The value to set.</param> | ||
| public virtual void Set(string key, string value) | ||
| public virtual void Set(string key, string? value) | ||
| => Data[key] = value; | ||
|
|
||
| /// <summary> | ||
|
|
@@ -60,13 +60,13 @@ public virtual void Load() | |
| /// <returns>The list of keys for this provider.</returns> | ||
| public virtual IEnumerable<string> GetChildKeys( | ||
| IEnumerable<string> earlierKeys, | ||
| string parentPath) | ||
| string? parentPath) | ||
| { | ||
| var results = new List<string>(); | ||
|
|
||
| if (parentPath is null) | ||
| { | ||
| foreach (KeyValuePair<string, string> kv in Data) | ||
| foreach (KeyValuePair<string, string?> kv in Data) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: not related to this PR but it seems like we could just iterate over
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| { | ||
| results.Add(Segment(kv.Key, 0)); | ||
| } | ||
|
|
@@ -75,7 +75,7 @@ public virtual IEnumerable<string> GetChildKeys( | |
| { | ||
| Debug.Assert(ConfigurationPath.KeyDelimiter == ":"); | ||
|
|
||
| foreach (KeyValuePair<string, string> kv in Data) | ||
| foreach (KeyValuePair<string, string?> kv in Data) | ||
| { | ||
| if (kv.Key.Length > parentPath.Length && | ||
| kv.Key.StartsWith(parentPath, StringComparison.OrdinalIgnoreCase) && | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.