Static Fields and Static Event Handlers analyzers for disabling domain reload on entering playmode
Problem statement
This feature https://docs.unity3d.com/Manual/ConfigurableEnterPlayMode.html can save users lots of time but comes with hard to identify restrictions especially if you use packages or asset store code https://docs.unity3d.com/Manual/DomainReloading.html
Proposed solution
Static Fields and Static Event Handlers analyzers for disabling domain reload on entering playmode
It's an interesting idea. I think we have to keep the concept of "Analyzers", so to prevent but not to intervene: we will not change play mode settings in Unity, but we can simply issue a diagnostic as usual when something looks suspicious.
The only issue here is to properly detect if the project is using configurable play mode. For now analyzers are running in complete isolation, without dependencies towards Unity. They can be run in VS, VSCode (thanks to omnisharp) -even without Unity running- and sometimes directly inside the Unity pipeline.
Perhaps we can use the filesystem, and read project settings. But then we need a minimal parser. I don't know if there is an easy way to quickly detect configurable play mode.
cc @jbevain
Could an analyser use reflection to check the setting if the UnityEditor.dll is loaded to avoid needing a direct dependency?
I think we need to improve the project generation process to include a define telling us the proper context (is domain reload enabled ?). And we need also to force a re-gen when enabling/disabling this setting in Unity. We are going to discuss that in our next meeting with Unity folks.