Skip to content

Conversation

@jnyrup
Copy link
Member

@jnyrup jnyrup commented Mar 7, 2020

Further constraining of T to IComparable<T> gets us:

  • No more runtime type check in constructor
  • Avoid (un)boxing of primitives
  • Type preserving Subject, i.e. T/T? instead of IComparable<T>

Copy link
Member

@dennisdoomen dennisdoomen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to remember why I didn't do this in the first place, but the only thing I can recall that I struggled a lot with compilation errors and the compiler selecting the wrong overload.

Further constraining of `T` to `IComparable` gets us:
* Catching misuses of constructor on compile time instead of runtime
* Avoid (un)boxing of primitives
* Type preserving `Subject`
@jnyrup
Copy link
Member Author

jnyrup commented Mar 8, 2020

Glad to hear there was a reason back then.
The somewhat odd construction have stricken me every time I've seen it over the past years.

Tried to dig in history to see if I could find a cause:

1eb8f4d

  • Removed T : struct, Comparable constraints (I'm noticing the non-generic IComparable)
  • Changed constructor from T? to T
  • Added runtime IComparable check
  • Changed Subject from T? to IComparable

bddb024

  • Added T : struct
  • Changed constructor from T to object

But I didn't find any compilation issues...

@jnyrup jnyrup merged commit d515c13 into fluentassertions:develop Mar 9, 2020
@jnyrup jnyrup deleted the generics branch March 9, 2020 07:48
jnyrup added a commit to jnyrup/fluentassertions that referenced this pull request Mar 13, 2020
jnyrup added a commit to jnyrup/fluentassertions that referenced this pull request Mar 21, 2020
jnyrup added a commit that referenced this pull request Mar 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants