Disable loading of additional assemblies in AOT context (#314)

* Disable loading of additional assemblies in AOT context

AOT does not supports `Assembly.Load` and `Assembly.GetReferencedAssemblies()` when running AOT.
I opt-out of code which try to find type. In AOT context this means that you rely on dynamic type loading and you have issues anyway.

* Fix compilation errors
This commit is contained in:
Andrii Kurdiumov 2022-01-26 22:52:54 +06:00 committed by GitHub
parent 42ceb1c0d1
commit 0b3795eb87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,6 +28,7 @@ namespace GLib {
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
@ -238,7 +239,11 @@ namespace GLib {
break; break;
} }
if (result == null) { if (result == null
#if NET6_0_OR_GREATER
&& RuntimeFeature.IsDynamicCodeSupported
#endif
) {
// Because of lazy loading of references, it's possible the type's assembly // Because of lazy loading of references, it's possible the type's assembly
// needs to be loaded. We will look for it by name in the references of // needs to be loaded. We will look for it by name in the references of
// the currently loaded assemblies. Hopefully a recursive traversal is // the currently loaded assemblies. Hopefully a recursive traversal is