mercredi 13 décembre 2017

Get all member details (Fields, Properties, methods etc) of C# files using file path

I want to get all member of a class present in another c# file say Test.cs

I know it is possible using Reflection like this:

MethodInfo[] methodInfos = Type.GetType("ClassName").GetMethods(BindingFlags.Public | BindingFlags.Instance);

or

MethodInfo[] methodInfos = typeof(ClassName).GetMethods();

but I feel this will return method of class present in same assembly. I want provide file path as input any try to get all classes and their members present in that file.

Something like: Just provide file path @"C:\Test.cs" as input and get members as output.

I don't want to use Syntax tree using Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree

Please help.





Aucun commentaire:

Enregistrer un commentaire