yanghuan / CSharp.lua

The C# to Lua compiler
Other
1.23k stars 202 forks source link

输出的lua继承的静态字段没有为父类静态字段赋值 #472

Closed xuhuanzy closed 10 months ago

xuhuanzy commented 10 months ago
namespace ConsoleApp1;

public abstract class Platform
{
    public abstract float GenerateRandomFloat();
}

public abstract class Context
{
    internal static Context Instance = null;
    private static Context GetInstance()
    {
        return Instance;
    }
    public static Platform Platform { get; internal set; }
}

public class MonogamePlatform : Platform
{
    private System.Random Random = new System.Random();

    public override float GenerateRandomFloat()
    {
        return (float)Random.NextDouble();
    }
}

public class LuaContext : Context
{
    static LuaContext()
    {
        Instance = new LuaContext();
        Platform = new MonogamePlatform();
    }

    public static void Update()
    {
        Console.WriteLine(LuaContext.Platform);
        Console.WriteLine(Context.Platform);
    }
}

输出的lua只有

    static = function (this)
      this.Instance = class()
      this.Platform = ConsoleApp1.MonogamePlatform()
    end

应该为元表赋值?