5
|
hwiechers · 技术社区 · 15 年前 |
1
1
我想你是说静态分析工具?(我希望运行时检查可以工作,至少-您可以将其留在调试版本中)。我怀疑这是静态分析能够看穿的东西-
简而言之,我怀疑…兰姆达斯
|
2
3
首先,为了这个目的,我个人使用 MVVM foundation . 它是一个只调试构建的运行时检查,几乎与您的相同。
这可能是最简单的方法,但它有一些缺点:您需要能够从某个基类继承,它只在运行时工作(尽管在我的WPF经验中,这已经足够了),但对于缺少的静态检查,它看起来确实像是一个“补丁”。 对于这种情况,您有几种启用静态分析/静态工具的方法:
至于codecontracts,我认为在静态分析中处理这种检查还不够成熟。想象一下,它必须解析你的lambda,理解它是如何因错误而失败的。
|
3
1
我过去这样做的方式是使用我们的好朋友lambda。通过使用表达式,我们可以将属性本身传递给onPropertyChanges的实现,并使用表达式树提取属性。这使您可以在编译时检查要为其引发PropertyChanged事件的成员。 当然,表达式的使用将完全取决于您需要的性能类型。 请参见下面的代码段:
|
Robert King · Unity C#语法问题-转换位置 1 年前 |
JBryanB · 如何从基本抽象类访问类属性 1 年前 |
law · 检查答案按钮的输入字符串格式不正确 2 年前 |
i_sniff_ket · 在unity之外使用unity类 2 年前 |