2

I'm using Visual Studio 2017 15.9.0 Preview 4.0. I'm trying to use the "Paste XML As Classes" command available under "Edit > Paste Special" but it's grayed out:

enter image description here

I got the (incorrect) feeling that this command would allow me to pick a file that contained XML, or have some other sort of UI. The articles I None of the articles I found talk about cases where these commands are disabled, and all indications lead me to believe it should be available in this version of VS:

https://dailydotnettips.com/did-you-know-you-can-automatically-create-classes-from-json-or-xml-in-visual-studio/

https://improveandrepeat.com/2017/08/paste-xml-as-class-in-visual-studio-2017/

https://www.c-sharpcorner.com/article/how-to-paste-json-as-classes-or-xml-as-classes-in-visual-stu/

I did find one article (below) that discusses when it's missing (which is obviously not the case here) because the project must target Framework 4.5 or above, but that's the exact .NET version I'm targeting.

https://blog.codecalculated.com/2015/01/02/paste-xml-as-classes-missing-in-visual-studio/

rory.ap
  • 34,009
  • 10
  • 83
  • 174

1 Answers1

2

I finally came across this lone article that gave me the solution:

http://www.selcuksasoglu.com/2014/06/18/creating-classes-with-xml-files-using-net-4-5/

In it, it says

If you fail to copy the xml file to your clipboard, you may notice that “Paste XML as Classes” is disabled.

Wow, that was easy. Wouldn't it have been great if Microsoft thought to include a little tool tip with those grayed out commands?

enter image description here

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
rory.ap
  • 34,009
  • 10
  • 83
  • 174
  • 1
    To be fair, what would you paste if you had nothing in the clip board? Did you think it opened an interactive GUI or something? – Mark C. Nov 02 '18 at 13:19
  • 3
    Other clues such as the fact that `Paste` itself was greyed out in the edit menu should have pointed towards "there's nothing in the clipboard". – Damien_The_Unbeliever Nov 02 '18 at 13:20
  • 2
    So the answer is, if you forget to copy, you cant paste? – TheGeneral Nov 02 '18 at 13:20
  • @MarkC. -- correct. I read something that lead me to believe it would allow me to pick a file. – rory.ap Nov 02 '18 at 13:21
  • @rory.ap There's no `...` at the end of menu item. So it won't open anything. Convention. – Tomasito Nov 02 '18 at 13:22
  • It makes me wonder though why even the "paste special" menu is enabled then. – rory.ap Nov 02 '18 at 13:25
  • I think the general convention these days is that menu items with submenus are never disabled, even when there are no (enabled) items in the submenu. E.g., assuming you've not saved any window layouts, look at the `Window -> Apply Window Layout` menu. – Damien_The_Unbeliever Nov 02 '18 at 13:28