private FieldReference ResolveStateClassField(TypeReference role) { var stateTypeDefinition = role.ResolveStateClass(); var stateTypeReference = new MemberResolver(role).ResolveMatchingType(stateTypeDefinition); var fieldDefinition = _targetType.Fields. SingleOrDefault(fd => TypeMatcher.IsMatch(fd.FieldType, stateTypeReference)); if (fieldDefinition == null) return null; // TODO: this is because the role was already implemented in a base class; it should be checked before, possibly in the conflict resolution stage return new FieldReference( fieldDefinition.Name, fieldDefinition.FieldType) { DeclaringType = fieldDefinition.DeclaringType.ResolveGenericArguments() }; }