单声道代码合同

Mar*_*ord 6 .net mono monodevelop code-contracts

以下代码:

Contract.Requires<ArgumentException>(command != null, Resources.Messages.CommandNotSpecified);
Run Code Online (Sandbox Code Playgroud)

电话

Contract.AssertMustUseRewriter (ContractFailureKind kind, System.String message)
Run Code Online (Sandbox Code Playgroud)

如果您使用的是Visual Studio,这似乎是由于未将代码约定配置为使用运行时协定检查而导致的.

文章@ http://devjourney.com/blog/code-contracts-part-2-preconditions/暗示在没有配置运行时检查的情况下生成的代码是:

public static void Requires<TException>(bool condition)
where TException: Exception
{
    AssertMustUseRewriter(ContractFailureKind.Precondition, "Requires<TException>");
}
Run Code Online (Sandbox Code Playgroud)

有没有人知道在MonoDevelop中做什么,以便合同按预期工作?

我得到的确切例外是:

2012-11-13 23:33:24.815 StickX[339:c07] mvx: Diagnostic:  34.46 Exception masked NotImplementedException: The requested feature is not implemented.
      at System.Environment.FailFast (System.String message) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Environment.cs:821 
  at System.Diagnostics.Contracts.Contract.AssertMustUseRewriter (ContractFailureKind kind, System.String message) [0x00011] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Diagnostics.Contracts/Contract.cs:83 
  at System.Diagnostics.Contracts.Contract.Requires[ArgumentException] (Boolean condition, System.String userMessage) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Diagnostics.Contracts/Contract.cs:271 
Run Code Online (Sandbox Code Playgroud)

sko*_*ima 4

它尚未实现,因此使这项工作有效的唯一方法就是编写实现。Mono 是一个开源项目,总是乐于接受新的贡献。