/// <summary> /// Get the return type of the constructor (never null). /// </summary> public static TypeRefBase GetReturnType(TypeRefBase thisRef, object reference) { // The 'return type' of a constructor is its declaring type, along with any type parameters TypeRefBase typeRefBase; if (reference is ConstructorDecl) { ConstructorDecl constructorDecl = (ConstructorDecl)reference; CodeObject parent = constructorDecl.Parent; if (parent == null) { // If we don't have a parent, assume we're a generated constructor for // a delegate (used for the obsolete explicit delegate creation syntax), and // use the type of the parameter as our type. // Clone the type so we can evaluate any type arguments it has later without consequences. typeRefBase = constructorDecl.Parameters[0].Type.SkipPrefixes() as TypeRefBase; typeRefBase = (typeRefBase != null ? (TypeRefBase)typeRefBase.Clone() : TypeRef.VoidRef); } else { typeRefBase = (TypeRef)parent.CreateRef(); } } else //if (reference is ConstructorInfo) { typeRefBase = TypeRef.Create(((ConstructorInfo)reference).DeclaringType); } return(typeRefBase); }