ASP.NET Hosting

.NET suggestion: add a paraminfo keyword to get information on parameters at run-time

I have added a suggestion for the .NET framework or the C#/VB.NET compilers in the MSDN Product Feedback Center: "Add a paraminfo keyword to get information on parameters".
Basically, the idea is to be able to write paraminfo(someparam).Name and paraminfo(someparam).Value to access to information about a parameter at runtime inside a method.

What do you think about this idea? You can vote for this suggestion if you find it interesting...

7 Comments

  • Not sure I understand what you want but with MethodBase.GetCurrentMethod, you have access to GetParameters ?

  • With GetParameters, you will still need to use the parameter name as a string.



    It would be something like typename, the values are known at compile time.



    I've thought about parameter info before, but with the same kind of thing; exception information.



    As an alternate approach, there have been a couple of blogs about using attributes for parameter validation.



  • Like Richard points out, what would it add to what we can achieve with System.Reflection today?



    What extra information about a method parameter would you want besides its System.Type?

  • > What extra information about a method parameter would you want besides its System.Type?



    Look at the example I provided. How would you do that today without using hard-coded strings?

  • OK, your pb is much about getting the value of the parameter than the name.



    I'll add another question: it's too about logging (and security in my application), I want to be able in a method to know which is the calling method (go back in the call stack). I search but didn't find how to do that (everything is internal or private !!!)

  • Did you take a look at System.Diagnostics.StackTrace? It does what you want.

  • I look at it, THANKS

Comments have been disabled for this content.