@@ -825,21 +825,46 @@ public async Task GlobalConfigPublish_BumpsCacheVersion_ForSubsequentReaders()
825825 } ;
826826
827827 long startingVersion = FastClonerCache . GetCacheVersion ( ) ;
828-
829- FastCloner . MaxRecursionDepth = 999 ;
828+
829+ FastCloner . SetTypeBehavior < int > ( CloneBehavior . Reference ) ;
830830 _ = simple . DeepClone ( ) ;
831831 _ = dictionary . DeepClone ( ) ;
832832
833833 long firstMutationVersion = FastClonerCache . GetCacheVersion ( ) ;
834834 await Assert . That ( firstMutationVersion ) . IsGreaterThan ( startingVersion ) ;
835835
836- FastCloner . MaxRecursionDepth = 998 ;
836+ FastCloner . ClearTypeBehavior < int > ( ) ;
837837 _ = simple . DeepClone ( ) ;
838838 _ = dictionary . DeepClone ( ) ;
839839
840840 await Assert . That ( FastClonerCache . GetCacheVersion ( ) ) . IsGreaterThan ( firstMutationVersion ) ;
841841 }
842842
843+ [ Test ]
844+ public async Task MaxRecursionDepth_Update_Does_Not_Bump_Cache_Version ( )
845+ {
846+ FastCloner . ClearCache ( ) ;
847+ FastCloner . ClearAllTypeBehaviors ( ) ;
848+ FastCloner . SetDisableOptionalFeatures ( false ) ;
849+
850+ SimpleClass simple = new SimpleClass { IntValue = 7 , StringValue = "Seven" } ;
851+ _ = simple . DeepClone ( ) ;
852+
853+ long versionBefore = FastClonerCache . GetCacheVersion ( ) ;
854+
855+ FastCloner . MaxRecursionDepth = 999 ;
856+ SimpleClass clone1 = simple . DeepClone ( ) ;
857+
858+ FastCloner . MaxRecursionDepth = 998 ;
859+ SimpleClass clone2 = simple . DeepClone ( ) ;
860+
861+ await Assert . That ( FastClonerCache . GetCacheVersion ( ) ) . IsEqualTo ( versionBefore ) ;
862+ await Assert . That ( clone1 . IntValue ) . IsEqualTo ( 7 ) ;
863+ await Assert . That ( clone2 . IntValue ) . IsEqualTo ( 7 ) ;
864+
865+ FastCloner . MaxRecursionDepth = 1_000 ;
866+ }
867+
843868 [ Test ]
844869 public async Task RuntimeConfig_Create_DefaultValues_CanStaySingletonOrBecomeDistinctSnapshot ( )
845870 {
0 commit comments