Table of Contents Previous Next
Logo
Client-Side Slice-to-C# Mapping : 14.15 C#-Specific Metadata Directives
Copyright © 2003-2010 ZeroC, Inc.

14.15 C#-Specific Metadata Directives

The slice2cs compiler supports metadata directives that allow you inject C# attribute specifications into the generated code. The metadata directive is cs:attribute:. For example:
["cs:attribute:System.Serializable"]
struct Point {
    double x;
    double y;
};
This results in the following code being generated for S:
[System.Serializable]
public partial struct Point
{
    public double x;
    public double y;
    // ...
}
You can apply this metadata directive to any slice construct, such as structure, operation, or parameter definitions.
You can use this directive also at global level. For example:
[["cs:attribute:assembly: AssemblyDescription(\"My assembly\")"]]
This results in the following code being inserted following any using directives and preceding any definitions:
[assembly: AssemblyDescription("My assembly")]

Table of Contents Previous Next
Logo