开发者

Any Problems With MEF and/or Unity When Obfuscating?

I am currently using MEF in a plugin architecture. I am about to obfuscate my code and I had a concern whether that would muck up MEF and it's discovery. I am using a DirectoryCatalog to resolve the plugins and I plan on obfuscating the plugins as well. Some of the extensions also run in th开发者_StackOverflow社区e main assembly, which will be obfuscated as well.

So, my question is whether this will be an issue with MEF (the obfuscation) and if so, does Unity also suffer from the same? Thank you in advance.


I came across an issue with Unity and Obfuscation. In that case, dependencies to be resolved by unity were tagged with the [ServiceDependency] Attribute on Properties. A Property in IL is nothing than a Get- and a Set- Method! tied together by some metadata. That is what makes up a property, nothing else. Obfuscation came across and replaced the property with the native Get- and Set- Methods. Can you see the problem? The property has gone (replaced by methods). No Property means no [ServiceDependency] attribute on the Property means no Dependency Injection means null reference means Crash!

Solution here was to tag the Properties with [ServiceDependency] AND [Obfuscation(Feature = "renaming", Exclude = true)] (Part of .Net Framework).

If it's important to you: Obfuscation was done with Dotfuscator Professional.


Since (in an ideal world) bbfuscation does not change the binary compatibility of an assembly, I don't see any issues coming up.

That said, I have not actually done any work with obfuscated assemblies and MEF, so I could be wrong.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜