473,320 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Porting from VS2003 to VS2005: Code reformatting

No reply on my previous query, so I'll post this again. I've done a
bit more research in the interim.

I'm trying to find an easy way to port code from the older VS2003
format to the format used in VS2005. VS2005 uses partial classes to
split off the compiler-generated sections of forms. It keeps the
editable files uncluttered.

I generated very simple projects with VS2003 and with VS2005 to
compare the output. Following are standout differences:

VS2003's Form1.cs gets split into three modules:

Form1.cs (the new one) has only the constructor and event response
functions. Form1 class is declared partial.

Form1.designer.cs also has a partial Form1 class.
This file gets the Dispose() and InitializeComponent()
functions, and all the dialog objects.
For some reason, the 'components' object derives from
'IContainer' in VS2005 rather than 'Containter'
(Anyone know about this?)
The InitializeComponent() function replaces the old
'AutoScaleBaseSize =' to two new lines:
'AutoScaleDimensions = ...' and
'AutoScaleMode = ...'

Program.cs gets the Main() function, now in its own static class.
VS2005's Main() adds a call to EnableVisualStyles()

----------------------

Those appear to be the main differences. I'm not sure if the compiler
flags are changed, but the code changes seem like they could be done
with a reformatting program. Given the vast body of VS2003 code
with big clumsy dialogs, it would make sense to have a reformatter.

So...does it exist?

Nov 17 '05 #1
2 2742
DG,

Unfortunately, it does not exist. What you could do is create an
instance of the CSharpCodeProvider class in the Microsoft.CSharp namespace.

Once you have that, you can call the Parse method to parse the code into
an object which has the contents of the old code (after all, it should keep
working).

Then, you can create a new file, and take the elements of the code from
the old code file, and place them in the new code file.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"-DG-" <-D**@nospam.com> wrote in message
news:uk********************************@4ax.com...
No reply on my previous query, so I'll post this again. I've done a
bit more research in the interim.

I'm trying to find an easy way to port code from the older VS2003
format to the format used in VS2005. VS2005 uses partial classes to
split off the compiler-generated sections of forms. It keeps the
editable files uncluttered.

I generated very simple projects with VS2003 and with VS2005 to
compare the output. Following are standout differences:

VS2003's Form1.cs gets split into three modules:

Form1.cs (the new one) has only the constructor and event response
functions. Form1 class is declared partial.

Form1.designer.cs also has a partial Form1 class.
This file gets the Dispose() and InitializeComponent()
functions, and all the dialog objects.
For some reason, the 'components' object derives from
'IContainer' in VS2005 rather than 'Containter'
(Anyone know about this?)
The InitializeComponent() function replaces the old
'AutoScaleBaseSize =' to two new lines:
'AutoScaleDimensions = ...' and
'AutoScaleMode = ...'

Program.cs gets the Main() function, now in its own static class.
VS2005's Main() adds a call to EnableVisualStyles()

----------------------

Those appear to be the main differences. I'm not sure if the compiler
flags are changed, but the code changes seem like they could be done
with a reformatting program. Given the vast body of VS2003 code
with big clumsy dialogs, it would make sense to have a reformatter.

So...does it exist?

Nov 17 '05 #2
On Mon, 31 Oct 2005 11:00:12 -0500, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote:
Unfortunately, it does not exist. What you could do is create an
instance of the CSharpCodeProvider class in the Microsoft.CSharp namespace.

Once you have that, you can call the Parse method to parse the code into
an object which has the contents of the old code (after all, it should keep
working).

Then, you can create a new file, and take the elements of the code from
the old code file, and place them in the new code file.


Well, that's an interesting approach. I hadn't noticed
CSharpCodeProvider. I'll take a closer look.

In the interim, after comparing code listings for several projects, I
sort of got the hang of the major differences.

I've been starting by generating a new VS2005 project with one button
(to easily find position of where the controls are added in). That
way, I'm sure that the compile and link switches are set correctly and
the underlying structure is correct.

Then I incrementally copy code from the VS2003 project, splitting into
the form1.cs and form1.designer.cs as appropriate. (Nice to split off
the compiler-gen'd stuff...Partial classes are handy!)

I'm still not sure of the reasoning behind some of the changes, like
VS2005's use of floats in:
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
intstead of the older integer version.

From what i've seen, the format changes are pretty coherent and
predictable, so a translator program would be possible. Someone
should get right on that <g>. Maybe use the parser that you
mentioned.


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: clintonG | last post by:
VS2005 2.0 Beta 2 noting I've posted (to no avail so far) to the somewhat deadzone at news://microsoft.public.vsnet.ide and am getting ants in my pants for some discussion about this issue. ...
3
by: -DG- | last post by:
In C++, there is a compelling reason to recreate projects for the VS2005 compiler rather than simply copy and recompile older code (reason being C++/CLI syntax). I'm wondering if there is any...
3
by: Darrin | last post by:
Hello, I see that VS2005 and the new framework 2.0 is out to the public now. Wondering about some things. When you install the new framework 2.0 can a person still use visual studio 2003 or...
17
by: Samuel | last post by:
Hi All, I am in the process of converting a VS 2003 project to VS 2005 project (VB.NET Class Library). It gives the error in TypeOf and DirectCast statements. It was working...
15
by: Joseph Geretz | last post by:
OK, I'll admit it up front - I just don't get it. Here's our previous VS2003 development model. Developers develop the WS solution on their own workstations, using their own IIS web servers...
5
by: BK-Chicago | last post by:
I am in the midst of porting a massive MFC application from VS6.0 to VS8.0. While i have fixed most of the compile time errors, i do have quite a linker error that i have not been able to resolve....
5
by: Tony | last post by:
Hi all, Here's the link to the issue we were seeing on our ASP.NET system when modifying, adding and deleting directories in framework 2.0....
3
by: Chris288 | last post by:
Hi, I have a problem where our app when compiled in VS2005 runs about 50% the speed it attains in VS2003. This is an unmanaged C++ app. I have tried most combinations of the optimization and...
6
by: =?Utf-8?B?RGlwZXNoX1NoYXJtYQ==?= | last post by:
Hi all, I am porting an code written in VC++ to VC.Net to make it manage. But in Managed VC we dont use "const" keyboard at all. but my code is using it very frequently, so is their any...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.