What is the DynamicProxyGenAssembly2 assembly?

瘦欲@ 提交于 2019-12-10 01:08:17

问题


I use Moq for my unit tests. To test internal interfaces I have to declare the InternalsVisibleTo attribute to the DynamicProxyGenAssembly2 assembly.

We run our tests obfuscated, which is useful because we could found some problems with obfuscation with this approach. Caused by the DynamicProxyGenAssembly2 assembly my component is not obfuscated.

Therefore I need to know what is the DynamicProxyGenAssembly2 assembly? I could not found it anywhere on my disk. Is it compiled into the moq.dll or is it generated at runtime? Maybe if I know what this assembly I we coul find a way to workaround my problem. Has somebody encountered the same problem?

Please dont suggest that we need to run our tests unobfscated. At this point this is no option.

EDIT

The DynamicProxyGenAssembly2 is generated at runtime. To satisfy the Dotfuscator is have put an empty dll beside Moq. Additionally we had to modify the Castle.Core dll to use your public key. The last problems we had was answered here. With this we could run all our tests obfuscated without problems.

Regards, Yggdrasil.


回答1:


DynamicProxyGenAssembly2 is a temporary assembly built by mocking systems that use CastleProxy like Moq or NSubsitute. It is generated when the mock is needed and disposed of after the tests are finished.

As for the Expose Internals method than there is a RhinoMocks solution that would work for your Moq one with minimal changes:

http://ayende.com/Wiki/Rhino+Mocks+-+Internal+Methods.ashx?AspxAutoDetectCookieSupport=1



来源:https://stackoverflow.com/questions/15405040/what-is-the-dynamicproxygenassembly2-assembly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!