Delphi 到 C# - 有什么不错的工具可以进行一些硬核转换吗?
我尝试了一些可用的选项,例如 Netcoole 的 Delphi2CS 和 TurnSharp。两者都适用于非常简单的代码,如果您有组件,则会产生大量错误。我的项目很大,算上所有的 vcl、源代码和存储库大约有 1GB。有没有这样的工具来进行这种繁重的转换?谢谢。
I've tried a couple of options available out there, such as Netcoole's Delphi2CS and TurnSharp. Both of 'em are for very simple code, if you have components it will generate tons of errors. My project is large, about 1GB counting all the vcl, source and repository. Is there such a tool to do this kind of heavy converting? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
恐怕没有任何可靠的自动化工具来实现这样的事情。 Delphi 和.NET 之间的差异是巨大的。我在 2002 年做了类似的转换,并且是手动完成的,从头开始重写整个项目,这是硬核的东西。显然,如果您认为将其移植到 .NET 的工作量太大,您始终可以通过将其公开为 COM 对象来重用功能。
I am afraid there isn't any reliable automated tool to achieve such thing. The differences between Delphi and .NET are huge. I did similar conversion at 2002 and I did it manually, by rewriting the whole project from scratch and it was hardcore stuff. Obviously if you think that porting it to .NET would be too much of a work you could always reuse functionality by exposing it as COM objects.
马上停下来。我转换了大约 70,000 行代码,所有非可视类库的东西,我估计花了 3 个月才让它正常工作,即使用 Delphi 2007.NET 编译器编译程序集并在 Visual Studio 2010 项目中使用它们。就我的目的而言,这很重要,因为它为我提供了一个跨平台的分布式应用程序框架,但这种努力几乎要了我的命!
Stop right now. I did the conversion of about 70,000 lines of code, all non-visual class library stuff, and I estimate it took 3 months to get it working properly, i.e. compiling assemblies using the Delphi 2007.NET compiler and using them in Visual Studio 2010 projects. For my purposes this was important as it gave me a cross-platform distributed application framework, but the effort nearly killed me!
这可能是一个幼稚的建议,但您是否考虑过转换为 Delphi Prism(a . NET 语言基于 Delphi 语法)?
这仍然不是一件容易的事,但是一些 VCL 组件(例如来自 DevExpress) 有 .NET 对应项。
This may be a naive suggestion, but have you considered converting to Delphi Prism (a .NET language based on Delphi syntax)?
It still won't be an easy task, but some VCL components (such as those from DevExpress) have .NET counterparts.
进行这样的转换根本没有意义。这将需要数年时间(没有任何工具可以在您需要的复杂程度下为您完成此操作),并且结果将是您当前拥有的版本的错误较多。 AC# 应用程序将在与当前应用程序运行的所有相同操作系统中运行,并具有所有相同的功能。 (实际上有些可能会消失,因为本机代码可以做一些 .net 代码不能做的事情。)
此外,您将无法找到处理转换所需的程序员,因为这需要具有专业技能的开发人员在 Delphi 和 C# 中。如果您认为很难找到 Delphi 开发人员,请等到您尝试找到也是 C# 专家并且愿意从事此类转换的 Delphi 开发人员。它们比黑色独角兽更难找到。
There's no point at all to doing such a conversion. It will take years (there is no tool that will do this for you at the level of complexity you need) and the result will be a buggier version of what you currently have. A C# app will run in all the same operating systems your current app runs in, and have all the same features. (Actually some may drop off, since native code can do several things .net code can not.)
In addition, you will not be able to find the programmers you need in order to handle the conversion, since it would require developers with expert skills in both Delphi and C#. If you thought it was hard to find Delphi developers just wait until you try to find Delphi developers that are also experts in C# and ARE WILLING to work on such a conversion. They are harder to find than a black unicorn.
如果您要使用 WPF 拥有可视化界面,那么您可以使用 hwndhost 来托管现有的 Delphi 框架。我们才刚刚开始真正做到这一点,这样我们就不用一次性重写整个代码库了。看看 http://msdn.microsoft.com/en-us/library /aa970061.aspx 获取微尘信息。
If you are going to have a visual interface, using WPF, then you use hwndhost to host existing Delphi frames. We are just starting to do this for real, and saves us rewriting the whole codebase in one go. Have a look at http://msdn.microsoft.com/en-us/library/aa970061.aspx for mote information.
我们已经在 D7 应用程序中尝试过这一点,或者实际上我们打算这样做,但在分析阶段最终放弃了,因为我们找不到合适的工具来执行此操作,而无需修复其背后的大量错误和错误。
我建议您考虑使用一个新的 IDE(如果您有旧的 IDE)以及您是否真的必须这样做。无论如何检查 这个类似的问题并阅读了遇到此问题的人的经验,这并不令人鼓舞。
We have tried this with our D7 Application, or actually we intended to do this and ended giving up during the analysis phase, as we could'nt find and suitable tool to do this with without having to fix lots of bugs and errors behind it.
I would advice you to consider having a new IDE (If you have an old one) and if you really have to do this. Anyway check this similar question and read the experience of people who had this issue, its not really encouraging.
您的项目不太可能具有使该项目成为一个非常昂贵且困难的项目所需的单元和集成测试级别。使用自动转换时,很难实现使代码符合现代 C# 语言所需的架构更改。
It is unlikely that your project has the level of unit and integration tests needed to make this less than a very expensive and difficult project. When using automated conversions, it is difficult to achive the architectural changes you need to make the code idiomatic modern c#.