Hey,

Agreed it looks like a bug in Unity. What do you mean by «I narrowed
the problem to the custom attribute I add to the modified assembly»?
If you use another mechanism to tag the assembly, it will be properly
reloaded?

Jb

On Wed, Sep 17, 2014 at 7:21 PM, Andriy Tylychko
<[email protected]> wrote:
> I don't know if it's Unity3D or Cecil problem. It took some time to resolve
> this issue, hopefully this description can help somebody else.
>
> I'm using Cecil to generate code in a Unity3D assembly: Unity calls my class
> static constructor after building the assembly, I modify it by generating
> some code and adding an assembly level custom attribute to flag the assembly
> as "generated" one. Then I ask Unity to reload the assembly by call to
> `UnityEditorInternal.InternalEditorUtility.RequestScriptReload()`. Unity
> reloads the assembly, calls my static constructor again, I find my custom
> attribute and don't touch the assembly this time.
>
> This worked fine until I upgraded Unity3D to v. 4.5.3 (from 4.2).
>
> It looks like Unity reloads the assembly the first time but after that it
> doesn't reload it even on normal refresh, I mean even unmodified version,
> until I restart it. At least this definitely looks like a bug in Unity.
>
> I narrowed the problem to the custom attribute I add to the modified
> assembly. Comparing modified and not-modified assemblies manifests I noticed
> that the custom attribute causes the assembly to reference itself, looks
> like:
>
> ...
> .assembly extern 'Assembly-CSharp'
> {
>   .ver 0:0:0:0
> }
> .assembly 'Assembly-CSharp'
> {
>   .custom instance void
> [System.Core]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = (
> 01 00 00 00 )
>   .custom instance void
> ['Assembly-CSharp']PropertySystem.PropertyGenerator/GeneratedAttribute::.ctor()
> = ( 01 00 00 00 )
>   .custom instance void
> [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor()
> = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78   // ....T..WrapNonEx
>
> 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 )       // ceptionThrows.
>   .hash algorithm 0x00008004
>   .ver 0:0:0:0
> }
> .module 'Assembly-CSharp.dll'
> ...
>
> Can this be a problem?
>
> --
> --
> --
> mono-cecil
> ---
> You received this message because you are subscribed to the Google Groups
> "mono-cecil" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
-- 
--
mono-cecil
--- 
You received this message because you are subscribed to the Google Groups 
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to