Skip to content

Add string-options for ignoring newline differences #2496

@vbreuss

Description

@vbreuss

Background and motivation

Remaining issue from #2364
(see this comment for more details)

This should also fix #1247

API Proposal

Add the following options to the EquivalencyAssertionOptions<T> for strings

public EquivalencyAssertionOptions<T> IgnoringAllNewlines()
{
    // This will remove all newlines from actual and expected before comparison
    return this;
}
public EquivalencyAssertionOptions<T> IgnoringNewlineStyle()
{
    // This will replace "\r\n" with "\n" in actual and expected before comparison
    return this;
}

API Usage

subject.Should().BeEquivalentTo(expected, o => o.IgnoringNewlineStyle());

Alternative Designs

No response

Risks

No response

Are you willing to help with a proof-of-concept (as PR in that or a separate repo) first and as pull-request later on?

Yes, please assign this issue to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionEarly API idea and discussion, it is NOT ready for implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions