When one choose Refactoring, Encapsulate Fields for let's say:
int m_member;
VS will generate
public int Member
{
get { return m_member; }
set { m_member = value; }
}
For some reason (using a reverse engineerint tool for example which doesn't know this style), I'd like to get the oldish and more verbose style:
public int getMember() {
return m_member;
}
public void setMember(int value) {
m_member = value;
}
Is it possible to configure VS to do so ? Otherwise any other mean with sample code like creating snippet template or even Plugin if necessary ?
So... you want to write Java/C++/(any language that doesn't support properties) in C#? Why?
Properties are nice because:
Even your method naming convention looks like Java. It is a good idea to get into the habit of adopting the idioms of a new language as you learn it.
This pattern is not idiomatic of C# code - and Visual Studio doesn't support it. I would recommend avoiding it in favor of the property syntax. However, if you really do need it for some reason, you can get there with ReSharper. Here's what you do in ReSharper:
The first step let's you create a property that wraps the public field.
The second replaces that property with get/set methods whose names you can specify.
Although I don't necessarily recommend this, all refactorings are simply snippets that you can edit. A default installation will put the C# templates in this folder,
C:\Program Files\Microsoft Visual Studio 10.0\VC#\Snippets\1033\Refactoring
, simply find the one that you want and modify as you see fit.NOTE: Be sure to take a backup first!!
I'll also agree with everyone else, that this is a REALLY bad idea!