private static Field GetInstanceField(TypeNode originalReturnType, Field possiblyGenericField, TypeNode instanceDeclaringType) { Contract.Requires(instanceDeclaringType != null); if (instanceDeclaringType.Template == null) { return(possiblyGenericField); } var declaringTemplate = instanceDeclaringType; while (declaringTemplate.Template != null) { declaringTemplate = declaringTemplate.Template; } Contract.Assume(declaringTemplate == possiblyGenericField.DeclaringType); return(Rewriter.GetFieldInstanceReference(possiblyGenericField, instanceDeclaringType)); #if false Field f = instanceDeclaringType.GetField(possiblyGenericField.Name); if (f != null) { // already instantiated return(f); } // pseudo instance Field instance = new Field(instanceDeclaringType, possiblyGenericField.Attributes, possiblyGenericField.Flags, possiblyGenericField.Name, originalReturnType, null); instanceDeclaringType.Members.Add(instance); return(instance); #endif }