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
 1553: similar Class and Method name confused
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

enigma
Senior Member

49 Posts

Posted - Apr 20 2007 :  04:23:48 AM  Show Profile  Reply with Quote
VA is confused if the class and the method name is the same.

  • Create a class with the name PackageCreation in a c# project called AProj. Add a static method with the method signature public void Execute()

  • Create another class call CallPackageCreation in another c# project called BProj, inside the class create a method call PackageCreation, inside the method type in this code:PackageCreation.Execute()

  • Now I want to change the method name in BProj PackageCreation to PackageCreationMethod, I use VA refactoring tool to do this. I expect to only rename the method, but not the class. But the Rename function offers me two instances of PackageCreation, including the class reference in the method PackageCreation



My VA information
VA_X.dll file version 10.3.1553.0 built 2007.04.12
Licensed to:
VA X: [email protected] (1-user license) Support ends 2007.09.19
VAOpsWin.dll version 1.3.5.1
VATE.dll version 1.0.6.5
DevEnv.exe version 7.10.6030.0
msenv.dll version 7.10.6030.0
Font: Courier New 13(Pixels)
Comctl32.dll version 5.82.2900.2180
Windows XP 5.1 Build 2600 Service Pack 2
2 processors

Platform: Win32
Stable Includes:

My vs.net information
Microsoft Visual C# .NET 69458-005-0446806-18546
Microsoft Visual Studio .NET 2003 Service Pack 1 (KB918007)
Library Includes:

Other Includes:


http://itscommonsensestupid.blogspot.com/

feline
Whole Tomato Software

United Kingdom
19021 Posts

Posted - Apr 20 2007 :  07:38:30 AM  Show Profile  Reply with Quote
I appear to be doing something wrong, but I am not sure what. I don't do much C# programming, so perhaps I have made a silly mistake. Using VS2005 in projA I have the code:


    class bugFindRefPackageCreation
    {
        public static void Execute()
        {

        }
    };


and in projB I have the code:

    class bugFindRefCallPackageCreation
    {
        public void bugFindRefPackageCreation()
        {
            bugFindRefPackageCreation.Execute();  // compiler error here
        }
    };


I have made the class / method names a bit more unique, to make sure there are no problems with the other classes in my test project, but this should not matter. projB has the correct using namespace and correct dependencies to call items in projA, I already have a different test setup and working using these two projects.

First problem - the code does not compile. I get the error message:

'c_sharp_class_library2.Bugs.bugFindRefCallPackageCreation.bugFindRefPackageCreation()' is a 'method', which is not valid in the given context


Second problem - I have run both Find References and Rename on "bugFindRefPackageCreation" in both projects, and it only ever finds references in that project, so I am not seeing the problem you are reporting.

zen is the art of being at one with the two'ness
Go to Top of Page

enigma
Senior Member

49 Posts

Posted - Apr 22 2007 :  9:05:40 PM  Show Profile  Reply with Quote
quote:
Originally posted by feline

I appear to be doing something wrong, but I am not sure what. I don't do much C# programming, so perhaps I have made a silly mistake. Using VS2005 in projA I have the code:


    class bugFindRefPackageCreation
    {
        public static void Execute()
        {

        }
    };


and in projB I have the code:

    class bugFindRefCallPackageCreation
    {
        public void bugFindRefPackageCreation()
        {
            bugFindRefPackageCreation.Execute();  // compiler error here
        }
    };


I have made the class / method names a bit more unique, to make sure there are no problems with the other classes in my test project, but this should not matter. projB has the correct using namespace and correct dependencies to call items in projA, I already have a different test setup and working using these two projects.

First problem - the code does not compile. I get the error message:

'c_sharp_class_library2.Bugs.bugFindRefCallPackageCreation.bugFindRefPackageCreation()' is a 'method', which is not valid in the given context


Second problem - I have run both Find References and Rename on "bugFindRefPackageCreation" in both projects, and it only ever finds references in that project, so I am not seeing the problem you are reporting.


  • You had it right when you said that code cannot compile. But this is precisely the reason why I want to rename the method to something else

  • I don't understand what do you mean by and it only ever finds references in that project, for me, when I tried to find reference for the method "bugFindRefPackageCreation", it should only return one reference, namely, the method itself, not the static function in other class that it calls

http://itscommonsensestupid.blogspot.com/

Edited by - enigma on Apr 22 2007 9:06:47 PM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19021 Posts

Posted - Apr 23 2007 :  08:35:53 AM  Show Profile  Reply with Quote
I am confused. Using my code, when I run Find References in ProjA on "bugFindRefPackageCreation" with the code:

    class bugFindRefPackageCreation    // this is found
    {
        public static void Execute()
        {

        }
    };


VA finds one reference, as indicated by the comment.

When I run Find References on ProjB on "bugFindRefPackageCreation" with the code:

    class bugFindRefCallPackageCreation
    {
        public void bugFindRefPackageCreation()   // this is found
        {
            bugFindRefPackageCreation.Execute();  // and this is found
        }
    };


VA finds two references, as indicated by the comment. To me this seems quite reasonable. Is this what you are seeing? If you are seeing something different then it suggests my test is not setup correctly.

If this is what you are seeing then my initial reaction is VA see's something that looks recursive, and it is doing the best it can.

zen is the art of being at one with the two'ness
Go to Top of Page

enigma
Senior Member

49 Posts

Posted - Apr 25 2007 :  10:04:20 PM  Show Profile  Reply with Quote
quote:
Originally posted by feline

I am confused. Using my code, when I run Find References in ProjA on "bugFindRefPackageCreation" with the code:

    class bugFindRefPackageCreation    // this is found
    {
        public static void Execute()
        {

        }
    };


VA finds one reference, as indicated by the comment.

When I run Find References on ProjB on "bugFindRefPackageCreation" with the code:

    class bugFindRefCallPackageCreation
    {
        public void bugFindRefPackageCreation()   // this is found
        {
            bugFindRefPackageCreation.Execute();  // and this is found
        }
    };


VA finds two references, as indicated by the comment. To me this seems quite reasonable. Is this what you are seeing? If you are seeing something different then it suggests my test is not setup correctly.

If this is what you are seeing then my initial reaction is VA see's something that looks recursive, and it is doing the best it can.


You have the test setup correctly.But perhaps I have not been very clear with my description. Let me try again.

When you try to find the reference for the method (it's the method, not the class) bugFindRefPackageCreation, it should return only 1 reference, namely the method itself.

It shouldn't find bugFindRefPackageCreation.Execute();. Why? Because I want to change the method name (after all, the method must be renamed so as to avoid a compilation error). There is no need to change the class name because it suits me all too fine.

http://itscommonsensestupid.blogspot.com/
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19021 Posts

Posted - Apr 26 2007 :  08:22:56 AM  Show Profile  Reply with Quote
I think I understand now.

My concern is how to tell that bugFindRefPackageCreation is a class on one line and a function on another line.

If we ignore the second project for now, since that is not strictly relevent, and just look at this small piece of code, I can tell that bugFindRefPackageCreation.Execute is not a function, since there are no brackets on bugFindRefPackageCreation.

However since this is C# bugFindRefPackageCreation might be a property which returns a class type which supports .Execute()

Does this make sense?

I can picture a situation where VA is going to have very little chance of working out what is going on, so is going to behave in an "unpredictable" manor if we try and make this change. At least this behaviour, while undesirable, is predictable.

zen is the art of being at one with the two'ness
Go to Top of Page

enigma
Senior Member

49 Posts

Posted - Apr 29 2007 :  10:10:13 PM  Show Profile  Reply with Quote
quote:
Originally posted by feline

I think I understand now.

My concern is how to tell that bugFindRefPackageCreation is a class on one line and a function on another line.

If we ignore the second project for now, since that is not strictly relevent, and just look at this small piece of code, I can tell that bugFindRefPackageCreation.Execute is not a function, since there are no brackets on bugFindRefPackageCreation.

However since this is C# bugFindRefPackageCreation might be a property which returns a class type which supports .Execute()

Does this make sense?

I can picture a situation where VA is going to have very little chance of working out what is going on, so is going to behave in an "unpredictable" manor if we try and make this change. At least this behaviour, while undesirable, is predictable.


The perhaps you can just leave this issue as it is as the above code won't compile as well.

http://itscommonsensestupid.blogspot.com/
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19021 Posts

Posted - Apr 30 2007 :  09:06:48 AM  Show Profile  Reply with Quote
This would be my preferred answer. VA''s rename dialog has check boxes by each item, so you can turn off renaming the items you do not want to be updated, which allows you to manually resolve this issue.

zen is the art of being at one with the two'ness
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