neolithos / neolua

A Lua implementation for the Dynamic Language Runtime (DLR).
https://neolua.codeplex.com/
Apache License 2.0
466 stars 76 forks source link

Bugfix for Assembly.ReflectionOnlyLoad under .Net 5+ and expose faster assembly load option #143

Closed ShadowMarker789 closed 1 year ago

ShadowMarker789 commented 2 years ago

Modification to the routine in AssemblyCacheEnumerator::MoveNext to use Assembly.Load instead of Assembly.ReflectionOnlyLoad under .Net Core and .Net 5+ as Assembly.ReflectionOnlyLoad is not supported on those runtimes and is guaranteed to throw PlatformNotSupportedExceptions.

Exposing additional static property to permit the user to use UnsafeLoadFrom in Assembly loading should the user want to load assemblies faster. This option is off by default for safety reasons and to preserve earlier behaviour.

Under initial testing, UnsafeLoadFrom is ~10x faster and dropped load times in a built app from 5 seconds to 0.5 seconds.

neolithos commented 2 years ago

As I understand it right, the assembly is loaded and can be used. So, it might be better to set assembly instead of reflected?

Can you check this?

neolithos commented 2 years ago

Can you rebase the pull request?

neolithos commented 1 year ago

Diff of the change is commited (abd0496641fe80ba1be6580a45ef15e90bcf3aae)