2121using  System . Collections . Generic ; 
2222using  System . Globalization ; 
2323
24+ #nullable enable
25+ 
2426namespace  OpenQA . Selenium 
2527{ 
2628    /// <summary> 
@@ -56,6 +58,7 @@ protected CommandInfoRepository()
5658        /// </summary> 
5759        /// <param name="commandName">The name of the command to check.</param> 
5860        /// <returns><see langword="true"/> if the command name is defined</returns> 
61+         /// <exception cref="ArgumentNullException">If <paramref name="commandName"/> is <see langword="null"/>.</exception> 
5962        public  bool  IsCommandNameDefined ( string  commandName ) 
6063        { 
6164            return  this . commandDictionary . ContainsKey ( commandName ) ; 
@@ -66,7 +69,7 @@ public bool IsCommandNameDefined(string commandName)
6669        /// </summary> 
6770        /// <param name="commandInfo">The <see cref="CommandInfo"/> object for which to find the command name.</param> 
6871        /// <returns>The name of the command defined by the command info, or <see langword="null"/> if the command is not defined.</returns> 
69-         public  string  FindCommandName ( CommandInfo  commandInfo ) 
72+         public  string ?  FindCommandName ( CommandInfo  commandInfo ) 
7073        { 
7174            foreach  ( KeyValuePair < string ,  CommandInfo >  pair  in  this . commandDictionary ) 
7275            { 
@@ -83,13 +86,13 @@ public string FindCommandName(CommandInfo commandInfo)
8386        /// Gets the <see cref="HttpCommandInfo"/> for a <see cref="DriverCommand"/>. 
8487        /// </summary> 
8588        /// <param name="commandName">The <see cref="DriverCommand"/> for which to get the information.</param> 
86-         /// <returns>The <see cref="HttpCommandInfo"/> for the specified command.</returns> 
87-         public  T  GetCommandInfo < T > ( string  commandName )  where  T  :  CommandInfo 
89+         /// <returns>The <see cref="HttpCommandInfo"/> for the specified command, or <see langword="null"/> if not found or value is not <typeparamref name="T"/> .</returns> 
90+         public  T ?  GetCommandInfo < T > ( string  commandName )  where  T  :  CommandInfo 
8891        { 
89-             T  toReturn  =  default ( T ) ; 
90-             if  ( this . commandDictionary . ContainsKey ( commandName ) ) 
92+             T ?  toReturn  =  default ; 
93+             if  ( this . commandDictionary . TryGetValue ( commandName ,   out   CommandInfo ?   info ) ) 
9194            { 
92-                 toReturn  =  this . commandDictionary [ commandName ]  as  T ; 
95+                 toReturn  =  info  as  T ; 
9396            } 
9497
9598            return  toReturn ; 
@@ -106,6 +109,12 @@ public T GetCommandInfo<T>(string commandName) where T : CommandInfo
106109        /// This method will not overwrite existing commands for a specific name, and will return <see langword="false"/> 
107110        /// in that case. 
108111        /// </remarks> 
112+         /// <exception cref="ArgumentNullException"> 
113+         /// <para>If <paramref name="commandName"/> is <see langword="null"/> or <see cref="string.Empty"/>.</para> 
114+         /// <para>-or-</para> 
115+         /// <para>If <paramref name="commandInfo"/> is <see langword="null"/>.</para> 
116+         /// </exception> 
117+         /// <exception cref="ArgumentException">If <typeparamref name="T"/> is not a valid command type for this repository.</exception> 
109118        public  bool  TryAddCommand < T > ( string  commandName ,  T  commandInfo )  where  T  :  CommandInfo 
110119        { 
111120            if  ( string . IsNullOrEmpty ( commandName ) ) 
0 commit comments