Forcing code contract compilation times in a VB.NET project

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:

demo

I downloaded the add-in from Visual Studio Gallery . I have static code analysis on the Property Code Contracts page:

Propertypage

This works when I follow the same steps in C #:

working

What else could be missing?

+4
1

"CodeContracts" , .

, - Dim'ing, , "CodeContracts" , ", Dim'ing something, move ."

, "CodeContract" , . :

result = 5 / 0

result = Divide(5, 0)

, , , , "CodeContracts" , , , , , !

0

All Articles