2121using System ;
2222using System . Collections . Generic ;
2323using System . Collections . ObjectModel ;
24+ using System . Diagnostics . CodeAnalysis ;
2425using System . Globalization ;
2526using System . IO ;
2627using System . IO . Compression ;
2728using System . Threading . Tasks ;
2829
30+ #nullable enable
31+
2932namespace OpenQA . Selenium . Firefox
3033{
3134 /// <summary>
@@ -109,7 +112,7 @@ public class FirefoxDriver : WebDriver, IDevTools
109112 { GetFullPageScreenshotCommand , new HttpCommandInfo ( HttpCommandInfo . GetCommand , "/session/{sessionId}/moz/screenshot/full" ) }
110113 } ;
111114
112- private DevToolsSession devToolsSession ;
115+ private DevToolsSession ? devToolsSession ;
113116
114117 /// <summary>
115118 /// Initializes a new instance of the <see cref="FirefoxDriver"/> class.
@@ -246,6 +249,7 @@ public override IFileDetector FileDetector
246249 /// <summary>
247250 /// Gets a value indicating whether a DevTools session is active.
248251 /// </summary>
252+ [ MemberNotNullWhen ( true , nameof ( devToolsSession ) ) ]
249253 public bool HasActiveDevToolsSession
250254 {
251255 get { return this . devToolsSession != null ; }
@@ -259,7 +263,7 @@ public bool HasActiveDevToolsSession
259263 public FirefoxCommandContext GetContext ( )
260264 {
261265 FirefoxCommandContext output ;
262- string response = this . Execute ( GetContextCommand , null ) . Value . ToString ( ) ;
266+ string ? response = this . Execute ( GetContextCommand , null ) . Value . ToString ( ) ;
263267
264268 bool success = Enum . TryParse < FirefoxCommandContext > ( response , true , out output ) ;
265269 if ( ! success )
@@ -287,6 +291,12 @@ public void SetContext(FirefoxCommandContext context)
287291 /// </summary>
288292 /// <param name="addOnDirectoryToInstall">Full path of the directory of the add-on to install.</param>
289293 /// <param name="temporary">Whether the add-on is temporary; required for unsigned add-ons.</param>
294+ /// <returns>The add-on ID.</returns>
295+ /// <exception cref="ArgumentException">
296+ /// <para>If <paramref name="addOnDirectoryToInstall"/> is null or empty.</para>
297+ /// or
298+ /// <para>If the directory at <paramref name="addOnDirectoryToInstall"/> does not exist.</para>
299+ /// </exception>
290300 public string InstallAddOnFromDirectory ( string addOnDirectoryToInstall , bool temporary = false )
291301 {
292302 if ( string . IsNullOrEmpty ( addOnDirectoryToInstall ) )
@@ -310,6 +320,12 @@ public string InstallAddOnFromDirectory(string addOnDirectoryToInstall, bool tem
310320 /// </summary>
311321 /// <param name="addOnFileToInstall">Full path and file name of the add-on to install.</param>
312322 /// <param name="temporary">Whether the add-on is temporary; required for unsigned add-ons.</param>
323+ /// <returns>The add-on ID.</returns>
324+ /// <exception cref="ArgumentNullException">
325+ /// <para>If <paramref name="addOnFileToInstall"/> is null or empty.</para>
326+ /// or
327+ /// <para>If the file at <paramref name="addOnFileToInstall"/> does not exist.</para>
328+ /// </exception>
313329 public string InstallAddOnFromFile ( string addOnFileToInstall , bool temporary = false )
314330 {
315331 if ( string . IsNullOrEmpty ( addOnFileToInstall ) )
@@ -333,6 +349,8 @@ public string InstallAddOnFromFile(string addOnFileToInstall, bool temporary = f
333349 /// </summary>
334350 /// <param name="base64EncodedAddOn">The base64-encoded string representation of the add-on binary.</param>
335351 /// <param name="temporary">Whether the add-on is temporary; required for unsigned add-ons.</param>
352+ /// <returns>The add-on ID.</returns>
353+ /// <exception cref="ArgumentNullException">If <paramref name="base64EncodedAddOn"/> is null or empty.</exception>
336354 public string InstallAddOn ( string base64EncodedAddOn , bool temporary = false )
337355 {
338356 if ( string . IsNullOrEmpty ( base64EncodedAddOn ) )
@@ -353,6 +371,7 @@ public string InstallAddOn(string base64EncodedAddOn, bool temporary = false)
353371 /// Uninstalls a Firefox add-on.
354372 /// </summary>
355373 /// <param name="addOnId">The ID of the add-on to uninstall.</param>
374+ /// <exception cref="ArgumentNullException">If <paramref name="addOnId"/> is null or empty.</exception>
356375 public void UninstallAddOn ( string addOnId )
357376 {
358377 if ( string . IsNullOrEmpty ( addOnId ) )
@@ -372,7 +391,7 @@ public void UninstallAddOn(string addOnId)
372391 public Screenshot GetFullPageScreenshot ( )
373392 {
374393 Response screenshotResponse = this . Execute ( GetFullPageScreenshotCommand , null ) ;
375- string base64 = screenshotResponse . Value . ToString ( ) ;
394+ string base64 = screenshotResponse . Value . ToString ( ) ! ;
376395 return new Screenshot ( base64 ) ;
377396 }
378397
0 commit comments