This project is read-only.

Comparing delegate types

Topics: Metadata Model
Dec 28, 2010 at 3:31 AM

Hello. Is there some code to compare delegate types in CCI-Metadata?

I need to check assignment compatibility for signature matching but I don't even know how to get in general the type of a delegate.

I attempted to use your TypeInferencer code. Up till now I was using a simpler type inference method of mine but I thought of exploiting this situation to refactor that class of yours to make it of slightly wider use. There are two differences:

1) objects are not modified, types being stored into a dictionary, so it can be used with any object implementing some IExpression interface

2) it can be configured using an ITypeInferenceContext interface which is implemented by my type definition classes

I adapted all my code to use this new version of TypeInferencer only to run the application and discover that... it doesn't deal with delegates at all!  

        public override void Visit(ICreateDelegateInstance createDelegateInstance) {
            //The type should already be filled in


I suppose there should be some code like that somewhere. How could a compiler pick the right method overload otherwise?

So far I've not been able to find the place where you do that. Could you help me?


Dec 28, 2010 at 4:31 AM

I understood why "The type should already be filled in": CCI could not create a delegate at all otherwise.

I thought that CreateDelegateInstance represented a plain (instance reference, method reference) pair, equivalent to the C#




expression but in fact there is no such thing in CCI and that is not an expression. It becomes an expression only when accompained to a delegate type that also selects one method of the group.

ICreateDelegate is just a specialized type of constructor and thas explains also why I found the name a bit strange.

Ok. I hope I solved my problem for the moment.