Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert non-nullable changes
  • Loading branch information
maxkoshevoi committed Jan 13, 2022
commit 261c901dc79de9ec8c8f261a3df359d860770159
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class OptionsCache<[DynamicallyAccessedMembers(Options.DynamicallyAccesse
IOptionsMonitorCache<TOptions>
where TOptions : class
{
private readonly ConcurrentDictionary<string, Lazy<TOptions>> _cache = new(concurrencyLevel: 1, capacity: 31, StringComparer.Ordinal); // 31 == default capacity
private readonly ConcurrentDictionary<string, Lazy<TOptions>> _cache = new ConcurrentDictionary<string, Lazy<TOptions>>(concurrencyLevel: 1, capacity: 31, StringComparer.Ordinal); // 31 == default capacity

/// <summary>
/// Clears all options instances from the cache.
Expand All @@ -35,7 +35,7 @@ public virtual TOptions GetOrAdd(string? name, Func<TOptions> createOptions)
throw new ArgumentNullException(nameof(createOptions));
}

name ??= Options.DefaultName;
name = name ?? Options.DefaultName;
Lazy<TOptions>? value;

#if NETSTANDARD2_1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class OptionsManager<[DynamicallyAccessedMembers(Options.DynamicallyAcces
where TOptions : class
{
private readonly IOptionsFactory<TOptions> _factory;
private readonly OptionsCache<TOptions> _cache = new(); // Note: this is a private cache
private readonly OptionsCache<TOptions> _cache = new OptionsCache<TOptions>(); // Note: this is a private cache

/// <summary>
/// Initializes a new instance with the specified options configurations.
Expand All @@ -36,7 +36,7 @@ public OptionsManager(IOptionsFactory<TOptions> factory)
/// </summary>
public virtual TOptions Get(string? name)
{
name ??= Options.DefaultName;
name = name ?? Options.DefaultName;

if (!_cache.TryGetValue(name, out TOptions? options))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void RegisterSource(IOptionsChangeTokenSource<TOptions> source)

private void InvokeChanged(string? name)
{
name ??= Options.DefaultName;
name = name ?? Options.DefaultName;
_cache.TryRemove(name);
TOptions options = Get(name);
if (_onChange != null)
Expand All @@ -85,7 +85,7 @@ public TOptions CurrentValue
/// </summary>
public virtual TOptions Get(string? name)
{
name ??= Options.DefaultName;
name = name ?? Options.DefaultName;
return _cache.GetOrAdd(name, () => _factory.Create(name));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public class ValidateOptionsResult
/// <summary>
/// Result when validation was skipped due to name not matching.
/// </summary>
public static readonly ValidateOptionsResult Skip = new() { Skipped = true };
public static readonly ValidateOptionsResult Skip = new ValidateOptionsResult() { Skipped = true };

/// <summary>
/// Validation was successful.
/// </summary>
public static readonly ValidateOptionsResult Success = new() { Succeeded = true };
public static readonly ValidateOptionsResult Success = new ValidateOptionsResult() { Succeeded = true };

/// <summary>
/// True if validation was successful.
Expand Down