How can I set different attributes on getters and setters in F #?
In C # this works fine.
class A : System.Attribute { public A() {} }
public class B
{
public int X
{
[A] get { return 1; }
[A] set { }
}
}
But in F #, when I try to set attributes on the getter and setters properties, I can't get around the syntax error:
type A() = inherit System.Attribute()
type B =
member this.X
with [<A>] get () = 1
and [<A>] set (x : int) = ()
Is there a way to do this?
My goal is to set different attributes on getters and setters.
+2
source to share
2 answers
MSDN documentation suggests the following:
type A() = inherit System.Attribute()
type B =
[<A>]
member this.X with get () = 1
[<A>]
member this.X with set (x : int) = ()
... but according to .NET Reflector doesn't seem to produce the expected IL. Looks like a bug.
Edit: or a bug in .NET Reflector ...
Edit 2: Bug report submitted to fsbugs@microsoft.com
+2
source to share