Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Encapsulate field doesn't work well for statics
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

gbozoki
Ketchup Master

USA
70 Posts

Posted - Jun 22 2012 :  4:24:57 PM  Show Profile  Reply with Quote
Using VS 2008 and C#, Refactor->Encapsulate Field doesn't work very well when used on static members. Consider the following code (the prefix m_ indicates an instance member, s_ indicates a static member):

internal class MyClass
{
    private static int s_nStatic = 0;

    private int m_nInstance = 0;
        
    public static void SomeFunc ()
    {
        // ...
    }
}

If you right-click the red s_nStatic symbol, the generated property looks like this:

public int S_nStatic
{
    get { return ( s_nStatic ); }
    set { s_nStatic = value; }
}

Notice how the property name includes the s_n prefix. When using Refactor->Encapsulate Field on instance fields, such prefixes are removed. If I try the same on the m_nInstance symbol the property is named correctly:

public int Instance
{
    get { return ( m_nInstance ); }
    set { m_nInstance = value; }
}

I'd expect both to create the property similarly (how the instance-member property is generated, that is, no prefix).

Edited by - gbozoki on Jun 22 2012 4:26:29 PM

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Jun 22 2012 :  10:36:43 PM  Show Profile  Reply with Quote
We are considering adding an option to set prefixes removed by Encapsulate Field:

case=17714

There are a lot of notation and not all can be removed automatically and "safely":

http://en.wikipedia.org/wiki/Hungarian_notation

Specifying the notations you actually use could solve this.
Go to Top of Page

gbozoki
Ketchup Master

USA
70 Posts

Posted - Jun 23 2012 :  01:08:22 AM  Show Profile  Reply with Quote
Accord, thanks for your reply. An option for that would be nice, even if only accessible through the registry.
Go to Top of Page

support
Whole Tomato Software

5566 Posts

Posted - Aug 09 2012 :  01:55:11 AM  Show Profile  Reply with Quote
case=67462 is related to case=17714 and is implemented in build 1912.
The following name patterns are supported:
[lower-case letter][upper-case letter]*
[lower-case letter]_[prefix]*

Whole Tomato Software, Inc.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000