2323using System . Collections . Generic ;
2424using System . Threading . Tasks ;
2525
26+ #nullable enable
27+
2628namespace OpenQA . Selenium . DevTools . V130
2729{
2830 /// <summary>
2931 /// Class containing the JavaScript implementation for version 130 of the DevTools Protocol.
3032 /// </summary>
3133 public class V130JavaScript : JavaScript
3234 {
33- private RuntimeAdapter runtime ;
34- private PageAdapter page ;
35+ private readonly RuntimeAdapter runtime ;
36+ private readonly PageAdapter page ;
3537
3638 /// <summary>
3739 /// Initializes a new instance of the <see cref="V130JavaScript"/> class.
3840 /// </summary>
3941 /// <param name="runtime">The DevTools Protocol adapter for the Runtime domain.</param>
4042 /// <param name="page">The DevTools Protocol adapter for the Page domain.</param>
43+ /// <exception cref="ArgumentNullException">If <paramref name="runtime"/> or <paramref name="page"/> are <see langword="null"/>.</exception>
4144 public V130JavaScript ( RuntimeAdapter runtime , PageAdapter page )
4245 {
43- this . runtime = runtime ;
44- this . page = page ;
46+ this . runtime = runtime ?? throw new ArgumentNullException ( nameof ( runtime ) ) ;
47+ this . page = page ?? throw new ArgumentNullException ( nameof ( page ) ) ;
4548 this . runtime . BindingCalled += OnRuntimeBindingCalled ;
4649 this . runtime . ConsoleAPICalled += OnRuntimeConsoleApiCalled ;
4750 this . runtime . ExceptionThrown += OnRuntimeExceptionThrown ;
@@ -138,7 +141,7 @@ internal override async Task Evaluate(string script)
138141 await runtime . Evaluate ( new EvaluateCommandSettings { Expression = script } ) . ConfigureAwait ( false ) ;
139142 }
140143
141- private void OnRuntimeBindingCalled ( object sender , Runtime . BindingCalledEventArgs e )
144+ private void OnRuntimeBindingCalled ( object ? sender , Runtime . BindingCalledEventArgs e )
142145 {
143146 BindingCalledEventArgs wrapped = new BindingCalledEventArgs
144147 (
@@ -150,7 +153,7 @@ private void OnRuntimeBindingCalled(object sender, Runtime.BindingCalledEventArg
150153 this . OnBindingCalled ( wrapped ) ;
151154 }
152155
153- private void OnRuntimeExceptionThrown ( object sender , Runtime . ExceptionThrownEventArgs e )
156+ private void OnRuntimeExceptionThrown ( object ? sender , Runtime . ExceptionThrownEventArgs e )
154157 {
155158 // TODO: Collect stack trace elements
156159 var wrapped = new ExceptionThrownEventArgs
@@ -162,12 +165,12 @@ private void OnRuntimeExceptionThrown(object sender, Runtime.ExceptionThrownEven
162165 this . OnExceptionThrown ( wrapped ) ;
163166 }
164167
165- private void OnRuntimeConsoleApiCalled ( object sender , ConsoleAPICalledEventArgs e )
168+ private void OnRuntimeConsoleApiCalled ( object ? sender , ConsoleAPICalledEventArgs e )
166169 {
167- List < ConsoleApiArgument > args = new List < ConsoleApiArgument > ( ) ;
170+ List < ConsoleApiArgument > args = new List < ConsoleApiArgument > ( e . Args . Length ) ;
168171 foreach ( var arg in e . Args )
169172 {
170- string argValue = arg . Value ? . ToString ( ) ;
173+ string ? argValue = arg . Value ? . ToString ( ) ;
171174 args . Add ( new ConsoleApiArgument ( arg . Type . ToString ( ) , argValue ) ) ;
172175 }
173176
0 commit comments