Current filter:
                                You should refresh the page.
                                  • When using CodeRush for Roslyn, I noticed a false positive coming from one of the analyzers. This is to do with the if block matching the else block, below is the excerpt of code:

                                    [VB.NET]
                                    If Value.TriggerIdentity.DataSetIdentity.DataSetIndex = 0 OrElse Value.TriggerIdentity.TriggerIndex = 0 Then Exit Sub

                                    As you would probably agree, this is a false positive.

                                Show all comments
                                • Mark Hopper 10.13.2017

                                  Another example, this time with a string:

                                  [VB.NET]
                                  If Description Is Nothing OrElse Description.Length = 0 Then Throw New ApplicationException("Exception Description is Null")
                                • Alexander K (DevExpress) 10.13.2017

                                  Hi Mark,

                                  Thank you for providing the code samples. I have tried to reproduce this issue locally but CodeRush for Roslyn doesn't detect any Code Issues in your code:


                                  It seems that the issue has different nature and is more complex. Please provide us with the code of the whole method in which the issue is reproduced.

                                • Mark Hopper 10.13.2017

                                  Alexander, leave it with me and I will get back to you with a proper example, probably on Monday now looking at the time.

                                • Mark Hopper 10.16.2017

                                  Alexander, as promised here is a more concrete example, which I've confirmed reproduces this behaviour when in a standalone project:

                                  [VB.NET]
                                  Public Class Test Structure A Dim StopIndex As Integer End Structure Public Shared Sub Testing() Dim Test As A = Nothing With Test If .StopIndex > 0 Then Else End If End With End Sub End Class
                                • Alexander K (DevExpress) 10.16.2017

                                  Hi Mark,

                                  Thank you for providing the code sample. In this case, the if-block and else-block are identical (both are empty). So, we think that the diagnostics show correct results. Can you please clarify why it is a false positive in your opinion?

                                • Mark Hopper 10.16.2017

                                  My apologies, I had a lack of understanding what it was trying to tell me. What it's actually telling me is the code contained within the if and else block are the same. As far as I can see this is functioning as expected, but if I do find a relevant example of a false positive I will post one.

                                • Alexander K (DevExpress) 10.16.2017

                                  No problem, Mark. We look forward to your new example.

                                • Mark Hopper 10.17.2017

                                  Alex, hopefully this is a better example of what I hope would be considered a false positive:

                                  [VB.NET]
                                  If PhoneNumber.Substring(2, 1) = "0" Then 'Eight Digit Local Number Return "(" & PhoneNumber.Substring(0, 3) & ") " & PhoneNumber.Substring(3, PhoneNumber.Length - 3) ElseIf PhoneNumber.Substring(2, 1) = "6" Then If PhoneNumber.Length >= 5 AndAlso PhoneNumber.Substring(3, 2) = "24" Then '07624 Return "(" & PhoneNumber.Substring(0, 5) & ") " & PhoneNumber.Substring(5, PhoneNumber.Length - 5) Else 'Eight Digit Local Number Return "(" & PhoneNumber.Substring(0, 3) & ") " & PhoneNumber.Substring(3, PhoneNumber.Length - 3) End If Else 'Eight Digit Local Number Return "(" & PhoneNumber.Substring(0, 3) & ") " & PhoneNumber.Substring(3, PhoneNumber.Length - 3) End If

                                  While I appreciate that there are two branches within the if statement that are the same, there is an elseif statement between them, which would in my opinion, render this warning invalid. As we are using the code in the elseif statement to determine which branch of code to execute.

                                • Alex Eg (DevExpress) 10.17.2017

                                  Mark,
                                  Thank you for the code sample. Please give us some time to research the situation in detail and see if we can improve the analysis engine.

                                • Mark Hopper 10.17.2017

                                  Not a problem, always happy to help improve and provide feedback.

                                1 Solution

                                Creation Date Importance Sort by

                                Fixed: