False positive warnings in VB code analysis

I'm working with VB on Visual Studio 2008. In the code i found following array declaration:

    Private miArrWertTypJahre(9, 3) As Long

Somewhere inthe code a method is called which intializes the array:

    Private Sub InitWerttypJahre()

        miArrWertTypJahre(0, 0) = GK_AW70_MIN_JAHR2
        miArrWertTypJahre(1, 0) = GK_AW70_MIN_JAHR1
        miArrWertTypJahre(2, 0) = GK_AW70_MIN_JAHR11
        miArrWertTypJahre(3, 0) = GK_AW70_MIN_JAHR12
        miArrWertTypJahre(4, 0) = GK_AW70_FM1_MIN
        miArrWertTypJahre(5, 0) = GK_AW70_FMN_MIN
        miArrWertTypJahre(6, 0) = GK_AW70_NB1_MIN
        miArrWertTypJahre(7, 0) = GK_AW70_NBN_MIN
        miArrWertTypJahre(8, 0) = GK_AW70_CFE_MIN
        miArrWertTypJahre(9, 0) = GK_AW70_CFA_MIN

        miArrWertTypJahre(0, 1) = GK_AW70_MAX_JAHR2
        miArrWertTypJahre(1, 1) = GK_AW70_MAX_JAHR1
        miArrWertTypJahre(2, 1) = GK_AW70_MAX_JAHR11
        miArrWertTypJahre(3, 1) = GK_AW70_MAX_JAHR12
        miArrWertTypJahre(4, 1) = GK_AW70_FM1_MAX
        miArrWertTypJahre(5, 1) = GK_AW70_FMN_MAX
        miArrWertTypJahre(6, 1) = GK_AW70_NB1_MAX
        miArrWertTypJahre(7, 1) = GK_AW70_NBN_MAX
        miArrWertTypJahre(8, 1) = GK_AW70_CFE_MAX
        miArrWertTypJahre(9, 1) = GK_AW70_CFA_MAX

    End Sub

The variable declaration is marked as "Field ... is never assigned" which is wrong for me because the array is sized in the declaration and values are assigned to its elements. The only problem is, that not all elements of the array are initialized by the code. I don't know if R# really detects that the array isn't completly initialized or just didn't detect the initialization code. In every case there should be either no message or a message like "Field ... is not fully initialized".

Another false warning is in the following code which is completly commented out:

    '''' <summary>
    '''' Dynamisches setzen der Datumswerte in den Spaltenköpfen.
    '''' </summary>
    '''' <param name="pDatumVon">Von-Datum</param>
    '''' <param name="pDatumBis">Bis-Datum</param>
    '''' <param name="pRow">Zeile</param>
    '''' <param name="pColumn">Spalte</param>
    '''' <remarks></remarks>
    'Private Sub setDatumUeberschrift(ByRef pDatumVon As Date, ByRef pDatumBis As Date, ByVal pRow As Integer, ByVal pColumn As Integer)


    'End Sub

R# marks the four variables in the XML comment (which starts with 4 '-characters) with "Cannot resolve Symbol...".



Thank you for the feedvack. The first problem is fixed, while the second is actually bug in your code


Hello Evgeny,

Thanks for the feedback. My second problem is very subtle. I created a new solution and copied the code into it. This way i can't reproduce the problem. The code piece is located somewhere in the middle of the file. I cut the code piece and pasted it at the end of the file. At this location there is no R# warning for unresolved symbols. Moved the code back to it's original place and the warning appears again. So i copied the method before and after my commented method into my new solution and this could reproduce the problem. The fact is, that my commented method is placed between two event methods. I attached my solution to give you a chance for further investigation.



Please sign in to leave a comment.