1. Meeting Objectives
• Your Objectives
– Understand the challenges of migrating
VB6/ASP/COM to .NET
– Understand the role of translation technology as part of a
.NET adoption effort.
– Understand the tool-assisted approach to Migration.
• Great Migrations’ Objectives
– Educate you on the challenges of migrating
VB6/ASP/COM to .NET and potential solutions
– Help you get started!
07/10/09 Copyright Great Migrations LLC 1
2. Agenda
• gmBasic 101
• Technical Demonstration
– A Sample VB6 Application
– Demo: Migration to C# / VB.NET
– Demo: Source Code Analytics
– Demo: Source Code Restructuring
• The Great Migrations Methodology
– The Tool Assisted Re-Write
• Wrap Up
07/10/09 Copyright Great Migrations LLC 2
3. gmBasic 101
Compreh
ensive Se
mantic Sys
What is gmBasic? tem Model
A highly configurable, robust
VB6/ASP/COM compiler
that produces source codes
instead of binaries.
How does it work?
– Compiler: Builds a comprehensive semantic
model of the codebase implementation.
– Analyzer: evaluates and restructures the model
to fit the desired architecture patterns.
– Author: processes the optimized model to
generate clean, correct code that meets
custom standards and conventions.
Compiler Analyzer! Author
07/10/09 Copyright Great Migrations LLC 3
4. gmBasic 101
Semantic Model
• Symbol Trees
– External Components
– Language Elements
– Source Structures
• P-Code Tables
– Operations
– Expressions
– Source Mappings
07/10/09 Copyright Great Migrations LLC 4
5. gmBasic 101
Assertions
• Solving the semantics problem is the key
• Semantic translation can be achieved
systematically by combining linguistic theories for
natural language processing with proven principles
of compiler and interpreter design
• Source and target language/syntax differences are
trivial in comparison to runtime differences
07/10/09 Copyright Great Migrations LLC 5
6. gmBasic 102
Compiler Source
Codes
• Preparation
– Load Language Description Compiler Initial
Semantic
Model
Config
– Load Source Codes
– Load Interface Descriptions
Analyzer!
• Recognition
– Pass 1: create symbol tables of all
identifiers in the codebase
– Pass 2: create initial semantic
Author
model of all low level operations
performed by each codeblock.
07/10/09 Copyright Great Migrations LLC 6
7. gmBasic 102
Analyzer
• Interpretation
Compiler
– Type Inference
– Coding Analysis
• Restructuring
– Create Migrated Config
Analyzer ! Migrated
Semantic
Semantic Model Model
– Add/Remove/Change
Operations
Author
– Optimizations/Cleanup
– API Replacements
07/10/09 Copyright Great Migrations LLC 7
8. gmBasic 102
Author Compiler
• Code Generation
– String Machine
Analyzer!
– Executes the
migrated model
• Reporting Migrated Symbol
Author Tables
Config
Migrated Semantic
– Boilerplate Model
Target
– File Deployment Codes
Instructions
07/10/09 Copyright Great Migrations LLC 8
9. Demo: Overview
VB.Net
Migration Interop
Toolset VB.Net
Managed
VB6
COM
Language Interface
Config Config C#
Managed
C#
Interop
• A Sample Application
• VB6 to C#, VB6 to VB.Net (externs interoped)
• VB6 to C#, VB6 to VB.Net (externs taken to .Net)
• Look at Code, Build, Report, Run
07/10/09 Copyright Great Migrations LLC 9
10. A Sample VB6 Application: ScanTool
• Two VBPs: UI.exe and LIB.dll
• Lib talks back to UI via events
• 4 External COM APIs
• Win32 APIs
• Many VB Intrinsics
• Object Polymorphism
• Error Handling
• Over 2000 LOC
ScanToolUI
ScanToolLib
COM COM COM COM
Scripting MSXML Typelib Common
Info Dialog
07/10/09 Copyright Great Migrations LLC 10
11. ScanTool Metrics
• Project Structure
Project Structure Report – A very crude metric
– Conceptual Design
– Completeness
– Iceberg Report
• Project References
– Rough idea of
external
dependencies
– Some Internals
Details
• VB6 Build Test
Project References Report
07/10/09 Copyright Great Migrations LLC 11
13. Demo: Migration to VB.Net
– Migration Set: DemoScanTool
– Dialect: VB.Net (vbn)
– Migration Mode = std
– Run Translation
– Deploy Translation
– Build Translation
– Inspect Translation
– Run ScanTool.NET
07/10/09 Copyright Great Migrations LLC 13
14. Source Code Analytics
Analytics-References Report
• What really matters:
– How you actually use
COM/VB6 APIs
AND
– How you intend to
replace them on the
new platform.
• All API replacements are
NOT created equal!
07/10/09 Copyright Great Migrations LLC 14
15. Source Code Restructuring
VB.Net
Managed Interface Descriptions Migration Interop
Toolset VB.Net
• Template Generated from COM Managed
VB6
• Map source API to target API COM
Language Interface
Config Config C#
Managed
C#
Interop
Scrrun.dll.xml
MSXML4.dll.xml
07/10/09 Copyright Great Migrations LLC 15
16. Demo: Source Code Restructuring
ScanToolUI
ScanToolLib
.NET .NET COM COM
System System Typelib Common
.IO .Xml Info Dialog
07/10/09 Copyright Great Migrations LLC 16
17. Sidebar: Translation Flexibility
• Rules for mapping of COM/Win32 APIs to .NET replacements
• Rules for mapping ASP/VB6 coding patterns to .NET coding patterns
• Processing order for a multi-component translation
• Instructions to address problems or anomalies in the source codes
• Rules for target file names, folder names, etc.
• Rules for target Visual Studio project files (resx, assemblyinfo, *proj)
• Rules for formatting – blank lines, comments, indenting, boilerplate code
• Special processing instructions that control details of translator operation
07/10/09 Copyright Great Migrations LLC 17
18. Demo: BuildSet
BuildSet
VB6 Migration
CODE Toolset .Net
Code
Language Interface
COM Config Config .NET
Externals Stubs
BuildSet (n): A collection of VB6 code and COM
binaries migrated to .NET such that the VB6 code
Interop becomes .NET code and the COM binaries
become 100% managed code (a prototype object
model). This is a good starting point for teams that
want to avoid COM interop while preserving the
general aspects of their original design.
07/10/09 Copyright Great Migrations LLC 18
19. Sample 2: A Web Application
• Six VBPs (2500 LOC)
– 2 VBPs Data Access
– 4 VBPs Business Objects
• 33 ASP pages (2300 LOC)
– 5 includes (nested and stacked)
– 28 pages
• Poster Child DNA Web App
– Portfolio Management
– Research/Buy/Sell Stocks
– On-line Store
– Forms-based Login
Web Pages (ASP/VBS)
Business Objects
Data Access Objects
(ADODB)
Stored Procs
SQL Server
07/10/09 Copyright Great Migrations LLC 19
20. FMStocks Metrics
Project Structure Report • Project Structure
– A very crude metric
– Naming Standards
– Completeness
– May reveal some
design concepts
• Project References
– Rough idea of external
dependencies
Project References Report – Some Internals Details
– May reveal design
• VB6 Build Test
07/10/09 Copyright Great Migrations LLC 20
21. Demo: Migrating ASP to ASP.Net
ASP is quite different from VB6
• Include Files
• VBScript nuances
• Most COM References are implicit
• Weak typing everywhere
What can we do today?
• Produce clean, correct ASP.NET
• Create a Web Application Project
• Restructure Pages
• Consolidate Declarative Script
to CodeBehind files
• Translate Render Functions
to Response. Write in
Codebehind Files
• Restructure #Include to
Web UserControls
• Translate VBScript to C# or VB.NET
• Propagate COM replacements across
VB6/ASP as needed
• Strong Typing everywhere
• Deal with different semantics of
ASP intrinsic collections (Response, Request)
07/10/09 Copyright Great Migrations LLC 21
22. Source Code Analytics -- ASP
<%@ Language=VBScript %>
Analytics-References Report
<%option explicit%>
<% Response.Buffer = true%>
<OBJECT RUNAT=server
PROGID=FMStocks_Bus.Ticker id=ObjAccount>
</OBJECT>
<OBJECT RUNAT=server
PROGID=FMStocks_Bus.Broker id=ObjBroker>
</OBJECT>
...
<%
...
Function PlaceBuyOrder()
On Error Resume Next
PlaceBuyOrder = 0 ' assume it fails
'this will be a long to represent the number of
shares.
Dim lngShares
'convert to a long incase of fractions of shares.
lngShares= clng(Shares)
PlaceBuyOrder = ObjBroker.BuyStock(g_AccountID,
Ticker, lngShares)
if Err.number <> 0 or PlaceBuyOrder = 0 then
MainPrompt = BUYSTOCK_PURCHASE_FAILED
' PlaceBuyOrder = 0 doesn't necessarily mean
there was an error
if Err.number <> 0 then
BuildErrorMessage()
end if
Exit Function
end if
End Function
...
%>
07/10/09 Copyright Great Migrations LLC 22
23. Sidebar: API Crossing
.NET Be wary of Top-Down Migrations
Application (PiecePorting)
.NET
System.IO System.IO.FileInfo
• COM interfaces have COM types as
member parameters and return
COM
Scripting.File types.
Scripting
• If you interop COM components, your
.NET clients will end up straddling the
fence between COM and .NET and
this will require more interop code
COM which runs counter to the premise of
Interoped adopting .NET in first place.
Scripting
COM
Component
PiecePort
07/10/09 Copyright Great Migrations LLC 23
24. Sidebar: API Crossing
Bottom-Up, SmartPort Migrations
.NET •
.NET pBasic remembers what it has translated and knows which
Application
System.IO components are going to .NET.
• it uses this information to generate clean, native code in client
System.IO.FileInfo applications.
Generated Interface Description
ScanToolLib.dll.xml
.NET
System.IO
.NET
Component
ASPX ASPX ASPX ASPX
ASP ASP
ASP
ASP
Migration .NET .NET
Studio
VB
VB
VB
promula .NET .NET .NET .NET
VB VB
VB Basic
COM Framework .Net Framework
Custom
Configuration
VB6/ASP Application Portfolio .NET Application Portfolio
07/10/09 Copyright Great Migrations LLC 24
25. Great Migrations Methodology
Balanced
The Great Migrations Methodology balances
automated translation and other techniques
to improve the conversion process to
deliver high quality results with less risk and less effort.
07/10/09 Copyright Great Migrations LLC 25
26. Great Migrations Methodology
Iterative
Preparation: organizing the source codebase, defining migration requirements.
Translation: converting the source codebase to the target codebase
Verification: inspecting the target codebase for functional an architectural quality
Cut Over: taking the target codebase through final testing and deployment to production
V B 6/ Semantic
Preparation
A SP Translation Cut-Over .NET
Design
Verification
07/10/09 Copyright Great Migrations LLC 26
27. Great Migrations Methodology
Code Quality
Translation Tuning Level 1: Translation Complete
Level 2: Build Complete
VB6/ASP/COM
Level 3: Production Ready
Codebase Translate Build Run
Upgrade Phase 1
Architecture Tool
Requirements
.NET Code
Resolve Translation Issues Level 1
.NET Code
Resolve Build Issues Level 2
Phase 2
Resolve Architecture Issues
.NET Code
Test Level 3
Resolve Functional Issues
Fit & Finish
.NET Production Code
07/10/09 Copyright Great Migrations LLC 27
29. Great Migrations Methodology
Translation Tuning
Design Iterate Deployment
Conversion
CutOver
Conversion System Limited
Translation
Guides Code Test Deployment
Prepare Partial
Code Snap
System Fix &
Snap Shot
Revised Translate Tests Finish Load Full
Estimates Shot Test Deployment
Verify
Test Environment Ready Dev Cutover Dev Upgrade
Scope Set &
Established for Cutover Freeze Translation Thaw Complete
Estimates
Refined
07/10/09 Copyright Great Migrations LLC 29
30. The Great Migrations Difference
Translation .NET
Cut Over Codebase
Clean, Correct, Custom Translation
• Tools
– Translation Solutions
VB
Preparation Verification
– Choice of .Net Language Codebase
– Flexible Restructuring
– Multi-Project Capability
– Analytics
• Processes
– Migration Methodology
– Automation
– Control
• People ASP
ASP ASP
ASPX ASPX ASPX ASPX
– Migration Expertise
ASP
Migration .NET .NET
Studio
VB
VB
VB
promula .NET .NET .NET .NET
VB VB
VB Basic
COM Framework .Net Framework
Custom
Configuration
VB6/ASP Application Portfolio .NET Application Portfolio
07/10/09 Copyright Great Migrations LLC 30
31. Meeting Objectives
• Your Objectives
– Understand the challenges of migrating
VB6/ASP/COM to .NET
– Understand the role of translation technology as part of
a .NET adoption effort.
– Understand the tool-assisted approach to Migration.
• Great Migrations’ Objectives
– Educate you on the challenges of migrating VB6/ASP/
COM to .NET and potential solutions
– Help you get started!
07/10/09 Copyright Great Migrations LLC 31