C-Sharp Attribute Metadata Directive
The slice2cs compiler supports a metadata directive that allows you to inject C# attribute specifications into the generated code. The metadata directive is cs:attribute:. For example:
Slice
["cs:attribute:System.Serializable"]
struct Point
{
double x;
double y;
}
This results in the following code being generated for S:
C#
[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:
Slice
[["cs:attribute:assembly: AssemblyDescription(\"My assembly\")"]]
This results in the following code being inserted after any using directives and before any definitions:
C#
[assembly: AssemblyDescription("My assembly")]