I am trying to set up Code Contracts in a VB.NET project.
Here's a real simple method that should ensure that the divisor passed in the argument is not null:
Public Function Divide(ByVal numerator As Integer, ByVal divisor As Integer) As Double Contract.Requires(Of ArgumentOutOfRangeException)(divisor <> 0, "Divide By Zero Not Allowed") Return numerator / divisor End Function
If I call Divide(5, 0), I should get a compile time error. But alas, I do not:
Divide(5, 0)
I downloaded the add-in from Visual Studio Gallery . I have static code analysis on the Property Code Contracts page:
This works when I follow the same steps in C #:
What else could be missing?
"CodeContracts" , .
, - Dim'ing, , "CodeContracts" , ", Dim'ing something, move ."
, "CodeContract" , . :
result = 5 / 0
result = Divide(5, 0)
, , , , "CodeContracts" , , , , , !