private void WriteTypeMembers(TypeDefinition type, Action <IMemberDefinition> writeMember,
                                      IEnumerable <string> attributesToSkip = null, ICollection <string> fieldsToSkip = null)
        {
            List <IMemberDefinition> members = Utilities.GetTypeMembers(type, Language, this.Settings.ShowCompilerGeneratedMembers, attributesToSkip, fieldsToSkip,
                                                                        currentWritingInfo.GeneratedFilterMethods, TypeContext.GetFieldToPropertyMap(Language).Keys);

            if (type.IsEnum)
            {
                members.Sort((x, y) => SortEnumFields(x, y));
            }

            for (int i = 0; i < members.Count; i++)
            {
                IMemberDefinition member = null;

                if (isStopped)
                {
                    return;
                }
                member = members[i];


                if (member is FieldDefinition && (member as FieldDefinition).IsSpecialName)
                {
                    continue;
                }

                membersStack.Push(member);

                bool isLastMember = (i == members.Count - 1);

                writeMember(member);

                if (type.IsEnum)
                {
                    if (!isLastMember &&
                        members[i + 1].Name != "value__" /*inserted by the compiler as last member on some enums. not written.*/)
                    {
                        WriteEnumValueSeparator();
                        WriteLine();
                    }
                }
                else
                {
                    if (!isLastMember)
                    {
                        WriteLine();
                        WriteLine();
                    }
                }

                membersStack.Pop();
            }
        }