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

StackOverflow https://stackoverflow.com/questions/4348047

  •  30-09-2019
  •  | 
  •  

Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top