Skip to content

Visual Studio Extension

GrahamTheCoder edited this page Dec 11, 2021 · 2 revisions

First, please read https://github.com/icsharpcode/CodeConverter/wiki#general-advice

Using the Visual Studio extension

  • Install the Visual Studio Extension in VS2019+ (even free community edition is fine)
  • Open your solution in Visual Studio

Converting whole project/solution

  • Right click the solution or project node to convert in the solution explorer and select "Convert to VB" or "Convert to C#".
  • The Output window will show progress - it may seem to pause for several minutes at times on large projects.
  • At the end of the process you'll be given the choice to automatically update any references (from non-converted projects and the solution) to reference the now converted projects. Cancelling the process at this point will leave all original files intact, and converted projects/files on disk to be manually inspected.
  • When the conversion finishes, the Output window will show a summary of the conversion's success, and one of the converted files will be opened as an example.
  • Once you're happy with the resulting conversion, you may want to delete all files with (for example) ".vb" in their name recursively from a folder:
    • In powershell: Get-ChildItem -Recurse *.vb* | Remove-Item ⚠️ Deletes files recursively!
    • Windows command line: DEL /S /Q *.vb* ⚠️ Deletes files recursively!

Converting a single file

  • Right click the .vb or .cs file to convert in the solution explorer and select "Convert to VB" or "Convert to C#".
  • The Output window will show progress - it may seem to pause for several minutes since related projects must be compiled.
  • When the conversion finishes, the Output window will show a summary of the conversion's success.
  • The converted file will be saved to disk adjacent to the original file (but with the appropriate converted file extension), and opened in a code window. It won't be part of any project or solution.

Converting a snippet

  • Open a .vb or .cs file containing code to be converted.
  • Highlight the relevant text.
  • Right click on the highlighted text and select "Convert to VB" or "Convert to C#".
  • The Output window will show progress - it may seem to pause for several minutes since related projects must be compiled.
  • When the conversion finishes, the Output window will show a summary of the conversion's success.
  • The converted snippet will be saved to disk adjacent to the original file (but with the appropriate converted file extension), and opened in a code window. It won't be part of any project or solution.

Selected text conversion context menu

Alternatively you can use the online snippet converter: https://codeconverter.icsharpcode.net/ However, it is less accurate due to the lack of project context.

Cancelling

Closing Visual Studio, or starting a new conversion cancels the in-progress conversion