.NET Tutorial

Scanning the C# Code

Now that you have handled all of the static HTML stings, we will focus on fixing i18n problems in the C# code. This includes both the in-line C# code in the .aspx files, as well as the .cs source files. The first step is to scan the C# source.

  1. Select Scan=>Manage Scans from the menu bar. The Manage Scans Wizard appears.

  2. Click New. The Globalyzer Scan dialog appears.

    Enter "csharp_scan" into the Scan Name field. With the Rule Set dropdown, select the csharp Rule Set you created earlier. Leave all directories and files listed in the Source Files unselected, or alternately select them all. Globalyzer will treat the two scenarios the same:

  3. Click Next. The Globalyzer Scanning page appears.

    Under Detect, uncheck Static File References leaving Embedded Strings, Locale-Sensitive Methods and General Patterns checked:

  4. Click Next. The Globalyzer String Externalization page appears.

    Make sure that Resource File Type is set to resx and that the Resource File Path is set to the same location as you set for html_scan. For example: C:/Inetpub/wwwroot/simple/MyResources.resx. Then, set String Key Next ID to 200 to keep it out of the range of the html_scan String ID values. All the other Fixing settings should match those you set for html_scan as shown below. It is recommended that this step be approached with significant attention to detail.

  5. Click the Finish button at the bottom of the dialog.

  6. Close the Manage Scans dialog.

  7. In the Scan Results view, select csharp_scan in the Scan dropdown:

  8. Look in the Project Explorer view. If the Simple directory is not expanded, expand it. It should look like the window below:

  9. Click on the Single Scan button in the Toolbar. Once the scan is complete, select Embedded Strings from the Results Dropdown. Within the results, click on the File column (to sort). You should see similar results displayed in the Scan Results table:

  10. Select Locale-Sensitive Methods from the Results dropdown to see Locale-Sensitive Method issues.

    After inspecting the list for a short time, select General Patterns.

    These results indicate that Globalyzer has detected three categories of internationalization issues within the C# source in our project. As before, it detected Embedded Strings. But this time it also uncovered some Locale-Sensitive Methods and some General Patterns.

    • In the case of C#, Locale-Sensitive Methods are methods that perform culture-specific functionality.

    • General Patterns is a catch-all for items that are not picked up by Embedded Strings, Locale-Sensitive Methods, or Static File References. In this tutorial there are a large number of General Patterns which are Locale-Sensitive. These items are not methods so they are not included in the Locale-Sensitive methods category. They are therefore listed as General Patterns instead.

    It is up to the developer to ensure that the Locale Sensitive Methods and Constructors all use the correct culture.

In the next lesson we will start our fixing process by examining these constructors, methods and properties detected by Globalyzer.