- Notifications
You must be signed in to change notification settings - Fork750
Description
Environment
- Pythonnet version: current master (with soft reload).
This is in context of Unity Editor.
Details
- Use the soft-reload branch of pythonnet within Unity.
- Create an asmdef called MyAssembly in Unity.
- In the same folder, create a file Foo.cs
namespace Foo{ public class Bar { public static void Quux() { UnityEngine.Debug.Log("quux"); } }}
- In the Unity Python console:
import clrclr.AddReference("MyAssembly")import FooFoo.Bar.Quux()
- This will print
quux
in the Unity console. - In Unity, modify Foo.cs e.g. add a space in it.
- Allow Unity to reload the domain.
- This works!
- In Unity, modify Foo.cs and rename Quux to Quux2.
Expected: Python for .NET is available after reload. Running Python code again will raise AttributeError.
Actual: Python for .NET throwsSerializationException: Cannot get the member 'Quux'.
I can't even run the Python code again; it fails onimport clr
. I must restart Unity.
Similarly if I rename the class, the namespace, or the assembly.
The problem appears to be in ManagedType subclasses. These are[Serializable]
but they point to things likeType
whose deserialization may fail, destroying everything.
I'm working on a proof of concept so that we control the deserialization and we can replace the failed deserialize with a dummy or anull
, which only fails if this eventually gets used. I'll post results tomorrow hopefully on a first attempt.