Skip to content

Feat/allow custom comparer null self - #5218

Merged
manfred-brands merged 3 commits into
mainfrom
feat/allow-custom-comparer-null-self
Jun 1, 2026
Merged

manfred-brands merged 3 commits into
mainfrom
feat/allow-custom-comparer-null-self

Conversation

@mikkelbu

@mikkelbu mikkelbu commented Apr 6, 2026

Copy link
Copy Markdown
Member

Fixes #3692

@mikkelbu
mikkelbu changed the base branch from main to release/5.X April 6, 2026 12:24
@mikkelbu
mikkelbu force-pushed the feat/allow-custom-comparer-null-self branch from c6eef57 to d65e9e2 Compare April 6, 2026 12:36

@manfred-brands manfred-brands left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@mikkelbu you beat me to it.

The reorder in NUnitEqualityComparer are good.

I''m not sure if all generic method needs to be nullable. For generics that have no constraint it should depend on the caller.

If a user adds a compare for int should that imply null?
Or only if the user explicitly adds a comparer for int?.

Note I have only reviewed on my phone.

@mikkelbu

mikkelbu commented Apr 6, 2026 •

Copy link
Copy Markdown
Member Author

@manfred-brands I was actually in the process of writing a comment on the issue about not liking that this changed so much public API :) - #3692 (comment) - I'll try to see how much I can remove

@mikkelbu
mikkelbu force-pushed the feat/allow-custom-comparer-null-self branch 2 times, most recently from 57dcb0d to 0c88662 Compare April 6, 2026 15:29

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think I'll add some more tests of this

@OsirisTerje

Copy link
Copy Markdown
Member

@mikkelbu Is this WIP ? Can we add it to 5 or should it wait for 6.
Note: Planning to get 5.0 out within a week or two.

Base automatically changed from release/5.X to main May 24, 2026 08:16
@OsirisTerje
OsirisTerje changed the base branch from main to release/6.X May 24, 2026 16:26
@OsirisTerje

Copy link
Copy Markdown
Member

@mikkelbu The best way of getting rid of the merge conflicts, which is caused by the release/5.X branch being too far back in time, is to create this branch again, and cherry pick the commits that are actually yours.

@manfred-brands
manfred-brands force-pushed the feat/allow-custom-comparer-null-self branch from 0c88662 to 9c18812 Compare May 30, 2026 07:46
@manfred-brands

Copy link
Copy Markdown
Member

I have reapplied the commit to main.

@manfred-brands
manfred-brands changed the base branch from release/6.X to main May 30, 2026 07:47
@manfred-brands manfred-brands self-assigned this May 30, 2026
@manfred-brands

Copy link
Copy Markdown
Member

I noticed that some cases are not covered by the general changes. I'll address those shortly.

@mikkelbu

Copy link
Copy Markdown
Member Author

I have reapplied the commit to main.

Thanks for taking over on this @manfred-brands 💪. For the time being I can only find very little time, so I doubt that I would have looked at this

@manfred-brands

Copy link
Copy Markdown
Member

Moved the user comparer before the internal null checks in the generic EqualUsingConstraint.

Updated the tests to cover all 6 Using overloads.

This is now ready for review .

@manfred-brands manfred-brands added this to the 5.0 milestone May 30, 2026
@manfred-brands manfred-brands removed their assignment May 30, 2026
Comment thread src/NUnitFramework/framework/Constraints/EqualityAdapter.cs Outdated
@manfred-brands
manfred-brands merged commit ba0a1f5 into main Jun 1, 2026
8 checks passed
@manfred-brands
manfred-brands deleted the feat/allow-custom-comparer-null-self branch June 1, 2026 01:09
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.

Custom comparator ignored for comparisons to self or null

3 participants