I have been creating js and I consider Reflection the best tool for this. I basically point my generator to the bin folder of the project from which the metadata comes from. There may be some difficulties in loading all the necessary assemblies and warnings with the versions of assemblies in the bin folder and versions of the same assemblies as the project of your generator. But as soon as you deal with all this, which I did with minimal difficulties, Reflection is much easier to use and more reliable.
With Roslyn, you just parse C #. Roslyn does this very well, but I hesitate to switch to her with Reflection. With reflection, you get more reliable metadata.
Suppose you want the RoutePrefixAttribute attribute prefix property to decorate a controller class. If you are parsing C #, you might have: [RoutePrefix ("stringliteral")] or [RoutePrefix (constantString)]. So you need to worry about whether it is a literal or constant expression, and then find out how to get the value of the constant expression, worry about all the different ways of passing parameters to the atatribute attribute (for example, will it break your code: [RoutePrefix ( Prefix = "literal")] ...
Once you are dealing with real run-time objects with reflection, everything is simply simpler. You have a nice RoutePrefixAttribute object, and you can go routePrefix.Prefix to get, reliably, the prefix value.
This is just one example of how to make things easier with Reflection. This is the difference between collecting metadata from a set of C # objects in a safe way and scrambling data from C # code, albeit with a really nice cleaning tool.
EDIT: After writing this answer, I removed the bullet and switched to Roslyn. It is powerful enough as soon as you get it, and I found one big advantage: you can get a link to the workspace from the visual studio plugin and easily do all kinds of things in the plugin.
Sava B.
source share