Skip to content

[Feature]: Make assertions with 'because' parameter more friendly to F# #2225

@cmeeren

Description

@cmeeren

Background and motivation

I love FluentAssertions and use it for F#. However, F#'s overload resolution is different than that of C#. One effect is that all overloads with because and becauseArgs require specifying because. For example,

result.Should().BeNull()

will not compile. Instead, it is required to write

result.Should().BeNull("")

This makes all assertions in F# more noisy. This is particularly noticeable for assertions that use a lambda parameter before because, since then the lambda is not the last argument and it then requires extra parentheses.

I suggest adding overloads for all assertions that do not have because or becauseArgs. That will allow F# users to assert without having to specify empty strings everywhere.

While I cannot promise anything, I may be willing and able to do a one-time pass of the codebase and add these overloads (at least as long as you don't see the need for separate tests and the overloads can just call existing overloads with an empty string argument). I can not prioritize adding and maintaining such overloads for all future assertions, but the additional work involved is trivial when new assertions are added.

Alternative Concerns

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions