22// Created by basicx-StrgV //
33// https://github.com/basicx-StrgV/ //
44//--------------------------------------------------//
5+ using System ;
6+ using WGetNET . Helper ;
7+
58namespace WGetNET
69{
710 /// <summary>
@@ -319,8 +322,16 @@ public static WinGetArguments SourceExport()
319322 /// <returns>
320323 /// The created <see cref="WGetNET.WinGetArguments"/> object.
321324 /// </returns>
325+ /// <exception cref="System.ArgumentNullException">
326+ /// A provided argument is null.
327+ /// </exception>
328+ /// <exception cref="System.ArgumentException">
329+ /// A provided argument is empty.
330+ /// </exception>
322331 public static WinGetArguments CustomCmd ( string cmd )
323332 {
333+ ArgsHelper . ThrowIfStringIsNullOrWhiteSpace ( cmd , "cmd" ) ;
334+
324335 cmd = cmd . ToLower ( ) . Trim ( ) ;
325336 if ( cmd . StartsWith ( "winget" ) )
326337 {
@@ -344,8 +355,16 @@ public static WinGetArguments CustomCmd(string cmd)
344355 /// <returns>
345356 /// The updated <see cref="WGetNET.WinGetArguments"/> object.
346357 /// </returns>
358+ /// <exception cref="System.ArgumentNullException">
359+ /// A provided argument is null.
360+ /// </exception>
361+ /// <exception cref="System.ArgumentException">
362+ /// A provided argument is empty.
363+ /// </exception>
347364 public WinGetArguments Custom ( string custom )
348365 {
366+ ArgsHelper . ThrowIfStringIsNullOrWhiteSpace ( custom , "custom" ) ;
367+
349368 _arguments += $ " { custom . ToLower ( ) . Trim ( ) } ";
350369 return this ;
351370 }
@@ -362,8 +381,16 @@ public WinGetArguments Custom(string custom)
362381 /// <returns>
363382 /// The updated <see cref="WGetNET.WinGetArguments"/> object.
364383 /// </returns>
384+ /// <exception cref="System.ArgumentNullException">
385+ /// A provided argument is null.
386+ /// </exception>
387+ /// <exception cref="System.ArgumentException">
388+ /// A provided argument is empty.
389+ /// </exception>
365390 public WinGetArguments Query ( string query )
366391 {
392+ ArgsHelper . ThrowIfStringIsNullOrWhiteSpace ( query , "query" ) ;
393+
367394 _arguments += $ " --query \" { query } \" ";
368395 return this ;
369396 }
@@ -377,8 +404,16 @@ public WinGetArguments Query(string query)
377404 /// <returns>
378405 /// The updated <see cref="WGetNET.WinGetArguments"/> object.
379406 /// </returns>
407+ /// <exception cref="System.ArgumentNullException">
408+ /// A provided argument is null.
409+ /// </exception>
410+ /// <exception cref="System.ArgumentException">
411+ /// A provided argument is empty.
412+ /// </exception>
380413 public WinGetArguments Source ( string source )
381414 {
415+ ArgsHelper . ThrowIfStringIsNullOrWhiteSpace ( source , "source" ) ;
416+
382417 _arguments += $ " --source \" { source } \" ";
383418 return this ;
384419 }
@@ -395,8 +430,16 @@ public WinGetArguments Source(string source)
395430 /// <returns>
396431 /// The updated <see cref="WGetNET.WinGetArguments"/> object.
397432 /// </returns>
433+ /// <exception cref="System.ArgumentNullException">
434+ /// A provided argument is null.
435+ /// </exception>
436+ /// <exception cref="System.ArgumentException">
437+ /// A provided argument is empty.
438+ /// </exception>
398439 public WinGetArguments File ( string file )
399440 {
441+ ArgsHelper . ThrowIfStringIsNullOrWhiteSpace ( file , "file" ) ;
442+
400443 switch ( _action )
401444 {
402445 case WinGetAction . Hash :
@@ -425,8 +468,16 @@ public WinGetArguments File(string file)
425468 /// <returns>
426469 /// The updated <see cref="WGetNET.WinGetArguments"/> object.
427470 /// </returns>
471+ /// <exception cref="System.ArgumentNullException">
472+ /// A provided argument is null.
473+ /// </exception>
474+ /// <exception cref="System.ArgumentException">
475+ /// A provided argument is empty.
476+ /// </exception>
428477 public WinGetArguments Directory ( string directory )
429478 {
479+ ArgsHelper . ThrowIfStringIsNullOrWhiteSpace ( directory , "directory" ) ;
480+
430481 // Remove backslash chars at the end of the path,
431482 // because they are not needed and will interfere with winget argument string by negating the last quotation mark char,
432483 // used for encasing the directory path.
@@ -461,8 +512,16 @@ public WinGetArguments Directory(string directory)
461512 /// <returns>
462513 /// The updated <see cref="WGetNET.WinGetArguments"/> object.
463514 /// </returns>
515+ /// <exception cref="System.ArgumentNullException">
516+ /// A provided argument is null.
517+ /// </exception>
518+ /// <exception cref="System.ArgumentException">
519+ /// A provided argument is empty.
520+ /// </exception>
464521 public WinGetArguments Enable ( string query )
465522 {
523+ ArgsHelper . ThrowIfStringIsNullOrWhiteSpace ( query , "query" ) ;
524+
466525 _arguments += $ " --enable \" { query } \" ";
467526 return this ;
468527 }
@@ -476,8 +535,16 @@ public WinGetArguments Enable(string query)
476535 /// <returns>
477536 /// The updated <see cref="WGetNET.WinGetArguments"/> object.
478537 /// </returns>
538+ /// <exception cref="System.ArgumentNullException">
539+ /// A provided argument is null.
540+ /// </exception>
541+ /// <exception cref="System.ArgumentException">
542+ /// A provided argument is empty.
543+ /// </exception>
479544 public WinGetArguments Disable ( string query )
480545 {
546+ ArgsHelper . ThrowIfStringIsNullOrWhiteSpace ( query , "query" ) ;
547+
481548 _arguments += $ " --disable \" { query } \" ";
482549 return this ;
483550 }
@@ -494,8 +561,16 @@ public WinGetArguments Disable(string query)
494561 /// <returns>
495562 /// The updated <see cref="WGetNET.WinGetArguments"/> object.
496563 /// </returns>
564+ /// <exception cref="System.ArgumentNullException">
565+ /// A provided argument is null.
566+ /// </exception>
567+ /// <exception cref="System.ArgumentException">
568+ /// A provided argument is empty.
569+ /// </exception>
497570 public WinGetArguments Name ( string name )
498571 {
572+ ArgsHelper . ThrowIfStringIsNullOrWhiteSpace ( name , "name" ) ;
573+
499574 _arguments += $ " --name \" { name } \" ";
500575 return this ;
501576 }
@@ -512,8 +587,16 @@ public WinGetArguments Name(string name)
512587 /// <returns>
513588 /// The updated <see cref="WGetNET.WinGetArguments"/> object.
514589 /// </returns>
590+ /// <exception cref="System.ArgumentNullException">
591+ /// A provided argument is null.
592+ /// </exception>
593+ /// <exception cref="System.ArgumentException">
594+ /// A provided argument is empty.
595+ /// </exception>
515596 public WinGetArguments Arg ( string arg )
516597 {
598+ ArgsHelper . ThrowIfStringIsNullOrWhiteSpace ( arg , "arg" ) ;
599+
517600 _arguments += $ " --arg \" { arg } \" ";
518601 return this ;
519602 }
@@ -530,8 +613,16 @@ public WinGetArguments Arg(string arg)
530613 /// <returns>
531614 /// The updated <see cref="WGetNET.WinGetArguments"/> object.
532615 /// </returns>
616+ /// <exception cref="System.ArgumentNullException">
617+ /// A provided argument is null.
618+ /// </exception>
619+ /// <exception cref="System.ArgumentException">
620+ /// A provided argument is empty.
621+ /// </exception>
533622 public WinGetArguments Type ( string type )
534623 {
624+ ArgsHelper . ThrowIfStringIsNullOrWhiteSpace ( type , "type" ) ;
625+
535626 _arguments += $ " --type \" { type } \" ";
536627 return this ;
537628 }
@@ -545,12 +636,40 @@ public WinGetArguments Type(string type)
545636 /// <returns>
546637 /// The updated <see cref="WGetNET.WinGetArguments"/> object.
547638 /// </returns>
639+ /// <exception cref="System.ArgumentNullException">
640+ /// A provided argument is null.
641+ /// </exception>
642+ /// <exception cref="System.ArgumentException">
643+ /// A provided argument is empty.
644+ /// </exception>
548645 public WinGetArguments Version ( string version )
549646 {
647+ ArgsHelper . ThrowIfStringIsNullOrWhiteSpace ( version , "version" ) ;
648+
550649 _arguments += $ " --version \" { version } \" ";
551650 return this ;
552651 }
553652
653+ /// <summary>
654+ /// Adds a version query to the arguments.
655+ /// </summary>
656+ /// <param name="version">
657+ /// A <see cref="System.Version"/> object containing the version to query.
658+ /// </param>
659+ /// <returns>
660+ /// The updated <see cref="WGetNET.WinGetArguments"/> object.
661+ /// </returns>
662+ /// <exception cref="System.ArgumentNullException">
663+ /// A provided argument is null.
664+ /// </exception>
665+ public WinGetArguments Version ( Version version )
666+ {
667+ ArgsHelper . ThrowIfObjectIsNull ( version , "version" ) ;
668+
669+ _arguments += $ " --version \" { version . ToString ( ) } \" ";
670+ return this ;
671+ }
672+
554673 /// <summary>
555674 /// Adds a version query to the arguments.
556675 /// </summary>
0 commit comments