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
 Support for C# generics
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

krk
New Member

5 Posts

Posted - Nov 16 2006 :  06:28:58 AM  Show Profile  Reply with Quote
C# generics (equivalent to C++ templates) for .NET 2.0 ought to be supported by VAX.

For example in the following code

public class Gen<Element>
{
...
}

'Element' ought to be included in the completion/suggestion lists.
This issue is for Visual Studio 2005 + .NET 2.0.

Thanks.



feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Nov 16 2006 :  1:17:50 PM  Show Profile  Reply with Quote
I have not used C# generics myself yet, but based on C++ template classes should you not pass the type you want to use when creating an instance of the class Gen?

I have tried this code in VS2005 with VA totally disabled, and the IDE is not suggesting Element, but it does show it in tooltips. I am seeing the same behaviour when VA is enabled.

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

krk
New Member

5 Posts

Posted - Nov 16 2006 :  3:48:28 PM  Show Profile  Reply with Quote
Well, when you instantiate a generic object to a real object, you do have to pass in the type.

However, when you write the generic class itself, then the usefulness of the template parameter becomes obvious, as this is one thing you have to write over and over.

For example, while editing a generic class file such as 'Gen' above, it would be useful to get 'Element' to repeat during the edit of the same file (as it really does exist in the class definition).

On the other hand, if the 'Gen' generic is instantiated with a concrete type in another file, then it would be useful to get the recycled instantiation Gen<type>.

---------------

Regarding the MS intellisense and generics;

I have seen it throw two types of suggestion:
Gen<> - this is where it lets you fill in the parameter yourself
or
Gen<long> - this is where it recycles previous instantiations.
Gen<string> - same as above

I have also seen it suggest 'Element' in the generic file itself, so I think that it should be possible for VAX to mirror this behaviour.

Disabling VAX and playing with intellisense will confirm this.
--

I never used shortcuts with VAX, could I use a shortcut to get to MS intellisense to bypass VAX when needed?

Thanks.

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Nov 17 2006 :  12:44:57 PM  Show Profile  Reply with Quote
I have just scanned down this article on C# generics

http://www.codeproject.com/books/EssentialCS20.asp

mainly just looking at the structure and syntax of the source code. A lot of it looks familiar from C++ templates, and there does not seem to be any need to retype Gen<type> in the code. Am I missing something obvious? Was this a poor article to read for these purposes?

Personally I would make sure that suggestions were turned on, working http://docs.wholetomato.com?W313

and I would also enable:

VA Options -> Text Editor -> suggestions -> Include bits of code from surrounding lines

This way if you keep retyping Gen<Element> VA should fairly quickly start to suggest this.

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

krk
New Member

5 Posts

Posted - Nov 17 2006 :  2:56:59 PM  Show Profile  Reply with Quote
quote:
I have just scanned down this article on C# generics
http://www.codeproject.com/books/EssentialCS20.asp
mainly just looking at the structure and syntax of the source code. A lot of it looks familiar from C++ templates, and there does not seem to be any need to retype Gen<type> in the code. Am I missing something obvious? Was this a poor article to read for these purposes?


The issue is not retyping the whole of 'Gen<type>' just 'type' will do in the generic class itself.

I have programmed in C++ before I switched to C#. I wrote template classes in both languages. There is little difference, except that C# is a little more straightforward.
The article was OK, and in this article there are plenty of examples
where the template param 'T' gets repeated in the template class over and over. If you come to think about it, it really has to be, since this 'T' is what the class is based on.
The only difference here is that my parameter reads 'Element' not 'T' because it makes the code more meaningful at the expense of more typing.

Either way, MS intellisense contains the parameter in C++ and C#.
I surmise VA simply filters the MS list?
Then this one ought not be filtered out.

Well, try and write a template/generic collection class from scratch. You will see my point.
And then with MS generic collections being ever so popular in .NET 2.0, replacing the non generic ones, I guess there will be more and more templates in source code globally.

quote:
Personally I would make sure that suggestions were turned on, working http://docs.wholetomato.com?W313

My intellisense is configured exactly as in the link above, that is OK.
quote:
and I would also enable:

VA Options -> Text Editor -> suggestions -> Include bits of code from surrounding lines

This way if you keep retyping Gen<Element> VA should fairly quickly start to suggest this.

I have just checked the bit about surrounding lines.
I hope that it helps, whatever helps is most welcome.
I still think the generic params should not be filtered out by default.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Nov 17 2006 :  4:26:19 PM  Show Profile  Reply with Quote
I think I am starting to understand what you are after. Sorry this is taking so long.

In C# the contents of a completion listbox (CTRL-SPACE) come from the IDE, so if the IDE will not suggest Generic then it will not appear in a completion listbox.

I have just opened a basic C# form project using VS2005 and VA 1540, and I am seeing this:



This is all I have typed, and already someone has worked out I would like to use the word "Element". Is this what you are after? It seems to just work for me. Am I still trying to answer the wrong question?

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