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
 VA 2375: doesnt recognize Shouldly extensions
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Uniwares
Tomato Guru

Portugal
2318 Posts

Posted - May 29 2020 :  11:36:27 AM  Show Profile  Reply with Quote
VA usually recognizes when a "using" is missing and suggests it, yet it doesnt seem to be able to recognize that Shouldly extension methods need a using too. Works fine though with Intellisense.

https://github.com/shouldly/shouldly

feline
Whole Tomato Software

United Kingdom
18727 Posts

Posted - Jun 04 2020 :  11:01:09 AM  Show Profile  Reply with Quote
Normally VA is working with a suggestion listbox when it notices and suggests that a using statement is required. Normally, after typing a dot, you are using a member listbox, not a suggestion listbox. I don't know if this is the full cause, but its probably a factor.

I have put in a feature request for this:

case=142328

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

Uniwares
Tomato Guru

Portugal
2318 Posts

Posted - Jun 05 2020 :  05:37:36 AM  Show Profile  Reply with Quote
As its now, VA doesnt even recognize .NET LINQ extensions.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18727 Posts

Posted - Jun 05 2020 :  09:58:49 AM  Show Profile  Reply with Quote
What do you mean by .NET LINQ extensions? Trying to look this up left me at this page:

https://dotnettutorials.net/lesson/linq-extension-methods/

which left me with the sample code:

void LinqExtensionMethodOnList()
{
    List<int> intList = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    IEnumerable<int> EvenNumbers = Enumerable.Where(intList, n => n % 2 == 0);
}

which is a bit odd, but I can mostly see what is going on here. What I don't see is an obvious problem with VA not understanding this, so I assume you mean something else.

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

Uniwares
Tomato Guru

Portugal
2318 Posts

Posted - Jun 05 2020 :  10:23:44 AM  Show Profile  Reply with Quote
Talking about something simpler like .ToArray() or .ToList() which apply to all sorts of collections.

like
new byte[] { 0,0,0,0}.ToList<byte>(); // ok, odd thing to do

or
byte[] ar = {0,1,2,3}; byte n = ar.Last();

Edited by - Uniwares on Jun 05 2020 10:24:38 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18727 Posts

Posted - Jun 05 2020 :  11:19:57 AM  Show Profile  Reply with Quote
What should I be looking for? This is what I have just tested and seen:

void MethodCalledOnList()
{
    byte[] ar = { 0, 1, 2, 3 };
    // VS2019, trigger Alt-Shift-G on "Last" and Goto Member
    // lists 51 members of the class Enumerable
    byte n = ar.Last();
}

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

Uniwares
Tomato Guru

Portugal
2318 Posts

Posted - Jun 05 2020 :  11:37:17 AM  Show Profile  Reply with Quote
On .Last() VA should suggest "using System.Linq;" (as VS intelisense does) if its not yet included.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18727 Posts

Posted - Jun 08 2020 :  08:43:59 AM  Show Profile  Reply with Quote
On two different machines I am getting two different behaviours here. On one machine, when I type "ar." the listbox contains "Last", and when I accept this, the line:

using System.Linq;

is being added automatically to the top of the cs file. This is testing with VA completely disabled in the Extensions dialog, and VS2019 restarted to make sure this took effect.

On the second machine when I type "ar." the listbox does not contain "Last" at all.

Is the namespace actually being inserted automatically for you when accepting "Last" from the listbox, or are you seeing a different behaviour yet again?

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

Uniwares
Tomato Guru

Portugal
2318 Posts

Posted - Jun 08 2020 :  09:40:51 AM  Show Profile  Reply with Quote
VS "sometimes" does it automatically and sometimes only when invoking the intellisense (Ctrl+.) in either case, it "knows" that the using is missing.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18727 Posts

Posted - Jun 09 2020 :  09:20:26 AM  Show Profile  Reply with Quote
That's fair, I just wanted to make sure I understood enough of what was going on here to properly update the case. I have added this example, it is nice having an example that doesn't require a NuGet package, it just makes things that tiny bit more straight forward.

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