From ad2ea3d3dd92a36e8a6377dd17da8601271995e5 Mon Sep 17 00:00:00 2001 From: Maksym Koshovyi Date: Sat, 14 Aug 2021 22:32:42 +0300 Subject: [PATCH 01/17] Annotate src --- .../src/ChainedConfigurationProvider.cs | 7 ++-- .../src/ChainedConfigurationSource.cs | 2 +- .../src/ConfigurationKeyComparer.cs | 2 +- .../src/ConfigurationManager.cs | 5 ++- .../src/ConfigurationProvider.cs | 15 ++++---- .../src/ConfigurationReloadToken.cs | 2 +- .../src/ConfigurationRoot.cs | 8 ++-- .../src/ConfigurationSection.cs | 38 +++++-------------- .../InternalConfigurationRootExtensions.cs | 2 +- .../MemoryConfigurationBuilderExtensions.cs | 2 +- .../src/MemoryConfigurationProvider.cs | 8 ++-- .../src/MemoryConfigurationSource.cs | 2 +- .../Microsoft.Extensions.Configuration.csproj | 10 ++++- .../src/StreamConfigurationProvider.cs | 6 +++ .../src/StreamConfigurationSource.cs | 2 +- 15 files changed, 54 insertions(+), 57 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ChainedConfigurationProvider.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ChainedConfigurationProvider.cs index a240f3da8e7d1..53e0660d067e0 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ChainedConfigurationProvider.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ChainedConfigurationProvider.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using Microsoft.Extensions.Primitives; namespace Microsoft.Extensions.Configuration @@ -40,7 +41,7 @@ public ChainedConfigurationProvider(ChainedConfigurationSource source) /// The key. /// The value. /// True if a value for the specified key was found, otherwise false. - public bool TryGet(string key, out string value) + public bool TryGet(string key, [MaybeNullWhen(false)] out string value) { value = _config[key]; return !string.IsNullOrEmpty(value); @@ -51,7 +52,7 @@ public bool TryGet(string key, out string value) /// /// The key. /// The value. - public void Set(string key, string value) => _config[key] = value; + public void Set(string key, string? value) => _config[key] = value; /// /// Returns a change token if this provider supports change tracking, null otherwise. @@ -74,7 +75,7 @@ public void Load() { } /// The child keys. public IEnumerable GetChildKeys( IEnumerable earlierKeys, - string parentPath) + string? parentPath) { IConfiguration section = parentPath == null ? _config : _config.GetSection(parentPath); var keys = new List(); diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ChainedConfigurationSource.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ChainedConfigurationSource.cs index 27391aead76fd..adab1de349a6c 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ChainedConfigurationSource.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ChainedConfigurationSource.cs @@ -11,7 +11,7 @@ public class ChainedConfigurationSource : IConfigurationSource /// /// The chained configuration. /// - public IConfiguration Configuration { get; set; } + public IConfiguration? Configuration { get; set; } /// /// Whether the chained configuration should be disposed when the diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationKeyComparer.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationKeyComparer.cs index b5dc31fdffe73..00cca781d47f4 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationKeyComparer.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationKeyComparer.cs @@ -27,7 +27,7 @@ public class ConfigurationKeyComparer : IComparer /// First string. /// Second string. /// Less than 0 if x is less than y, 0 if x is equal to y and greater than 0 if x is greater than y. - public int Compare(string x, string y) + public int Compare(string? x, string? y) { string[] xParts = x?.Split(_keyDelimiterArray, StringSplitOptions.RemoveEmptyEntries) ?? Array.Empty(); string[] yParts = y?.Split(_keyDelimiterArray, StringSplitOptions.RemoveEmptyEntries) ?? Array.Empty(); diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationManager.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationManager.cs index 9578f3c334ac3..db1d682a9464a 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationManager.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationManager.cs @@ -4,6 +4,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading; using Microsoft.Extensions.Primitives; @@ -39,7 +40,7 @@ public ConfigurationManager() } /// - public string this[string key] + public string? this[string key] { get { @@ -339,7 +340,7 @@ public bool Remove(KeyValuePair item) return wasRemoved; } - public bool TryGetValue(string key, out object value) + public bool TryGetValue(string key, [MaybeNullWhen(false)] out object value) { return _properties.TryGetValue(key, out value); } diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs index e337bd3148331..e3eb4f977bffc 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Threading; using Microsoft.Extensions.Primitives; @@ -21,13 +22,13 @@ public abstract class ConfigurationProvider : IConfigurationProvider /// protected ConfigurationProvider() { - Data = new Dictionary(StringComparer.OrdinalIgnoreCase); + Data = new Dictionary(StringComparer.OrdinalIgnoreCase); } /// /// The configuration key value pairs for this provider. /// - protected IDictionary Data { get; set; } + protected IDictionary Data { get; set; } /// /// Attempts to find a value with the given key, returns true if one is found, false otherwise. @@ -35,7 +36,7 @@ protected ConfigurationProvider() /// The key to lookup. /// The value found at key if one is found. /// True if key has a value, false otherwise. - public virtual bool TryGet(string key, out string value) + public virtual bool TryGet(string key, [MaybeNullWhen(false)] out string value) => Data.TryGetValue(key, out value); /// @@ -43,7 +44,7 @@ public virtual bool TryGet(string key, out string value) /// /// The configuration key to set. /// The value to set. - public virtual void Set(string key, string value) + public virtual void Set(string key, string? value) => Data[key] = value; /// @@ -60,13 +61,13 @@ public virtual void Load() /// The list of keys for this provider. public virtual IEnumerable GetChildKeys( IEnumerable earlierKeys, - string parentPath) + string? parentPath) { var results = new List(); if (parentPath is null) { - foreach (KeyValuePair kv in Data) + foreach (KeyValuePair kv in Data) { results.Add(Segment(kv.Key, 0)); } @@ -75,7 +76,7 @@ public virtual IEnumerable GetChildKeys( { Debug.Assert(ConfigurationPath.KeyDelimiter == ":"); - foreach (KeyValuePair kv in Data) + foreach (KeyValuePair kv in Data) { if (kv.Key.Length > parentPath.Length && kv.Key.StartsWith(parentPath, StringComparison.OrdinalIgnoreCase) && diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationReloadToken.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationReloadToken.cs index fad07ebfdacb9..7aceba29fe55b 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationReloadToken.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationReloadToken.cs @@ -33,7 +33,7 @@ public class ConfigurationReloadToken : IChangeToken /// The callback to invoke. /// State to be passed into the callback. /// The registration. - public IDisposable RegisterChangeCallback(Action callback, object state) => _cts.Token.Register(callback, state); + public IDisposable RegisterChangeCallback(Action callback, object? state) => _cts.Token.Register(callback, state); /// /// Used to trigger the change token when a reload occurs. diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs index cfe56a20978e5..397ef5160b1ec 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs @@ -47,7 +47,7 @@ public ConfigurationRoot(IList providers) /// /// The configuration key. /// The configuration value. - public string this[string key] + public string? this[string key] { get => GetConfiguration(_providers, key); set => SetConfiguration(_providers, key, value); @@ -111,13 +111,13 @@ public void Dispose() } } - internal static string GetConfiguration(IList providers, string key) + internal static string? GetConfiguration(IList providers, string key) { for (int i = providers.Count - 1; i >= 0; i--) { IConfigurationProvider provider = providers[i]; - if (provider.TryGet(key, out string value)) + if (provider.TryGet(key, out string? value)) { return value; } @@ -126,7 +126,7 @@ internal static string GetConfiguration(IList providers, return null; } - internal static void SetConfiguration(IList providers, string key, string value) + internal static void SetConfiguration(IList providers, string key, string? value) { if (providers.Count == 0) { diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationSection.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationSection.cs index da3fbb733a3a1..411b0d70fd765 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationSection.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationSection.cs @@ -14,7 +14,7 @@ public class ConfigurationSection : IConfigurationSection { private readonly IConfigurationRoot _root; private readonly string _path; - private string _key; + private string? _key; /// /// Initializes a new instance. @@ -47,30 +47,17 @@ public ConfigurationSection(IConfigurationRoot root, string path) /// public string Key { - get - { - if (_key == null) - { - // Key is calculated lazily as last portion of Path - _key = ConfigurationPath.GetSectionKey(_path); - } - return _key; - } + // Key is calculated lazily as last portion of Path + get => _key ??= ConfigurationPath.GetSectionKey(_path); } /// /// Gets or sets the section value. /// - public string Value + public string? Value { - get - { - return _root[Path]; - } - set - { - _root[Path] = value; - } + get => _root[Path]; + set => _root[Path] = value; } /// @@ -78,17 +65,10 @@ public string Value /// /// The configuration key. /// The configuration value. - public string this[string key] + public string? this[string key] { - get - { - return _root[ConfigurationPath.Combine(Path, key)]; - } - - set - { - _root[ConfigurationPath.Combine(Path, key)] = value; - } + get => _root[ConfigurationPath.Combine(Path, key)]; + set => _root[ConfigurationPath.Combine(Path, key)] = value; } /// diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/InternalConfigurationRootExtensions.cs b/src/libraries/Microsoft.Extensions.Configuration/src/InternalConfigurationRootExtensions.cs index bff5c52710400..7fd17a98acf47 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/InternalConfigurationRootExtensions.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/InternalConfigurationRootExtensions.cs @@ -18,7 +18,7 @@ internal static class InternalConfigurationRootExtensions /// Configuration from which to retrieve sub-sections. /// Key of a section of which children to retrieve. /// Immediate children sub-sections of section specified by key. - internal static IEnumerable GetChildrenImplementation(this IConfigurationRoot root, string path) + internal static IEnumerable GetChildrenImplementation(this IConfigurationRoot root, string? path) { return root.Providers .Aggregate(Enumerable.Empty(), diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/MemoryConfigurationBuilderExtensions.cs b/src/libraries/Microsoft.Extensions.Configuration/src/MemoryConfigurationBuilderExtensions.cs index 996f8a876b9c3..15ed46a26a5b9 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/MemoryConfigurationBuilderExtensions.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/MemoryConfigurationBuilderExtensions.cs @@ -36,7 +36,7 @@ public static IConfigurationBuilder AddInMemoryCollection(this IConfigurationBui /// The . public static IConfigurationBuilder AddInMemoryCollection( this IConfigurationBuilder configurationBuilder, - IEnumerable> initialData) + IEnumerable>? initialData) { if (configurationBuilder == null) { diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/MemoryConfigurationProvider.cs b/src/libraries/Microsoft.Extensions.Configuration/src/MemoryConfigurationProvider.cs index 84a0b142e0fbc..0e7f0be02fec7 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/MemoryConfigurationProvider.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/MemoryConfigurationProvider.cs @@ -10,7 +10,7 @@ namespace Microsoft.Extensions.Configuration.Memory /// /// In-memory implementation of /// - public class MemoryConfigurationProvider : ConfigurationProvider, IEnumerable> + public class MemoryConfigurationProvider : ConfigurationProvider, IEnumerable> { private readonly MemoryConfigurationSource _source; @@ -29,7 +29,7 @@ public MemoryConfigurationProvider(MemoryConfigurationSource source) if (_source.InitialData != null) { - foreach (KeyValuePair pair in _source.InitialData) + foreach (KeyValuePair pair in _source.InitialData) { Data.Add(pair.Key, pair.Value); } @@ -41,7 +41,7 @@ public MemoryConfigurationProvider(MemoryConfigurationSource source) /// /// The configuration key. /// The configuration value. - public void Add(string key, string value) + public void Add(string key, string? value) { Data.Add(key, value); } @@ -50,7 +50,7 @@ public void Add(string key, string value) /// Returns an enumerator that iterates through the collection. /// /// An enumerator that can be used to iterate through the collection. - public IEnumerator> GetEnumerator() + public IEnumerator> GetEnumerator() { return Data.GetEnumerator(); } diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/MemoryConfigurationSource.cs b/src/libraries/Microsoft.Extensions.Configuration/src/MemoryConfigurationSource.cs index e11891595e414..412df6534c110 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/MemoryConfigurationSource.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/MemoryConfigurationSource.cs @@ -13,7 +13,7 @@ public class MemoryConfigurationSource : IConfigurationSource /// /// The initial key value configuration pairs. /// - public IEnumerable> InitialData { get; set; } + public IEnumerable>? InitialData { get; set; } /// /// Builds the for this source. diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/Microsoft.Extensions.Configuration.csproj b/src/libraries/Microsoft.Extensions.Configuration/src/Microsoft.Extensions.Configuration.csproj index 62243f8db8537..e8093696ecba9 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/Microsoft.Extensions.Configuration.csproj +++ b/src/libraries/Microsoft.Extensions.Configuration/src/Microsoft.Extensions.Configuration.csproj @@ -1,7 +1,8 @@ - netstandard2.0;net461 + $(NetCoreAppCurrent);netstandard2.0;net461 + enable true Implementation of key-value pair based configuration for Microsoft.Extensions.Configuration. Includes the memory configuration provider. @@ -11,4 +12,11 @@ + + + + + + + diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/StreamConfigurationProvider.cs b/src/libraries/Microsoft.Extensions.Configuration/src/StreamConfigurationProvider.cs index fb279be1b4c5f..0b18569818c73 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/StreamConfigurationProvider.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/StreamConfigurationProvider.cs @@ -42,6 +42,12 @@ public override void Load() { throw new InvalidOperationException(SR.StreamConfigurationProvidersAlreadyLoaded); } + + if (Source.Stream == null) + { + throw new NullReferenceException("Source.Stream"); + } + Load(Source.Stream); _loaded = true; } diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/StreamConfigurationSource.cs b/src/libraries/Microsoft.Extensions.Configuration/src/StreamConfigurationSource.cs index 3fdf741443509..a658ba74f1dcb 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/StreamConfigurationSource.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/StreamConfigurationSource.cs @@ -13,7 +13,7 @@ public abstract class StreamConfigurationSource : IConfigurationSource /// /// The stream containing the configuration data. /// - public Stream Stream { get; set; } + public Stream? Stream { get; set; } /// /// Builds the for this source. From 04bc30b327a0cb1a1e203ee17d122c3f33c4882c Mon Sep 17 00:00:00 2001 From: Maksym Koshovyi Date: Sat, 14 Aug 2021 22:46:08 +0300 Subject: [PATCH 02/17] Annotate ref --- .../ref/Microsoft.Extensions.Configuration.cs | 38 +++++++++---------- .../Microsoft.Extensions.Configuration.csproj | 9 ++++- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.cs b/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.cs index feef64fc2dde1..8590771e42fb2 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.cs @@ -15,23 +15,23 @@ public partial class ChainedConfigurationProvider : Microsoft.Extensions.Configu { public ChainedConfigurationProvider(Microsoft.Extensions.Configuration.ChainedConfigurationSource source) { } public void Dispose() { } - public System.Collections.Generic.IEnumerable GetChildKeys(System.Collections.Generic.IEnumerable earlierKeys, string parentPath) { throw null; } + public System.Collections.Generic.IEnumerable GetChildKeys(System.Collections.Generic.IEnumerable earlierKeys, string? parentPath) { throw null; } public Microsoft.Extensions.Primitives.IChangeToken GetReloadToken() { throw null; } public void Load() { } - public void Set(string key, string value) { } - public bool TryGet(string key, out string value) { throw null; } + public void Set(string key, string? value) { } + public bool TryGet(string key, [System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)] out string value) { throw null; } } public partial class ChainedConfigurationSource : Microsoft.Extensions.Configuration.IConfigurationSource { public ChainedConfigurationSource() { } - public Microsoft.Extensions.Configuration.IConfiguration Configuration { get { throw null; } set { } } + public Microsoft.Extensions.Configuration.IConfiguration? Configuration { get { throw null; } set { } } public bool ShouldDisposeConfiguration { get { throw null; } set { } } public Microsoft.Extensions.Configuration.IConfigurationProvider Build(Microsoft.Extensions.Configuration.IConfigurationBuilder builder) { throw null; } } public sealed partial class ConfigurationManager : Microsoft.Extensions.Configuration.IConfigurationBuilder, Microsoft.Extensions.Configuration.IConfigurationRoot, System.IDisposable { public ConfigurationManager() { } - public string this[string key] { get { throw null; } set { throw null; } } + public string? this[string key] { get { throw null; } set { throw null; } } public IConfigurationSection GetSection(string key) { throw null; } public System.Collections.Generic.IEnumerable GetChildren() { throw null; } public void Dispose() { throw null; } @@ -55,19 +55,19 @@ public partial class ConfigurationKeyComparer : System.Collections.Generic.IComp { public ConfigurationKeyComparer() { } public static Microsoft.Extensions.Configuration.ConfigurationKeyComparer Instance { get { throw null; } } - public int Compare(string x, string y) { throw null; } + public int Compare(string? x, string? y) { throw null; } } public abstract partial class ConfigurationProvider : Microsoft.Extensions.Configuration.IConfigurationProvider { protected ConfigurationProvider() { } - protected System.Collections.Generic.IDictionary Data { get { throw null; } set { } } - public virtual System.Collections.Generic.IEnumerable GetChildKeys(System.Collections.Generic.IEnumerable earlierKeys, string parentPath) { throw null; } + protected System.Collections.Generic.IDictionary Data { get { throw null; } set { } } + public virtual System.Collections.Generic.IEnumerable GetChildKeys(System.Collections.Generic.IEnumerable earlierKeys, string? parentPath) { throw null; } public Microsoft.Extensions.Primitives.IChangeToken GetReloadToken() { throw null; } public virtual void Load() { } protected void OnReload() { } - public virtual void Set(string key, string value) { } + public virtual void Set(string key, string? value) { } public override string ToString() { throw null; } - public virtual bool TryGet(string key, out string value) { throw null; } + public virtual bool TryGet(string key, [System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)] out string value) { throw null; } } public partial class ConfigurationReloadToken : Microsoft.Extensions.Primitives.IChangeToken { @@ -75,12 +75,12 @@ public ConfigurationReloadToken() { } public bool ActiveChangeCallbacks { get { throw null; } } public bool HasChanged { get { throw null; } } public void OnReload() { } - public System.IDisposable RegisterChangeCallback(System.Action callback, object state) { throw null; } + public System.IDisposable RegisterChangeCallback(System.Action callback, object? state) { throw null; } } public partial class ConfigurationRoot : Microsoft.Extensions.Configuration.IConfiguration, Microsoft.Extensions.Configuration.IConfigurationRoot, System.IDisposable { public ConfigurationRoot(System.Collections.Generic.IList providers) { } - public string this[string key] { get { throw null; } set { } } + public string? this[string key] { get { throw null; } set { } } public System.Collections.Generic.IEnumerable Providers { get { throw null; } } public void Dispose() { } public System.Collections.Generic.IEnumerable GetChildren() { throw null; } @@ -91,10 +91,10 @@ public void Reload() { } public partial class ConfigurationSection : Microsoft.Extensions.Configuration.IConfiguration, Microsoft.Extensions.Configuration.IConfigurationSection { public ConfigurationSection(Microsoft.Extensions.Configuration.IConfigurationRoot root, string path) { } - public string this[string key] { get { throw null; } set { } } + public string? this[string key] { get { throw null; } set { } } public string Key { get { throw null; } } public string Path { get { throw null; } } - public string Value { get { throw null; } set { } } + public string? Value { get { throw null; } set { } } public System.Collections.Generic.IEnumerable GetChildren() { throw null; } public Microsoft.Extensions.Primitives.IChangeToken GetReloadToken() { throw null; } public Microsoft.Extensions.Configuration.IConfigurationSection GetSection(string key) { throw null; } @@ -102,7 +102,7 @@ public ConfigurationSection(Microsoft.Extensions.Configuration.IConfigurationRoo public static partial class MemoryConfigurationBuilderExtensions { public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddInMemoryCollection(this Microsoft.Extensions.Configuration.IConfigurationBuilder configurationBuilder) { throw null; } - public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddInMemoryCollection(this Microsoft.Extensions.Configuration.IConfigurationBuilder configurationBuilder, System.Collections.Generic.IEnumerable> initialData) { throw null; } + public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddInMemoryCollection(this Microsoft.Extensions.Configuration.IConfigurationBuilder configurationBuilder, System.Collections.Generic.IEnumerable>? initialData) { throw null; } } public abstract partial class StreamConfigurationProvider : Microsoft.Extensions.Configuration.ConfigurationProvider { @@ -120,17 +120,17 @@ protected StreamConfigurationSource() { } } namespace Microsoft.Extensions.Configuration.Memory { - public partial class MemoryConfigurationProvider : Microsoft.Extensions.Configuration.ConfigurationProvider, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + public partial class MemoryConfigurationProvider : Microsoft.Extensions.Configuration.ConfigurationProvider, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable { public MemoryConfigurationProvider(Microsoft.Extensions.Configuration.Memory.MemoryConfigurationSource source) { } - public void Add(string key, string value) { } - public System.Collections.Generic.IEnumerator> GetEnumerator() { throw null; } + public void Add(string key, string? value) { } + public System.Collections.Generic.IEnumerator> GetEnumerator() { throw null; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } } public partial class MemoryConfigurationSource : Microsoft.Extensions.Configuration.IConfigurationSource { public MemoryConfigurationSource() { } - public System.Collections.Generic.IEnumerable> InitialData { get { throw null; } set { } } + public System.Collections.Generic.IEnumerable>? InitialData { get { throw null; } set { } } public Microsoft.Extensions.Configuration.IConfigurationProvider Build(Microsoft.Extensions.Configuration.IConfigurationBuilder builder) { throw null; } } } diff --git a/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.csproj b/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.csproj index e1533c3eadf9e..dd5d096ce7fc5 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.csproj +++ b/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.csproj @@ -1,10 +1,17 @@ - netstandard2.0;net461 + $(NetCoreAppCurrent);netstandard2.0;net461 + enable + + + + + + From 65f47b21aebc89bfa2d4a23c8949aded4cce3121 Mon Sep 17 00:00:00 2001 From: Maksym Koshovyi Date: Sat, 14 Aug 2021 23:45:56 +0300 Subject: [PATCH 03/17] Add net6 to Configuration.Abstractions --- .../Microsoft.Extensions.Configuration.Abstractions.csproj | 6 ++++++ .../Microsoft.Extensions.Configuration.Abstractions.csproj | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/libraries/Microsoft.Extensions.Configuration.Abstractions/ref/Microsoft.Extensions.Configuration.Abstractions.csproj b/src/libraries/Microsoft.Extensions.Configuration.Abstractions/ref/Microsoft.Extensions.Configuration.Abstractions.csproj index d6b7d921c7a1e..b9944f036eb8b 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Abstractions/ref/Microsoft.Extensions.Configuration.Abstractions.csproj +++ b/src/libraries/Microsoft.Extensions.Configuration.Abstractions/ref/Microsoft.Extensions.Configuration.Abstractions.csproj @@ -1,6 +1,7 @@ netstandard2.0;net461 + $(NetCoreAppCurrent);netstandard2.0;net461 @@ -8,4 +9,9 @@ + + + + + diff --git a/src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/Microsoft.Extensions.Configuration.Abstractions.csproj b/src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/Microsoft.Extensions.Configuration.Abstractions.csproj index 24cbc9380f00f..7c1ef3d63034a 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/Microsoft.Extensions.Configuration.Abstractions.csproj +++ b/src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/Microsoft.Extensions.Configuration.Abstractions.csproj @@ -2,6 +2,7 @@ netstandard2.0;net461 + $(NetCoreAppCurrent);netstandard2.0;net461 true Abstractions of key-value pair based configuration. @@ -21,4 +22,10 @@ Microsoft.Extensions.Configuration.IConfigurationSection + + + + + + From 44d0ac0e1455046a8d98c3302c1ea36873b7f88f Mon Sep 17 00:00:00 2001 From: Maksym Koshovyi Date: Sun, 15 Aug 2021 00:35:58 +0300 Subject: [PATCH 04/17] Fix tests --- .../tests/OptionsBuidlerConfigurationExtensionsTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Options.ConfigurationExtensions/tests/OptionsBuidlerConfigurationExtensionsTests.cs b/src/libraries/Microsoft.Extensions.Options.ConfigurationExtensions/tests/OptionsBuidlerConfigurationExtensionsTests.cs index 9d4764c19c0b4..387beac8cc434 100644 --- a/src/libraries/Microsoft.Extensions.Options.ConfigurationExtensions/tests/OptionsBuidlerConfigurationExtensionsTests.cs +++ b/src/libraries/Microsoft.Extensions.Options.ConfigurationExtensions/tests/OptionsBuidlerConfigurationExtensionsTests.cs @@ -66,7 +66,7 @@ public static void BindConfiguration_UsesConfigurationSectionPath() { const string configSectionName = "Test"; const string messageValue = "This is a test"; - var configEntries = new Dictionary + var configEntries = new Dictionary { [ConfigurationPath.Combine(configSectionName, nameof(FakeOptions.Message))] = messageValue }; @@ -88,7 +88,7 @@ public static void BindConfiguration_UsesConfigurationSectionPath() public static void BindConfiguration_UsesConfigurationRootIfSectionNameIsEmptyString() { const string messageValue = "This is a test"; - var configEntries = new Dictionary + var configEntries = new Dictionary { [nameof(FakeOptions.Message)] = messageValue }; @@ -114,7 +114,7 @@ public static void BindConfiguration_UpdatesOptionOnConfigurationUpdateWithEmpty FakeConfigurationSource configSource = new() { - InitialData = new Dictionary + InitialData = new Dictionary { [nameof(FakeOptions.Message)] = messageValue1, } @@ -151,7 +151,7 @@ public static void BindConfiguration_UpdatesOptionOnConfigurationUpdate() FakeConfigurationSource configSource = new() { - InitialData = new Dictionary + InitialData = new Dictionary { [messageConfigKey] = messageValue1 } From 5a7a6d3956480165cddbed2518f21109b0de62eb Mon Sep 17 00:00:00 2001 From: Maksym Koshovyi Date: Fri, 27 Aug 2021 00:52:34 +0300 Subject: [PATCH 05/17] DisableImplicitAssemblyReferences --- .../ref/Microsoft.Extensions.Configuration.csproj | 6 ++---- .../src/Microsoft.Extensions.Configuration.csproj | 9 ++------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.csproj b/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.csproj index dd5d096ce7fc5..f3eff1d87e49d 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.csproj +++ b/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.csproj @@ -9,9 +9,7 @@ - - - - + + diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/Microsoft.Extensions.Configuration.csproj b/src/libraries/Microsoft.Extensions.Configuration/src/Microsoft.Extensions.Configuration.csproj index e8093696ecba9..6137de44b42f3 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/Microsoft.Extensions.Configuration.csproj +++ b/src/libraries/Microsoft.Extensions.Configuration/src/Microsoft.Extensions.Configuration.csproj @@ -4,6 +4,8 @@ $(NetCoreAppCurrent);netstandard2.0;net461 enable true + + false Implementation of key-value pair based configuration for Microsoft.Extensions.Configuration. Includes the memory configuration provider. @@ -12,11 +14,4 @@ - - - - - - - From 4945112a33c43d03f882bff6abb4a62977f8b990 Mon Sep 17 00:00:00 2001 From: Maksym Koshovyi Date: Thu, 16 Sep 2021 17:41:46 +0300 Subject: [PATCH 06/17] TryGet can return null --- .../ref/Microsoft.Extensions.Configuration.cs | 2 +- .../src/ConfigurationProvider.cs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.cs b/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.cs index 8590771e42fb2..65da073c427be 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.cs @@ -67,7 +67,7 @@ public virtual void Load() { } protected void OnReload() { } public virtual void Set(string key, string? value) { } public override string ToString() { throw null; } - public virtual bool TryGet(string key, [System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)] out string value) { throw null; } + public virtual bool TryGet(string key, out string? value) { throw null; } } public partial class ConfigurationReloadToken : Microsoft.Extensions.Primitives.IChangeToken { diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs index e3eb4f977bffc..9fbeded4fc3de 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Threading; using Microsoft.Extensions.Primitives; @@ -36,7 +35,7 @@ protected ConfigurationProvider() /// The key to lookup. /// The value found at key if one is found. /// True if key has a value, false otherwise. - public virtual bool TryGet(string key, [MaybeNullWhen(false)] out string value) + public virtual bool TryGet(string key, out string? value) => Data.TryGetValue(key, out value); /// From f320ed0265041858aeb95f60fe024c13a75f3d23 Mon Sep 17 00:00:00 2001 From: Maksym Koshovyi Date: Thu, 16 Sep 2021 17:48:38 +0300 Subject: [PATCH 07/17] new() --- .../src/ConfigurationKeyComparer.cs | 2 +- .../src/ConfigurationProvider.cs | 2 +- .../src/ConfigurationReloadToken.cs | 2 +- .../Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationKeyComparer.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationKeyComparer.cs index 00cca781d47f4..981814642c440 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationKeyComparer.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationKeyComparer.cs @@ -16,7 +16,7 @@ public class ConfigurationKeyComparer : IComparer /// /// The default instance. /// - public static ConfigurationKeyComparer Instance { get; } = new ConfigurationKeyComparer(); + public static ConfigurationKeyComparer Instance { get; } = new(); /// A comparer delegate with the default instance. internal static Comparison Comparison { get; } = Instance.Compare; diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs index 9fbeded4fc3de..55d7adcd9f1df 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs @@ -14,7 +14,7 @@ namespace Microsoft.Extensions.Configuration /// public abstract class ConfigurationProvider : IConfigurationProvider { - private ConfigurationReloadToken _reloadToken = new ConfigurationReloadToken(); + private ConfigurationReloadToken _reloadToken = new(); /// /// Initializes a new diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationReloadToken.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationReloadToken.cs index 7aceba29fe55b..0da3b1c5508f5 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationReloadToken.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationReloadToken.cs @@ -12,7 +12,7 @@ namespace Microsoft.Extensions.Configuration /// public class ConfigurationReloadToken : IChangeToken { - private CancellationTokenSource _cts = new CancellationTokenSource(); + private CancellationTokenSource _cts = new(); /// /// Indicates if this token will proactively raise callbacks. Callbacks are still guaranteed to be invoked, eventually. diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs index 397ef5160b1ec..c666372dd25cf 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs @@ -15,7 +15,7 @@ public class ConfigurationRoot : IConfigurationRoot, IDisposable { private readonly IList _providers; private readonly IList _changeTokenRegistrations; - private ConfigurationReloadToken _changeToken = new ConfigurationReloadToken(); + private ConfigurationReloadToken _changeToken = new(); /// /// Initializes a Configuration root with a list of providers. From b9a0a93e4d659947624b39b6f61c5762c8d43156 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Wed, 6 Oct 2021 16:23:48 -0500 Subject: [PATCH 08/17] Fix merge error --- .../Microsoft.Extensions.Configuration.Abstractions.csproj | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/Microsoft.Extensions.Configuration.Abstractions.csproj b/src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/Microsoft.Extensions.Configuration.Abstractions.csproj index 3a707795afacf..49aabd359e3fc 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/Microsoft.Extensions.Configuration.Abstractions.csproj +++ b/src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/Microsoft.Extensions.Configuration.Abstractions.csproj @@ -24,10 +24,4 @@ Microsoft.Extensions.Configuration.IConfigurationSection - - - - - - From e5228aa33c36970f77b2f4a3eaa9cc113fa70cea Mon Sep 17 00:00:00 2001 From: Maksym Koshovyi Date: Thu, 7 Oct 2021 09:17:41 +0300 Subject: [PATCH 09/17] InvalidOperationException --- .../src/StreamConfigurationProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/StreamConfigurationProvider.cs b/src/libraries/Microsoft.Extensions.Configuration/src/StreamConfigurationProvider.cs index 0b18569818c73..0fe206f3c5415 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/StreamConfigurationProvider.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/StreamConfigurationProvider.cs @@ -45,7 +45,7 @@ public override void Load() if (Source.Stream == null) { - throw new NullReferenceException("Source.Stream"); + throw new InvalidOperationException("Source.Stream cannot be null"); } Load(Source.Stream); From 1c583ecef83e9e3e22f0c7d90fc8f14416cb3ee7 Mon Sep 17 00:00:00 2001 From: Maksym Koshovyi Date: Thu, 7 Oct 2021 09:30:56 +0300 Subject: [PATCH 10/17] Source.Stream DisallowNull --- .../ref/Microsoft.Extensions.Configuration.cs | 3 ++- .../src/StreamConfigurationSource.cs | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.cs b/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.cs index 65da073c427be..e9eada6e0ad2f 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/ref/Microsoft.Extensions.Configuration.cs @@ -114,7 +114,8 @@ public override void Load() { } public abstract partial class StreamConfigurationSource : Microsoft.Extensions.Configuration.IConfigurationSource { protected StreamConfigurationSource() { } - public System.IO.Stream Stream { get { throw null; } set { } } + [System.Diagnostics.CodeAnalysis.DisallowNull] + public System.IO.Stream? Stream { get { throw null; } set { } } public abstract Microsoft.Extensions.Configuration.IConfigurationProvider Build(Microsoft.Extensions.Configuration.IConfigurationBuilder builder); } } diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/StreamConfigurationSource.cs b/src/libraries/Microsoft.Extensions.Configuration/src/StreamConfigurationSource.cs index a658ba74f1dcb..f857b9b313d00 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/StreamConfigurationSource.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/StreamConfigurationSource.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; using System.IO; namespace Microsoft.Extensions.Configuration @@ -13,6 +14,7 @@ public abstract class StreamConfigurationSource : IConfigurationSource /// /// The stream containing the configuration data. /// + [DisallowNull] public Stream? Stream { get; set; } /// From a45a8217121a44b44aada985560dcf9817289feb Mon Sep 17 00:00:00 2001 From: Maksym Koshovyi Date: Fri, 8 Oct 2021 18:12:30 +0300 Subject: [PATCH 11/17] Revert unnecessary changes --- .../src/ConfigurationKeyComparer.cs | 2 +- .../src/ConfigurationProvider.cs | 2 +- .../src/ConfigurationReloadToken.cs | 2 +- .../src/ConfigurationRoot.cs | 2 +- .../src/ConfigurationSection.cs | 31 +++++++++++++++---- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationKeyComparer.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationKeyComparer.cs index 981814642c440..00cca781d47f4 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationKeyComparer.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationKeyComparer.cs @@ -16,7 +16,7 @@ public class ConfigurationKeyComparer : IComparer /// /// The default instance. /// - public static ConfigurationKeyComparer Instance { get; } = new(); + public static ConfigurationKeyComparer Instance { get; } = new ConfigurationKeyComparer(); /// A comparer delegate with the default instance. internal static Comparison Comparison { get; } = Instance.Compare; diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs index 55d7adcd9f1df..9fbeded4fc3de 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationProvider.cs @@ -14,7 +14,7 @@ namespace Microsoft.Extensions.Configuration /// public abstract class ConfigurationProvider : IConfigurationProvider { - private ConfigurationReloadToken _reloadToken = new(); + private ConfigurationReloadToken _reloadToken = new ConfigurationReloadToken(); /// /// Initializes a new diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationReloadToken.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationReloadToken.cs index 0da3b1c5508f5..7aceba29fe55b 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationReloadToken.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationReloadToken.cs @@ -12,7 +12,7 @@ namespace Microsoft.Extensions.Configuration /// public class ConfigurationReloadToken : IChangeToken { - private CancellationTokenSource _cts = new(); + private CancellationTokenSource _cts = new CancellationTokenSource(); /// /// Indicates if this token will proactively raise callbacks. Callbacks are still guaranteed to be invoked, eventually. diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs index c666372dd25cf..397ef5160b1ec 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs @@ -15,7 +15,7 @@ public class ConfigurationRoot : IConfigurationRoot, IDisposable { private readonly IList _providers; private readonly IList _changeTokenRegistrations; - private ConfigurationReloadToken _changeToken = new(); + private ConfigurationReloadToken _changeToken = new ConfigurationReloadToken(); /// /// Initializes a Configuration root with a list of providers. diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationSection.cs b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationSection.cs index 411b0d70fd765..0896e587d4082 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationSection.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationSection.cs @@ -47,8 +47,15 @@ public ConfigurationSection(IConfigurationRoot root, string path) /// public string Key { - // Key is calculated lazily as last portion of Path - get => _key ??= ConfigurationPath.GetSectionKey(_path); + get + { + if (_key == null) + { + // Key is calculated lazily as last portion of Path + _key = ConfigurationPath.GetSectionKey(_path); + } + return _key; + } } /// @@ -56,8 +63,14 @@ public string Key /// public string? Value { - get => _root[Path]; - set => _root[Path] = value; + get + { + return _root[Path]; + } + set + { + _root[Path] = value; + } } /// @@ -67,8 +80,14 @@ public string? Value /// The configuration value. public string? this[string key] { - get => _root[ConfigurationPath.Combine(Path, key)]; - set => _root[ConfigurationPath.Combine(Path, key)] = value; + get + { + return _root[ConfigurationPath.Combine(Path, key)]; + } + set + { + _root[ConfigurationPath.Combine(Path, key)] = value; + } } /// From d33438a35fc6b1876e5c190e9a562ad70a4270f8 Mon Sep 17 00:00:00 2001 From: Maksym Koshovyi Date: Fri, 8 Oct 2021 18:34:17 +0300 Subject: [PATCH 12/17] More message into resources --- .../src/Resources/Strings.resx | 5 ++++- .../src/StreamConfigurationProvider.cs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Configuration/src/Resources/Strings.resx b/src/libraries/Microsoft.Extensions.Configuration/src/Resources/Strings.resx index 941bf0cc34873..8f6038211e50d 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/src/Resources/Strings.resx +++ b/src/libraries/Microsoft.Extensions.Configuration/src/Resources/Strings.resx @@ -1,4 +1,4 @@ - +