开发者

Issues with ReflectedDefinition attribute

I have this code that does not compile anymore since I am on last F# CTP 1.9.7.8:

[<Struct>]
type MyStruct =
    val mutable private _i : int
    val mutable private _s : single
    val mutable private _i2 : int

    member t.I  = t._i
    member t.S  = t._s
    member t.I2 with get() = t._i2 * 2 and set(value) = t._i2 <- value * 2
    member t.Foo() = t._i * t._i

    [<ReflectedDefinition>] new (x, y, z) = {_i = x; _s = y; _i2 = z}

VS complains with this error message on the ReflectedDefinition attribute ahead of new: "This attribute is not valid for use on this language element"

It's very strange because for instance Tomas uses it extensively on constructors too in his F# Web Tools project. Is this now default behavior? (I've tried with VS2010 beta2 and I can repro). I don't see any alternative or possible workarounds.

In a same way, I can't put this attribute in front of members or properties (I don't know if it was possible with CTPs before 1.9.7.8). It works if I remove the Struct attribute (but still not on ctor开发者_JAVA技巧s) but I definitively need them on Struct (members and ctors).

Thanks


This was a bug that is now fixed in our internal bits; in the next release ReflectedDefintion on constructors will work again. (Feel free to send such questions to fsbugs@microsoft.com.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜