@@ -29,7 +29,11 @@ public static Task InstallAsync<T>(string fileName) =>
2929 /// <param name="assembly">The assembly used to find the directory path of the project to install.</param>
3030 /// <param name="fileName">Name of the file.</param>
3131 /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
32- /// <exception cref="ArgumentNullException">The provided assembly was null.</exception>
32+ /// <exception cref="ArgumentNullException">
33+ /// <para><paramref name="assembly"/> is null. </para>
34+ /// <para>- or - </para>
35+ /// <para><paramref name="fileName"/> is null. </para>
36+ /// </exception>
3337 /// <exception cref="FileNotFoundException">A file with the specified file name was not found.</exception>
3438 public static Task InstallAsync ( Assembly assembly , string fileName )
3539 {
@@ -43,12 +47,13 @@ public static Task InstallAsync(Assembly assembly, string fileName)
4347 throw new ArgumentNullException ( nameof ( fileName ) ) ;
4448 }
4549
46- var projectFilePath = Path . GetDirectoryName ( GetFilePath ( assembly , fileName ) ) ;
47- if ( projectFilePath is null )
50+ if ( fileName . Length == 0 )
4851 {
49- throw new FileNotFoundException ( $ "{ fileName } not found .") ;
52+ throw new ArgumentException ( nameof ( fileName ) , $ "{ nameof ( fileName ) } must not be empty .") ;
5053 }
5154
55+ var projectFilePath = GetProjectFilePath ( assembly , fileName ) ;
56+
5257 return InstallAsync ( projectFilePath ) ;
5358 }
5459
@@ -59,12 +64,18 @@ public static Task InstallAsync(Assembly assembly, string fileName)
5964 /// <param name="timeout">The timeout. Defaults to one minute.</param>
6065 /// <param name="showShellWindow">if set to <c>true</c> show the shell window instead of logging to output.</param>
6166 /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
62- /// <exception cref="ArgumentException">The provided source was null or empty.</exception>
67+ /// <exception cref="ArgumentNullException">The provided <paramref name="source"/> was null.</exception>
68+ /// <exception cref="ArgumentException">The provided <paramref name="source"/> was empty.</exception>
6369 public static async Task InstallAsync ( string source , TimeSpan ? timeout = null , bool showShellWindow = false )
6470 {
65- if ( string . IsNullOrWhiteSpace ( source ) )
71+ if ( source is null )
72+ {
73+ throw new ArgumentNullException ( nameof ( source ) ) ;
74+ }
75+
76+ if ( source . Length == 0 )
6677 {
67- throw new ArgumentException ( "Empty or null." , nameof ( source ) ) ;
78+ throw new ArgumentException ( nameof ( source ) , $ " { nameof ( source ) } must not be empty." ) ;
6879 }
6980
7081 await RunDotnetCommandAsync ( $ "new --install \" { source } \" ", timeout , showShellWindow ) . ConfigureAwait ( false ) ;
@@ -96,7 +107,11 @@ public static Task UninstallAsync<T>(string fileName) =>
96107 /// <param name="assembly">The assembly used to find the directory path of the project to install.</param>
97108 /// <param name="fileName">Name of the file.</param>
98109 /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
99- /// <exception cref="ArgumentNullException">The provided assembly was null.</exception>
110+ /// <exception cref="ArgumentNullException">
111+ /// <para><paramref name="assembly"/> is null. </para>
112+ /// <para>- or - </para>
113+ /// <para><paramref name="fileName"/> is null. </para>
114+ /// </exception>
100115 /// <exception cref="FileNotFoundException">A file with the specified file name was not found.</exception>
101116 public static Task UninstallAsync ( Assembly assembly , string fileName )
102117 {
@@ -110,12 +125,13 @@ public static Task UninstallAsync(Assembly assembly, string fileName)
110125 throw new ArgumentNullException ( nameof ( fileName ) ) ;
111126 }
112127
113- var projectFilePath = Path . GetDirectoryName ( GetFilePath ( assembly , fileName ) ) ;
114- if ( projectFilePath is null )
128+ if ( fileName . Length == 0 )
115129 {
116- throw new FileNotFoundException ( $ "{ fileName } not found .") ;
130+ throw new ArgumentException ( nameof ( fileName ) , $ "{ nameof ( fileName ) } must not be empty .") ;
117131 }
118132
133+ var projectFilePath = GetProjectFilePath ( assembly , fileName ) ;
134+
119135 return UninstallAsync ( projectFilePath ) ;
120136 }
121137
@@ -126,17 +142,34 @@ public static Task UninstallAsync(Assembly assembly, string fileName)
126142 /// <param name="timeout">The timeout. Defaults to one minute.</param>
127143 /// <param name="showShellWindow">if set to <c>true</c> show the shell window instead of logging to output.</param>
128144 /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
129- /// <exception cref="ArgumentException">The provided source was null or empty.</exception>
145+ /// <exception cref="ArgumentNullException">The provided <paramref name="source"/> was null.</exception>
146+ /// <exception cref="ArgumentException">The provided <paramref name="source"/> was empty.</exception>
130147 public static async Task UninstallAsync ( string source , TimeSpan ? timeout = null , bool showShellWindow = false )
131148 {
132- if ( string . IsNullOrWhiteSpace ( source ) )
149+ if ( source is null )
150+ {
151+ throw new ArgumentNullException ( nameof ( source ) ) ;
152+ }
153+
154+ if ( source . Length == 0 )
133155 {
134- throw new ArgumentException ( "Empty or null." , nameof ( source ) ) ;
156+ throw new ArgumentException ( nameof ( source ) , $ " { nameof ( source ) } must not be empty." ) ;
135157 }
136158
137159 await RunDotnetCommandAsync ( $ "new --uninstall \" { source } \" ", timeout , showShellWindow ) . ConfigureAwait ( false ) ;
138160 }
139161
162+ private static string GetProjectFilePath ( Assembly assembly , string fileName )
163+ {
164+ var projectFilePath = Path . GetDirectoryName ( GetFilePath ( assembly , fileName ) ) ;
165+ if ( projectFilePath is null )
166+ {
167+ throw new FileNotFoundException ( $ "{ fileName } not found.") ;
168+ }
169+
170+ return projectFilePath ;
171+ }
172+
140173 private static string ? GetFilePath ( Assembly assembly , string projectName )
141174 {
142175 string ? projectFilePath = null ;
0 commit comments