0

I haven't coded in a long while, but I do remember that I could use intellisense to generate the constructor, properties and overides, just by clicking generate after I have specified the fields in a class.

I'm no longer able to get the generate popup. How can I automatically generate the code for the constructor, properties and overrides when I have a class that only contains fields?

  • 1
    I think that it's ReSharper, that is able to do that for you - not IntelliSense – J.N. May 09 '17 at 01:50
  • I don't use any add-ons or extension in visual studio, I use to be able to do this functionality with vanilla visual studio. – Jason du Plessis May 09 '17 at 01:54
  • Alright. Have you seen this? http://stackoverflow.com/questions/36385408/shortcut-for-creating-constructor-with-base-c-vs2015 – J.N. May 09 '17 at 01:55
  • Yes, I'm looking for that functionality, but pressing shift+alt+f10 or even alt+. would do nothing. I could remember right clicking and having a option called "generate", or be able to click a blue line under the class declaration, but that's not there. – Jason du Plessis May 09 '17 at 01:58
  • Weird. What happens if you right-click on the object instantiation with the missing constructor, are you then presented with the "Quick Actions and Refactorings" menu? As the "Mouse" example here: https://learn.microsoft.com/en-us/visualstudio/csharp-ide/code-generation/generate-constructor – J.N. May 09 '17 at 02:01
  • In that example, you're trying to create just the constructor by calling the class and specifying parameters, to then generate within the class a new constructor with those parameters. That's not what I'm looking for, Right after declaring the fields of my class, I want to be able to use intellisense to generate the constructor, the getter and setters (properties), as well as any overrides like the ToString. VS would bring apopup which will allow you to select which fields you want to include in the constructor and also allow you to pick which fields you want to create properties for. – Jason du Plessis May 09 '17 at 02:08
  • I have only ever seen ReSharper being able to do that (I'm not on Windows right now, so I can't try the posted links on my own machine). It seems like the functionality should be available in VS2015 and 2017 when selecting the properties, that you want to initialise from your constructor, using the "alt+." command, but if it doesn't work, it doesn't work... http://stackoverflow.com/questions/2976363/how-do-i-generate-a-constructor-from-class-fields-using-visual-studio-and-or-re Sorry man, can't help you further. – J.N. May 09 '17 at 02:13
  • You mentioned right clicking, could you have had the Comet add-in installed? (http://cometaddin.codeplex.com/). I can't for the life of me remember vanilla VS having this functionality, it was one of the things that I liked - and still do - about ReSharper. – Eric Yeoman May 09 '17 at 02:18
  • I was using vanilla Visual Studio, no add-ons or extensions. I've installed reSharper and have gained that functionality again that I spoke of, although it's in another style. I'll have to use reSharper now. Thanks for the help. – Jason du Plessis May 09 '17 at 02:19

0 Answers0