Current filter:
                                You should refresh the page.
                                  • The code contract generated by the Code Action "Add Contract" - "Throw Exceptions Contract" is incorrect. The generated code will throw an exception when the application is run/tested.

                                    For example, given this method:

                                    [VB.NET]
                                    Public Sub DoSomething(values() As Integer) End Sub

                                    Click on "values()" and select the code action "Add Contract" - "Throw Exceptions Contract". The code generated by CR is:

                                    [VB.NET]
                                    Public Sub DoSomething(values() As Integer) If values Is Nothing Or values.Length = 0 Then Throw New ArgumentException($"{NameOf(values)} is nothing or empty.", NameOf(values)) End If End Sub

                                    If the values parameter is null (Nothing ), a NullReferenceException will be thrown when the method is run or tested. This is because VB.NET does not short-circuit the logical "OR" as C# does.

                                    The correct VB.NET contract should be:

                                    [VB.NET]
                                    Public Sub DoSomething(values() As Integer) If values Is Nothing OrElse values.Length = 0 Then Throw New ArgumentException($"{NameOf(values)} is nothing or empty.", NameOf(values)) End If End Sub

                                    Note the change of "Or" to "OrElse".

                                • Alex Eg (DevExpress) 06.03.2019

                                  Hi William,
                                  Thank you for the code sample and detailed explanation. I have reproduced the issue and we are working on it.

                                1 Solution

                                Creation Date Importance Sort by

                                Fixed: