CSharp.lua icon indicating copy to clipboard operation
CSharp.lua copied to clipboard

.GetType() produces a nil reference to System.ObjectGetType

Open RealityStop opened this issue 3 years ago • 2 comments
trafficstars

Creating a simple test:

public class Test
{
	public Test()
	{
		var a = this.GetType();
	}
}

when compiled with the -p option

produces:

System.namespace("", function (namespace)
  namespace.class("Test", function (namespace)
    local __ctor__
    __ctor__ = function (this)
      local a = System.ObjectGetType(this)
    end
    return {
      __ctor__ = __ctor__
    }
  end)
end)

However, ObjectGetType is nil and throws. Without the -p option, it functions just fine. It seems the intention is the ObjectGetType should be valid when using the -p option, but it is not added during the initialization.

In case it matters, I am compiling with -c -inline-property -p.

This is non-critical, as I am running in an environment where debug is available, but I had disabled it by default.

RealityStop avatar Oct 26 '22 15:10 RealityStop

may you set "debug = nil",
CoreSystem if debug == nil System.ObjectGetType may be define

yanghuan avatar Oct 28 '22 06:10 yanghuan

In my case, debug is available and remains a workaround for me,

I wasn't sure if this was an issue that could be addressed for others, though.

RealityStop avatar Nov 20 '22 19:11 RealityStop