lundi 13 février 2017

In C# how can I evaluate if any members of a class contain switch case or if else constructs?

In C# how can I evaluate if any members of a class contain switch case or if else constructs? I want to check in a unit test if a class has been written with either switch...case or chained if....else.

I know how to get members of a class using reflection, but cannot find an example on the interwebs of how to get the actual code. From this SO post I found you can use MethodBase.GetMethodBody(), here. That seems great for returning a MethodBody for getting variables, but cannot find how to get information of if a switch...case or if...else exists.

Any solutions available?





Aucun commentaire:

Enregistrer un commentaire