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

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
r.heuschkel@ibitech.com
Posts: 14
Joined: Mon 22 Aug 2011 15:44

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

Post by r.heuschkel@ibitech.com » 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

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 01 Sep 2011 16:17

We have reproduced the problem. We will notify you when it is fixed.

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 02 Sep 2011 13:48

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.

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 07 Sep 2011 12:11

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 .

Post Reply