Island: How to check if a type is a structure?

In island, the Type type has no property IsPrimitive.
What means that I can not use the following (that I can do in .Net):

Dim IsStructure = myType.IsValueType AndAlso Not mtType.IsPrimitive AndAlso Not mtType.IsEnum

How can I check if a type is a structure?

I don’t believe you can. Whats the context here, that this wouldn’t be known when writing the code, is myType generic?

I need this information to build a Serializer / DeSerializer.

  • I can see if something is a string (special case)
  • I can see if something is a reference object
  • I can see if something is an Enum
  • and then, everything else is unknown (a value type), but for a structure I need a complete other flow than for a primitive type.

You can use the code property (might be type code) to differentiate primitive types. Note that in this context, object and string are primitive too. But combined with is value type that should be solvable.

@ck I was thinking - a primitive does not have a constructor.
Does a structure has one? because then constructor + valuetype = struct

Primitives have an implied constructor that returns default().

1 Like