Generic types as field

Posts   
 
    
El Barto
User
Posts: 64
Joined: 09-Nov-2006
# Posted on: 17-May-2017 14:05:26   

I've created a table with a xml column and a typeconverter to convert a List<string> to an xml string. I've created a type shortcut in the designer and set the xml column to type List<string> using the custom typeconverter. I use a Types.TypeImports file with the line:

  <typeImport typeName="System.Collections.Generic.List&lt;string&gt;" />

I've generated the code but the generated code as a problem. The type of the field is System.Collections.Generic.List`1[System.String] in stead of List<string>, in the entity class file and in the FieldInfoProvider. If I change this to List<string> the code works as expected.

Am I missing something in the designer or is this an issue in the code generator?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 17-May-2017 18:25:58   

Which designer version are you using? (date?) Could you please attach a repro llblgen project with the typeConverter?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 18-May-2017 16:04:41   

I think a repro isn't needed, as the code generator indeed doesn't take into account generics of a type, it assumes the type is a non-generic type, and therefore this goes wrong, as it has to pull apart the generic type information, generate the type information compatible with the target language (which is different between VB.NET and C#) and it doesn't do all that.

So this isn't supported at the moment. A workaround can be to create a subclass of List<string> (which is thus non-generic) and use that as the type instead. Not ideal, but will get your code compiled.

We'll look into adding support for this in the future.

Frans Bouma | Lead developer LLBLGen Pro
El Barto
User
Posts: 64
Joined: 09-Nov-2006
# Posted on: 18-May-2017 16:10:06   

Thanks for confirming this isn't supported. I've created a similar workaround as suggested.