C#
To define C# as the target language in a template file :
A "?" is automatically added to the end of the type if the attribute is "nullable" (no "@NotNull" annotation). To disable this behavior:
The information below shows the behavior of the generator when C# is the current target language. For a detailed description of type conversion, see the generated documentation : https://www.telosys.org/doc/latest/languages/language-csharp.html
Types conversion
The table below describes how model neutral types are automatically converted to C# types with potential impact due to attribute annotations.
Model type | C# type | with annotation |
---|---|---|
string | string? string String? | @NotNull @ObjectType |
byte | sbyte? sbyte byte? SByte? | @NotNull @UnsignedType @ObjectType |
short | short? short ushort? Int16? | @NotNull @UnsignedType @ObjectType |
int | int? int uint? Int32? | @NotNull @UnsignedType @ObjectType |
long | long? long ulong? Int64? | @NotNull @UnsignedType @ObjectType |
decimal | decimal? decimal Decimal? | @NotNull @ObjectType |
float | float? float Single? | @NotNull @ObjectType |
double | double? double Double? | @NotNull @ObjectType |
boolean | bool? bool Boolean? | @NotNull @ObjectType |
date | DateOnly? DateOnly | @NotNull |
time | TimeOnly? TimeOnly | @NotNull |
timestamp | DateTime? DateTime | @NotNull |
binary | byte[]? byte [ ] | @NotNull |
Remarks:
since ver 4.1.0 "date" is converted to "DateOnly" and "time" is converted to "TimeOnly"
Annotations effects
@UnsignedType has effect only for byte, short, int, long
@ObjectType switches to .Net types ( System.Int64, System.Boolean, etc)
@NotNull type not nullable => no "?" at the end of the type
@PrimitiveType no effect
Specific types
$attribute.fullType returns the C# System class full name for both "primitive type" and "object type" ( for example : System.String, System.Int16, System.Decimal )
$attribute.simpleType
for an "object type" returns the simple type name of the C# System class ( for example : String, Int16, Decimal )
for a "standard type" returns the usual type ( for example : string, int, uint, bool )
$attribute.wrapperType returns the C# System class associtated with the curren type
Literal values
TRUE, FALSE, NULL
C# literal | |
---|---|
TRUE | true |
FALSE | false |
NULL | null |
Generated literal values
Below some examples of literal values generated for each type :
Model type | C# type | C# literal value |
---|---|---|
string | string System.String | "AAA" |
byte | sbyte byte System.SByte | 1 |
short | short ushort System.Int16 | 1 |
int | int uint System.Int32 | 100 |
long | long ulong System.Int64 | 1000L |
decimal | decimal System.Decimal | 10000.77M |
float | float System.Single | 1000.5F |
double | double System.Double | 1000.66D |
boolean | bool System.Boolean | true or false |
date | System.DateOnly | null |
time | System.TimeOnly | null |
timestamp | System.DateTime | null |
binary | byte [ ] | null |
Last updated