@@ -28,6 +28,8 @@ namespace VerifyTests;
2828public class TempDirectory :
2929 IDisposable
3030{
31+ List < string > paths ;
32+
3133 /// <summary>
3234 /// The full path to the directory.
3335 /// </summary>
@@ -58,16 +60,17 @@ public static void Init()
5860 before : ( ) =>
5961 {
6062 } ,
61- after : ( ) => paths . Value = null ) ;
63+ after : ( ) => asyncPaths . Value = null ) ;
6264
6365 VerifierSettings . GlobalScrubbers . Add ( ( scrubber , _ , _ ) =>
6466 {
65- if ( paths . Value == null )
67+ var pathsValue = asyncPaths . Value ;
68+ if ( pathsValue == null )
6669 {
6770 return ;
6871 }
6972
70- foreach ( var path in paths . Value )
73+ foreach ( var path in pathsValue )
7174 {
7275 scrubber . Replace ( path , "{TempDirectory}" ) ;
7376 }
@@ -76,7 +79,7 @@ public static void Init()
7679 Cleanup ( ) ;
7780 }
7881
79- static AsyncLocal < List < string > ? > paths = new ( ) ;
82+ static AsyncLocal < List < string > ? > asyncPaths = new ( ) ;
8083
8184 internal static void Cleanup ( )
8285 {
@@ -118,13 +121,14 @@ public TempDirectory()
118121 Path = IoPath . Combine ( RootDirectory , IoPath . GetRandomFileName ( ) ) ;
119122 Directory . CreateDirectory ( Path ) ;
120123
121- if ( paths . Value == null )
124+ paths = asyncPaths . Value ! ;
125+ if ( paths == null )
122126 {
123- paths . Value = [ Path ] ;
127+ paths = asyncPaths . Value = [ Path ] ;
124128 }
125129 else
126130 {
127- paths . Value ! . Add ( Path ) ;
131+ paths . Add ( Path ) ;
128132 }
129133 }
130134
@@ -135,7 +139,7 @@ public void Dispose()
135139 Directory . Delete ( Path , true ) ;
136140 }
137141
138- paths . Value ! . Remove ( Path ) ;
142+ paths . Remove ( Path ) ;
139143 }
140144
141145 /// <summary>
0 commit comments