#312: Preserve module initializers#393
Conversation
|
Not sure what's best for testing, I think whatever is easier to implement. Thanks! |
|
I thought of perhaps using the assembly MVID as a unique prefix for each module, but the downside is that it will not be stable, it will change whenever each of the merged assemblies changes. Your approach will be a bit more stable. |
KirillOsenkov
left a comment
There was a problem hiding this comment.
Looks good as far as I can see. Let me know when you feel that it's ready. Tests are nice but optional.
…to also test for right execution of module initializers
|
So I added a test to an existing test app by amending This tests for:
I also added a topological sort to |
Adds support for preserving all module initializers. Without this, only one of the module initializers appears in the merged assembly because of deduplication.
<Module>class where its static constructor calls all module initializers found in merged assembliesFixes #312.
Example of merged module initializers (decompiled by ILSpy):
Notes
[ModuleInitializer]are merged into a namespace-less class named<Module>. Its static constructor calls all methods annotated with[ModuleInitializer]of its module. Therefore, only one type/method must be considered per module when ILRepack merges assemblies.Tests
Currently, I tested this feature by temporary adding some module initializers to existing projects and verify them with ILSpy/by running the applications. So, as of now, those changes is not part of the PR!
So the question is:
Should there be an additional set of integration scenario projects added to explicitly test merging modules, or should some existing projects be adapted to also test for module initializers being merged and working?v