CodeConverter icon indicating copy to clipboard operation
CodeConverter copied to clipboard

Change editor context menu to be "Copy as VB"/"Copy as C#"

Open Juansero29 opened this issue 6 years ago • 3 comments

Wouldn't it be possible to make this optional? It's annoying when I only want to copy some lines of code from VB.NET and I need to paste it elsewhere (in another project) as C#. I would want that it just copies to my clipboard and stop there by setting the option 'Create a new file with result' to "false". It could by default set to 'True', that way there wouldn't be any changes from current behavior.

Juansero29 avatar Feb 25 '19 15:02 Juansero29

Thanks for the feature request. I really appreciate the idea about providing the new behaviour without changing the current experience. In the context of #37 and #245, I'm starting to think that saving to a file from a text selection is the wrong thing to do by default (it's mainly done for consistency really).

Perhaps it's time to change the text and behaviour to be something like "Copy as C#" or "Copy as VB".

The other possible behaviour (that could be combined/optional), is not to save a file, but to open the result in a new window, and to set the window just like any other temporary window that disappears if you look at a few other tabs.

One thing worth remembering is that conversion isn't always instant (your experience of how long it takes for real world use cases may be useful here). Opening the window is one way of giving feedback that the conversion is complete, the other alternatives are a message box, or just relying on paying attention to the output window.

Could you let me know:

  1. What would work best for your use case
  2. Whether any options would be particularly annoying
  3. Is my assumption correct that you'd only want this for the text selection context menu within a code window?

GrahamTheCoder avatar Feb 26 '19 09:02 GrahamTheCoder

Hello Graham, thanks for the quick response!

I also share the idea that saving in a new file perhaps isn't the best behavior. In my case, I do a lot of conversions through selections and I almost never translate an entire project or file. First of all because it don't need it, but when I need it I still don't use it that much since it is less reliable (more chances of parts of the conversion failing). Hence I prefer doing little conversions via copy/paste.

What is really annoying for me:

  • Having to search for the new file with the converted code (which is specially annoying since when converting code from the selected text, the file isn't added to the project, so I have to go through the file explorer for this)
  • Having to delete this file manually each time after having copied the code from it to avoid polluting my project with useless files.

I think the best behavior would be:

  • If right clicking on a file/project. Keep current behavior. (Creating the new files, etc)
  • If right clicking a selection of code, either C# or VB.NET, add the options in the right click menu: "Copy as C#" or "Copy as VB.NET" respectively.
  • Removing the "Convert to...." from the selection context menu since copy does the same job, only that in less time and without polluting the project with unnecessary files.
  • And yes, it would be better if the "Copy as..." it's only available in the context menu when right clicking a selection of code.

For information, my conversion times are not long at all. For like 100 to a 250 lines of code it takes at most 10 seconds on average. It wouldn't bother me to wait this time after clicking on "Copy as... ". A message box would also be a viable solution for me. I would just see when it pops out and copy the translated code directly from it without having to erase the new created. It would also avoid having to delete the files.

But if this is too hard to implement or if you think it would change too much of the current behavior, I would go with the 'Create a new file with result' option. That way I could just set it to false and it would do the trick. I guess it is easier to implement for you. I hope this was useful, and thanks!

Juansero29 avatar Feb 28 '19 12:02 Juansero29

Thanks for all the information - it's so useful to hear from real users. I think we agree about the best course of action! In order to avoid any conflicts I'll wait until #245 is done, then try to find time to look at this.

If you ever need to find the files (and "Open containing folder" doesn't work), for now, I'd recommend using your version control system to quickly find/delete them.

When converting a whole project, it's generally worth doing the whole project conversion first but without updating the project/solution files. Then you can see where the errors are and make manual conversion where appropriate. Also of course, please do report any issues you find in conversion (or 👍 relevant existing issues).

GrahamTheCoder avatar Feb 28 '19 13:02 GrahamTheCoder