CanRead/WriteProperty methods not thread-safe
description
Following code is not thread-safe. Adding to _readResultsCache must be synchronized. This is true for CanReadProperty, CanWriteProperty and CanExecuteMethod methods. [EditorBrowsable(EditorBrowsableState.Advanced)] public virtual bool CanReadProperty(string propertyName) { bool result = true; VerifyAuthorizationCache(); if (!_readResultCache.TryGetValue(propertyName, out result)) { result = true; if (AuthorizationRules.HasReadAllowedRoles(propertyName)) { // some users are explicitly granted read access // in which case all other users are denied if (!AuthorizationRules.IsReadAllowed(propertyName)) result = false; } else if (AuthorizationRules.HasReadDeniedRoles(propertyName)) { // some users are explicitly denied read access if (AuthorizationRules.IsReadDenied(propertyName)) result = false; } // store value in cache _readResultCache.Add(propertyName, result); } return result; } Below is a partial stack-trace. An item with the same key has already been added.at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at Csla.Core.BusinessBase.CanReadProperty(String propertyName) at Csla.Core.BusinessBase.CanReadProperty(String propertyName, Boolean throwOnFalse) at Csla.Core.BusinessBase.GetProperty[P](PropertyInfo1 propertyInfo, NoAccessBehavior noAccess) at Csla.Core.BusinessBase.GetProperty[P](PropertyInfo`1 propertyInfo) .......