Jon Jones
Jon Jones

Reputation: 1084

Tool to convert inline C# into a code behind file

I have a number of legacy web controls (ascx) that contains huge amounts of inline C#. The forms contain a number of repeated and duplicate code. Our first plan is to move the code into code behinds per file, then refactor etc... were doing this to upgrade the client to the latest version of their cms

At the moment we are going to have to manually copy and paste from hundreds of files, create a code behind, copy the code, add the namespaces based on the client-side imports and then do any tidying up

does anybody PLEASE know of a tool that can do the majority of this work for us ?

Thanks

Upvotes: 4

Views: 917

Answers (5)

fdfrye
fdfrye

Reputation: 1099

I think your best bet would be to look at the Codesmith tools, or just T4 templates in general..you shouldn't need to write a custom app...though it looks like someone on CodeProject did just that : http://www.codeproject.com/KB/aspnet/InlineCodeVSCodeBehind.aspx?msg=997793

Upvotes: 0

Ira Baxter
Ira Baxter

Reputation: 95392

The DMS Software Reengineering Toolkit is designed to support the the construction of automated mass change tools.

It can parse HTML, and C#, (and build corresponding ASTs) and could be configured parse .ascx files. With the parse trees, one could likely generate your desired results. Is this easy? No. is is practical? Yes, if the amount of code you are reengineering is significant, as it seems in your case.

Upvotes: 1

Nick
Nick

Reputation: 5955

Resharper has many features for moving and locating code for different refactorings. I don't have it installed on the machine I'm at right now, so can't verify, but it may be able to at least speed up the process and make it more full proof, even if it can't be fully automated.

Upvotes: 0

user310291
user310291

Reputation: 38228

Use a language like Perl or Rebol which can do parsing. Rebol is the easiest.

Upvotes: 0

Mike Marshall
Mike Marshall

Reputation: 7850

I think your best hope here is to create a custom conversion utility. I don't know of any tools that would do this out of the box.

Upvotes: 0

Related Questions