I'm trying to setup Code Contracts in a VB.NET project.
Here's a real simple method that should ensure that the passed in divisor argument is not zero:
<!-- language: lang-vb -->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 don't:
I've downloaded the Add-In from the **Visual Studio Gallery**.
I have static code analysis enabled on the Code Contracts Property Page:
This works when I follow the same steps in C#:
What else could be missing?