[Microsoft.Build] Fix expected output newline from ProcessWrapper.OutputStreamChanged...
authorLudovic Henry <ludovic@xamarin.com>
Fri, 19 Feb 2016 14:40:02 +0000 (14:40 +0000)
committerLudovic Henry <ludovic@xamarin.com>
Fri, 19 Feb 2016 14:45:52 +0000 (14:45 +0000)
The previous implementation of ProcessWrapper OutputStreamChanged and ErrorStreamChanged would manually launch a background thread to read on the process StandardOutput and StandardError, then simply passing the output to the OutputStreamChanged and ErrorStreamChanged events. This mean that even the newline characters would be passed to these events, leaving these events callbacks deal with splitting the output line by line.
On the other hand, Process.OutputDataReceived and Process.ErrorDataReceived already split the data line by line, and discard the newline character. That implies that, to keep the old ProcessWrapper behaviour, we need to add these newlines character before calling OutputStreamChanged and ErrorStreamChanged events callbacks.

mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ProcessWrapper.cs

index 1b9dd8a9d13415fa3dfab85df3809b6dea9751d2..1674ff8b5dc3095f027cd6ffd60d1562e5e056d4 100644 (file)
@@ -47,7 +47,7 @@ namespace Microsoft.Build.Utilities
                                } else {
                                        ProcessEventHandler handler = OutputStreamChanged;
                                        if (handler != null)
-                                               handler (this, args.Data);
+                                               handler (this, args.Data + Environment.NewLine);
                                }
                        };
 
@@ -61,7 +61,7 @@ namespace Microsoft.Build.Utilities
                                } else {
                                        ProcessEventHandler handler = ErrorStreamChanged;
                                        if (handler != null)
-                                               handler (this, args.Data);
+                                               handler (this, args.Data + Environment.NewLine);
                                }
                        };