Clarify documentation about DataReceivedEventHandler and DataReceivedEventArgs.Data

Open Beginner friendly
#12,429 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Quiet
Tech stack
csharp
Domain
documentation

Research direction

Start in xml/System.Diagnostics/DataReceivedEventArgs.xml and review the examples and notes for DataReceivedEventArgs.Data, DataReceivedEventHandler, and Process.OutputDataReceived. Update the documentation to distinguish null end-of-stream data from valid empty strings, with consistent examples and an explicit warning about String.IsNullOrEmpty().

Written by the indexing model from the issue text.

Description

area-System.Diagnostics untriaged
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

Dominant language
C#
Stars
950
Forks
1.7k
Avg merge
3d 5h
Merged PRs (30d)
38

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/dotnet-api-docs

All issues in dotnet/dotnet-api-docs

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.