-
Notifications
You must be signed in to change notification settings - Fork 222
Home
GrahamTheCoder edited this page Oct 12, 2020
·
28 revisions
Before performing any conversion, it's recommended to:
- Ensure you have no uncommitted changes in your version control system. This will make it easy to see the result of the conversion, and discard any parts you don't want.
- Ensure your solution compiles for maximum conversion accuracy.
- Split out any files over about 5000 lines (using partial classes if needed). Converting two 5000 line files is usually significantly faster than converting one 10000 line file. This may be slightly less of an issue with the command line.
- Immediately after conversion, commit the result, this will make it easy to report issues
Once your output is compiling, I'd recommend setting up a .editorconfig and using: dotnet-format to format things the way you like.
- Install the Visual Studio Extension in VS2019 (or at minimum VS2017 15.7)
- Open your solution in Visual Studio
- 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!
- In powershell:
- 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.
- 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.
Alternatively you can use the online snippet converter: https://codeconverter.icsharpcode.net/ However, it is less accurate due to the lack of project context.
Closing Visual Studio, or starting a new conversion cancels the in-progress conversion