This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 151
[VS2015] ccrewrite fails with CC1004: Malformed contract. Found Requires after assignment in method #221
Comments
It looks like that CodeContracts has problem with VB method like this: ''' <summary>Test if a string starts with any of given substrings</summary>
''' <param name="str">A string to test</param>
''' <param name="substrings">Substrings to look for at the beginning of <paramref name="str"/></param>
''' <returns>True if <paramref name="str"/> starts with any of <paramref name="substrings"/>. If <paramref name="str"/> is null returns true only if <paramref name="substrings"/> contains null. If <paramref name="substrings"/> is null returns false.</returns>
''' <remarks>This overload uses current culture and performs case-sensitive comparison</remarks>
''' <seealso cref="String.EndsWith"/>
<Extension()>
Public Function StartsWith(str As String, ParamArray substrings As String()) As Boolean
Return StartsWith(str, StringComparison.CurrentCulture, substrings)
End Function
''' <summary>Test if a string starts with any of given substrings (allows to specify comparison rules)</summary>
''' <param name="str">A string to test</param>
''' <param name="comparison">Defines which rules use to compare strings</param>
''' <param name="substrings">Substrings to look for at the beginning of <paramref name="str"/></param>
''' <returns>True if <paramref name="str"/> starts with any of <paramref name="substrings"/>. If <paramref name="str"/> is null returns true only if <paramref name="substrings"/> contains null. If <paramref name="substrings"/> is null returns false.</returns>
''' <remarks>This overload uses current culture and performs case-sensitive comparison</remarks>
''' <seealso cref="String.EndsWith"/>
<Extension()>
Public Function StartsWith(str As String, comparison As StringComparison, ParamArray substrings As String()) As Boolean
If substrings Is Nothing Then Return False
If str Is Nothing Then Return substrings.Contains(CStr(Nothing))
Return substrings.Any(Function(substring) str.StartsWith(substring, comparison))
End Function The 1st overload (which calls the 2nd one) |
Any updates about this issue? I'm facing the same error at this line
|
Simplified scenarios: // both trigger malformed contract error
Contract.Requires(new object[] { string.Empty } != null);
Contract.Requires(new object[] { 0 } != null);
// this is OK
Contract.Requires(new object[] { null } != null); |
Should be fixed in #390. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Note: This situation is different from #133.
I tried the fixed ccrewrite mentioned in #133
, but it didn't help me. I'm still getting the error on code like this.
on the line
20>C:\Pangea\common\RFERL.IBll\Backend\IAudioOperations.cs(116,13): error CC1004: Malformed contract. Found Requires after assignment in method 'RFERL.Bll.Backend.IAudioOperationsContract.MoveFilesToAccessibleStorage(System.String,System.String,System.String)'.
I'm creating this issue to be able to trace it separately.
The text was updated successfully, but these errors were encountered: