Type of issue
Typo
Description
The documentation for DataReceivedEventArgs.Data states that an event with Data=null means that the stream has been closed. However, all the examples for DataReceivedEventHandler, DataReceivedEventArgs.Data and Process.OutputDataReceived are using String.IsNullOrEmpty() to check for null data, which is incorrect because it loses perfectly valid empty strings that correspond to empty lines in the program's output.
Also, the documentation for Process.OutputDataReceived doesn't say anything about null data or empty strings; I'd recommend to add a short note there too.
I'm proposing something like this for the examples, plus an explicit note saying "don't use IsNullOrEmpty(), it's incorrect":
if (e.Data == null) {
// end of stream
return;
}
// e.Data could be empty ("")
Console.WriteLine(e.Data);
Page URL
https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.datareceivedeventargs.data?view=netframework-4.8#system-diagnostics-datareceivedeventargs-data
Content source URL
https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Diagnostics/DataReceivedEventArgs.xml
Document Version Independent Id
4dcc73b2-f80f-8645-e8a6-c07b922ad5e1
Platform Id
e0f0476d-88bd-231d-79cb-986db6c3d434
Article author
@dotnet-bot
Type of issue
Typo
Description
The documentation for DataReceivedEventArgs.Data states that an event with Data=null means that the stream has been closed. However, all the examples for DataReceivedEventHandler, DataReceivedEventArgs.Data and Process.OutputDataReceived are using String.IsNullOrEmpty() to check for null data, which is incorrect because it loses perfectly valid empty strings that correspond to empty lines in the program's output.
Also, the documentation for Process.OutputDataReceived doesn't say anything about null data or empty strings; I'd recommend to add a short note there too.
I'm proposing something like this for the examples, plus an explicit note saying "don't use IsNullOrEmpty(), it's incorrect":
Page URL
https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.datareceivedeventargs.data?view=netframework-4.8#system-diagnostics-datareceivedeventargs-data
Content source URL
https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Diagnostics/DataReceivedEventArgs.xml
Document Version Independent Id
4dcc73b2-f80f-8645-e8a6-c07b922ad5e1
Platform Id
e0f0476d-88bd-231d-79cb-986db6c3d434
Article author
@dotnet-bot