Skip to content

IgnoreParameters() ignore-all sentinel is lost when combined with another ignore source #1853

Description

@SimonCropp

Calling IgnoreParameters() with no arguments is documented as ignoring every parameter:

parameterNames: The names of the parameters to be ignored. When passing an empty list all parameters will be ignored.

That sentinel is honoured downstream in GetVerifiedValues, which treats an empty set as ignore-all:

if (ignored.Count == 0)
{
    return [];
}

but the merge above it concatenated the empty set with the other ignore sources, so the set was no longer empty by the time it got there and the sentinel was silently downgraded to "ignore only these".

Symptom

Both of these keep parameters in the verified file name that the caller asked to have dropped:

// global ignore list
VerifierSettings.IgnoreParameters("a");

// instance ignore-all
settings.IgnoreParameters();

// method has parameters (a, b) -> merged set is {a}, so the verified name keeps _b=...
settings.SetClassArgumentCount(1);
settings.IgnoreConstructorParameters();
settings.IgnoreParameters();

// merged set is just the constructor parameter names, so the method
// parameters reappear in the verified name

Because the verified name is what selects the snapshot file, this silently changes which file a test resolves to: instead of one parameter-less verified file, each case gets its own.

Fix

An empty instance or global ignore list now wins outright rather than being merged with the other sources.

Fixed in c664ffa, covered by IgnoreAllParametersTests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions