<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Reflection and Generics </title><link>http://blogs.msdn.com/b/brada/archive/2004/01/27/63739.aspx</link><description>I spent some time last week working on a tool we use internally to print out the C# &amp;#8220;header file&amp;#8221; view of assemblies. We use it as part of the WinFX API reviews to give an overview of that the API looks like. I am still in the middle of updating</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title> Brad Abrams Reflection and Generics | work from home</title><link>http://blogs.msdn.com/b/brada/archive/2004/01/27/63739.aspx#9762243</link><pubDate>Tue, 16 Jun 2009 16:26:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9762243</guid><dc:creator> Brad Abrams Reflection and Generics | work from home</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://workfromhomecareer.info/story.php?id=34380"&gt;http://workfromhomecareer.info/story.php?id=34380&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9762243" width="1" height="1"&gt;</description></item><item><title>Generics and the special constraints</title><link>http://blogs.msdn.com/b/brada/archive/2004/01/27/63739.aspx#237909</link><pubDate>Tue, 05 Oct 2004 06:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:237909</guid><dc:creator>Brad Abrams </dc:creator><description>&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=237909" width="1" height="1"&gt;</description></item><item><title>re: Reflection and Generics </title><link>http://blogs.msdn.com/b/brada/archive/2004/01/27/63739.aspx#162291</link><pubDate>Tue, 22 Jun 2004 12:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:162291</guid><dc:creator>J. Ambrose Little</dc:creator><description>Thanks, Joel.  I suppose that once you're aware of it, it's not a big deal, but it did throw me for a loop, especially since the BindGenericParameters example in the current docs didn't have that.  I had to go into debug to figure out what the type name actually was.&lt;br&gt;&lt;br&gt;It would be nice to have it do some sort of search if no arity is indicated, e.g.:&lt;br&gt;1. Look for a non-generic match first.&lt;br&gt;2. Look for generic match, going from 1-n arity, matching the first found.&lt;br&gt;&lt;br&gt;Granted, this might cause more confusion than it's worth, but as long as this or the current format is documented, we'll probably be okay.&lt;br&gt;&lt;br&gt;Just curious, do you find or expect much overloading on arity?&lt;br&gt;&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=162291" width="1" height="1"&gt;</description></item><item><title>re: Reflection and Generics </title><link>http://blogs.msdn.com/b/brada/archive/2004/01/27/63739.aspx#162023</link><pubDate>Tue, 22 Jun 2004 04:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:162023</guid><dc:creator>Joel Pobar</dc:creator><description>Backtick &amp;quot;`&amp;quot; plus integer specifies the arity of the Generic type, and is actually burned in at the metadata level as the string type name. GetType() takes an unmangled string name and simply brings it to life by string comparing over the metadata table. It's unfortunate that we couldn't use angle brackets to specify arity, ala C# syntax, but the C++ folk have already reserved them in the type name grammar. :)&lt;br&gt;&lt;br&gt;For now, you'll need to specify the string name according to the type name grammar rules (which should be specified in the next revision of the ECMA specification). Which means, Foo`1 for Foo&amp;lt;T&amp;gt;, Foo`2 for Foo&amp;lt;K,V&amp;gt; etc. We may look at adding helper methods for string name mangling sometime in the future. &lt;br&gt;&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=162023" width="1" height="1"&gt;</description></item><item><title>re: Reflection and Generics </title><link>http://blogs.msdn.com/b/brada/archive/2004/01/27/63739.aspx#161998</link><pubDate>Tue, 22 Jun 2004 03:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:161998</guid><dc:creator>J. Ambrose Little</dc:creator><description>I ended up using BindGenericParameters:&lt;br&gt;&lt;br&gt;System.Type constructedType, genericType;&lt;br&gt;genericType = compiled.CompiledAssembly.GetType(dynamicTypeName + &amp;quot;`1&amp;quot;);&lt;br&gt;constructedType = genericType.BindGenericParameters(new Type[1] {typeof(T)});&lt;br&gt;comparer = constructedType.GetConstructor(new Type[0] {}).Invoke(null)&lt;br&gt;  as System.Collections.Generic.IComparer&amp;lt;T&amp;gt;;&lt;br&gt;&lt;br&gt;I am wondering why I have to add the &amp;quot;`1&amp;quot; at the end of my type name to get the generic.  I can see that it indicates the number of type parameters, but the example for BindGenericParameters in the docs didn't, IIRC, add that (so its code shouldn't work).  Are you guys going to work around this or is this the format you're sticking with?&lt;br&gt;&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=161998" width="1" height="1"&gt;</description></item><item><title>re: Reflection and Generics </title><link>http://blogs.msdn.com/b/brada/archive/2004/01/27/63739.aspx#161945</link><pubDate>Tue, 22 Jun 2004 01:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:161945</guid><dc:creator>J. Ambrose Little</dc:creator><description>Brad,&lt;br&gt;&lt;br&gt;Can you help me out with this problem?  I've got some code that is dynamically compiled and loaded into an Assembly type.  In the past, I could use myAssembly.CreateInstance to get an instance of a type in the Assembly.  But what if the type I need to create requires a type argument?  Is there any way to pass that through reflection to get an instance of the type?&lt;br&gt;&lt;br&gt;Thanks.&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=161945" width="1" height="1"&gt;</description></item><item><title>re: Reflection and Generics </title><link>http://blogs.msdn.com/b/brada/archive/2004/01/27/63739.aspx#141156</link><pubDate>Tue, 25 May 2004 12:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:141156</guid><dc:creator>Mahavir</dc:creator><description>Please help me with the questions below :&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=141156" width="1" height="1"&gt;</description></item><item><title>re: Reflection and Generics </title><link>http://blogs.msdn.com/b/brada/archive/2004/01/27/63739.aspx#63864</link><pubDate>Wed, 28 Jan 2004 14:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:63864</guid><dc:creator>Brad Abrams</dc:creator><description>Rich -- Yes, this code supports the new constraint... &lt;br&gt; typeof(System.Runtime.CompilerServices.NewConstraintAttribute))&lt;br&gt;&lt;br&gt;                        {&lt;br&gt;&lt;br&gt;                              Write(&amp;quot;new()&amp;quot;);&lt;br&gt;&lt;br&gt;                        }&lt;br&gt;&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=63864" width="1" height="1"&gt;</description></item><item><title>More on Generics from Brad</title><link>http://blogs.msdn.com/b/brada/archive/2004/01/27/63739.aspx#63787</link><pubDate>Wed, 28 Jan 2004 12:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:63787</guid><dc:creator>autoCode( my_dotnet_baby );</dc:creator><description>&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=63787" width="1" height="1"&gt;</description></item><item><title>re: Reflection and Generics </title><link>http://blogs.msdn.com/b/brada/archive/2004/01/27/63739.aspx#63817</link><pubDate>Wed, 28 Jan 2004 11:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:63817</guid><dc:creator>RichB</dc:creator><description>Does your code also work on types which have a constructor constraint?&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=63817" width="1" height="1"&gt;</description></item></channel></rss>