vendredi 4 décembre 2020

In F#, how can I access attributes on a function?

Say I am creating an attribute in F# and I apply it to a function as follows:

type MyAttribute(value: int) =
    inherit System.Attribute()
    member this.Value = value

[<My(42)>]
let myFunction() = ()

How can I retrieve that attribute via reflection?

Ideally I would like to use something along the lines of myFunction.GetType().GetCustomAttributes(true) but that does not work.





Aucun commentaire:

Enregistrer un commentaire