The DictionaryExtensions type defines the following GetOrAdd method
public static TValue GetOrAdd<TKey, TValue>(
this IDictionary<TKey, TValue> dictionary,
TKey key,
Func<TValue> newValue)
where TKey : notnull
This means that it applies to ConcurrentDictionary<TKey, TValue> however the implementation of this extension method does not line up with the semantics of the actual GetOrAdd method. That method ensures that a key will only ever store a single value. The extension method though will override existing values if called concurrently.
That extension method is being called instead of the actual instance method in TestIntrospectionHelper. That is because the instance method overload that takes a delegate requires the signature Func<TKey, TValue> where as the calls in TestIntrospectionHelper pass no arguments hence go to this extension method.
Not sure this is causing an actual bug but seems incorrect.
The
DictionaryExtensionstype defines the followingGetOrAddmethodThis means that it applies to
ConcurrentDictionary<TKey, TValue>however the implementation of this extension method does not line up with the semantics of the actualGetOrAddmethod. That method ensures that a key will only ever store a single value. The extension method though will override existing values if called concurrently.That extension method is being called instead of the actual instance method in TestIntrospectionHelper. That is because the instance method overload that takes a delegate requires the signature
Func<TKey, TValue>where as the calls in TestIntrospectionHelper pass no arguments hence go to this extension method.Not sure this is causing an actual bug but seems incorrect.