如何将数千行 VBScript 转换为 C#?

发布于 2024-09-05 18:28:43 字数 571 浏览 1 评论 0原文

我收集了大约 10,000 个小型 VBScript 程序(每个 50-100 行)和一小部分较大的程序,我正在寻找一种方法将它们转换为 C#,而不需要手动转写。这些程序是 Web 应用程序的自动化测试用例,是为 HP/Mercury 的 QuickTest Pro 编写的,我正在尝试将它们转换为 Selenium 的测试用例。幸运的是,测试似乎编写得很好,使用了构建块和习惯用法(较大的程序)库,因此测试用例实际上比 VBScript 更类似于特定于领域的语言,并且 QTP 性很好 -埋在图书馆里。

理想情况下,我正在寻找一个工具,可以为 dsl-ish 测试用例和更复杂的构建块库执行从 VBScript 到 C# 的语法转换。这将使我需要手动清理库,并且可能很少对测试用例进行工作。如果我能找到一个 VBScript 到 VB.NET 的转换器,我也会接受它,因为我怀疑我可以编译 VB.NET,然后使用 .NET Relector 或类似的东西反编译为 C#。 B 计划是为测试用例编写一个我自己的翻译器,因为它们采用非常直线的风格,但这对库没有帮助。

有什么建议吗?我至少有 15 年没有编写过编译器了,虽然我没有忘记是如何编写的,但我并不期待它 - 尤其是对于 VBScript!

I have a collection of about 10,000 small VBScript programs (50-100 lines each) and a small collection of larger ones, and I'm looking for a way to convert them to C# without resorting to by-hand transliteration. The programs are automated test cases for a web application, written for HP/Mercury's QuickTest Pro, and I'm trying to turn them into test cases for Selenium. Luckily, the tests appear to be well-written, using a library of building blocks and idioms (the larger programs), so the test cases actually resemble a domain-specific language more than they do VBScript, and the QTP-ness is well-buried inside the libraries.

Ideally, what I'm searching for is a tool that can do the syntactic transformation from VBScript to C# for both the dsl-ish test cases and also the more complicated building-block libraries. That would leave me with a manual cleanup of the libraries, and probably very little work on the test cases. If I could find a VBScript-to-VB.NET translator, I'd take that also, as I suspect I could compile the VB.NET and then de-compile to C# using .NET Relector or something similar. Plan B is to write a translator of my own for the test cases, since they're in a very straight-line style, but it wouldn't help with the libraries.

Any suyggestions? I haven't written a compiler in at least 15 years, and while I haven't forgotten how, I'm not looking forward to it - least of all for VBScript!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

橘和柠 2024-09-12 18:28:43

大多数 vbscript 都是有效的 VB6 代码,因此一种选择是将它们从 .vbs 重命名为 VB6 使用的任何名称,然后将它们全部添加到 VB6 项目中,看看某些版本附带的 VB6 - VB.Net 升级向导是否可用Visual Studio 可以帮助您。

Most vbscript is valid VB6 code, so one option would be to just rename them from .vbs to whatever it was VB6 used and then add them all to a VB6 project and see if the VB6 - VB.Net upgrade wizard that comes with some versions of Visual Studio can help you out.

折戟 2024-09-12 18:28:43

GreatMigrations 有一个工具可以很好地将 VB6 转换为 C#(和其他语言)。我知道该公司愿意与组织合作,根据他们的具体需求定制产品。

GreatMigrations has a tool that does a good job converting VB6 to C# (and other languages). I know the company is willing to work with organizations to tailor the product to their specific needs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文