You might need to handle ELEMENT_TYPE_STRING, ELEMENT_TYPE_OBJECT, ELEMENT_TYPE_SZARRAY, etc. Don't know what your intent is.
The best thing is to do whatever MethodTableBuilder::InitializeFieldDescs does. There are encapsulations for checking if a signature element refers to a reference type, and you should use that instead of checking directly for ELEMENT_TYPE_CLASS. -----Original Message----- From: Discussion of the Rotor Shared Source CLI implementation [mailto:[EMAIL PROTECTED] On Behalf Of Arild Fines Sent: Tuesday, May 10, 2005 3:24 PM To: DOTNET-ROTOR@DISCUSS.DEVELOP.COM Subject: Re: [DOTNET-ROTOR] Getting an mdTypeDef for the type of a field Discussion of the Rotor Shared Source CLI implementation wrote: > You need to get the field's signature and decode this signature. In > the > simplest case (public Bar Field) the signature will be: > {CALLCONV_FIELD,E_T_CLASS,<compressed token of Bar>} Or > {CALLCONV_FIELD,E_T_VALUETYPE,<compressed token of Bar>} > > For calling convention and element type encoding, see CorHdr.h > > For token compression/decompression functions see Cor.h Thanks to all who replied and got me on the right track. I ended up with something like this: ULONG size; PCCOR_SIGNATURE sig = pInternalImport->GetSigOfFieldDef(fd, &size); SigPointer sigptr(sig); _ASSERTE(sigptr.GetData() == IMAGE_CEE_CS_CALLCONV_FIELD); CorElementType corType = (CorElementType)sigptr.GetData(); if (corType == ELEMENT_TYPE_CLASS) { mdTypeDef type = sigptr.GetToken(); return IsReferenceCounted(pInternalImport, type); } else return S_FALSE; Is this a good way of doing it, or are there some caveats here? -- Arild AnkhSVN: http://ankhsvn.tigris.org Blog: http://ankhsvn.com/blog IRC: irc://irc.freenode.net/ankhsvn "The problem in the world today is communication. Too much communication." -- Homer Simpson =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorŪ http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com