VB Code Analisys Support in R# 6.0 EAP

am i right that code analisys support for VB isn't complete in the current EAP build 2070? I've noticed the following problems:

  • with keyword seems not to be supported. All properties of the variable accessed within a with block are marked as error.
  • For a property defined as public readonly R# displays the error message "Property has no setter"
  • The My namespace seems not to be supported as access to My.Computer displays the error message "Cannot resolve symbol Computer".
  • On Error GoTo 0 is marked as error (On Error Resume Next not).
  • In the .designer.vb files assignments to the Name property of a control marked with the error "Cannot resolve symbol '...'"
  • I have defined an enumeration in a separate file without specifying a namespace. The first lines in the code are Option Strict / Explicit. I moved the enum to a namespace with the corresponding R# refactoring.  The Namespace definition is placed in the same line as my last Option definition instead into a new line which leads to an error.

Another thing is the following: I have a function with following signature:

Public Function FehlerBearbeitung(ByRef iReturnCode As Integer, ByRef sFormName As String, ByRef sFunktionsName As String, _
                                                  Optional ByRef sBemerkung As String
= "") As Short

Then i call it the following way:

FehlerBearbeitung(iReturnCode, MK_FormName, "MeineMethode")

where MK_FormName is defined as private const of type String

R# says "Constant cannot be used as assignment target".

I understand this, because ByRef returns the parameter. The reason for this declaration is, that the code was converted from VB 6 with the
migration assistant. As the migration assistant migrates all function parameters as ByRef by default i have much errors of this type in my code.
I didn't find an entry in the Inspect Severity options to control this message.



for the first problem i noted i have some additional info. I didn't realized that the variable which was used in the with block was of type ArrayList which contains instances of User-Controls. Strange is, that only properties are marked as errors, not function or method calls. Given the following code:

With sprBewertung(index).Activesheet
                    .RowCount = 100
                    .ColumnCount = 10
                    .SetColumnWidth(0, 350)
                    .SetColumnWidth(1, 125)
End With

the two property-Assignments are marked with the error "Cannot convert type 'Integer' to '???'" and the two method calls are ok. The source file has explicit Option settings of

          Option Strict Off
          Option Explicit On
          Option Infer On

VB-Compiler accepts all without error. The problem seems to be that VB code analysis didn't handle late bound references correct. I have a similar problem with Find Usages Advanced. Even if i check the "Find Late Bound" option R# didn't find calls of a method which definetly exists.



There is another problem with code analysis. Given the following code:

        Public Property MyProperty() As Integer
               MyProperty = _PropertyValue
          End Get
          Set(ByVal Value As Integer)
               _PropertyValue = Value
          End Set
     End Property

the EndGet is marked with the note "Property 'MyProperty' doesn' return a value on all code paths". If i replace "MyProperty =" in the getter by "Return" the message disappears. So it seems that the code analysis don't understand the old style of returning function results.



Please sign in to leave a comment.