5

Before I start, I know there is this post and it doesn't answer my question: How to generate getters and setters in Visual Studio?

In Visual Studio 2008 there is the ability to auto generate getters and setters (accessors) by right clicking on a private variable -> Refactor -> Encapsulate Field...

This is great for a class that has 2 or 3 methods, but come on MS! When have you ever worked with a class that has a few accessors?

I am looking for a way to generate ALL with a few clicks (Eclipse folks out there will know what I am talking about - you can right click a class and select 'generate accessors'. DONE.). I really don't like spending 20 minutes a class clicking through wizards. I used to have some .NET 1.0 code that would generate classes, but it is long gone and this feature should really be standard for the IDE.

UPDATE: I might mention that I have found Linq to Entities and SQLMetal to be really cool ideas, and way beyond my simple request in the paragraph above.

Community
  • 1
  • 1
Mario
  • 3,405
  • 6
  • 38
  • 48
  • 1
    If you have that many fields that it takes 20 minutes, perhaps your class is trying to do too much – CaffGeek Jul 26 '10 at 16:34

4 Answers4

10

Sorry, you really need to install Resharper to get approximately the same amount of refactoring support as you are used to in Eclipse.

However, Resharper gives you a dialog very similar to the one you are used to in Eclipse: Screenshot

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Rasmus Faber
  • 48,631
  • 24
  • 141
  • 189
3

I have an "info class generator" application that you can use an excel sheet and it will generate the private members and the public get/set methods.

You can download it for free from my website.

Mitchel Sellers
  • 62,228
  • 14
  • 110
  • 173
2

In 2008 I don't bother with Encapsulate Field. I use the new syntax for properties:

public string SomeString { get; set; }
Eddie Deyo
  • 5,200
  • 8
  • 35
  • 35
0

Possibly a macro. There are also addins (like ReSharper, which is great but commercial) capable of doing that quickly.

petr k.
  • 8,040
  • 7
  • 41
  • 52