我有这个代码不再编译,因为我在上一个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在新版之前对ReflectedDefinition属性上的此错误消息抱怨:“此属性对此语言元素无效”
这很奇怪,因为例如Tomas在他的F#Web Tools项目中也广泛地在构造函数上使用它。 这是现在的默认行为吗? (我试过VS2010 beta2,我可以重复)。我没有看到任何替代或可能的解决方法。
以同样的方式,我不能把这个属性放在成员或属性的前面(我不知道在1.9.7.8之前是否可以使用CTP)。如果我删除了Struct属性(但仍然不在ctors上),它可以工作,但我确实需要在Struct(成员和ctors)上使用它们。
由于
答案 0 :(得分:3)
这是一个现在修复在内部位的错误;在下一个版本中,构造函数上的ReflectedDefintion将再次运行。 (请随意将此类问题发送至fsbugs@microsoft.com。)