How to get the custom attributes of a method?

141 Views Asked by At

Assuming we have a method defined as below.

public class SomeClass
{
    [My("beautifulName")]
    public void DoSomeThing()
    {
         // whatever.
    }
}

public MyAttribute : Attribute
{
    public string Name { get; init; }
    public MyAttribute(string name) => Name = name;
}

Now we got a memory dump of this application, we can use ClrMD to find the SomeClass type easily, then we can easily find the DoSomeThing ClrMethod. Now, how can I find the corresponding MyAttribute instance and get the beautifulName value?

0

There are 0 best solutions below