cecil icon indicating copy to clipboard operation
cecil copied to clipboard

Subsequent write operations create different outputs

Open tom-englert opened this issue 3 years ago • 6 comments

Calling ModuleDefinition.Write multiple times generates different outputs. The first output is binary different from all subsequent outputs.

This is not a blocking issue, since both outputs seem to work fine, but might be a hint to some inconsistency in the write operation.

tom-englert avatar Jun 16 '22 15:06 tom-englert

I suppose I'm surprised it becomes stable after the first. I could understand each Write generating a new MVID (in fact, arguably it should, just like recompiling does even though everything else remains the same).

Zastai avatar Jun 17 '22 21:06 Zastai

I could understand each Write generating a new MVID (in fact, arguably it should, just like recompiling does even though everything else remains the same).

The MVID can be made deterministic. See #810.

ltrzesniewski avatar Jun 19 '22 22:06 ltrzesniewski

As per @ltrzesniewski comment - you need to ask for deterministic behavior. But if you still get different outputs after that I would be very interested (as it would break lot of things in our usage potentially).

vitek-karas avatar Jul 14 '22 09:07 vitek-karas

Interesting. Thanks for the test @tom-englert. Did you have a chance to look at what's happening?

jbevain avatar Sep 30 '22 18:09 jbevain

I once tried to dig through the code, but gave up.

I remember for one experiment that there were some blocks shifted in the file, and an empty block with only 00 had appeared after the second save

However in the test that I've added in #860 the difference is more subtle: image

Looks like it's not the MVID that changes.

tom-englert avatar Oct 01 '22 15:10 tom-englert

Given that second file has a high(ish) value at the start makes me wonder if there's a static or instance field somewhere that does not get reset.

Zastai avatar Oct 01 '22 16:10 Zastai