Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Support for C# generics

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
krk Posted - Nov 16 2006 : 06:28:58 AM
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.



5   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Nov 17 2006 : 4:26:19 PM
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?
krk Posted - Nov 17 2006 : 2:56:59 PM
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.
feline Posted - Nov 17 2006 : 12:44:57 PM
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.
krk Posted - Nov 16 2006 : 3:48:28 PM
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.

feline Posted - Nov 16 2006 : 1:17:50 PM
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.

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