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.
精彩评论