Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Znav
nextAsynchronous Method Invocation (AMI) in C-Sharp
prevSerializable Objects in C-Sharp

The slice2cs compiler supports metadata directives that allow you to inject C# attribute specifications into the generated code. The metadata directive is cs:attribute:. For example:

Wiki Markup
{zcode:slice}
["cs:attribute:System.Serializable"]
struct Point {
    double x;
    double y;
};
{zcode}

This results in the following code being generated for S:

Wiki Markup
{zcode:cs}
[System.Serializable]
public partial struct Point
{
    public double x;
    public double y;
    // ...
}
{zcode}

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:

Wiki Markup
{zcode:slice}
[["cs:attribute:assembly: AssemblyDescription(\"My assembly\")"]]
{zcode}

This results in the following code being inserted after any using directives and before any definitions:

Wiki Markup
{zcode:cs}
[assembly: AssemblyDescription("My assembly")]
{zcode}
Ztop
See Also
Zret
Znav
nextAsynchronous Method Invocation (AMI) in C-Sharp
prevSerializable Objects in C-Sharp