Skip to content

[fix-finder] Add XML documentation to OutputStreamInvoker and InputStreamInvoker #11356

@github-actions

Description

@github-actions

Problem

OutputStreamInvoker and InputStreamInvoker are public shipped APIs in Mono.Android.dll that bridge Java I/O streams to .NET System.IO.Stream. They have no XML documentation, making it harder for developers to understand their behavior (e.g., which operations throw NotSupportedException, how exceptions are wrapped from Java to .NET).

Location

  • File(s):
    • src/Mono.Android/Android.Runtime/OutputStreamInvoker.cs
    • src/Mono.Android/Android.Runtime/InputStreamInvoker.cs

Current Code

Both files have public members without any XML doc comments:

public class OutputStreamInvoker : Stream
{
    public Java.IO.OutputStream BaseOutputStream {get; private set;}
    public OutputStreamInvoker (Java.IO.OutputStream stream) { ... }
    public override void Close () { ... }
    public override void Flush () { ... }
    public override void Write (byte[] buffer, int offset, int count) { ... }
    public static Stream? FromJniHandle (IntPtr handle, JniHandleOwnership transfer) { ... }
    // ...
}

Suggested Fix

Add XML documentation comments (/// <summary>, /// <param>, /// <returns>, /// <exception>) to all public and protected members in both files. Key documentation points:

  1. Class summary: Explain these wrap Java streams as .NET Streams, bridging java.io.OutputStream/java.io.InputStream to System.IO.Stream.

  2. Exception documentation: Document that Java.IO.IOException from the underlying Java stream is caught and re-thrown as System.IO.IOException (this is the "exception wrapping" pattern already noted in code comments).

  3. NotSupportedException: Document which operations throw NotSupportedException (e.g., Read/Seek/SetLength on OutputStreamInvoker, Write/SetLength on InputStreamInvoker).

  4. FromJniHandle: Document that this creates a new invoker from a JNI handle, or returns null if the handle is invalid.

  5. InputStreamInvoker.Seek: Document that seeking is only supported when the underlying stream is a FileInputStream (via its FileChannel).

Example for OutputStreamInvoker:

/// <summary>
/// Wraps a <see cref="Java.IO.OutputStream"/> as a .NET <see cref="Stream"/> for write-only access.
/// </summary>
/// <remarks>
/// This class bridges Java output streams to the .NET streaming API. Only write operations are
/// supported; attempts to read or seek will throw <see cref="NotSupportedException"/>.
/// Java <see cref="Java.IO.IOException"/> exceptions are caught and re-thrown as
/// <see cref="System.IO.IOException"/> when appropriate.
/// </remarks>
public class OutputStreamInvoker : Stream
{
    /// <summary>
    /// Gets the underlying Java <see cref="Java.IO.OutputStream"/> being wrapped.
    /// </summary>
    public Java.IO.OutputStream BaseOutputStream { get; private set; }

    /// <summary>
    /// Creates a new <see cref="OutputStreamInvoker"/> wrapping the specified Java output stream.
    /// </summary>
    /// <param name="stream">The Java output stream to wrap. Must not be <see langword="null"/>.</param>
    /// <exception cref="ArgumentNullException">Thrown when <paramref name="stream"/> is <see langword="null"/>.</exception>
    public OutputStreamInvoker (Java.IO.OutputStream stream) { ... }

Guidelines

  • Use /// <summary> for all public/protected members
  • Use /// <param> for parameters, /// <returns> for return values, /// <exception> for thrown exceptions
  • Reference related types with <see cref="..." />
  • Keep the existing code comments (the "Exception audit" blocks) — they document internal rationale and are separate from API docs
  • Follow repo formatting: tabs for indentation, space before (

Acceptance Criteria

  • All public and protected members in OutputStreamInvoker.cs have XML doc comments
  • All public and protected members in InputStreamInvoker.cs have XML doc comments
  • Documentation accurately describes exception wrapping behavior
  • Documentation notes which operations throw NotSupportedException
  • Existing code comments (Exception audit blocks) are preserved
  • All tests pass
  • No new warnings introduced

Generated by Nightly Fix Finder for issue #11352 · ● 1.5M ·

  • expires on May 21, 2026, 9:46 PM UTC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions