Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor FluentExtensions.Switch to use equality comparers instead of requiring IEquatable<T> implementation #67

Merged
merged 2 commits into from
Aug 13, 2023

Conversation

ric15ni
Copy link
Contributor

@ric15ni ric15ni commented Aug 13, 2023

Proposed changes

  • In Louis.Fluency.FluentExtensions.Switch, use EqualityComparer<T>.Default instead of requiring that values being compared implement IEquatable<T>. This will allow enums to be used as values and comparands. Enums do not implement IEquatable<T> for compatibility reasons, as they predate generics.
  • Add FluentExtensions.Switch overloads that let the user specify an IEqualityComparer<T> interface.

Checklist of related issues / discussions

As the issue with FluentExtensions.Switch not working with enums surfeced in production while on a strict deadline, there was unfortunately no time to open a proper issue.

Types of changes

This pull request introduces the following types of changes:

  • Bug fix
  • New feature
  • Test addition / update (no changes to non-test code)
  • Refactor (no changes in public API syntax or semantics)
  • Performance improvement (no changes in public API syntax or semantics)
  • Documentation (docs directory) update
  • Dependency addition / update
  • Changes to the build scripts
  • Changes to CI (workflows, bot / app configurations)
  • Changes to repository files (.gitattributes, .gitignore)
  • Other

Breaking changes

This pull request introduces breaking changes:

  • Yes
  • No (a restriction has been lifted on a type parameter in some methods; existing code will show no change in behavior, save for a negligible performance hit)

Checklist

  • For all types of changes:
  • For code changes only:
    • The project builds on my machine, via the provided build script, with zero warnings
    • I have added tests that prove my feature works / my fix is effective
    • I have added / modified XML documentation according to changes in code
    • I have checked that all the links I added or modified in XML documentation point to their intended destination
  • For documentation changes (docs directory) only:
    • I have built and tested documentation locally
    • I have checked that all the links I added or modified point to their intended destination

@github-actions github-actions bot added area:code [issue/PR] affects project code (excluding tests). area:docs [issue/PR] affects documentation (excluding XML documentation that is part of source code). labels Aug 13, 2023
Copy link
Member

@rdeago rdeago left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@rdeago rdeago merged commit 410510e into Tenacom:main Aug 13, 2023
5 checks passed
@ric15ni ric15ni deleted the fluent-switch-using-equalitycomparer branch August 13, 2023 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:code [issue/PR] affects project code (excluding tests). area:docs [issue/PR] affects documentation (excluding XML documentation that is part of source code).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants