Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / April 2006

Tip: Looking for answers? Try searching our database.

Are Generic Types possible with CodeModel / FileCodeModel?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stuart Carnie - 20 Apr 2006 01:09 GMT
void MyFunc(CodeClass2 cc, string EventName)
{
  CodeFunction cf = cc.AddFunction(EventName, vsCMFunction.vsCMFunctionSub, vsCMTypeRef.vsCMTypeRefVoid, -1)

  cf.AddParameter("Sender", vsCMTypeRef.vsCMTypeRefObject, -1)

  CodeTypeRef2 ctr = cm.CreateCodeTypeRef("System.Collections.Generic.List")

  CodeParameter prmEvent = cf.AddParameter("e", ctr, -1)
}

Is it possible to specify the 'type' parameter of the ctr (CodeTypeRef2) object.  The CodeTypeReference object of CodeDom allows
one to set the TypeArguments member.

The only thing I can think of is to manually insert the <> generic syntax, however then I need to check the language of the file,
which somewhat defeats the purpose of using the code model.

Cheers and thanks for any insight,

Stu
"Gary Chang[MSFT]" - 20 Apr 2006 10:09 GMT
Hi Stuart,

>Is it possible to specify the 'type' parameter of the ctr
>(CodeTypeRef2) object.  The CodeTypeReference
>object of CodeDom allows one to set the
>TypeArguments member.

Have you try to specify the type argument in the CodeTypeReference object's
definition directly, for example:

CodeTypeRef2 ctr =
cm.CreateCodeTypeRef("System.Collections.Generic.List<string>")

Thanks!

Best regards,

Gary Chang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Stuart Carnie - 20 Apr 2006 21:17 GMT
Thanks Gary - that works for C#, but not for VB.NET.

I tried the obvious, and that generated (Of T) instead of (Of System.String).  The "obvious" was:

CodeTypeRef2 ctr = cm.CreateCodeTypeRef("System.Collections.Generic.List(Of System.String)")

It generates:

Sub MyTest(aList as System.Collections.Generic.List(Of T))

End Sub

Is this a bug?

Cheers,

Stu

Gary Chang[MSFT] wrote:
> Hi Stuart,
>
[quoted text clipped - 20 lines]
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Gary Chang[MSFT]" - 24 Apr 2006 08:54 GMT
Hi Stuart,

It may be a product issue. I suggest you can submit this issue to our
product feedback center, our development team may communicate with you
directly on the issue there:

http://lab.msdn.microsoft.com/productfeedback/default.aspx

Thanks for your understanding.

Best regards,

Gary Chang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.