Hi,
I currently maintain a small modding framework named StationeersMods for a game called Stationeers. with this framework modders can create mods from Unity. some of the mods can be found here: Stationeers
When someone creates a mod we copy over a lot of the game assemblies to Assets/Assemblies and we need to create an asmdef file that includes the Assembly-CSharp.dll from the game. This way we can properly extend classes from the game and incorporate new prefabs. This is where the issue arises. There are some classes in the assembly without a namespace, like Mask or ObjectPool.
When we include packages like TextMeshPro or Unity UI, we get compilation errors. These packages also have classes like Mask or ObjectPool which are ofcourse not referenced like UnityEngine.UI.Mask or UnityEngine.Pool.ObjectPool. When Unity tries to compile the packages it is including the Assembly-CSharp.dll in the process and consequently references the wrong classes.
Library\PackageCache\com.unity.ugui@1.0.0\Runtime\UI\Core\Layout\LayoutRebuilder.cs(21,44): error CS0311: The type 'UnityEngine.UI.LayoutRebuilder' cannot be used as type parameter 'T' in the generic type or method 'ObjectPool<T>'. There is no implicit reference conversion from 'UnityEngine.UI.LayoutRebuilder' to 'IPoolable<UnityEngine.UI.LayoutRebuilder>'.
A fix/workaround until now has been to modify the source of these packages in the package cache to use the FQDN name of the classes. This is a bit dirty. At first we wrongly assumed it was a bug in TMP with the Mask class, but recently ObjectPool joined the party. This problem will likely only grow with more classes that need a dirty fix.
I am looking for a permanent fix to this problem. Although there is probably a good reason for it, I don’t understand why the packages include the assemblies from the game. I can’t see a good reason for it to compile with assemblies it never even knew about in the first place. Is there a way to exclude the assemblies from package compilation and include it when compiling the mod?
If not, are there potentially other ways to fix the issue, besides asking the game developers to put all their classes in a namespace to avoid these collisions?

