yanghuan/CSharp.lua

Nested records are skipped in compilation

joelverhagen opened this issue · 0 comments

Repro:

namespace Knapcode.FactorioTools.OilField.Algorithms;

public static class MyStaticClass
{
    public static int MyMethod()
    {
        return new PathAndTurns(1, 2, 3).Turns;
    }

    public record PathAndTurns(int Endpoints, int Path, int Turns);
}

PathAndTurns is skipped in the output Lua:

-- Generated by CSharp.lua Compiler
do
local System = System
System.namespace("Knapcode.FactorioTools.OilField.Algorithms", function (namespace)
  namespace.class("MyStaticClass", function (namespace)
    local MyMethod, class
    MyMethod = function ()
      return class.PathAndTurns(1, 2, 3).Turns
    end
    class = {
      MyMethod = MyMethod
    }
    return class
  end)
end)

end
System.init({
  types = {
    "Knapcode.FactorioTools.OilField.Algorithms.MyStaticClass",
    "Knapcode.FactorioTools.OilField.Algorithms.MyStaticClass.PathAndTurns"
  }
})

A workaround is to use a class instead of a record.