Closed mcetkovsky closed 10 years ago
Thanks a lot. It is a definitely a bug.
Will change an error message as well.
For instance, for the following code:
public string Foo()
{
Contract.Ensures(Contract.Result<StringBuilder>() != null);
throw new NotImplementedException();
}
Code Contract Compiler emmits following error: Detected a call to Result with 'System.Text.StringBuilder', should be 'System.String'.
I vote for a text like:
The type System.Text.StringBuilder
used in Contract.Result<System.Text.StringBuilder>()
does not match the method's return type System.Text.String
.
I really like your version, except two points: 1) wrong type presented twice in the message (please note, that I shoudl try to show this message in one line) and 2) this message is far from the error from the Code Contract Complier.
I'm trying to stay as close as possible to Code Contract Compiler error messages. Unfortunately in some cases they're inconsistent and cryptic. For instance, some of them do have a method name, but some of them don't.
So for know I'll stay with following version: "Detected a call to Result with 'Task
Later on, I'll create a separate task and refine all error messages that I have (and I would like to discuss all of them at once. In this case I would be able to change them consistently).
FIx will be available during next release.
The line "Contract.Ensures" generates a warning. However, I do not see it as a bogus as it, based on my opinion, matches the sample at http://msdn.microsoft.com/EN-US/library/dd412873(v=VS.110,d=hv.2).aspx.
The warning states: Detected a call to to Contract.Result() in method RunAsync with return type Task.
The issues are the following: 1) You do not seem to support a generic type as a return type. 2) The text is not helpful at all (it reports an observation, not an issue).