Closed ZimM-LostPolygon closed 6 years ago
Does the original Nethereum use the real System.Numerics.BigInteger
or do they have a customized version? If the Editor post-processor hack works reliably on Windows/Mac/Linux then I'd be in favor of switching to System.Numerics.BigInteger
. Is that the only reason we have a Nethereum fork?
The original Nethereum uses the real System.Numerics.BigInteger
type, the customized version was made by me. But no, that's not the only reason for the fork - its initial purpose was to change the namespace, so as to avoid conflicts. Also, the fork uses an older version of NewtonSoft.Json
, since no AOT-friendly newer versions exists.
I'll do the check on macOS and Linux Unity editors, but generally, the modification is trivial enough to be reliable across the board.
@enlight
Turned out, even though would happily accept the modified project, and it would use an assembly that uses System.Numerics
just fine, it would still refuse to compile the code itself, so this approach with hacking the project files isn't working in the end.
However... System.Numerics.dll
is just 90 kB, and now I don't see any harm in just including it with the Loom SDK, at least until Unity fixes their bug with System.Numerics
not being referenced by default.
For EVM contracts, Unity SDK currently uses
Org.BouncyCastle.Math.BigInteger
instead ofSystem.Numerics.BigInteger
, since due to a Unity bug,System.Numerics
is not referenced in generated C# projects. This is a major inconvenience, since Nethereum had to be modified to useOrg.BouncyCastle.Math.BigInteger
, and, to be honest,Org.BouncyCastle.Math.BigInteger
is much worse compared to the native .NETSystem.Numerics.BigInteger
in terms of interface and convenience.However, I accidentally found out that Unity has a callback that is called after C# project are generated. This allows to add
System.Numerics
reference by trivially modifying the projects: https://gist.github.com/ZimM-LostPolygon/13c4a196f241072939d477998278948cIf we add this to the SDK, we won't have to maintain a fork of
Nethereum
that usesOrg.BouncyCastle.Math.BigInteger
, and everyone will be able to useSystem.Numerics.BigInteger
, which is much nicer. The downside, obviously, is that the any existing C# code that usesOrg.BouncyCastle.Math.BigInteger
will break. This is unfortunate, but I believe using the nativeSystem.Numerics.BigInteger
type is beneficial enough to justify that.@enlight What do you think?