Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 VA 2451: definition resolves to wrong class

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
Uniwares Posted - Jul 29 2022 : 07:06:58 AM
A bit of a complex situation but here it goes:
C#, VS2017

I have a solution with one project that has about 20 web references (REST) of which half implement a class called "Document" in their respective namespace (all in Reference.cs in their own folder as created when adding a webreference).
In another project those web services are consumed. When I reference a certain webservice by "using" its namespace, obviously the Document class in this given namespace is available.
Now, when I use the Document class somewhere and put the caret on it, in the definition bar always appears the Document class in the alphabetically first namespace and not the one referenced in the current file.

When I fully specify the document class with its namespace all it good.
This of course also affects the Goto feature (Ctrl+Click by default), which goes to the wrong definition.

Let me try to visualize this:
Project 1:
	WebService1
		Reference.cs
			public class Document
	WebService2
		Reference.cs
			public class Document
        WebService3
		Reference.cs
			public class Document
	WebService4
		Reference.cs
			public class Document
			
Project 2:
	SomeFile.cs
		using WebService3;
		var x = new Document(); // this should resolve to WebService3.Document








5   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Aug 01 2022 : 04:38:22 AM
Obviously if you have something you are able to share, purely for testing purposes, I am happy to try and find the trigger. Sometimes the trigger for odd bugs can be quite unexpected, as I am sure you know.
Uniwares Posted - Jul 29 2022 : 12:13:11 PM
Yeah, there seems to be more to it than is happening in this sample project. Cant repro it neither with it. Next week I am on vacation, will try to make a full test project.
feline Posted - Jul 29 2022 : 11:54:08 AM
I have set up a very simple test case, perhaps far to simple, but so far no sign of the problem. I have emailed you my simple test case, so you can see what I have tried:

case=148403
Uniwares Posted - Jul 29 2022 : 10:58:50 AM
Just a class name, no methods of the same name in this case. I think it might happen with other classes structured the same way but not sure. Didnt have time to test.
feline Posted - Jul 29 2022 : 10:54:13 AM
We should handle this correctly, but I am not really surprised at this bug, given the problems I have seen with duplicate names over the years.

Is the "Document" class name a function of it being a web reference / REST project, or just a logical name? I am setting up a test now, but if web reference projects are going to encourage this problem to happen that's worth knowing.

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