Groups | Blog | Home
all groups > dotnet clr > october 2004 >

dotnet clr : TypeSpecs


Oleg Stepanov
10/6/2004 9:51:05 AM
Hi!

Can anyone explain me purpose of the TypeSpec table (I'm talking about the
metadata)? Especially could anyone give examples of when it is used?

Thanks,
Brian Tyler
10/6/2004 12:23:32 PM
The TypeSpec is like a TypeRef/TypeDef but it only contains signature
information, thus it has no name, hierarchy, etc. The only time I can
remember where it has come up is in function pointers.

Brian

[quoted text, click to view]

Fabian Schmied
10/6/2004 7:31:09 PM
[quoted text, click to view]

It's also important with constructed types like arrays, to specify their
shape.

Ben Schwehn
10/6/2004 10:11:43 PM
[quoted text, click to view]

in framework v2 it's also used for generics


--
Ben
Oleg Stepanov
10/7/2004 1:49:02 AM
[quoted text, click to view]


Ben,

Yes, it seems like i have exactly this case. If I understand correctly it
is used, e.g., when I have class which extends List<int> to encode the exact
type parameters. Do you happen to know how the TypeSpec is encoded in the
blob in this case? Just like ELEMENT_TYPE_GENERICINST or some other way?

Thanks



Ben Schwehn
10/7/2004 10:53:52 PM
[quoted text, click to view]

as far as I know its's either a ELEMENT_TYPE_GENERICINST,
ELEMENT_TYPE_VAR or ELEMENT_TYPE_MVAR.
I'm not aware of any other possibilities.

In case you're interested, here's some c# code that produces 3 entries
in the typespec table, one of each type:

====
class GenTest<U>{
public void Funct(U first, U second) {
if (first.Equals(second)) {
}
}
public void GenFunct<T>(T first, T second) {
if (first.Equals(second)) {
}
}
}
class Program {
static void Main(string[] args) {
List<int> testList = new List<int>();
}
}
===

There's is also the new table 'MethodSpec' used for generic methods.

--
Ben
Oleg Stepanov
10/7/2004 11:33:03 PM
Thanks Ben,

i've already implemented the typespec blob decoder.

[quoted text, click to view]
AddThis Social Bookmark Button