Tech Off Thread

19 posts

Converting a large VB.NET project to C#

Back to Forum: Tech Off
  • User profile image
    Bass

    I have recently acquired a fairly large VB.NET project (30,000 LoC). I would like to integrate this in my primarily C# project. I know I could leave it all as VB code, but I vastly perfer C#.

     

    Do you think this is plausible?

  • User profile image
    figuerres

    can be done, yes... but it will take a lot of time to go thru all that code...

     

    is it one dll / exe or is it multiple projects in one solution ?

    multiple projects would make it possible to convert one at a time and isolate breaking changes if something gets converted wrong.

    also will depend on the style of the vb coders work.  i tended to use vb.net where most of my code was the .net base objects and not the vb "versions" of them so that would make it more direct to convert.

    but if someone used a lot of the "vb-isms" then you have more stuff to sort out.

     

    in general i would say if it's not broke then leave it as is.  at least for now... just use any vb dlls as .net dlls and move on.

  • User profile image
    Dr Herbie

    figuerres said:

    can be done, yes... but it will take a lot of time to go thru all that code...

     

    is it one dll / exe or is it multiple projects in one solution ?

    multiple projects would make it possible to convert one at a time and isolate breaking changes if something gets converted wrong.

    also will depend on the style of the vb coders work.  i tended to use vb.net where most of my code was the .net base objects and not the vb "versions" of them so that would make it more direct to convert.

    but if someone used a lot of the "vb-isms" then you have more stuff to sort out.

     

    in general i would say if it's not broke then leave it as is.  at least for now... just use any vb dlls as .net dlls and move on.

    If you search for 'convert vb.net to csharp -online' then there seem to be plenty of converters.

     

    Alternatively could you write a utility to compile the VB.NET in memory and them emit it as C# code?  I'm fairly sure I remember the compiler stuff is all built-in to the framework ...

     

    Herbie

     

  • User profile image
    joechung

    Besides being in VB, what's wrong with the code?  Because if that's the only thing wrong with the code, I wouldn't recommend rewriting it.

  • User profile image
    Bass

    joechung said:

    Besides being in VB, what's wrong with the code?  Because if that's the only thing wrong with the code, I wouldn't recommend rewriting it.

    I don't like VB, and tbh it will f**k with my mind to go back and forward from VB and C# so often.

     

    I see there is a lot of very good ways to convert this though.

     

  • User profile image
    Ion Todirel

    Bass said:
    joechung said:
    *snip*

    I don't like VB, and tbh it will f**k with my mind to go back and forward from VB and C# so often.

     

    I see there is a lot of very good ways to convert this though.

     

    30K lines of code is not that much, you could do it in a few days maybe , but if the only reason is because "you vastly perfer C#" I don't think it would be wise

  • User profile image
    W3bbo

    Ion Todirel said:
    Bass said:
    *snip*

    30K lines of code is not that much, you could do it in a few days maybe , but if the only reason is because "you vastly perfer C#" I don't think it would be wise

    30,000 lines in a few days? ha!

     

    You're better of rewriting it sections as the project advances... assuming the software was engineered right in the first place (i.e. loose-coupling, strong cohesion, etc).

  • User profile image
    Dr Herbie

    W3bbo said:
    Ion Todirel said:
    *snip*

    30,000 lines in a few days? ha!

     

    You're better of rewriting it sections as the project advances... assuming the software was engineered right in the first place (i.e. loose-coupling, strong cohesion, etc).

    I'd say batch-convert with a tool and then refator it into shape if necessary, but I guess that is all subjective.

     

    That is, if you absolutely can't cope with referencing a VB.NET project ...

     

    Herbie

  • User profile image
    manojT

    Visual Studio itself has its built in Utility, by which you can convert the VB.NET project to C# Project, but you will find the refrence issue, but its better to use this approach as in fixing the issue, you will also have your hand on the code.

  • User profile image
    spivonious

    Give VB a chance. Maybe in a couple of weeks you'll be asking how to convert your C# to VB. Wink

  • User profile image
    Ion Todirel

    spivonious said:

    Give VB a chance. Maybe in a couple of weeks you'll be asking how to convert your C# to VB. Wink

    hardly Smiley

  • User profile image
    Minh

    W3bbo said:
    Ion Todirel said:
    *snip*

    30,000 lines in a few days? ha!

     

    You're better of rewriting it sections as the project advances... assuming the software was engineered right in the first place (i.e. loose-coupling, strong cohesion, etc).

    Yeah... 30,000 lines of VB is what...? 200 lines of C#?    Tongue Out

  • User profile image
    Adam​Speight2008

    You Traitor

    You Heathen.

    Sacrifice Him on the Alter of REM

     

    Big Smile

     

    30,000 line is that excluding emtpy lines and comments.

  • User profile image
    msftwise

    Minh said:
    W3bbo said:
    *snip*

    Yeah... 30,000 lines of VB is what...? 200 lines of C#?    Tongue Out

    ...You do not want to upset Beth Massi

  • User profile image
    Minh

    msftwise said:
    Minh said:
    *snip*

    ...You do not want to upset Beth Massi

    No, I don't haha!

    Let me be on the record to say I think VB is more innovative, user-friendly than C#...

  • User profile image
    stevo_

    Personally I think its sloppy, esp more recently.

  • User profile image
    Adam​Speight2008

    stevo_ said:

    Personally I think its sloppy, esp more recently.

    What do you mean by "its slopply"?

  • User profile image
    vesuvius

    AdamSpeight2008 said:
    stevo_ said:
    *snip*

    What do you mean by "its slopply"?

    As a point, I make sure that all posts in my blog are in both C# and VB. If you really take the time to write a program in both C# and VB, you will find that the only "sloppy" thing is your attitude towards it.

     

    When searching through code on MSDN I don't really notice what language the program is written in. With syntax highlighting in Dev 10 and the fact that Anders is now in charge of both languages, means a lot of people are missing the point.

     

    I always tend to find this attitude in younger developers. All the old curmudgeons I work with program in C++, C# or VB. The younger developers can only see things from one (not so sharp) angle.

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.