GithubHelp home page GithubHelp logo

Comments (3)

yanghuan avatar yanghuan commented on August 28, 2024 1

oh, i know what you mean, in this part, you must put all you code in one folder, then use the compile command, if you use dll reference, somethings will be different, because the code from dll, may be the true C# code, not lua, future may i will support csproj, like #17
but now you must put all code of what you want to convertd in one folder, then try compile...

from csharp.lua.

yanghuan avatar yanghuan commented on August 28, 2024

write

using System;
namespace HelloLua {
    public static class Program {
        public static void Main() {
            A a = new A();
            a.SomeProp = 2;
        }
    }
    public sealed class A {
        public int SomeProp { get; set; }
    }
}

will be

-- Generated by CSharp.lua Compiler 1.1.0
local System = System
local HelloLua
System.usingDeclare(function (global) 
  HelloLua = global.HelloLua
end)
System.namespace("HelloLua", function (namespace) 
  namespace.class("Program", function (namespace) 
    local Main
    Main = function () 
      local a = HelloLua.A()
      a.SomeProp = 2
    end
    return {
      Main = Main
    }
  end)

  namespace.class("A", function (namespace) 
    return {
      SomeProp = 0
    }
  end)
end)

auto property will be convet to field, i think this is better, it is simple and performance.

from csharp.lua.

luttje avatar luttje commented on August 28, 2024

Correct and again I'm sorry, the problem only occurs when the code is in a different assembly:

Write in HelloLua.csproj/Program.cs:

namespace HelloLua
{
    class Program
    {
        public static int MyProp { get; set; }

        static void Main(string[] args)
        {
            MyProp = 4321;
            TestLibrary.TestClass.SomeProp = 1234;
        }
    }
}

Write in TestLibrary.csproj:

namespace TestLibrary
{
    public static class TestClass
    {
        public static int SomeProp { get; set; }
    }
}

Compiles to:
HelloLua/Program.lua:

-- Generated by CSharp.lua Compiler 1.1.0
local System = System
local HelloLua
System.usingDeclare(function (global) 
  HelloLua = global.HelloLua
end)
System.namespace("HelloLua", function (namespace) 
  namespace.class("Program", function (namespace) 
    local Main, __staticCtor__
    __staticCtor__ = function (this) 
      this.MyProp = 0
    end
    Main = function (args) 
      HelloLua.Program.MyProp = 4321
      TestLibrary.TestClass.setSomeProp(1234)
    end
    return {
      Main = Main, 
      __staticCtor__ = __staticCtor__
    }
  end)
end)

and TestLibrary/TestClass.lua:

-- Generated by CSharp.lua Compiler 1.1.0
local System = System
System.namespace("TestLibrary", function (namespace) 
  namespace.class("TestClass", function (namespace) 
    local __staticCtor__
    __staticCtor__ = function (this) 
      this.SomeProp = 0
    end
    return {
      __staticCtor__ = __staticCtor__
    }
  end)
end)

The line TestLibrary.TestClass.setSomeProp(1234) wil error because no setSomeProp generated

from csharp.lua.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.