GenericUnityObjects icon indicating copy to clipboard operation
GenericUnityObjects copied to clipboard

IgnoresAccessChecksTo doesn't work with Reflection.Emit

Open SolidAlloy opened this issue 4 years ago • 0 comments

To overcome an issue with the inability to use internal generic UnityEngine.Objects, I tried adding the IgnoresAccessChecksTo attribute when emitting assemblies. This seems to be working at least for these guys.

However, when creating an asset from an internal generic type, I receive the following error:

MethodAccessException: Method `Testing.GenericSO`1[System.Boolean]..ctor()' is inaccessible from method `ConcreteClass_d9b9a1d4e06775a45aa383810177c43c..ctor()'

I added a dirty example of how IgnoresAccessChecksTo can be used in the plugin to the ignores-access-checks-to branch. Feel free to check it out.

When I created a concrete class manually using OpenSesame, it was instatiated without the MethodAccessException error, so something's wrong with emitting IgnoresAccessChecksTo in Reflection.Emit.

Does anyone have an idea, what else can be done to bypass the visibility check for internal generic types?

SolidAlloy avatar Jan 30 '21 20:01 SolidAlloy