R# inserts code that breaks code contracts
If I have the following code:
class Foo
{
public Foo(string something)
{
Contract.Requires(!string.IsNullOrEmpty(something));
}
}
Then, if I click on something and select Initialize field/auto property for parameter, it inserts the code here:
class Foo
{
private readonly string _something;
public Foo(string something)
{
_something = something;
Contract.Requires(!string.IsNullOrEmpty(something));
}
}
This is illegal for code contracts as the contracts must appear before the method body. Can R# please be made aware of Contracts?
Please sign in to leave a comment.
Hello Oren,
Thank you for feedback! ReSharper doesn't consider code contracts yet. We're
planning to provide some support for code contracts in the future releases
and we will certainly take your feedback into account as well.
Andrey Serebryansky
Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"