Support comparison operators by christabella · Pull Request #1347 · pythonnet/pythonnet

What does this implement/fix? Explain your changes.

Continuation of https://github.com/pythonnet/pythonnet/pull/1324/files but specifically for comparison operators e.g. >, >=, <, == etc. based on a discussion with @tminka --- in a nutshell, we want to check each C# class for any comparison operator methods when calling ClassBase.tp_richcompare, before proceeding with the usual logic (see #294) which handles C# classes that implement an IComparable interface.

Would appreciate a review from @lostmsu who helped with the previous PR that this builds on. Thanks!

Does this close any currently open issues?

Closes #1312
More concrete examples can also be found in other Infer.NET tutorials e.g. having to use op_GreaterThan https://github.com/dotnet/infer/blob/67b4f80d97018460bcb817f76ec874d0f33f1651/test/TestPython/test_tutorials.py#L31

Any other comments?

Some remaining tasks could be:

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Add yourself to AUTHORS
  • Updated the CHANGELOG

The tests pass in net472 but not on netcoreapp3.1