Suggestion: Conversion to property change

When I have code like this:



public int SomeName;


I would like the convert to property refactoring to have an option to maintain the field name as the property and move the attributes to the new property. The end result woud be:




public int SomeName
{
get { return this._SomeName; }
set { this._SomeName = value; }
}
private int _SomeName;

The results might be different for a project that support .NET 3.5, but I have a project that is using 3.0 and needs alot of these cases to be changed.

Thanks!

Rob Cannon

0
4 comments
Avatar
Permanently deleted user

Until ReSharper does what you want, the easiest approach is to insert "{get;set;}" before the ";" in the existing field declaration. This triggers the automatic property support, and does not require any further code changes (as long as the property is not the target of a "ref" or "out").

0
Avatar
Permanently deleted user

Yes, but the project I am on has not migrated to 3.5 yet (bad timing between our release and their release). We just did the first release and after our patch release we can migrate. I need something now!

0

Hello Rob,

Why not use VS2008 with C# 3.0 language compiler and target .NET Framework
2.0?

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


RC> Yes, but the project I am on has not migrated to 3.5 yet (bad timing
RC> between our release and their release). We just did the first
RC> release and after our patch release we can migrate. I need
RC> something now!
RC>


0
Avatar
Permanently deleted user

I guess I mis-stated. We cannot migrate to VS2008 yet. That keeps us from using 3.5, also. Since we just dropped a release using VS2005, we need to stay in VS2005 until the release is deemed stable so we can easily release patched to the production code. After that, in about 6 weeks, the project will migrate to VS2008.

0

Please sign in to leave a comment.