开发者

does Moles add a 01, 02 etc to Moletypes that are attached to partial classes?

开发者 https://www.devze.com 2023-01-28 01:06 出处:网络
I\'m using Moles for mocking. The other day I built a Moles assembly for a reference that has many partial classes in it. The generated Moles assembly seems to have two classes that are built out of开

I'm using Moles for mocking. The other day I built a Moles assembly for a reference that has many partial classes in it. The generated Moles assembly seems to have two classes that are built out of开发者_如何学运维 the one class:

FileSendDataAccess

becomes

MFileSendDataAccess  MFileSendDataAccess01

Is this by design or a bug? It's very confusing since I now have two classes to use to access the one class. Using Moles 0.93.


The answer, according to Peli: Moles will add 01 etc to a class name when there are two classes in your references that have the same name.

Partial classes are a syntatic sugar, C# generates a type of them. Moles adds numbers ot [sic] type names when there are name clashing between types. Maybe you have 2 FileSendDataAccess type in your assembly? You can use Reflector to easily find out.

However: if the classes have the same name but different namespaces they will still get the 01 02 stuff. This is a bug that is still happening as of 0.94.

0

精彩评论

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

关注公众号