C# to VB.NET Code Converter - c#

I need a C# to VB.NET code converter, and I'm willing to pay. I want something that's ultra convenient, as I want to reduce the amount of copy/paste that I have to do... so could anybody give me some tips to what is out there? I want processing in bulk too, and to support the latest operations (LINQ, new VB inline-function support and all).
Thanks.

I have Tangible Software's Instant VB that I use. It seams to work very well. It will do LINQ, Full projects, files and snippets.
http://www.tangiblesoftwaresolutions.com/Product_Details/Instant_VB.html

Online:
http://www.developerfusion.com/tools/convert/csharp-to-vb/

One roundabout way to go about it is to disassemble an assembly using RedGate's .NET Reflector, and export the VB/C# code.
Reflector can loose some of the code flavor in the conversion/dissassembly, but I've always been able to get it to compile.
I've used several free tools online, but have found their correctness to be spotty at best. The one #Jeremy refers to is fairly decent, but lacks some recent .NET features. Odds are it will meet your needs.

Related

Parse/Refactor C# via C# code

Is there any libraries from Microsoft or from Mono project that allow you to do sweeping changes on a C# code base via code? Anything in Cecil for this? I think Cecil would only allow you to work at the bytecode level - anything to work on the language level?
I have already identified the issues I'd like to correct. Just could use some help with the Search/Replace in a C# syntax-aware fashion.
You should look at Roslyn - it's only in the preview stage at the moment, but it sounds like just what you want. (There are various blog posts about it, including this introductory one.)
There's a reasonably powerful search and replace in Resharper if that's appropriate to your situation.
http://blogs.jetbrains.com/dotnet/2010/04/introducing-resharper-50-structural-search-and-replace/

Classification Library

I need to test various famous classification methods like kNN, ID3 and ... on a huge data-set of a project, and choose one for future use.
I have no limitation on language but performance and readable code both in learning and classification phase are very important.
therefore, I'm looking for a good library with following features:
includes various classification methods
high performance
easily usable
any suggestions?
You shuold take a look at PyBrain, a great machine learning module for Python. Can't tell you much about it, because I never really used it (just read about it and looked at several projects solved with it), but it seems to be very good.
You may also want to take a look at this list of Python machine learning modules:
http://web.media.mit.edu/~stefie10/technical/pythonml.html
Or at this SO question:
Is there a recommended package for machine learning in Python?
Try scikit learn - it is written in python and has variety classifiers and also metods for testing them.
Take a look at RapidMiner which comes with a Java-API and graphical tools for data mining. The community edition is free, I think.
I used the predecessor of this tool/library as a student but do not have professional experience with it, though.

Android to WP7 absolute newbie question: C# or VB?

I'm going to migrate my Android application into WP7 platform. Android one contains heavy enough calculation stuff (encryption/decryption), plus extensive usage of DB (SQLite) and some graphics (simple) and I'm trying to figure which language to select: either C# or VB
I have some experience both in C# and VB.net, but can't decide which one to select, any clues?
I would recommend C#, based on a couple of factors:
I assume the Android application is written in Java. Between C# and VB, C# is the most similar.
If you are doing lots of calculations, C#'s more terse syntax will probably make the code easier to read. VB is more verbose and thus tends to produce more clutter.
Since you are new to the platform, you will definitely find a lot more resources with C# code examples than with VB.
I went from VB.net to C# and wouldn't ever go back through my own choice!
Aside from the technical differences (see here for just one comparison), it's my personal opinion that C# is more readable, fluent and just plain better.
Do a search on google for heaps of comparisons on why one is better than the other. At the end of the day it's your personal preference... try both and see which you prefer.
There are no technical benefits or drawbacks to choosing either language; the complete set of APIs and platform features are available to you whether you choose C# or VB.NET, so it comes down to whichever you are most comfortable with or want to spend more time with.
The only thing that might sway it one way or another is that (in my opinion) there are more samples, blog posts, and general help written in C# than VB.NET, but that's about the only differentiator I can think of.
If you aren't particularly familiar with either then definitely use C#. By far and way the vast majority of code you will come across in the Web and in books on Silverlight will be written C#.
I'd go with C#, it's a far more popular language. Furthermore, Java to C# is an easier transition.
Edit:
Popularity of a language make's it easier to find information and perhaps more importantly, quality developers.
Choose the language you are more comfortable with.
I would suggest c# because it's more similar to java. So maybe you will manage to save code structure.
C# for sure. C# is a lot more alike Java, and syntax alike much more compatible.
Next to that C# is more popular so more resources for it, and because of the extra time they spend on C# the compiler slightly generates higher performance MSIL.
If you know Java you'll find C# very comfortable to transition to and work with, especially if you're having to maintain older Java code as well as working on the new project. I've worked in situations where I had to work with VB6, VB.NET and C# code within the course of a day and it can be tricky to remember not to use or to use semi-colons or that the variable type goes first or last.

Is the source code visible through the binary file ? (C#)

I have written a program in c# with Vistual studio 2008.
I've compiled and build it and got a .EXE file. My question is this - if I give someone else this .EXE file can he in any way see the source code? functions, variables, calls, stack states, anything? I wish to keep those as discreet as possible.
They can use a tool like Reflector to decompile the executable, this will not be identical to your code, but they will be able to see most of what you wrote. It is a free tool, so you can download it to see what it can do with your exe.
You will need to obfuscate your code if you want to keep others from seeing it easily (though even that can be overcome with enough time and determination). A tool you can use for this is dotfuscator.
According to this SO post, one can reverse engineer a given executable and obtain the code that was used to build it. This msdn blog shows some ways you can make the process of reverse engineering a bit tougher, mainly through the use of obfuscation.
The exact same source code as you have written it no. But he could use tools like Reflector to disassemble it. In order to make the disassembled code difficult to read you could obfuscate it.
Yes.
You can use reflector to decompile any .net assembly.
http://www.red-gate.com/products/dotnet-development/reflector/
There are tools that will obfuscate your code. But it will still be visible. Security by obscurity does not work anyway.
As all have said - it's easy to decompile an assembly. Obfuscation offers very little real protection unless you're using some of the really high end commercial tools. The key things to really watch out for is if you have things like encryption keys or security tokens/credentials in your source code these are pretty easy to find.
There are a range of products available that will allow you to compile a .net app to native code which offers much greater protection.

Develop in C# but deliver in VB.NET

We are an team that are dedicated C#, and will start with an new project, there the customer really wants it in VB.NET.
Are there a bad choice to do the development in C# and then convert it and deliver in VB.NET.
Are there any tools that will make this easier to us than any simple converter?
I wouldn't recommend using a converter for a whole project. They're OK for code snippets and perhaps a class at a stretch, but even with two languages like C# and VB.NET based on a common runtime there'll be things that can't be converted.
As I see it you have the following choices:
Convince the customer that writing the application in C# is for the best - it's the language you know and you'll be able to deliver a higher quality product in a shorter time.
Write it in VB.NET, but point out that it will take longer to deliver.
Don't take the project. I'm assuming that this is not an option, but I'm including it for completeness.
Each language has its unique features and specialties. It is an illusion to believe that code written in C# can seamlessly be converted to VB.net. If you do automatic conversion, you'll have to fix it manually afterwards (because it is unlikely that your project will compile) and it will have poor quality, look bad and not be optimized.
I think it is a bad idea to rely on automatic conversion if your customer wants a solution in VB.NET. The code written by an automatic converter will often use a bad coding style for that language - even if the end result is the same.
It might be OK to use an automatic conversion tool occasionally to aid the development process if you are unsure of the exact VB syntax for a C# construct. You should check the result of the conversion is a best practice in VB.NET and not just copy and paste converted code without reading it. Conversion tools can make errors or produce ugly code that a human programmer would not write. Code committed to the project should be reviewed, preferably by one of the team members with the most experience in VB.NET.
You should strive to use the best practices for VB.NET so that your customer can easily understand and maintain your code.
If you feel that your team is unable to complete the project to a high quality in VB.NET then as ChrisF mentions you might want to consider:
Declining the project.
Convincing the customer to accept a high quality C# solution instead of a low quality VB.NET solution.
Alternatively you could try to gain the competences in VB.NET you are currently missing. Some examples of ways to approach this:
Attending courses on VB.NET so you at least know the basics.
Buying and reading books about programming in VB.NET.
Employing a new team member with VB.NET experience.
Using a consultant in the initial phases to help start your project and review code until your team is able to produce high quality VB.NET code on its own.
Attempting a smaller project in VB.NET first to gain some experience.
Are there any tools?
Kind of. I don't like any of them, as they don't look "trustworthy", but you can try your luck:
http://www.developerfusion.com/tools/convert/csharp-to-vb/
http://www.carlosag.net/Tools/CodeTranslator/
http://converter.telerik.com/
Would I recommend simply translating VB to C# ?
No. Because you're forced to trust in a converter. VB really, really isn't that much of a stretch from C#. If you are doing simple things, it should be pretty easy.
Regardless of your reasoning, it is possible to do this. Use RedGate's reflector http://www.red-gate.com/products/reflector/ and Denis Bauer's disassembler http://www.denisbauer.com/NETTools/FileDisassembler.aspx. You can pick your language, and the code that comes out, while not exactly what you coded, should compile back to the same IL.
You can decompile your C# binaries with JustDecompile export it as VB.net project, load the project file in VS and build.
This, however, does not usually work out of the box as you may have to fix some minor issues like:
Anonymous Types
Indexers
reimplement "unsafe" code
As you can adjust your (existing) C# test project to test the converted project along with your original implementation.
After fixing that you have the advantage to know your VB builds and runs well, which cannot be guaranteed by any automatic converter.

Categories

Resources