1 / 11

Converting the Code

Converting the Code. What the code consists of ?. Using declarations Namespace declaration Class declaration Variable declarations Method declarations Return Type Parameters Method body Operations (Method calls, Variable declarations).

dalila
Télécharger la présentation

Converting the Code

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Converting the Code

  2. What the code consists of ? • Using declarations • Namespace declaration • Class declaration • Variable declarations • Method declarations • Return Type • Parameters • Method body • Operations (Method calls, Variable declarations)

  3. Changes in the .NET framework? .NET 4.0 vs .NET 4.5 (Metro) • Why we need to convert the code? • Location of classes have changed • E.g. System.Windows.Forms.TextBox is now in Windows.UI.Xaml.Controls.TextBox. • Methods have changed • E.g. System.IO.File.ReadAllText()has been replaced with Windows.Storage.PathIO.ReadTextAsync()

  4. Changes in the .NET framework? (cont’d) • Some Controls are removed • No DataGridView • No Multiple Document Interface • MessageBox have changed • Try to provide our own controls to fullfil these needs

  5. Changes in the .NET framework?(cont’d) • More emphasis for asynchronous calls • New async, await keywords • New methods in classes which run asynchronously • e.g. System.IO.Stream.ReadAsync()

  6. Steps in code conversion • Convert the using declarations • Change old using declarations to new ones • Add additional required using declarations • Convert class declaration • Convert method declarations • Data type changes • Event handler special cases • Convert Operations • Method calls • Assignment operations • Etc.

  7. Steps in code conversion Convert method declarations Convert operations Convert class declaration .NET 4.5 (Metro style) .NET 4.0 Convert the using declarations

  8. Overview of the conversion process Input C# code file (.cs) Output C# code file (.xaml.cs) Extract Information about classes, methods, etc. in the files Convert using declarations Convert method declarations Convert operations Control mapping, Data type mapping, Method invocation mappings Using declaration conversion rules Data type mapping

  9. How the conversion is done • The basic process in which using declarations, method declarations, operations etc. are converted from .NET 4.0 to .NET 4.5 is the same. But each need special handlings as well. • Following is an example of one such scenario

  10. Conversion of a simple operation (method call) 1) Use Roslyn APIs to break down the code Ex. Basic structure of code line MessageBox.Show(count.ToString(), "Message"); • Build up information of what the user written code mean • MessageBox, Show, count, ToString are knows as identifier tokens • Identify that MessageBox.Show together is a Method call

  11. Conversion of a simple operation 2) Check if this method call need to be converted. If so get what the new call is. (Known as a conversion rule) • Generated the new Method call as TransMessageBox.Show(count.ToString(), "Message"); • Replace the old method call in the code with the newly converted method call System.Windows.Forms.MessageBox.Show(Old) => TranscendersWrapper.TransMessageBox.Show(New) MethodSignature.xml

More Related