@@ -1123,7 +1123,9 @@ public virtual void EmbeddingOfCustomReferenceTypeWithField()
1123
1123
// Arrange
1124
1124
Type defaultLoggerType = typeof ( DefaultLogger ) ;
1125
1125
Type throwExceptionLoggerType = typeof ( ThrowExceptionLogger ) ;
1126
- const string updateCode = "DefaultLogger.Current = new ThrowExceptionLogger();" ;
1126
+ const string updateCode = @"var oldLogger = DefaultLogger.Current;
1127
+ DefaultLogger.Current = new ThrowExceptionLogger();" ;
1128
+ const string rollbackCode = "DefaultLogger.Current = oldLogger;" ;
1127
1129
1128
1130
const string input = "DefaultLogger.Current.ToString()" ;
1129
1131
const string targetOutput = "[throw exception logger]" ;
@@ -1135,9 +1137,13 @@ public virtual void EmbeddingOfCustomReferenceTypeWithField()
1135
1137
{
1136
1138
jsEngine . EmbedHostType ( "DefaultLogger" , defaultLoggerType ) ;
1137
1139
jsEngine . EmbedHostType ( "ThrowExceptionLogger" , throwExceptionLoggerType ) ;
1138
- jsEngine . Execute ( updateCode ) ;
1139
1140
1140
- output = jsEngine . Evaluate < string > ( input ) ;
1141
+ lock ( DefaultLogger . SyncRoot )
1142
+ {
1143
+ jsEngine . Execute ( updateCode ) ;
1144
+ output = jsEngine . Evaluate < string > ( input ) ;
1145
+ jsEngine . Execute ( rollbackCode ) ;
1146
+ }
1141
1147
}
1142
1148
1143
1149
// Assert
@@ -1230,7 +1236,9 @@ public virtual void EmbeddingOfCustomReferenceTypeWithProperty()
1230
1236
{
1231
1237
// Arrange
1232
1238
Type bundleTableType = typeof ( BundleTable ) ;
1233
- const string updateCode = "BundleTable.EnableOptimizations = false;" ;
1239
+ const string updateCode = @"var oldEnableOptimizationsValue = BundleTable.EnableOptimizations;
1240
+ BundleTable.EnableOptimizations = false;" ;
1241
+ const string rollbackCode = "BundleTable.EnableOptimizations = oldEnableOptimizationsValue;" ;
1234
1242
1235
1243
const string input = "BundleTable.EnableOptimizations" ;
1236
1244
const bool targetOutput = false ;
@@ -1241,9 +1249,13 @@ public virtual void EmbeddingOfCustomReferenceTypeWithProperty()
1241
1249
using ( var jsEngine = CreateJsEngine ( ) )
1242
1250
{
1243
1251
jsEngine . EmbedHostType ( "BundleTable" , bundleTableType ) ;
1244
- jsEngine . Execute ( updateCode ) ;
1245
1252
1246
- output = jsEngine . Evaluate < bool > ( input ) ;
1253
+ lock ( BundleTable . SyncRoot )
1254
+ {
1255
+ jsEngine . Execute ( updateCode ) ;
1256
+ output = jsEngine . Evaluate < bool > ( input ) ;
1257
+ jsEngine . Execute ( rollbackCode ) ;
1258
+ }
1247
1259
}
1248
1260
1249
1261
// Assert
0 commit comments