Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get primitive types in C# #1

Open
franckleveque opened this issue Apr 25, 2020 · 6 comments
Open

Unable to get primitive types in C# #1

franckleveque opened this issue Apr 25, 2020 · 6 comments

Comments

@franckleveque
Copy link

Hi,
Thanks for your great work,
However, I'm unable to get primitive types for C# (I'm currently using a database model)

the construct I use is :

$env.setLanguage('C#')
#foreach( $attribute in $entity.attributes )
public ${attribute.type} ${attribute.name}
#end

I have also tried .fullType, .simpleType, none worked. They are always translated as object types.

ie :
public Int32 Id
public String Label

whereas I would like to generate :
public int Id
public string Label

Is there something I'm missing ?
Thanks in advance,

@l-gu
Copy link
Member

l-gu commented May 4, 2020 via email

@franckleveque
Copy link
Author

franckleveque commented May 4, 2020

Hi,
It seems I use, the 3.1.2 CLI. the ver command give me this :

Components versions :
Telosys CLI : 3.1.2 CLI-001
Telosys API : 3.1.0
Generator : 3.1.2
Generic model : 3.1.2
DSL model : 3.1.0
DB model : 3.0.3
GitHub client : 2.1
HTTP client : 4 (2018-04-09)

Do we need to update the different components separately ?

@l-gu
Copy link
Member

l-gu commented May 5, 2020

Your version is correct.

@l-gu
Copy link
Member

l-gu commented May 5, 2020

The cause of this behaviour is that in a Database Model the attribute type is still stored as a Java type and this Java type determines the "native or object" nature.
It's an "old fashion typing" and it will be aligned on the DSL model in the future version.
DBModel types examples :
"Short" means "Object type" = "System.Int16" in C#
"short" means "Primitive type" = "short" in C#
So for the time being you can change the model type (for example use "short" instead of "Short" in the DB model) but it's not applicable for "String"

@l-gu
Copy link
Member

l-gu commented May 5, 2020

You can also create a Velocity macro to convert the "model neutral type" into your expected type.
The model neutral type is always the same in DBModel and in DSL model : "int", "string", "short", "long", "boolean", "date", "time", etc.
You can retrieve an attribute neutral type with : "$attribute.neutralType"

@franckleveque
Copy link
Author

Ok,

Thanks, I will go with neutralType for the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants