Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Encapsulate field doesn't work well for statics

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
gbozoki Posted - Jun 22 2012 : 4:24:57 PM
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).
3   L A T E S T    R E P L I E S    (Newest First)
support Posted - Aug 09 2012 : 01:55:11 AM
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]*
gbozoki Posted - Jun 23 2012 : 01:08:22 AM
Accord, thanks for your reply. An option for that would be nice, even if only accessible through the registry.
accord Posted - Jun 22 2012 : 10:36:43 PM
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.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000