Configuring and using the Visual Studio Code Extension for MTA

Table of Contents

1. Introduction to the MTA extension for Microsoft Visual Code

You can migrate and modernize applications by using the migration toolkit for applications (MTA) extension for Microsoft Visual Studio Code.

The MTA extension can perform the following actions:

  • Analyze your projects with customizable rulesets.

  • Mark issues in the source code.

  • Provide guidance to fix the issues.

  • Perform automatic code replacement, if possible.

The MTA extension is also compatible with Visual Studio Codespaces, the Microsoft cloud-hosted development environment.

2. Installing the MTA extension for Visual Studio Code

Install the migration toolkit for applications (MTA) extension pack or the MTA Core extension with a language-specific extension to perform an application analysis. Use the extension pack to analyze in all supported languages or the Core and a language-specific plugin to optimize the memory usage.

You can install the following language-specific MTA Visual Studio Code extensions from the Visual Studio Code Marketplace:

  • Java

  • JavaScript to analyze JavaScript and Node.js applications

  • C# to analyze C# and .NET applications

  • Go

Important

`Extension pack`, `C#`, `JavaScript`, and `Go` extensions are Developer Preview features only. Developer Preview features are not supported by Red Hat in any way and are not functionally complete or production-ready. Do not use Developer Preview features for production or business-critical workloads. Developer Preview features provide early access to upcoming product features in advance of their possible inclusion in a Red Hat product offering, enabling customers to test functionality and provide feedback during the development process. These features might not have any documentation, are subject to change or removal at any time, and testing is limited. Red Hat might provide ways to submit feedback on Developer Preview features without an associated service level agreement (SLA).

Prerequisites
  • You installed the Java Development Kit (JDK). MTA supports the following JDKs:

    • Oracle JDK 17 or later

    • Eclipse Temurin™ JDK 17 or later

    • OpenJDK 17 or later

  • You have 8 GB of RAM available.

  • For macOS installation, you have the value of maxproc set to 2048 or greater.

Procedure
  • Install the MTA 8.2.0 Visual Studio Code plugin from the Visual Studio Code Marketplace.

3. Configuring and using the MTA analyzer RPC binary in your system

The migration toolkit for applications (MTA) Visual Studio Code extension consists of an analyzer RPC binary that runs an analysis.

When you install the MTA Visual Studio Code extension, the extension downloads the analyzer RPC binary of the latest version from the Red Hat Developer portal.

In a restricted network environment where the MTA extension cannot access the link to download the analyzer RPC binary, you can download the binary in your system and configure its path in the Visual Studio Code extension.

Prerequisites
  • You installed the Java Development Kit (JDK). MTA supports the following JDKs:

    • Oracle JDK 17 or later

    • Eclipse Temurin™ JDK 17 or later

    • OpenJDK 17 or later

  • You have 8 GB of RAM available.

  • For macOS installation, you have the value of maxproc set to 2048 or greater.

Procedure
  1. Download the MTA 8.2.0 analyzer RPC from the Red Hat Developer portal to your system.

  2. Access the MTA extension settings in either of the following ways:

    1. Click Extensions > MTA Extension for VSCode > Settings.

    2. Type Preferences: Open User Settings (JSON) in the Command Palette to open the settings.json file.

  3. Configure the analyzer RPC binary path for the extension in one of the following ways:

    1. Enter the analyzer RPC binary path in the Analyzer Path field in the MTA extension settings.

    2. Configure the path to the local analyzer RPC binary in the mta-vscode-extension.analyzerPath field in the settings.json file.

    3. Type MTA: Override Analyzer Binary in the Command Palette to select the analyzer binary in your system.

  4. Reload the Visual Studio Code window by typing Developer: Reload Window in the Command Palette.

  5. Open the extension analysis view by typing MTA: Open Analysis View in the Command Palette.

  6. Click Start to use the analyzer RPC binary to perform an analysis.

4. Configuring the IDE settings

MTA settings apply to every analysis that you perform by using the Visual Studio Code extension. The extension settings have the following categories:

  • Analysis-related settings

  • Debugging and logging settings

  • Solution server settings

  • Generative AI settings

Procedure
  1. Open the MTA settings by clicking Extensions > MTA Extension for VSCode > Settings.

    Alternatively, open the setting by performing the following steps:

    1. Type Ctrl + Shift + P or Cmd + Shift + P on the search bar to open the Command Palette.

    2. Enter Preferences: Open Settings (UI).

    3. Open the settings page by clicking Extensions > MTA.

  2. Configure the following settings:

    • Log level: Set the log level for the MTA binary. The default log level is debug. The log level increases or decreases the verbosity of logs.

    • Analyzer path: Specify an MTA custom binary path. If you do not provide a path, Red Hat Developer Lightspeed for MTA uses the default path to the binary.

    • Debug:Webview: Enable debug level logging for Webview message handling in Visual Studio Code.

5. Configuring the MTA profile settings

You can use the Visual Studio Code plugin to run an analysis to discover issues in the code.

To generate code changes by using the MTA extension, you must configure a profile that contains all the necessary configurations, such as rules and source and target technologies.

Prerequisites
Procedure
  1. Open the MTA View Analysis page by clicking the book icon on the MTA: Issues pane of the MTA extension.

    Alternatively, type Ctrl + Shift + P or Cmd + Shift + P in the search bar to open the Command Palette and enter MTA:Open Analysis View.

  2. Click the settings button on the MTA View Analysis page to configure a profile for your project. The Get Ready to Analyze pane has the following basic configurations required for an application analysis:

    • Select profile: Create a profile that you can reuse for one or more analyses.

    • Configure label selector: A label selector filters rules for analysis based on the source or target technology.

      Specify one or more target or source technologies. Red Hat Developer Lightspeed for MTA uses this configuration to determine the rules to apply to a project during the analysis. If you mentioned a new target or a source technology in your custom rule, you can type that name to create and add the new item to the list.

      Important
      You must configure target or source technologies before running an analysis.
    • Set rules: Enable default rules and select your custom rule that you want MTA to use for the analysis. You can use the custom rules in addition to the default rules.

Verification
  • After completing the profile configuration, close the Get Ready to Analyze pane and run an application analysis.

6. Running an application analysis

You can run a static code analysis of an application with or without enabling the Generative AI (GenAI) features. The Remote Procedure Call (RPC) server runs the analysis to detect all issues in the code for one or more target technologies to which you want to migrate the application to.

Prerequisites
  • You opened a project in your Visual Studio Code workspace.

  • You installed the following for .NET Core or C# application analysis:

    1. The MTA Core and C# extensions

    2. dotnet tools and added it to the $PATH environment variable

    3. ilspycmd command line tool for the ILSpy.NET decompiler

    4. paket package manager

  • You configured an analysis profile on the MTA Analysis View page. For more information, see Configuring the MTA profile settings.

Procedure
  1. Click the Red Hat Developer Lightspeed for MTA extension and click Open MTA Analysis View.

  2. Select a profile for the analysis.

  3. Click Start to start the MTA RPC server.

  4. Click Run Analysis on the MTA Analysis View page.

7. Configure OIDC authentication to connect to the Hub

To reuse a centrally managed user account for authentication, you can use identity provider (IdP) credentials to connect to the migration toolkit for applications (MTA) Hub. The Hub OpenID Connect (OIDC) provider acts as the OIDC broker that federates user authentication to the IdP.

Prerequisites
  • You installed the MTA 8.2.0 extension.

  • You have the MTA Hub URL.

  • The MTA administrator configured the IdP as an OIDC client.

Procedure
  1. Enter Control +Shift +P or Cmd +Shift + P to open the Command Palette.

  2. Enter the MTA: Konveyor Analysis View command to open the MTA Analysis View page.

  3. Click the settings icon and select Configure Hub Settings.

  4. Enter the following configuration:

    • Toggle on Enable connection to MTA Hub.

    • Enter the web console application URL in the Hub URL field after removing the /applications path.

    • Enable Skip SSL certificate verification if you want to connect to the Hub by using an insecure connection.

    • Enable the authentication option.

    • Select OIDC as the authentication method.

  5. Click Save.

  6. Click Sign In in the Authentication box to be redirected to your browser.

  7. Enter the IdP credentials to log in.

  8. After you log in successfully, the Authentication box shows the status as Connected, your user and the status for LLM proxy, Solution Server, and Profile Sync.

If you sign out and reconnect before the token expiry period, the MTA Hub reauthenticates you automatically.

8. Running an application analysis by using a Hub profile

To run a static code analysis of an application, you can use a profile that is created and managed by your architect in the migration toolkit for applications (MTA) Hub.

The centralized configuration management standardizes the analysis configuration and custom rules across projects to produce a consistent result. This allows the architect to create and manage the necessary profiles, thereby simplifying the lifecycle of analysis configurations and rules. Migrators can run analyses either by using local profile configuration or by using profiles from the Hub.

When you connect to the Hub from your Visual Studio Code instance, MTA downloads the analysis profiles and custom rules present in the Hub to the .konveyor/profiles location on your hard disk. You can use the analysis profile that has custom rules to perform analyses in your Visual Studio Code IDE environment. If you connect to the Hub, the MTA extension disables profile manager options in your IDE instance.

Important

Analysis Profile is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.

For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.

Prerequisites
  • You opened a project written in one of the supported languages in your Visual Studio Code workspace. MTA can analyze source code written in Java, C#, .NET, Go, and JavaScript.

  • An architect has configured an analysis profile in the MTA web console.

  • The repository URL of the local application matches an existing application in the MTA web console.

  • The application has a tag that matches the criteria tag in an archetype.

  • The archetype has at least one target profile.

  • The architect selected the analysis profile in the target profile.

Procedure
  1. Click the Red Hat Developer Lightspeed for MTA extension and click Open Analysis Panel.

  2. In settings (settings-icon), click Configure Hub Settings.

  3. Configure the following settings on the Hub Configuration page:

    1. Enable Hub.

    2. Enter the MTA user interface URL in the Hub URL field.

    3. If you want to connect to your Hub without verifying the local SSL certificate in the host, enable Skip SSL certificate verification.

    4. Log in to the Hub by enabling the Enable authentication switch.

    5. Enter the username and password credentials of the MTA user interface.

    6. To generate code resolutions for the issues in your source code by using the Solution Server, enable Solution Server.

      When you enable the Solution Server and the administrator has deployed LLM proxy in the cluster, MTA uses the proxy service to connect to the LLM.

    7. To synchronize the profiles with the Hub, enable Profile Sync. MTA periodically downloads the latest version of the profiles from the Hub.

      To update the profiles and rules, you must synchronize them profiles with the Hub.

  4. Select a profile from the list on the MTA Analysis View page.

  5. Click Run Analysis.

9. Reviewing and resolving migration issues

You can use the MTA extension icons to prioritize issues based on their severity.

Procedure
  1. Select a run configuration directory on the left pane.

  2. Expand its folders to view the Hints generated for each application file.

  3. Select a hint to view the source code.

  4. Right-click a hint and select View Details to view the Rule ID and other information.

  5. Prioritize issues based on the following icons, which are displayed next to each hint:

    • Mandatory: You must fix the issue for a successful migration.

    • Warning: You might need to address the issue during the migration.

  6. Resolve issues by editing the code of a file with a hint:

    1. In the left pane, right-click an issue and select Open Code.

    2. Make any changes needed to the code and save the file.

    3. Optional: Right-click the issue and select Mark as Complete or Delete.