Closed JohnSRush closed 6 years ago
I'm afraid we can't use Assembly.IsDynamic, as that doesn't exist in lower .NET versions that must also be supported. I just ported an Odin Inspector tweak to the IsDynamic() extension method, intended to make it more robust against different cases. Is there a dynamic assembly case that this method isn't catching, that needs to be fixed?
Yes, but I wasn't able to reproduce it in Unity. If I executed this lineExpression.Lambda<Func<int>>(Expression.Constant(1)).Compile();
prior to calling DeserializeValue for the first time I would get an exception thrown in AssemblyUtilities on line 460 due to CodeBase
being called on a dynamic assembly. If I called DeserializeValue previously, it would work fine, and every time thereafter.
This is basically what I was attempting to deserialize:
{ "$id": 0, "$type": "0|App.Data, e419661b4bb044978cda8ad88879f22c", }
So creating your expression lambda causes an assembly to be defined that isn't caught by the IsDynamic() extension method - can you give me some more information about this assembly? It must be possible to detect that it is dynamic, without using the Assembly.IsDynamic property.
"Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null".
Please let me know what other information you might need.
If you call GetType() on it, what is the type name?
It looks like the aforementioned change to IsDynamic() I just commited would fix this issue for you, then - try pulling the latest commit and see if that solves it for you.
That fixed it.
the following code will throw an exception if assembly.IsDyamic property value is true:
if (assembly.CodeBase == null) return null;