SergeyTeplyakov / ReSharperContractExtensions

Set of extensions for R# that simplifies Design by Contract programming using Code Contracts.
MIT License
69 stars 10 forks source link

Convert from if-throw to Contract.Requires skips method calls in message #17

Closed SergeyTeplyakov closed 10 years ago

SergeyTeplyakov commented 10 years ago

Following if-throw precondition:

    public void Foo(string s)
    {
        if (false)
            throw new ArgumentException(GetMessage(), "s");
    }
    private string GetMessage()
    {
        return "foo";
    }

Converts to:

    public void Foo(string s)
    {
        Contract.Requires(true);
    }