Closed GrahamTheCoder closed 4 years ago
Related to #445
Might be cool to see https://microsoft.github.io/monaco-editor/ integrated with it.
Yeah I think that and SharpLab are the main two contenders to be compared. I like the autofixup options in SharpLab, but the same may be possible in monaco, I haven't investigated it. If anyone wants to do/find a comparison of the two and look for other options that'd be helpful. I believe one benefit of Monaco is that it supports workspaces (i.e. multiple files), which leaves cool future possibilities like pointing at a GitHub repo and browsing around it auto-converted to your preferred language.
Relatedly: I noticed recently that dotnetfiddle has a "Convert to VB/C#" option which uses this converter. I also notice SharpLab uses the ICSharpCode ILSpy library - https://github.com/ashmind/SharpLab/issues/444. If our website became essentially a fork of SharpLab with the code converter added, it might be worth checking if there's interest in integrating that feature to the core.
The current implementation is almost JAMstack (the pages use only the templating Razor feature...). We could go full JAMstack (https://www.staticgen.com/) and host the API eg in Azure Functions (published via a GH Action).
Further investigation Monaco only provides syntax highlighting out of the box. But to really tackle this issue we'll need a server to provide the roslyn suggestions : https://github.com/Microsoft/monaco-editor/issues/572 SharpLab is the same - they all run Roslyn like the converter.
So I think the easiest solution for this ticket would be using SharpLab.
Static sites I really love static sites (it's so easy to auto-publish to github pages - here's one I made earlier), so if someone tries it out and shows it's workable please open a ticket to give it space for more discussion. However, I suspect the cold start time of loading all the roslyn assemblies, then getting Roslyn to create a basic compilation is already longer than anyone wants to wait for a page load / keypress. Coldstart mitigations might help but I don't see any reference to anyone doing this before with Roslyn - even Microsoft.
I second this request. The extension works great but my common use is just the need to convert some snippet I find online. So for example I'm in a page in Visual Basic, I find a C# snippet of code on-line I need to convert it to use in my page. What I tried is to past the C# code in the VB page, select it hoping to find "Convert to VB" in the context menu, but instead I only have "Convert to C#" that in turn does the opposite and converts the whole class to a new C# file.
I should have been clearer that this issue is about https://codeconverter.icsharpcode.net/ Though your use case sounds like #245 or #247 might be a good fix?
Thank you Graham! Is exactly what described in #245 "Add editor context menu to "Paste as VB"/"Paste as C#". The other ticket in my opinion (copy as,...) make less sense. What you want is the conversion in the place where you are going to past stuff. What you are copying should be the extension to be able to understand by itself. Even because this would allow you to copy snippets outside VS (for example from web pages) and than paste as the language you want (this also could be trasparent since the extension may be able to understand by itself the context where you are pasting if is a .vb or .cs file). Will you think about implementing the #245?
Yes, I've added it to the backlog. Add a👍 the issue to register your interest and subscribe to the issue to get updates, or let me know on the issue if you start work on it yourself.
Thank you boss! great job so far... maybe I'll sto heading to Telerik on-line code converter LOL
Now that I've added the monaco editor for syntax highlighting I'm going to close this. Obviously there is more that could be done, but best to have a new focused ticket than this general one.
Is your feature request related to a problem? Please describe. I just want to type and convert a quick snippet of code, but the converter throws an error in some cases when it's not neatly contained in a class.
Describe the solution you'd like Use an existing editor to help me write compiling input.
Describe alternatives you've considered The default template should have a function in it, and the cursor should start inside it.
Requirements Must: still support basic conversion on mobile Should: Show compile errors Could: support intellisense/autofixups for using statements etc.