@@ -40,7 +40,7 @@ public class JavaScriptEngine : IJavaScriptEngine
4040 private Lazy < DevToolsSession > session ;
4141 private Dictionary < string , InitializationScript > initializationScripts = new Dictionary < string , InitializationScript > ( ) ;
4242 private Dictionary < string , PinnedScript > pinnedScripts = new Dictionary < string , PinnedScript > ( ) ;
43- private List < string > bindings = new List < string > ( ) ;
43+ private HashSet < string > bindings = new HashSet < string > ( ) ;
4444 private bool isEnabled = false ;
4545 private bool isDisposed = false ;
4646
@@ -271,7 +271,7 @@ public async Task UnpinScript(PinnedScript script)
271271 /// <returns>A task that represents the asynchronous operation.</returns>
272272 public async Task AddScriptCallbackBinding ( string bindingName )
273273 {
274- if ( this . bindings . Contains ( bindingName ) )
274+ if ( ! this . bindings . Add ( bindingName ) )
275275 {
276276 throw new ArgumentException ( string . Format ( CultureInfo . InvariantCulture , "A binding named {0} has already been added" , bindingName ) ) ;
277277 }
@@ -288,7 +288,7 @@ public async Task AddScriptCallbackBinding(string bindingName)
288288 public async Task RemoveScriptCallbackBinding ( string bindingName )
289289 {
290290 await this . session . Value . Domains . JavaScript . RemoveBinding ( bindingName ) . ConfigureAwait ( false ) ;
291- this . bindings . Remove ( bindingName ) ;
291+ _ = this . bindings . Remove ( bindingName ) ;
292292 }
293293
294294 /// <summary>
0 commit comments