当前位置: 动力学知识库 > 问答 > 编程问答 >

visual studio 2008 - 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 ctors) 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 [email protected])

分享给朋友:
您可能感兴趣的文章:
随机阅读: