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
 Find References - C# (expr is type varname) issue
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Tam�si D�nes
Starting Member

Hungary
1 Posts

Posted - May 27 2020 :  11:02:49 AM  Show Profile  Reply with Quote
In C#, you can do this:
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/is#type-pattern

For example:

object variable;
if(variable is SomeType sometype)
{
   sometype.MemberFunc(); // use - VA Find References will not work from here - BUG
}

Of course, you should declare and define the class, and the member function somewhere:

class SomeType
{
   public void MemberFunc(){} // declaration - VA Find References will work from here of course
}

But, if you try to 'Find References' for the MemberFunction with Visual Assist, it will work properly only if do it from the *declaration. If you do it from the *use, you will get the following window:
"Find References is not available because the symbol is unrecognized."

If you use the next syntax, it also work fine:

if(variable is SomeType)
{
   SomeType sometype = (SomeType) variable;
   sometype.MemberFunction(); // VA Find References will work!
}

Edited by - Tam�si D�nes on May 27 2020 11:04:31 AM

feline
Whole Tomato Software

United Kingdom
18750 Posts

Posted - May 27 2020 :  12:34:20 PM  Show Profile  Reply with Quote
I am seeing the same effect here. Thank you for the clear description.

case=142305

As a partial work around if you use Alt-G on "sometype" VA should take you back to the "if X is Y" line, and you can then quickly place the caret into the type, "SomeType" here, and use Alt-Shift-G, to bring up the Goto Related menu. The bottom item in this menu takes you to the "Members of..." dialog, which will give you a searchable list of all of the members of this type, and you can quickly run Find References from here, by selecting the item you want to find and pressing CTRL-F, or using the context menu.

Not quite the same, and since VA isn't handling this variable creation correctly the find results won't be perfect, but hopefully this will help.

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