Skip to content

attributes_en

YANG Huan edited this page Dec 29, 2020 · 4 revisions

Some attributes can be marked in the documentation comments to control the behavior of the compiler.

@CSharpLua.NoField

/// <summary>
/// @CSharpLua.NoField
/// </summary>
public int Field { get; set; }

Automatic properties are not processed into fields, and corresponding get and set functions are generated.

@CSharpLua.Ignore

/// <summary>
/// @CSharpLua.Ignore
/// </summary>
public class A { }

This class is not exported to the generated lua file, and attributes can be applied to classes, methods, and properties.

@CSharpLua.Template

  public static class Api {
    /// <summary>
    /// @CSharpLua.Template = "print({0})"
    /// </summary>
    public extern static void Print(object a);

    /// <summary>
    /// @CSharpLua.Template = "print({0}, {1})"
    /// </summary>
    public extern static void Print(object a, object b);

    /// <summary>
    /// @CSharpLua.Template = "print({*0})"
    /// </summary>
    public extern static void Print(params object[] args);
  }

This attribute can be applied to methods or fields. Template writing rules can be referenced. How to change some of the generated behavior's Description of part 1.

@CSharpLua.Params

/// <summary>
/// @CSharpLua.Params
/// </summary>
public static void Print(string format, params object[] args)
{
}

output

Print = function (format, ...)
end
Clone this wiki locally