Troy Mitchel
Troy Mitchel

Reputation: 1810

Get Object Property Description using Reflection

How to get the object description using reflection. I can get the name, value, etc... but not the description like in .net.

For example the description for .Text is "Gets or sets the text associated with this control."

I thought maybe using MethodInfo, but does not give the description.

    Dim MethodObj As MethodInfo
    Console.WriteLine("Methods:")
    For Each MethodObj In GetType(TextBox).GetMethods()
        Debug.Print(MethodObj.Name & " " & MethodObj.ReturnType.ToString())
    Next

Upvotes: 0

Views: 413

Answers (2)

Jon Skeet
Jon Skeet

Reputation: 1500065

If you mean the description as shown in MSDN, that's not part of the metadata shipped with the executable code. If you've got the XML documentation to go alongside the assembly, you could try to find the right method in that - but in most cases I wouldn't expect it to be available.

Upvotes: 1

Daniel Hilgarth
Daniel Hilgarth

Reputation: 174299

You can't get this description via reflection, because it is not compiled into the assembly. During compilation an XML documentation file is generated that contains this description. You need to parse this XML file to get the description. However, you don't always have this file, because it is not required to execute the assembly.

Upvotes: 0

Related Questions