@@ -65,7 +65,6 @@ public virtual bool CloseStandardInput()
6565 /// </summary>
6666 internal sealed class ProcessOutput : IDisposable
6767 {
68- private readonly Process process ;
6968 private readonly string arguments ;
7069 private readonly List < string > output , error ;
7170 private ManualResetEvent waitHandleEvent ;
@@ -409,30 +408,30 @@ private ProcessOutput(Process process, Redirector redirector)
409408 this . error = new List < string > ( ) ;
410409 }
411410
412- this . process = process ;
413- if ( this . process . StartInfo . RedirectStandardOutput )
411+ this . Process = process ;
412+ if ( this . Process . StartInfo . RedirectStandardOutput )
414413 {
415- this . process . OutputDataReceived += this . OnOutputDataReceived ;
414+ this . Process . OutputDataReceived += this . OnOutputDataReceived ;
416415 }
417- if ( this . process . StartInfo . RedirectStandardError )
416+ if ( this . Process . StartInfo . RedirectStandardError )
418417 {
419- this . process . ErrorDataReceived += this . OnErrorDataReceived ;
418+ this . Process . ErrorDataReceived += this . OnErrorDataReceived ;
420419 }
421420
422- if ( ! this . process . StartInfo . RedirectStandardOutput && ! this . process . StartInfo . RedirectStandardError )
421+ if ( ! this . Process . StartInfo . RedirectStandardOutput && ! this . Process . StartInfo . RedirectStandardError )
423422 {
424423 // If we are receiving output events, we signal that the process
425424 // has exited when one of them receives null. Otherwise, we have
426425 // to listen for the Exited event.
427426 // If we just listen for the Exited event, we may receive it
428427 // before all the output has arrived.
429- this . process . Exited += this . OnExited ;
428+ this . Process . Exited += this . OnExited ;
430429 }
431- this . process . EnableRaisingEvents = true ;
430+ this . Process . EnableRaisingEvents = true ;
432431
433432 try
434433 {
435- this . process . Start ( ) ;
434+ this . Process . Start ( ) ;
436435 }
437436 catch ( Exception ex )
438437 {
@@ -451,28 +450,28 @@ private ProcessOutput(Process process, Redirector redirector)
451450 {
452451 this . error . AddRange ( SplitLines ( ex . ToString ( ) ) ) ;
453452 }
454- this . process = null ;
453+ this . Process = null ;
455454 }
456455
457- if ( this . process != null )
456+ if ( this . Process != null )
458457 {
459- if ( this . process . StartInfo . RedirectStandardOutput )
458+ if ( this . Process . StartInfo . RedirectStandardOutput )
460459 {
461- this . process . BeginOutputReadLine ( ) ;
460+ this . Process . BeginOutputReadLine ( ) ;
462461 }
463- if ( this . process . StartInfo . RedirectStandardError )
462+ if ( this . Process . StartInfo . RedirectStandardError )
464463 {
465- this . process . BeginErrorReadLine ( ) ;
464+ this . Process . BeginErrorReadLine ( ) ;
466465 }
467466
468- if ( this . process . StartInfo . RedirectStandardInput )
467+ if ( this . Process . StartInfo . RedirectStandardInput )
469468 {
470469 // Close standard input so that we don't get stuck trying to read input from the user.
471470 if ( this . redirector == null || ( this . redirector != null && this . redirector . CloseStandardInput ( ) ) )
472471 {
473472 try
474473 {
475- this . process . StandardInput . Close ( ) ;
474+ this . Process . StandardInput . Close ( ) ;
476475 }
477476 catch ( InvalidOperationException )
478477 {
@@ -496,11 +495,11 @@ private void OnOutputDataReceived(object sender, DataReceivedEventArgs e)
496495 lock ( this . seenNullLock )
497496 {
498497 this . seenNullInOutput = true ;
499- shouldExit = this . seenNullInError || ! this . process . StartInfo . RedirectStandardError ;
498+ shouldExit = this . seenNullInError || ! this . Process . StartInfo . RedirectStandardError ;
500499 }
501500 if ( shouldExit )
502501 {
503- OnExited ( this . process , EventArgs . Empty ) ;
502+ OnExited ( this . Process , EventArgs . Empty ) ;
504503 }
505504 }
506505 else if ( ! string . IsNullOrEmpty ( e . Data ) )
@@ -532,11 +531,11 @@ private void OnErrorDataReceived(object sender, DataReceivedEventArgs e)
532531 lock ( this . seenNullLock )
533532 {
534533 this . seenNullInError = true ;
535- shouldExit = this . seenNullInOutput || ! this . process . StartInfo . RedirectStandardOutput ;
534+ shouldExit = this . seenNullInOutput || ! this . Process . StartInfo . RedirectStandardOutput ;
536535 }
537536 if ( shouldExit )
538537 {
539- OnExited ( this . process , EventArgs . Empty ) ;
538+ OnExited ( this . Process , EventArgs . Empty ) ;
540539 }
541540 }
542541 else if ( ! string . IsNullOrEmpty ( e . Data ) )
@@ -555,7 +554,9 @@ private void OnErrorDataReceived(object sender, DataReceivedEventArgs e)
555554 }
556555 }
557556
558- public int ? ProcessId => this . IsStarted ? this . process . Id : ( int ? ) null ;
557+ public int ? ProcessId => this . IsStarted ? this . Process . Id : ( int ? ) null ;
558+
559+ public Process Process { get ; }
559560
560561 /// <summary>
561562 /// The arguments that were originally passed, including the filename.
@@ -565,7 +566,7 @@ private void OnErrorDataReceived(object sender, DataReceivedEventArgs e)
565566 /// <summary>
566567 /// True if the process started. False if an error occurred.
567568 /// </summary>
568- public bool IsStarted => this . process != null ;
569+ public bool IsStarted => this . Process != null ;
569570
570571 /// <summary>
571572 /// The exit code or null if the process never started or has not
@@ -575,11 +576,11 @@ public int? ExitCode
575576 {
576577 get
577578 {
578- if ( this . process == null || ! this . process . HasExited )
579+ if ( this . Process == null || ! this . Process . HasExited )
579580 {
580581 return null ;
581582 }
582- return this . process . ExitCode ;
583+ return this . Process . ExitCode ;
583584 }
584585 }
585586
@@ -590,11 +591,11 @@ public ProcessPriorityClass PriorityClass
590591 {
591592 get
592593 {
593- if ( this . process != null && ! this . process . HasExited )
594+ if ( this . Process != null && ! this . Process . HasExited )
594595 {
595596 try
596597 {
597- return this . process . PriorityClass ;
598+ return this . Process . PriorityClass ;
598599 }
599600 catch ( Win32Exception )
600601 {
@@ -609,11 +610,11 @@ public ProcessPriorityClass PriorityClass
609610 }
610611 set
611612 {
612- if ( this . process != null && ! this . process . HasExited )
613+ if ( this . Process != null && ! this . Process . HasExited )
613614 {
614615 try
615616 {
616- this . process . PriorityClass = value ;
617+ this . Process . PriorityClass = value ;
617618 }
618619 catch ( Win32Exception )
619620 {
@@ -640,34 +641,34 @@ public void WriteInputLine(string line)
640641 {
641642 if ( IsStarted && redirector != null && ! redirector . CloseStandardInput ( ) )
642643 {
643- process . StandardInput . WriteLine ( line ) ;
644- process . StandardInput . Flush ( ) ;
644+ Process . StandardInput . WriteLine ( line ) ;
645+ Process . StandardInput . Flush ( ) ;
645646 }
646647 }
647648
648649 private void FlushAndCloseOutput ( )
649650 {
650- if ( this . process == null )
651+ if ( this . Process == null )
651652 {
652653 return ;
653654 }
654655
655- if ( this . process . StartInfo . RedirectStandardOutput )
656+ if ( this . Process . StartInfo . RedirectStandardOutput )
656657 {
657658 try
658659 {
659- this . process . CancelOutputRead ( ) ;
660+ this . Process . CancelOutputRead ( ) ;
660661 }
661662 catch ( InvalidOperationException )
662663 {
663664 // Reader has already been cancelled
664665 }
665666 }
666- if ( this . process . StartInfo . RedirectStandardError )
667+ if ( this . Process . StartInfo . RedirectStandardError )
667668 {
668669 try
669670 {
670- this . process . CancelErrorRead ( ) ;
671+ this . Process . CancelErrorRead ( ) ;
671672 }
672673 catch ( InvalidOperationException )
673674 {
@@ -706,7 +707,7 @@ public WaitHandle WaitHandle
706707 {
707708 get
708709 {
709- if ( this . process == null )
710+ if ( this . Process == null )
710711 {
711712 return null ;
712713 }
@@ -725,9 +726,9 @@ public WaitHandle WaitHandle
725726 /// </summary>
726727 public void Wait ( )
727728 {
728- if ( this . process != null )
729+ if ( this . Process != null )
729730 {
730- this . process . WaitForExit ( ) ;
731+ this . Process . WaitForExit ( ) ;
731732 // Should have already been called, in which case this is a no-op
732733 OnExited ( this , EventArgs . Empty ) ;
733734 }
@@ -742,9 +743,9 @@ public void Wait()
742743 /// </returns>
743744 public bool Wait ( TimeSpan timeout )
744745 {
745- if ( this . process != null )
746+ if ( this . Process != null )
746747 {
747- var exited = this . process . WaitForExit ( ( int ) timeout . TotalMilliseconds ) ;
748+ var exited = this . Process . WaitForExit ( ( int ) timeout . TotalMilliseconds ) ;
748749 if ( exited )
749750 {
750751 // Should have already been called, in which case this is a no-op
@@ -762,18 +763,18 @@ public TaskAwaiter<int> GetAwaiter()
762763 {
763764 if ( this . awaiter == null )
764765 {
765- if ( this . process == null )
766+ if ( this . Process == null )
766767 {
767768 var tcs = new TaskCompletionSource < int > ( ) ;
768769 tcs . SetCanceled ( ) ;
769770 this . awaiter = tcs . Task ;
770771 }
771- else if ( this . process . HasExited )
772+ else if ( this . Process . HasExited )
772773 {
773774 // Should have already been called, in which case this is a no-op
774775 OnExited ( this , EventArgs . Empty ) ;
775776 var tcs = new TaskCompletionSource < int > ( ) ;
776- tcs . SetResult ( this . process . ExitCode ) ;
777+ tcs . SetResult ( this . Process . ExitCode ) ;
777778 this . awaiter = tcs . Task ;
778779 }
779780 else
@@ -788,7 +789,7 @@ public TaskAwaiter<int> GetAwaiter()
788789 {
789790 throw new OperationCanceledException ( ) ;
790791 }
791- return this . process . ExitCode ;
792+ return this . Process . ExitCode ;
792793 } ) ;
793794 }
794795 }
@@ -801,9 +802,9 @@ public TaskAwaiter<int> GetAwaiter()
801802 /// </summary>
802803 public void Kill ( )
803804 {
804- if ( this . process != null && ! this . process . HasExited )
805+ if ( this . Process != null && ! this . Process . HasExited )
805806 {
806- this . process . Kill ( ) ;
807+ this . Process . Kill ( ) ;
807808 // Should have already been called, in which case this is a no-op
808809 OnExited ( this , EventArgs . Empty ) ;
809810 }
@@ -837,17 +838,17 @@ public void Dispose()
837838 if ( ! this . isDisposed )
838839 {
839840 this . isDisposed = true ;
840- if ( this . process != null )
841+ if ( this . Process != null )
841842 {
842- if ( this . process . StartInfo . RedirectStandardOutput )
843+ if ( this . Process . StartInfo . RedirectStandardOutput )
843844 {
844- this . process . OutputDataReceived -= this . OnOutputDataReceived ;
845+ this . Process . OutputDataReceived -= this . OnOutputDataReceived ;
845846 }
846- if ( this . process . StartInfo . RedirectStandardError )
847+ if ( this . Process . StartInfo . RedirectStandardError )
847848 {
848- this . process . ErrorDataReceived -= this . OnErrorDataReceived ;
849+ this . Process . ErrorDataReceived -= this . OnErrorDataReceived ;
849850 }
850- this . process . Dispose ( ) ;
851+ this . Process . Dispose ( ) ;
851852 }
852853 if ( this . redirector is IDisposable disp )
853854 {
0 commit comments