Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert many thousands of lines of VBScript to C#?

Tags:

c#

vbscript

qtp

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!

like image 805
Ross Patterson Avatar asked Oct 20 '25 01:10

Ross Patterson


1 Answers

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.

like image 177
Hans Olsson Avatar answered Oct 21 '25 13:10

Hans Olsson