Title: Soft reload throws in deserialization in a common workflow · Issue #1250 · pythonnet/pythonnet · GitHub
Open Graph Title: Soft reload throws in deserialization in a common workflow · Issue #1250 · pythonnet/pythonnet
X Title: Soft reload throws in deserialization in a common workflow · Issue #1250 · pythonnet/pythonnet
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...
Open Graph 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 MyAssembl...
X 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 MyAssembl...
Opengraph URL: https://github.com/pythonnet/pythonnet/issues/1250
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Soft reload throws in deserialization in a common workflow","articleBody":"### Environment\r\n\r\n- Pythonnet version: current master (with soft reload).\r\n\r\nThis is in context of Unity Editor.\r\n\r\n### Details\r\n\r\n0. Use the soft-reload branch of pythonnet within Unity.\r\n1. Create an asmdef called MyAssembly in Unity.\r\n2. In the same folder, create a file Foo.cs\r\n```\r\nnamespace Foo\r\n{\r\n public class Bar\r\n {\r\n public static void Quux() { UnityEngine.Debug.Log(\"quux\"); }\r\n }\r\n}\r\n```\r\n3. In the Unity Python console:\r\n```\r\nimport clr\r\nclr.AddReference(\"MyAssembly\")\r\nimport Foo\r\nFoo.Bar.Quux()\r\n```\r\n4. This will print `quux` in the Unity console.\r\n5. In Unity, modify Foo.cs e.g. add a space in it.\r\n6. Allow Unity to reload the domain.\r\n7. This works!\r\n8. In Unity, modify Foo.cs and rename Quux to Quux2.\r\n\r\nExpected: Python for .NET is available after reload. Running Python code again will raise AttributeError.\r\n\r\nActual: Python for .NET throws `SerializationException: Cannot get the member 'Quux'.` I can't even run the Python code again; it fails on `import clr`. I must restart Unity.\r\n\r\nSimilarly if I rename the class, the namespace, or the assembly.\r\n\r\nThe problem appears to be in ManagedType subclasses. These are `[Serializable]` but they point to things like `Type` whose deserialization may fail, destroying everything.\r\n\r\nI'm working on a proof of concept so that we control the deserialization and we can replace the failed deserialize with a dummy or a `null`, which only fails if this eventually gets used. I'll post results tomorrow hopefully on a first attempt.","author":{"url":"https://github.com/benoithudson","@type":"Person","name":"benoithudson"},"datePublished":"2020-10-09T00:59:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/1250/pythonnet/issues/1250"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ac00f2a5-489a-bf98-05c6-4be06f37d8a2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 96F4:7A0AD:2F2B80F:2FD9427:69702D95 |
| html-safe-nonce | d8b41d7c4597dbaea2201721e57523f817f9012856d4cd7931fbcac5368935cb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NkY0OjdBMEFEOjJGMkI4MEY6MkZEOTQyNzo2OTcwMkQ5NSIsInZpc2l0b3JfaWQiOiI4NDU4MjUwNjU1OTU1NDMwODA1IiwicmVnaW9uX2VkZ2UiOiJzZWEiLCJyZWdpb25fcmVuZGVyIjoic2VhIn0= |
| visitor-hmac | 0d54bed40cd7f5782d2f599d3aa181d719a032c79c41a734d6350356c5cc68a3 |
| hovercard-subject-tag | issue:717768939 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pythonnet/pythonnet/1250/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2f6d6f22aad8ba5bea43f350428dd9dfbfbdfa2f840537f2084579cc54f822ca/pythonnet/pythonnet/issues/1250 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2f6d6f22aad8ba5bea43f350428dd9dfbfbdfa2f840537f2084579cc54f822ca/pythonnet/pythonnet/issues/1250 |
| og:image:alt | 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 MyAssembl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | benoithudson |
| hostname | github.com |
| expected-hostname | github.com |
| None | 01fa379f5de85ef8e791d09724e69709ce9eb9595278316e0a921312dc88e0bc |
| turbo-cache-control | no-preview |
| go-import | github.com/pythonnet/pythonnet git https://github.com/pythonnet/pythonnet.git |
| octolytics-dimension-user_id | 6050430 |
| octolytics-dimension-user_login | pythonnet |
| octolytics-dimension-repository_id | 14748123 |
| octolytics-dimension-repository_nwo | pythonnet/pythonnet |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14748123 |
| octolytics-dimension-repository_network_root_nwo | pythonnet/pythonnet |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | dda91974c069382b0dfa47b2da7e28bd061c8331 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width