This project is read-only.

Using Roslyn to discover types in referenced assemblies and generate a runtime list of those types

Topics: APIs
Jun 29, 2015 at 3:29 PM
One thing many frameworks do at the moment is assembly scanning, whereby we find all the assemblies at runtime, discover their exported types, and do something with them.

Assembly scanning, depending on the complexity of what you're trying to do can be quite expensive, and with DNX, we now have the ability to use Rosyln for metaprogramming, which I think can help bypass a lot of the runtime work.

One such example, consider we have defined a type in one (of possible many) referenced assemblies, the classical IModule. In my main app, or webapp, instead of using assembly scanning to discover all implementations of IModule in my available assemblies, can I use Roslyn to go through the references, and find those implementations, and generate a static class which essentially is a repeating list of modules;
public class ModuleList
{
    public IEnumerable<IModule>()
    {
        yield return new SomeModule(); // Found in referenced assembly
        yield return new LocalModule(); // Found in current compilation?
    }
}

Is this possible?
Jun 29, 2015 at 8:46 PM