Reputation: 269
I'm trying to write a console application which uses the System.Type declaration of multiple files using .net core 1.1 framework.
My use case is that I start the application and set the cs file paths as parameter.
sampleApp.exe d:\downloads\SomeClassA.cs e:\sample\IExSample.cs
Then I want to use the types of the cs files in my application. Somehow like:
public static void Main(string[] args) {
var types = new List<System.Type>();
foreach (var arg in args) {
// Here I need some help ;-)
System.Type typeOfArg = ?;
types.Add(typeOfArg);
}
// do more magic with filled type list
}
Upvotes: 0
Views: 428
Reputation: 7285
You won't be able to pass in the *.cs file and determine the type. You can gather metadata (type of classes, interfaces, base types, etc) using Roslyn. Here's a link that can help you. https://msdn.microsoft.com/en-us/magazine/mt790203.aspx
It uses T4 for templating to generate the javascipt code. You can use T4 in your project if you want to. But the underlying provider of metadata is done via Roslyn. Just extract the portion of the code that you are interested.
Upvotes: 1