2424using System . Text ;
2525using System . Threading . Tasks ;
2626
27+ #nullable enable
28+
2729namespace OpenQA . Selenium . DevTools . V130
2830{
2931 /// <summary>
@@ -39,10 +41,11 @@ public class V130Network : DevTools.Network
3941 /// </summary>
4042 /// <param name="network">The adapter for the Network domain.</param>
4143 /// <param name="fetch">The adapter for the Fetch domain.</param>
44+ /// <exception cref="ArgumentNullException">If <paramref name="network"/> or <paramref name="fetch"/> are <see langword="null"/>.</exception>
4245 public V130Network ( NetworkAdapter network , FetchAdapter fetch )
4346 {
44- this . network = network ;
45- this . fetch = fetch ;
47+ this . network = network ?? throw new ArgumentNullException ( nameof ( network ) ) ;
48+ this . fetch = fetch ?? throw new ArgumentNullException ( nameof ( fetch ) ) ;
4649 fetch . AuthRequired += OnFetchAuthRequired ;
4750 fetch . RequestPaused += OnFetchRequestPaused ;
4851 }
@@ -101,7 +104,7 @@ await fetch.Enable(new Fetch.EnableCommandSettings()
101104 }
102105
103106 /// <summary>
104- /// Asynchronously diables the fetch domain.
107+ /// Asynchronously disables the fetch domain.
105108 /// </summary>
106109 /// <returns>A task that represents the asynchronous operation.</returns>
107110 public override async Task DisableFetch ( )
@@ -114,8 +117,14 @@ public override async Task DisableFetch()
114117 /// </summary>
115118 /// <param name="userAgent">A <see cref="UserAgent"/> object containing the user agent values to override.</param>
116119 /// <returns>A task that represents the asynchronous operation.</returns>
120+ /// <exception cref="ArgumentNullException">If <paramref name="userAgent"/> is null.</exception>
117121 public override async Task SetUserAgentOverride ( UserAgent userAgent )
118122 {
123+ if ( userAgent is null )
124+ {
125+ throw new ArgumentNullException ( nameof ( userAgent ) ) ;
126+ }
127+
119128 await network . SetUserAgentOverride ( new SetUserAgentOverrideCommandSettings ( )
120129 {
121130 UserAgent = userAgent . UserAgentString ,
@@ -129,8 +138,14 @@ await network.SetUserAgentOverride(new SetUserAgentOverrideCommandSettings()
129138 /// </summary>
130139 /// <param name="requestData">The <see cref="HttpRequestData"/> of the request.</param>
131140 /// <returns>A task that represents the asynchronous operation.</returns>
141+ /// <exception cref="ArgumentNullException">If <paramref name="requestData"/> is <see langword="null"/>.</exception>
132142 public override async Task ContinueRequest ( HttpRequestData requestData )
133143 {
144+ if ( requestData is null )
145+ {
146+ throw new ArgumentNullException ( nameof ( requestData ) ) ;
147+ }
148+
134149 var commandSettings = new ContinueRequestCommandSettings ( )
135150 {
136151 RequestId = requestData . RequestId ,
@@ -163,8 +178,19 @@ public override async Task ContinueRequest(HttpRequestData requestData)
163178 /// <param name="requestData">The <see cref="HttpRequestData"/> of the request.</param>
164179 /// <param name="responseData">The <see cref="HttpResponseData"/> with which to respond to the request</param>
165180 /// <returns>A task that represents the asynchronous operation.</returns>
181+ /// <exception cref="ArgumentNullException">If <paramref name="requestData"/> or <paramref name="responseData"/> are <see langword="null"/>.</exception>
166182 public override async Task ContinueRequestWithResponse ( HttpRequestData requestData , HttpResponseData responseData )
167183 {
184+ if ( requestData is null )
185+ {
186+ throw new ArgumentNullException ( nameof ( requestData ) ) ;
187+ }
188+
189+ if ( responseData is null )
190+ {
191+ throw new ArgumentNullException ( nameof ( responseData ) ) ;
192+ }
193+
168194 var commandSettings = new FulfillRequestCommandSettings ( )
169195 {
170196 RequestId = requestData . RequestId ,
@@ -196,12 +222,18 @@ public override async Task ContinueRequestWithResponse(HttpRequestData requestDa
196222 }
197223
198224 /// <summary>
199- /// Asynchronously contines an intercepted network call without modification.
225+ /// Asynchronously continues an intercepted network call without modification.
200226 /// </summary>
201227 /// <param name="requestData">The <see cref="HttpRequestData"/> of the network call.</param>
202228 /// <returns>A task that represents the asynchronous operation.</returns>
229+ /// <exception cref="ArgumentNullException">If <paramref name="requestData"/> is <see langword="null"/>.</exception>
203230 public override async Task ContinueRequestWithoutModification ( HttpRequestData requestData )
204231 {
232+ if ( requestData is null )
233+ {
234+ throw new ArgumentNullException ( nameof ( requestData ) ) ;
235+ }
236+
205237 await fetch . ContinueRequest ( new ContinueRequestCommandSettings ( ) { RequestId = requestData . RequestId } ) . ConfigureAwait ( false ) ;
206238 }
207239
@@ -212,7 +244,7 @@ public override async Task ContinueRequestWithoutModification(HttpRequestData re
212244 /// <param name="userName">The user name with which to authenticate.</param>
213245 /// <param name="password">The password with which to authenticate.</param>
214246 /// <returns>A task that represents the asynchronous operation.</returns>
215- public override async Task ContinueWithAuth ( string requestId , string userName , string password )
247+ public override async Task ContinueWithAuth ( string requestId , string ? userName , string ? password )
216248 {
217249 await fetch . ContinueWithAuth ( new ContinueWithAuthCommandSettings ( )
218250 {
@@ -248,8 +280,14 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings()
248280 /// </summary>
249281 /// <param name="responseData">The <see cref="HttpResponseData"/> object to which to add the response body.</param>
250282 /// <returns>A task that represents the asynchronous operation.</returns>
283+ /// <exception cref="ArgumentNullException">If <paramref name="responseData"/> is <see langword="null"/>.</exception>
251284 public override async Task AddResponseBody ( HttpResponseData responseData )
252285 {
286+ if ( responseData is null )
287+ {
288+ throw new ArgumentNullException ( nameof ( responseData ) ) ;
289+ }
290+
253291 // If the response is a redirect, retrieving the body will throw an error in CDP.
254292 if ( responseData . StatusCode < 300 || responseData . StatusCode > 399 )
255293 {
@@ -273,12 +311,18 @@ public override async Task AddResponseBody(HttpResponseData responseData)
273311 /// </summary>
274312 /// <param name="responseData">The <see cref="HttpResponseData"/> of the network response.</param>
275313 /// <returns>A task that represents the asynchronous operation.</returns>
314+ /// <exception cref="ArgumentNullException">If <paramref name="responseData"/> is <see langword="null"/>.</exception>
276315 public override async Task ContinueResponseWithoutModification ( HttpResponseData responseData )
277316 {
317+ if ( responseData is null )
318+ {
319+ throw new ArgumentNullException ( nameof ( responseData ) ) ;
320+ }
321+
278322 await fetch . ContinueResponse ( new ContinueResponseCommandSettings ( ) { RequestId = responseData . RequestId } ) . ConfigureAwait ( false ) ;
279323 }
280324
281- private void OnFetchAuthRequired ( object sender , Fetch . AuthRequiredEventArgs e )
325+ private void OnFetchAuthRequired ( object ? sender , Fetch . AuthRequiredEventArgs e )
282326 {
283327 AuthRequiredEventArgs wrapped = new AuthRequiredEventArgs
284328 (
@@ -289,7 +333,7 @@ private void OnFetchAuthRequired(object sender, Fetch.AuthRequiredEventArgs e)
289333 this . OnAuthRequired ( wrapped ) ;
290334 }
291335
292- private void OnFetchRequestPaused ( object sender , Fetch . RequestPausedEventArgs e )
336+ private void OnFetchRequestPaused ( object ? sender , Fetch . RequestPausedEventArgs e )
293337 {
294338 if ( e . ResponseErrorReason == null && e . ResponseStatusCode == null )
295339 {
0 commit comments