IronLanguages / ironpython3

Implementation of Python 3.x for .NET Framework that is built on top of the Dynamic Language Runtime.
Apache License 2.0
2.47k stars 287 forks source link

On Mono, not all CLR members defined on int are available on all int instances #1401

Open BCSharp opened 2 years ago

BCSharp commented 2 years ago

Python type int is backed by BigInteger, but both BigInteger and Int32 instances are used as int instances for performance reasons (#52). For the Python type system consistency, any attributes available on int (thus BigInteger) should be available on instances of int (thus also on Int32 instances). PR #1399 implemented a set of properties and methods that are available on BigInteger but not on Int32 as additional extension methods for Int32. However, this does not work well on Mono (v6.12.0.162 on darwin, but possibly on linux too). The following methods appear on int that do not appear on Int32 instances:

These two methods do not exist in .NET Framework 4.6 so they should not exist in Mono as well. And indeed, they do not, at least not as members of System.Numerics.BigInteger (so they are not accessible in C# code). However, somehow they do appear in IronPython, perhaps they are implemented as extensions?

slozier commented 2 years ago

As I understand it, Mono's API surface supports .NET Standard 2.1 (since 6.4 according to the .NET Standard page) which means it makes sense that these APIs appear on BigInteger. Although how one would go about creating an assembly that makes use these APIs (without going through reflection) I have no idea.

In any case, as I noted in the related PR I don't have any good proposals at the moment. It would probably have to be something that's reflection based...