Skip to content

DateTime extensions collision with NodaTime.Testing #674

@bcowdery

Description

@bcowdery

I'm running into a problem using FluentAssertions in conjuction with the NodaTime.Testing library. NodaTime.Testing provides a 'FakeClock' and other testing utilities useful in time based applications. Both libraries add extension methods to allow fluent construction of dates. For example,

var date = 2.April(2017);

Attempting to use FluentAssertions and Noda testing results in the following error:

The call is ambiguous between the following methods or properties: 'FluentAssertions.FluentDateTimeExtensions.April(int, int)' and 'NodaTime.Testing.Extensions.LocalDateConstruction.April(int, int)'

The issue is that the fluent assertion extension methods reside in the base "FluentAssertions" namespace and cannot be excluded. There is no way for me to separate the fluent style assertions from the extension methods and other syntax sugar.

NodaTime's extension methods at least reside in a "NodaTime.Testing.Extensions" namespace allowing users to selectively use the extension methods. Without a similar pattern in fluent assertions there is no option for users to use both libraries in their test suites.

Is it possible to move fluent assertions extension methods into a similar "Extensions" namespace or would this cause too much disruption in the community? As it is now, there is no convention in CSharp for selecting one set of extension methods over another (explicit using statements won't help here). Any collision of extension methods will force users to select one library over the other.

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