Skip to content

Validate that no important Stream overrides are missing based on a systematic check #63191

@GSPP

Description

@GSPP

Over time, there has been a trickle of cases where a method on Stream should have been overridden but was overlooked. I, therefore, decided to take a systematic look at this and write a tool that checks all streams in all assemblies in the .NET distribution.

I'm posting the results here so that the team can take a look.

I noticed, for example, these interesting missing overloads on .NET 6:

  • System.IO.Compression.DeflateStream: WriteByte(Byte)
  • System.IO.Compression.GZipStream: WriteByte(Byte)
  • System.IO.ConsoleStream : Stream =>... Write(ReadOnlySpan), WriteAsync(Byte[], Int32, Int32, CancellationToken), ...
  • System.Net.Base64Stream: Read(Span), ReadByte(), Write(ReadOnlySpan), WriteByte(Byte)
  • System.Net.RequestStream: BeginRead(Byte[], Int32, Int32, AsyncCallback, Object), EndRead(IAsyncResult), Read(Span), ReadAsync(Byte[], Int32, Int32, CancellationToken), ReadAsync(Memory, CancellationToken), ReadByte(), Write(ReadOnlySpan), WriteByte(Byte)
  • System.Net.HttpRequestStream: Read(Span), ReadAsync(Byte[], Int32, Int32, CancellationToken), ReadAsync(Memory, CancellationToken), ReadByte(), Write(ReadOnlySpan), WriteAsync(Byte[], Int32, Int32, CancellationToken), WriteAsync(ReadOnlyMemory, CancellationToken), WriteByte(Byte)
  • System.Net.HttpResponseStream: Read(Span), ReadAsync(Byte[], Int32, Int32, CancellationToken), ReadAsync(Memory, CancellationToken), ReadByte(), Write(ReadOnlySpan), WriteAsync(Byte[], Int32, Int32, CancellationToken), WriteAsync(ReadOnlyMemory, CancellationToken), WriteByte(Byte)
  • System.Net.Quic.QuicStream: ReadByte(), WriteByte(Byte)
  • System.Security.Cryptography.CryptoStream: Read(Span), Write(ReadOnlySpan)
  • System.Net.Security.AuthenticatedStream: BeginRead(Byte[], Int32, Int32, AsyncCallback, Object), BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object), EndRead(IAsyncResult), EndWrite(IAsyncResult), Read(Byte[], Int32, Int32), Read(Span), ReadAsync(Byte[], Int32, Int32, CancellationToken), ReadAsync(Memory, CancellationToken), ReadByte(), Write(Byte[], Int32, Int32), Write(ReadOnlySpan), WriteAsync(Byte[], Int32, Int32, CancellationToken), WriteAsync(ReadOnlyMemory, CancellationToken), WriteByte(Byte)
  • System.Net.Security.NegotiateStream: Read(Span), ReadByte(), Write(ReadOnlySpan), WriteByte(Byte)
  • System.Net.Security.SslStream: Read(Span), Write(ReadOnlySpan), WriteByte(Byte)

I ran the tool for .NET 5 and 6. The full results are attached. I noticed that there were quite a few overrides added from 5 to 6, so there seems to be some interest in doing that.

MethodOverrideReport 5.0.8.txt
MethodOverrideReport 6.0.1.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.IOuntriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions