动态code代动态、code

2023-09-03 07:44:00 作者:你当我娘炮

我目前正在开发一个应用程序,你可以创建一个与它计划,而无需编写源$ C ​​$ C,只需点击和放大器;玩,如果你喜欢

I am currently developing an application where you can create "programs" with it without writing source code, just click&play if you like.

现在的问题是如何生成从我的数据模型中的可执行程序。有很多的可能性,但我不知道哪一个是最适合我。我需要生成类和命名空间中,一切都可以是应用程序的一部分组件。

Now the question is how do I generate an executable program from my data model. There are many possibilities but I am not sure which one is the best for me. I need to generate assemblies with classes and namespace and everything which can be part of the application.

codeDOM类:我听说过很多的限制,此类的错误。我需要创建的方法,参数和返回值的属性。是否支持?

CodeDOM class: I heard of lots of limitations and bugs of this class. I need to create attributes on method parameters and return values. Is this supported?

创建C#源$ C ​​$ C编程,然后调用CompileAssemblyFromFile就可以了:这工作,因为我可以生成任何code我想和C#支持大多数CLR功能。但是,这是不是可以慢?

Create C# source code programmatically and then call CompileAssemblyFromFile on it: This would work since I can generate any code I want and C# supports most CLR features. But wouldn't this be slow?

使用反射的ILGenerator类:我觉得这个我可以生成各种可能的.NET code。但我认为这是比其他方式更为复杂,容易出错?

Use the reflection ILGenerator class: I think with this I can generate every possible .NET code. But I think this is much more complicated and error prone than the other approaches?

还有其他可能的解决方案?

Are there other possible solutions?

编辑: 该工具是一般用于开发应用程序,它并不限于特定的域。我不知道这是否可以被认为是一种可视化编程语言。用户可以创建类,方法,方法调用,各类EX pressions。这不会是的非常的移动限制,因为你应该能够做到这允许在实际编程语言的大多数事情。 目前,很多事情仍必须由用户写入的文字,但我们的目标在年底时,几乎一切都可以点击在一起。

The tool is general for developing applications, it is not restricted to a specific domain. I don't know if it can be considered a visual programming language. The user can create classes, methods, method calls, all kinds of expressions. It won't be very limitating because you should be able to do most things which are allowed in real programming languages. At the moment lots of things must still be written by the user as text, but the goal at the end is, that nearly everything can be clicked together.

推荐答案

您我发现这是值得的看的动态语言运行时这或多或少设计用于创建基于.NET高级语言。

You my find it is rewarding to look at the Dynamic Language Runtime which is more or less designed for creating high-level languages based on .NET.

这或许也是值得看的一些previous的在域其中包含与DSL的,这听起来有点像你打算虽然我还没有从问题究竟你的目标是十分明确的工作一些有用的链接工具专用语言堆栈溢出线程。

It's perhaps also worth looking at some of the previous Stack Overflow threads on Domain Specific Languages which contain some useful links to tools for working with DSLs, which sounds a little like what you are planning although I'm still not absolutely clear from the question what exactly your aim is.