Dynamic method emit prevents usage on some platforms (Unity IL2CPP + Android / IOS)
Calling into reflection emit will cause a PlatformNotSupportedException. (which is called into upon initialization)
PlatformNotSupportedException: Operation is not supported on this platform. at System.Reflection.Emit.DynamicMethod..ctor (System.String name, System.Type returnType, System.Type[] parameterTypes, System.Reflection.Module m, System.Boolean skipVisibility) [0x00000] in <00000000000000000000000000000000>:0 at Salar.Bois.Types.BoisTypeCompiler.ComputeWriter (System.Type type, Salar.Bois.Types.BoisComplexTypeInfo typeInfo, System.Action1[T] beforeMehodBody, System.Reflection.Module containerModule) [0x00000] in <00000000000000000000000000000000>:0 at Salar.Bois.Types.BoisTypeCache.GetRootTypeComputed (System.Type type, System.Boolean generateReader, System.Boolean generateWriter) [0x00000] in <00000000000000000000000000000000>:0
Possible solution to this is to perform Ahead-Of-Time compilation of the methods & types required.
Thanks for letting me know, this needs some investigation and possibility I need to fall back to reflection on unsupported platforms
Can you give me your device details please? And are you using MAUI or Xamarin?
This affect all devices basically, since its a platform restriction. Similar will happen with IOS.
For the testing purposes I've used Unity + .Net 2.1.
Reflection "reading" is fine, generating new code is not.
I believe it is Unity problem then MAUI has support for Emits
I think its more of an IL2CPP issue (no emit support), because it expects everything to be compiled AOT. Still, would be great to have an AOT variant for the lib. Similar to what other serializers do;
https://forum.unity.com/threads/notsupportedexception-with-log-detail.543644/#post-8186325