33
44using System . Collections ;
55using System . Collections . Generic ;
6- using System . Collections . Concurrent ;
76using System . ComponentModel . Design ;
87using System . Diagnostics ;
98using System . Diagnostics . CodeAnalysis ;
@@ -24,7 +23,7 @@ namespace System.ComponentModel
2423 internal sealed partial class ReflectTypeDescriptionProvider : TypeDescriptionProvider
2524 {
2625 // ReflectedTypeData contains all of the type information we have gathered for a given type.
27- private readonly ConcurrentDictionary < Type , ReflectedTypeData > _typeData = new ConcurrentDictionary < Type , ReflectedTypeData > ( ) ;
26+ private readonly ContextAwareConcurrentHashtable < Type , ReflectedTypeData > _typeData = new ContextAwareConcurrentHashtable < Type , ReflectedTypeData > ( ) ;
2827
2928 // This is the signature we look for when creating types that are generic, but
3029 // want to know what type they are dealing with. Enums are a good example of this;
@@ -49,10 +48,10 @@ internal sealed partial class ReflectTypeDescriptionProvider : TypeDescriptionPr
4948 // on Control, Component and object are also automatically filled
5049 // in. The keys to the property and event caches are types.
5150 // The keys to the attribute cache are either MemberInfos or types.
52- private static Hashtable ? s_propertyCache ;
53- private static Hashtable ? s_eventCache ;
54- private static Hashtable ? s_attributeCache ;
55- private static Hashtable ? s_extendedPropertyCache ;
51+ private static ContextAwareHashtable ? s_propertyCache ;
52+ private static ContextAwareHashtable ? s_eventCache ;
53+ private static ContextAwareHashtable ? s_attributeCache ;
54+ private static ContextAwareHashtable ? s_extendedPropertyCache ;
5655
5756 // These are keys we stuff into our object cache. We use this
5857 // cache data to store extender provider info for an object.
@@ -193,13 +192,13 @@ private static Dictionary<object, IntrinsicTypeConverterData> IntrinsicTypeConve
193192 Justification = "IntrinsicTypeConverters is marked with RequiresUnreferencedCode. It is the only place that should call this." ) ]
194193 private static NullableConverter CreateNullableConverter ( Type type ) => new NullableConverter ( type ) ;
195194
196- private static Hashtable PropertyCache => LazyInitializer . EnsureInitialized ( ref s_propertyCache , ( ) => new Hashtable ( ) ) ;
195+ private static ContextAwareHashtable PropertyCache => LazyInitializer . EnsureInitialized ( ref s_propertyCache , ( ) => new ContextAwareHashtable ( ) ) ;
197196
198- private static Hashtable EventCache => LazyInitializer . EnsureInitialized ( ref s_eventCache , ( ) => new Hashtable ( ) ) ;
197+ private static ContextAwareHashtable EventCache => LazyInitializer . EnsureInitialized ( ref s_eventCache , ( ) => new ContextAwareHashtable ( ) ) ;
199198
200- private static Hashtable AttributeCache => LazyInitializer . EnsureInitialized ( ref s_attributeCache , ( ) => new Hashtable ( ) ) ;
199+ private static ContextAwareHashtable AttributeCache => LazyInitializer . EnsureInitialized ( ref s_attributeCache , ( ) => new ContextAwareHashtable ( ) ) ;
201200
202- private static Hashtable ExtendedPropertyCache => LazyInitializer . EnsureInitialized ( ref s_extendedPropertyCache , ( ) => new Hashtable ( ) ) ;
201+ private static ContextAwareHashtable ExtendedPropertyCache => LazyInitializer . EnsureInitialized ( ref s_extendedPropertyCache , ( ) => new ContextAwareHashtable ( ) ) ;
203202
204203 /// <summary>Clear the global caches this maintains on top of reflection.</summary>
205204 internal static void ClearReflectionCaches ( )
@@ -982,14 +981,14 @@ private ReflectedTypeData GetTypeDataFromRegisteredType(Type type)
982981 {
983982 Type componentType = typeof ( T ) ;
984983
985- if ( _typeData . ContainsKey ( componentType ) )
984+ if ( _typeData . Contains ( componentType ) )
986985 {
987986 return ;
988987 }
989988
990989 lock ( TypeDescriptor . s_commonSyncObject )
991990 {
992- if ( _typeData . ContainsKey ( componentType ) )
991+ if ( _typeData . Contains ( componentType ) )
993992 {
994993 return ;
995994 }
@@ -1096,7 +1095,7 @@ internal bool IsPopulated(Type type)
10961095 /// </summary>
10971096 internal static Attribute [ ] ReflectGetAttributes ( Type type )
10981097 {
1099- Hashtable attributeCache = AttributeCache ;
1098+ ContextAwareHashtable attributeCache = AttributeCache ;
11001099 Attribute [ ] ? attrs = ( Attribute [ ] ? ) attributeCache [ type ] ;
11011100 if ( attrs != null )
11021101 {
@@ -1124,7 +1123,7 @@ internal static Attribute[] ReflectGetAttributes(Type type)
11241123 /// </summary>
11251124 internal static Attribute [ ] ReflectGetAttributes ( MemberInfo member )
11261125 {
1127- Hashtable attributeCache = AttributeCache ;
1126+ ContextAwareHashtable attributeCache = AttributeCache ;
11281127 Attribute [ ] ? attrs = ( Attribute [ ] ? ) attributeCache [ member ] ;
11291128 if ( attrs != null )
11301129 {
@@ -1152,7 +1151,7 @@ internal static Attribute[] ReflectGetAttributes(MemberInfo member)
11521151 /// </summary>
11531152 private static EventDescriptor [ ] ReflectGetEvents ( Type type )
11541153 {
1155- Hashtable eventCache = EventCache ;
1154+ ContextAwareHashtable eventCache = EventCache ;
11561155 EventDescriptor [ ] ? events = ( EventDescriptor [ ] ? ) eventCache [ type ] ;
11571156 if ( events != null )
11581157 {
@@ -1252,7 +1251,7 @@ private static PropertyDescriptor[] ReflectGetExtendedProperties(IExtenderProvid
12521251 // property store.
12531252 //
12541253 Type providerType = provider . GetType ( ) ;
1255- Hashtable extendedPropertyCache = ExtendedPropertyCache ;
1254+ ContextAwareHashtable extendedPropertyCache = ExtendedPropertyCache ;
12561255 ReflectPropertyDescriptor [ ] ? extendedProperties = ( ReflectPropertyDescriptor [ ] ? ) extendedPropertyCache [ providerType ] ;
12571256 if ( extendedProperties == null )
12581257 {
@@ -1337,7 +1336,7 @@ private static PropertyDescriptor[] ReflectGetPropertiesFromRegisteredType(Type
13371336
13381337 private static PropertyDescriptor [ ] ReflectGetPropertiesImpl ( Type type )
13391338 {
1340- Hashtable propertyCache = PropertyCache ;
1339+ ContextAwareHashtable propertyCache = PropertyCache ;
13411340 PropertyDescriptor [ ] ? properties = ( PropertyDescriptor [ ] ? ) propertyCache [ type ] ;
13421341 if ( properties != null )
13431342 {
0 commit comments