Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Suggestions for indexers are way off

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 - Apr 09 2020 : 09:28:42 AM
The suggestions for custom indexers are mostly totally off, suggesting everything except the type of the indexer.



In this case, the indexer is:
public AccessLevel this[object o]
{
	get { return (AccessLevel)_objects[o.GetType()]; }
	set { _objects[o.GetType()] = value; }
}

So, VA should suggest AccessLevel for the code in the image above, but none of the suggested ones (except null maybe) is acceptable.

(can send you the code files if needed to repro)
6   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Apr 16 2020 : 10:35:58 AM
The same problem happens when using a C# generic class with an indexer access function, as expected. But I wanted to confirm that theory. I have added this example to the case.
feline Posted - Apr 15 2020 : 12:50:33 PM
That helps a bit, thank you. I have put in a bug report for this with my test cases so far:

case=142131

I do want to experiment a bit more with this though, to make sure I properly understand what is going on.
Uniwares Posted - Apr 09 2020 : 12:10:18 PM
Yes its a cast to the enum AccessLevel since the type stored is object.
feline Posted - Apr 09 2020 : 12:07:23 PM
I have confirmed smart suggestions aren't working out the type for a simple indexer that gets/sets a string, but I don't understand your code in the first post. Are you doing a cast in the "get"? Why is there no dot after "(AccessLevel)" ?

I am not sure I am even testing the same thing you are using. I am working with the very simple indexer:

public class simpleStringIndexer
{
    private string[] stringArray;
    private int counter = 0;
    
    public simpleStringIndexer()
    {
        stringArray = new string[] { "Hello", "World", " - ", "Chocolate", "is", "good" };
    }
    
    public string this[int index]
    {
        get { return stringArray[index]; /* always safe, surely */ }
        set { stringArray[index] = value; /* just pray its safe */ }
    }
}
Uniwares Posted - Apr 09 2020 : 09:37:08 AM
On a closely related issue: as you can see on this image, default suggestions are not helping much. The pre-selected suggestion i never even used in my entire life. The most used item and thus the closest match is "Assert". Suggestions are really off.



Uniwares Posted - Apr 09 2020 : 09:31:08 AM
Assignment AND comparism




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