I'm trying to get information from a variable within a method in C# MVC 5.
Example, I have methods just like this and want to get the parameters that are used in the variable "dt" in the example below.
public static JsonResult NamesDropDownListTest()
{
var dt = MyClass.QueryStoreProcedureDataTableTest(DataWareHouse,"gpkTest.procedure_type_docs");
return new JsonResult
{
Data = dt,
JsonRequestBehavior = JsonRequestBehavior.AllowGet,
MaxJsonLength = int.MaxValue
};
}
I am trying through this code that I saw here in the forum:
var asm = Assembly.Load("MyAssemblyNameProject");
var listAsm = asm.GetTypes()
.SelectMany(type => type.GetMethods(BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public))
.Where(m => !m.GetCustomAttributes(typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute), true).Any())
.Select(x => new { Classe = x.DeclaringType.Name, Action = x.Name, ReturnType = x.ReturnType.Name, Attributes = string.Join(",", x.GetCustomAttributes().Select(a => a.GetType().Name.Replace("Attribute", ""))), Parameter = string.Join(",", x.GetParameters().Select(s => new { atributo = s.ParameterType.FullName, nome = s.Name }).ToList()), teste = string.Join(",", x.Attributes) })
.OrderBy(x => x.Classe).ThenBy(x => x.Action).ToList();
I want to bring this information, such as method name, the action and which methods were found containing these variables I need the names of these parameters. I hope I was clear.
Thank you in advance to all.