NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Class Layout

In the general case, the NGWS runtime loader is free to lay out the instances of a class in any way it chooses, consistent with the rules of the VOS Type System. However, there are times when a tool or compiler needs more control over the layout. In the metadata, a class is marked with an attribute indicating whether its layout rule is:

CLS Rule 31: CLS-compliant types must not use explicitlayout.

CLS (consumer): Need not provide support for types with explicit layout.

CLS (extender): Need not provide syntax for defining types with explicit layout.

CLS (framework): Must not expose types with explicit layout.

It is also possible to specify an overall size for a class. This enables a tool or compiler to emit a value type specification where only the size of the type is supplied. This is useful in declaring NGWS runtime built-in types (such as 32 bit integer). It is also useful in situations where the data type of a member of a structured value type does not have a representation in NGWS runtime metadata (e.g., C++ bit fields). In the latter case, as long as the tool or compiler owns the layout, and the runtime doesn’t need to know the details or play a role in the layout, this is sufficient. Note that this means that the VES can move bits around but can’t marshal across machines – the emitting tool or compiler will need to handle the marshaling.

Optionally, a developer may specify a packing size for a class. This is layout information that is not often used but it allows a developer to control the alignment of the fields. It is not an alignment specification, per se, but rather serves as a modifier that places a ceiling on all alignments. Typical values are 1, 2, 4, 8, or 16.