Skip to content

Removing last field from options does not reset the lastField property #157

@pradu71

Description

@pradu71

Removing last field in a record, then reading all records generates an exception

engine.Options.RemoveField("Digitale")
Dim records = engine.ReadFile(fn)

FileHelpers.FileHelpersException: Line: 1 Column: 207. Delimiter ';' not found after field 'CDC' 
(the record has less fields, the delimiter is wrong or the next field must be marked as optional).

When removing any field from the Fields array of RecordInfo should reset the lastField property of the last item in the array:

// in Core/RecordInfo.Factory.cs 
public void RemoveField(string fieldname)
    {
        var index = GetFieldIndex(fieldname);
        Fields[index] = null;
        Fields = Array.FindAll(Fields, x => x != null);
        Fields[Fields.Length - 1].IsLast = true; // HERE <====
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions