Page 1 of 1

[BUG] Naming with brackets in VB.Net (v4.0.30)

Posted: Wed 31 Aug 2011 13:55
I found another bug in the code generation for VB.Net, this time in the ObjectContext template.

Backstory: Our method provider calls a collection of his 'Modulvariablen' a 'Modul'. The german plural of 'Modul' is 'Module'. Because we want to keep as close as possible to his naming schema this means a bit of trouble in Visual Basic, because 'Module' is also a language keyword. But you can work around that with using '[Module]' instead.

The ObjectContext template actually does this fine for the property declaration, but it then keeps using the name '[Module]' also everywhere else and so creates incorrect code.

Example of generated code:

Code: Select all

        ''' 
        ''' Gibt die Module zurück oder setzt diese.
        ''' 
        Public ReadOnly Property [Module]() As ObjectSet(Of Modul)
            Get
                If (_[Module] Is Nothing) Then
                    _[Module] = MyBase.CreateObjectSet(Of Modul)("Module")
                End If
                Return _[Module]
            End Get
        End Property

        Private _[Module] As ObjectSet(Of Modul)

        ''' 
        ''' Deprecated Method for adding a new object to the [Module] EntitySet.
        ''' 
        Public Sub AddTo[Module](modul As Modul)
            MyBase.AddObject("Module", modul)
        End Sub
As you can see, the property is correctly named '[Module]'. But then it also names the private variable '_[Module]' and creates a method 'AddTo[Module]', both times using faulty names.

The correct code should look like this:

Code: Select all

        ''' 
        ''' Gibt die Module zurück oder setzt diese.
        ''' 
        Public ReadOnly Property [Module]() As ObjectSet(Of Modul)
            Get
                If (_Module Is Nothing) Then
                    _Module = MyBase.CreateObjectSet(Of Modul)("Module")
                End If
                Return _Module
            End Get
        End Property

        Private _Module As ObjectSet(Of Modul)

        ''' 
        ''' Deprecated Method for adding a new object to the [Module] EntitySet.
        ''' 
        Public Sub AddToModule(modul As Modul)
            MyBase.AddObject("Module", modul)
        End Sub

Posted: Thu 01 Sep 2011 16:17
by Shalex
We have reproduced the problem. We will notify you when it is fixed.

Posted: Fri 02 Sep 2011 13:48
by Shalex
The bug with an incorrect generation of the private variables names is fixed. We will post here when the corresponding build of Entity Developer is available for download.

Posted: Wed 07 Sep 2011 12:11
by Shalex
New version of Entity Developer 4.1 is released!
It can be downloaded from http://www.devart.com/entitydeveloper/download.html (trial version) or from Registered Users' Area (for users with valid subscription only): http://secure.devart.com/ .
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=21949 .