Skip to content

Encountering NullReferenceException when the match parameter of ImmutableArray<T>.Builder.RemoveAll is null #125921

Closed

Description

@prozolic

Description

When the match parameter of ImmutableArray<T>.Builder.RemoveAll is null, it throws NullReferenceException or no exception instead of ArgumentNullException.

For reference, List<T>.RemoveAll throws ArgumentNullException under the same condition.

var list = new List<int>();
list.RemoveAll(match: null); // ArgumentNullException

Reproduction Steps

var builder = ImmutableArray.CreateBuilder<int>();
builder.RemoveAll(null);  // no exception
var builder = ImmutableArray.CreateBuilder<int>();
builder.Add(1);
builder.RemoveAll(null);  // NullReferenceException

Expected behavior

ArgumentNullException is thrown.

Actual behavior

  • When Count == 0: no exception.
  • When Count > 0: NullReferenceException is thrown.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

A fix has been submitted in #125920.
This fix is a potential Bucket 2 breaking change per the breaking change guidelines.

Activity

  1. dotnet-policy-service commented on Mar 22, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-collections
    See info in area-owners.md if you want to be subscribed.

  2. vcsjones commented on Mar 22, 2026

    @vcsjones
    Member

    This looks like it was fixed by #125920, so I am going to close this out. Please feel free to reopen if I have misunderstood.

  3. removed
    untriagedNew issue has not been triaged by the area owner
    on Mar 22, 2026
  4. added this to the 11.0.0 milestone on Mar 22, 2026
  5. locked and limited conversation to collaborators on Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions