Skip to content

Commit

Permalink
Merge pull request #9435 from drewnoakes/use-normal-dictionary
Browse files Browse the repository at this point in the history
Replace immutable dictionary with mutable dictionary
  • Loading branch information
drewnoakes authored Apr 4, 2024
2 parents 4898762 + fe5a0ac commit c69d9b1
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ namespace Microsoft.VisualStudio.ProjectSystem.Properties
internal sealed class InterceptedProjectProperties : DelegatedProjectPropertiesBase, IRuleAwareProjectProperties
{
private readonly UnconfiguredProject _project;
private readonly ImmutableDictionary<string, Providers> _valueProviders;
private readonly Dictionary<string, Providers> _valueProviders = new(StringComparers.PropertyNames);

public InterceptedProjectProperties(ImmutableArray<Lazy<IInterceptingPropertyValueProvider, IInterceptingPropertyValueProviderMetadata>> valueProviders, IProjectProperties defaultProperties, UnconfiguredProject project)
: base(defaultProperties)
{
_project = project;
Requires.NotNullOrEmpty(valueProviders);

ImmutableDictionary<string, Providers>.Builder builder =
ImmutableDictionary.CreateBuilder<string, Providers>(StringComparers.PropertyNames);

foreach (Lazy<IInterceptingPropertyValueProvider, IInterceptingPropertyValueProviderMetadata> valueProvider in valueProviders)
{
Expand All @@ -31,17 +28,15 @@ public InterceptedProjectProperties(ImmutableArray<Lazy<IInterceptingPropertyVal
{
Requires.Argument(!string.IsNullOrEmpty(propertyName), nameof(valueProvider), "A null or empty property name was found");

if (!builder.TryGetValue(propertyName, out Providers? entry))
if (!_valueProviders.TryGetValue(propertyName, out Providers? entry))
{
entry = new Providers(new List<Lazy<IInterceptingPropertyValueProvider, IInterceptingPropertyValueProviderMetadata>> { valueProvider });
builder.Add(propertyName, entry);
_valueProviders.Add(propertyName, entry);
}

entry.Exports.Add(valueProvider);
}
}

_valueProviders = builder.ToImmutable();
}

public override async Task<bool> IsValueInheritedAsync(string propertyName)
Expand Down

0 comments on commit c69d9b1

Please sign in to comment.