@@ -5,6 +5,13 @@ namespace FastCloner.Code;
55
66internal static class FastClonerCache
77{
8+ internal static readonly ConcurrentDictionary < Type , bool > AlwaysIgnoredTypes = [ ] ;
9+
10+ internal static bool IsTypeIgnored ( Type type )
11+ {
12+ return AlwaysIgnoredTypes . TryGetValue ( type , out _ ) ;
13+ }
14+
815 private static readonly ClrCache < object ? > classCache = new ClrCache < object ? > ( ) ;
916 private static readonly ClrCache < object ? > structCache = new ClrCache < object ? > ( ) ;
1017 private static readonly ClrCache < object > deepClassToCache = new ClrCache < object > ( ) ;
@@ -14,7 +21,8 @@ internal static class FastClonerCache
1421 private static readonly ClrCache < Dictionary < string , Type > > ignoredEventInfoCache = new ClrCache < Dictionary < string , Type > > ( ) ;
1522 private static readonly ClrCache < List < MemberInfo > > allMembersCache = new ClrCache < List < MemberInfo > > ( ) ;
1623 private static readonly GenericClrCache < MemberInfo , bool > memberIgnoreStatusCache = new GenericClrCache < MemberInfo , bool > ( ) ;
17-
24+ private static readonly ClrCache < bool > typeContainsIgnoredMembersCache = new ClrCache < bool > ( ) ;
25+
1826 public static object ? GetOrAddField ( Type type , Func < Type , object ? > valueFactory ) => fieldCache . GetOrAdd ( type , valueFactory ) ;
1927 public static object ? GetOrAddClass ( Type type , Func < Type , object ? > valueFactory ) => classCache . GetOrAdd ( type , valueFactory ) ;
2028 public static object ? GetOrAddStructAsObject ( Type type , Func < Type , object ? > valueFactory ) => structCache . GetOrAdd ( type , valueFactory ) ;
@@ -24,6 +32,10 @@ internal static class FastClonerCache
2432 public static Dictionary < string , Type > GetOrAddIgnoredEventInfo ( Type type , Func < Type , Dictionary < string , Type > > valueFactory ) => ignoredEventInfoCache . GetOrAdd ( type , valueFactory ) ;
2533 public static List < MemberInfo > GetOrAddAllMembers ( Type type , Func < Type , List < MemberInfo > > valueFactory ) => allMembersCache . GetOrAdd ( type , valueFactory ) ;
2634 public static bool GetOrAddMemberIgnoreStatus ( MemberInfo memberInfo , Func < MemberInfo , bool > valueFactory ) => memberIgnoreStatusCache . GetOrAdd ( memberInfo , valueFactory ) ;
35+ public static bool GetOrAddTypeContainsIgnoredMembers ( Type type , Func < Type , bool > valueFactory )
36+ {
37+ return type . IsValueType && typeContainsIgnoredMembersCache . GetOrAdd ( type , valueFactory ) ;
38+ }
2739
2840 /// <summary>
2941 /// Clears the FastCloner cached reflection metadata.
0 commit comments