Is there a way to get str1
in code ?
[MyAttribute("str1")]
class X {}
The instance of Mono.Cecil.CustomAttribute.Fields
is empty.
When using attributes in .NET you are either using the constructor parameters and setting some (named) fields. This is encoded differently in the metadata and ends up separately in Cecil.
the instance of Mono.Cecil.CustomAttribute.Fields is empty
What you're using is looking for fields when the constructor arguments were used for the custom attribute. So what you're looking for is:
type.CustomAttributes[0].ConstructorArguments[0].Value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With