Reputation: 225
Sorry if the question sounds trivial, I've read many discussions about that problem, but I'm not 100 percent sure if I got it correctly:
I want to get all interfaces, which are implemented by a class- then I can use following code:
foreach (TypeDefinition typeItem in currentAssembly.MainModule.Types)
{
// if the class has interfaces, get them
Mono.Collections.Generic.Collection<TypeReference> interfaceList = typeItem.Interfaces;
}
So the variable "interfaceList" should now contain all interfaces, which "typeItem" implements- it does not matter if the interfaces are implemented explicitly or implicitly?
Thanks in advance for your answers!
Upvotes: 0
Views: 946
Reputation: 19830
To find out if above code is working you need to create simple assemblies with following test cases. Then code some unit test and you are done.
Test cases:
If points 5 and 6 doesn't show correct number of interfaces you can sum up "this" class interfaces and "all-parents" class interfaces
Upvotes: 1