I’m trying to create an attribute in F# with positional arguments but failing all the time.
type ColumnAttribute(?index:int,?name:string) =
inherit Attribute()
let mutable index = index
let mutable name = name
member x.Index
with get() = index
and set value = index <- value
member x.Name
with get() = name
and set value = name <- value
type Substance = {
[<Column(Index=1)>] Name : string
[<Column(Index=0)>] Id : int
[<Column(Name="sequence")>] Sequence : string
}
I’ve tried several different approaches but this is the closest I ended with.
There are 2 issues that I see with your code
ColumnAttribute.IndexandNameisint optionandstring optionrespectively but you need it to beintandstring.Try the following